Skip to content

Commit

Permalink
Handle parenthesized trees
Browse files Browse the repository at this point in the history
  • Loading branch information
antonsviridov-src committed Aug 6, 2024
1 parent 8602980 commit bac4895
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.sun.source.tree.LiteralTree;
import com.sun.source.tree.NewArrayTree;
import com.sun.source.tree.AnnotationTree;
import com.sun.source.tree.ParenthesizedTree;

import java.util.HashMap;
import java.util.ArrayList;
Expand Down Expand Up @@ -160,6 +161,12 @@ private Semanticdb.Tree annotationParameter(ExpressionTree expr) {
unaryOpTree(
semanticdbUnaryOperator(unaryExpr.getKind()),
annotationParameter(unaryExpr.getExpression())));
} else if (expr instanceof ParenthesizedTree) {
ParenthesizedTree unaryExpr = (ParenthesizedTree) expr;
return annotationParameter(unaryExpr.getExpression());
// unaryOpTree(
// semanticdbUnaryOperator(unaryExpr.getKind()),
// annotationParameter(unaryExpr.getExpression())));
}
throw new IllegalArgumentException(
semanticdbUri
Expand Down
27 changes: 16 additions & 11 deletions tests/minimized/src/main/java/minimized/AnnotationParameters.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
package minimized;


@interface Bar {
double value();
double value();
}

@interface BarB {
boolean value();
boolean value();
}

@interface Nullable {
String value() default "";
}

interface Foo {
@Bar(-1d)
double test();
@Bar(-1d)
double test();

@Bar(~5)
@SuppressWarnings(value = "unchecked")
double test2();
@Bar(~5)
@SuppressWarnings(value = "unchecked")
double test2();

@BarB(!true)
double test3();
}
@BarB(!true)
double test3();

@Nullable(("what"))
Foo test4();
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package minimized;


@interface Bar {
// ^^^ definition semanticdb maven . . minimized/Bar#
// display_name Bar
// signature_documentation java @interface Bar
// kind Interface
// relationship is_implementation semanticdb maven jdk 11 java/lang/annotation/Annotation#
double value();
double value();
}

@interface BarB {
Expand All @@ -16,39 +15,56 @@
// signature_documentation java @interface BarB
// kind Interface
// relationship is_implementation semanticdb maven jdk 11 java/lang/annotation/Annotation#
boolean value();
boolean value();
}

@interface Nullable {
// ^^^^^^^^ definition semanticdb maven . . minimized/Nullable#
// display_name Nullable
// signature_documentation java @interface Nullable
// kind Interface
// relationship is_implementation semanticdb maven jdk 11 java/lang/annotation/Annotation#
String value() default "";
}

interface Foo {
// ^^^ definition semanticdb maven . . minimized/Foo#
// display_name Foo
// signature_documentation java interface Foo
// kind Interface
@Bar(-1d)
// ^^^ reference semanticdb maven . . minimized/Bar#
double test();
// ^^^^ definition semanticdb maven . . minimized/Foo#test().
// display_name test
// signature_documentation java @Bar(-1.0)\npublic abstract double test()
// kind AbstractMethod
@Bar(-1d)
//^^^ reference semanticdb maven . . minimized/Bar#
double test();
// ^^^^ definition semanticdb maven . . minimized/Foo#test().
// display_name test
// signature_documentation java @Bar(-1.0)\npublic abstract double test()
// kind AbstractMethod

@Bar(~5)
// ^^^ reference semanticdb maven . . minimized/Bar#
@SuppressWarnings(value = "unchecked")
// ^^^^^^^^^^^^^^^^ reference semanticdb maven jdk 11 java/lang/SuppressWarnings#
// ^^^^^ reference semanticdb maven jdk 11 java/lang/SuppressWarnings#value().
double test2();
// ^^^^^ definition semanticdb maven . . minimized/Foo#test2().
// display_name test2
// signature_documentation java @Bar(~5)\n@SuppressWarnings("unchecked")\npublic abstract double test2()
// kind AbstractMethod
@Bar(~5)
//^^^ reference semanticdb maven . . minimized/Bar#
@SuppressWarnings(value = "unchecked")
//^^^^^^^^^^^^^^^^ reference semanticdb maven jdk 11 java/lang/SuppressWarnings#
// ^^^^^ reference semanticdb maven jdk 11 java/lang/SuppressWarnings#value().
double test2();
// ^^^^^ definition semanticdb maven . . minimized/Foo#test2().
// display_name test2
// signature_documentation java @Bar(~5)\n@SuppressWarnings("unchecked")\npublic abstract double test2()
// kind AbstractMethod

@BarB(!true)
// ^^^^ reference semanticdb maven . . minimized/BarB#
double test3();
// ^^^^^ definition semanticdb maven . . minimized/Foo#test3().
// display_name test3
// signature_documentation java @BarB(!true)\npublic abstract double test3()
// kind AbstractMethod
}
@BarB(!true)
//^^^^ reference semanticdb maven . . minimized/BarB#
double test3();
// ^^^^^ definition semanticdb maven . . minimized/Foo#test3().
// display_name test3
// signature_documentation java @BarB(!true)\npublic abstract double test3()
// kind AbstractMethod

@Nullable(("what"))
//^^^^^^^^ reference semanticdb maven . . minimized/Nullable#
Foo test4();
//^^ reference semanticdb maven . . minimized/Foo#
// ^^^^^ definition semanticdb maven . . minimized/Foo#test4().
// display_name test4
// signature_documentation java @Nullable("what")\npublic abstract Foo test4()
// kind AbstractMethod
}

0 comments on commit bac4895

Please sign in to comment.