Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
eb6d145d
Commit
eb6d145d
authored
Mar 03, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix indent for anonymous classes
parent
63c003a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
9 deletions
+74
-9
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+10
-9
InternalJadxTest.java
jadx-core/src/test/java/jadx/api/InternalJadxTest.java
+9
-0
TestAnonymousClass3.java
...t/java/jadx/tests/internal/inner/TestAnonymousClass3.java
+55
-0
No files found.
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
eb6d145d
...
...
@@ -95,6 +95,14 @@ public class InsnGen {
return
code
;
}
public
void
addArgDot
(
CodeWriter
code
,
InsnArg
arg
)
throws
CodegenException
{
int
len
=
code
.
length
();
addArg
(
code
,
arg
,
true
);
if
(
len
!=
code
.
length
())
{
code
.
add
(
'.'
);
}
}
public
void
addArg
(
CodeWriter
code
,
InsnArg
arg
)
throws
CodegenException
{
addArg
(
code
,
arg
,
true
);
}
...
...
@@ -152,11 +160,7 @@ public class InsnGen {
return
;
}
}
int
len
=
code
.
length
();
addArg
(
code
,
arg
);
if
(
code
.
length
()
!=
len
)
{
code
.
add
(
'.'
);
}
addArgDot
(
code
,
arg
);
code
.
add
(
field
.
getName
());
}
...
...
@@ -609,10 +613,7 @@ public class InsnGen {
InsnArg
arg
=
insn
.
getArg
(
0
);
// FIXME: add 'this' for equals methods in scope
if
(!
arg
.
isThis
())
{
CodeWriter
argStr
=
arg
(
arg
);
if
(!
argStr
.
isEmpty
())
{
code
.
add
(
argStr
).
add
(
'.'
);
}
addArgDot
(
code
,
arg
);
}
k
++;
break
;
...
...
jadx-core/src/test/java/jadx/api/InternalJadxTest.java
View file @
eb6d145d
package
jadx
.
api
;
import
jadx.core.Jadx
;
import
jadx.core.codegen.CodeWriter
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.MethodNode
;
...
...
@@ -149,6 +150,14 @@ public abstract class InternalJadxTest {
}
}
protected
String
makeIndent
(
int
indent
)
{
StringBuilder
sb
=
new
StringBuilder
(
indent
*
CodeWriter
.
INDENT
.
length
());
for
(
int
i
=
0
;
i
<
indent
;
i
++)
{
sb
.
append
(
CodeWriter
.
INDENT
);
}
return
sb
.
toString
();
}
// Use only for debug purpose
@Deprecated
protected
void
setOutputCFG
()
{
...
...
jadx-core/src/test/java/jadx/tests/internal/inner/TestAnonymousClass3.java
0 → 100644
View file @
eb6d145d
package
jadx
.
tests
.
internal
.
inner
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestAnonymousClass3
extends
InternalJadxTest
{
public
static
class
TestCls
{
public
static
class
Inner
{
private
int
f
;
private
double
d
;
public
void
test
()
{
new
Thread
()
{
@Override
public
void
run
()
{
int
a
=
f
--;
p
(
a
);
f
+=
2
;
f
*=
2
;
a
=
++
f
;
p
(
a
);
d
/=
3
;
}
public
void
p
(
int
a
)
{
}
}.
start
();
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsString
(
makeIndent
(
4
)
+
"public void run() {"
));
assertThat
(
code
,
containsString
(
makeIndent
(
3
)
+
"}.start();"
));
// assertThat(code, not(containsString("synthetic")));
// assertThat(code, not(containsString("AnonymousClass_")));
// assertThat(code, containsString("a = f--;"));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment