Skip to content

Commit 6d9e315

Browse files
committed
remove annotate method
1 parent cd7b320 commit 6d9e315

File tree

7 files changed

+14
-16
lines changed

7 files changed

+14
-16
lines changed

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ dependencies {
2626
androidTestImplementation 'com.android.support.test:runner:1.0.2'
2727
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
2828

29-
implementation 'com.ihuntto:log-annotation:1.0.1'
30-
annotationProcessor 'com.ihuntto:log-compiler:1.0.1'
29+
implementation project(':log-annotation')
30+
annotationProcessor project(':log-compiler')
3131
}

app/src/main/java/com/ihuntto/simplelogger/demo/MainActivity.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@
66

77
import com.ihuntto.simplelogger.annotation.SimpleLog;
88

9-
109
@SimpleLog
1110
public class MainActivity extends AppCompatActivity {
1211

1312
@Override
14-
@SimpleLog
1513
protected void onCreate(Bundle savedInstanceState) {
1614
super.onCreate(savedInstanceState);
1715
setContentView(R.layout.activity_main);
1816
getWindow().getDecorView().setOnClickListener(new View.OnClickListener() {
1917
@Override
20-
@SimpleLog
2118
public void onClick(View v) {
2219

2320
}
2421
});
22+
log(this.getClass(), 0);
23+
}
24+
25+
private void log(Class clazz, int a) {
26+
System.out.print(clazz);
2527
}
2628

2729
@Override

log-annotation/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply plugin: 'java-library'
33
apply plugin: 'com.github.dcendents.android-maven'
44
apply plugin: 'com.jfrog.bintray'
55

6-
version = "1.0.1"
6+
version = "1.0.3"
77

88
dependencies {
99
implementation fileTree(dir: 'libs', include: ['*.jar'])

log-annotation/src/main/java/com/ihuntto/simplelogger/annotation/SimpleLog.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
import java.lang.annotation.Target;
1717

1818
@Retention(RetentionPolicy.SOURCE)
19-
@Target({ElementType.METHOD, ElementType.TYPE})
19+
@Target({ElementType.TYPE})
2020
public @interface SimpleLog {
2121
}

log-compiler/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ apply plugin: 'java-library'
33
apply plugin: 'com.github.dcendents.android-maven'
44
apply plugin: 'com.jfrog.bintray'
55

6-
version = "1.0.1"
6+
version = "1.0.5"
77

88
dependencies {
99
implementation fileTree(dir: 'libs', include: ['*.jar'])
10-
implementation 'com.ihuntto:log-annotation:1.0.1'
10+
implementation 'com.ihuntto:log-annotation:1.0.3'
1111
implementation 'com.google.auto.service:auto-service:1.0-rc5'
1212
implementation files(org.gradle.internal.jvm.Jvm.current().toolsJar)
1313
}

log-compiler/src/main/java/com/ihuntto/simplelogger/compiler/SimpleLogProcessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
6868
Set<? extends Element> elements =
6969
roundEnv.getElementsAnnotatedWith(SimpleLog.class);
7070
for (Element each : elements) {
71-
if (each.getKind() == ElementKind.CLASS || each.getKind() == ElementKind.METHOD) {
71+
if (each.getKind() == ElementKind.CLASS) {
7272
messager.printMessage(Diagnostic.Kind.NOTE, "handle element: " + each.getSimpleName());
7373
JCTree jcTree = (JCTree) trees.getTree(each);
7474
if (jcTree != null) {

log-compiler/src/main/java/com/ihuntto/simplelogger/compiler/SimpleLogTranslator.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ private void addLogToMethod(JCTree.JCMethodDecl jcMethodDecl, JCTree.JCStatement
6565
statements.append(logStatement);
6666
statements.append(firstStatement);
6767
}
68+
} else {
69+
statements.add(logStatement);
6870
}
6971
for (int i = 1; i < methodStatements.size(); i++) {
7072
statements.append(jcMethodDecl.getBody().getStatements().get(i));
@@ -136,12 +138,6 @@ private JCTree.JCExpression generateLogMessageExpression(JCTree.JCMethodDecl jcM
136138
return mTreeMaker.Binary(JCTree.Tag.PLUS, msgExpression, mTreeMaker.Literal(")"));
137139
}
138140

139-
@Override
140-
public void visitReturn(JCTree.JCReturn jcReturn) {
141-
super.visitReturn(jcReturn);
142-
System.out.println(jcReturn.expr.toString());
143-
}
144-
145141
private void note(String msg) {
146142
mMessager.printMessage(Diagnostic.Kind.NOTE, mTag + ": " + msg);
147143
}

0 commit comments

Comments
 (0)