From 35435b942332e7815d3815616389e376784ecc99 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Wed, 21 Aug 2024 08:52:21 +0100 Subject: [PATCH 01/13] docs: Put "cross-repo" optional step before SCIP index generation (#742) --- docs/manual-configuration.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/manual-configuration.md b/docs/manual-configuration.md index 60744883..f1a5e3ce 100644 --- a/docs/manual-configuration.md +++ b/docs/manual-configuration.md @@ -140,21 +140,8 @@ build/semanticdb-targetroot/META-INF/semanticdb/j8/src/main/java/example/Example ... ``` -## Step 4: Generate SCIP index from SemanticDB files -First, install the `scip-java` command-line tool according to the instructions -in the [getting started guide](getting-started.md). - -Next, run the `scip-java index-semanticdb` command to convert SemanticDB files -into SCIP. - -```sh -❯ scip-java index-semanticdb $TARGETROOT -❯ file index.scip -index.scip: JSON data -``` - -## Step 5 (optional): Enable cross-repository navigation +## Step 4 (optional): Enable cross-repository navigation Cross-repository navigation is a feature that allows "goto definition" and "find references" to show results from multiple repositories. @@ -228,3 +215,18 @@ Which allows you to invoke it by simply running `mvn sourcegraph:sourcegraphDepe Cross-repository navigation is a feature that allows "goto definition" and "find references" to show results from multiple repositories. + +## Step 5: Generate SCIP index from SemanticDB files + +First, install the `scip-java` command-line tool according to the instructions +in the [getting started guide](getting-started.md). + +Next, run the `scip-java index-semanticdb` command to convert SemanticDB files +into SCIP. + +```sh +❯ scip-java index-semanticdb $TARGETROOT +❯ file index.scip +index.scip: JSON data +``` + From ca095a43708e031de8f2b62bd7289b728eb6e807 Mon Sep 17 00:00:00 2001 From: Ben Madore <823868+madorb@users.noreply.github.com> Date: Thu, 12 Sep 2024 04:52:20 -0500 Subject: [PATCH 02/13] Also support Java 21 (#743) Co-authored-by: Ben Madore --- bin/docker-setup.sh | 2 +- bin/scip-java-docker-script.sh | 5 ++--- docs/getting-started.md | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/docker-setup.sh b/bin/docker-setup.sh index b249d611..fbd686da 100755 --- a/bin/docker-setup.sh +++ b/bin/docker-setup.sh @@ -15,7 +15,7 @@ rm gradle.zip mv /opt/gradle/*/* /opt/gradle # pre-install JDK for all major versions -for JVM_VERSION in 17 11 8 +for JVM_VERSION in 21 17 11 8 do coursier java --jvm $JVM_VERSION --jvm-index https://github.com/coursier/jvm-index/blob/master/index.json -- -version done diff --git a/bin/scip-java-docker-script.sh b/bin/scip-java-docker-script.sh index 0112ce41..1b780615 100755 --- a/bin/scip-java-docker-script.sh +++ b/bin/scip-java-docker-script.sh @@ -3,7 +3,7 @@ # version. It assumes that `coursier` is available on the `$PATH` and that the # `scip-java` binary is already installed at `/app/scip-java/bin/scip-java`. set -eu -JVM_VERSION="${JVM_VERSION:-17,11,8}" +JVM_VERSION="${JVM_VERSION:-21,17,11,8}" FILE="$PWD/lsif-java.json" if test -f "$FILE"; then FROM_CONFIG=$(jq -r '.jvm' "$FILE") @@ -23,12 +23,11 @@ do if [ "$LAST_CODE" != "0" ]; then echo "Using JVM version '$JVM_VERSION'" - if [ "$JVM_VERSION" = "17" ]; then + if [ "$JVM_VERSION" = "17" ] || [ "$JVM_VERSION" = "21" ]; then export JAVA_OPTS="--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" else export JAVA_OPTS="" fi - eval "$(coursier java --jvm "$JVM_VERSION" --env --jvm-index https://github.com/coursier/jvm-index/blob/master/index.json)" java -version diff --git a/docs/getting-started.md b/docs/getting-started.md index 5d9ae9cd..80c86c80 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -54,6 +54,10 @@ docker run -v $(pwd):/sources --env JVM_VERSION=11 sourcegraph/scip-java:latest # Java 17 (default) docker run -v $(pwd):/sources --env JVM_VERSION=17 sourcegraph/scip-java:latest scip-java index + +# Java 21 +docker run -v $(pwd):/sources --env JVM_VERSION=21 sourcegraph/scip-java:latest scip-java index + ``` ### Java launcher From e2d6e7eb401e8c473d8ff9a42cba8e5316188046 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 12 Sep 2024 12:45:19 +0100 Subject: [PATCH 03/13] Only install coursier and sbt in docker container (#751) - Also remove unnecessary jar copying which caused CI flakiness --- .github/workflows/ci.yml | 7 ++++--- bin/docker-setup.sh | 2 +- build.sbt | 14 +++----------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55fca90d..b16d8577 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,13 +46,14 @@ jobs: - name: Build Dockerised CLI run: sbt cli/docker - - run: | - + - name: Test repos + shell: bash + run: | set -eu check_repo() { REPO=$1 mkdir -p .repos/$REPO - git clone https://github.com/$REPO.git .repos/$REPO + git clone https://github.com/$REPO.git .repos/$REPO && cd .repos/$REPO && git submodule update --init docker run -v $PWD/.repos/$REPO:/sources -w /sources sourcegraph/scip-java:latest scip-java index file .repos/$REPO/index.scip || (echo "$REPO SCIP index doesn't exist!"; exit 1) diff --git a/bin/docker-setup.sh b/bin/docker-setup.sh index fbd686da..843f6103 100755 --- a/bin/docker-setup.sh +++ b/bin/docker-setup.sh @@ -2,7 +2,7 @@ set -eux curl -fLo /usr/local/bin/coursier https://github.com/coursier/coursier/releases/download/v2.1.5/coursier chmod +x /usr/local/bin/coursier -coursier setup --yes +coursier setup --yes --apps coursier,sbt curl -fLo maven.zip https://archive.apache.org/dist/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.zip unzip -d /opt/maven maven.zip diff --git a/build.sbt b/build.sbt index eaa153c8..f89e886c 100644 --- a/build.sbt +++ b/build.sbt @@ -591,19 +591,11 @@ lazy val fatjarPackageSettings = List[Def.Setting[_]]( oldStrategy(x) }, (Compile / Keys.`package`) := { - val slimJar = (Compile / Keys.`package`).value - val fatJar = crossTarget.value / (assembly / assemblyJarName).value - val _ = assembly.value - IO.copyFile(fatJar, slimJar, CopyOptions().withOverwrite(true)) - slimJar + assembly.value }, (Compile / packageBin / packagedArtifact) := { - val (art, slimJar) = (Compile / packageBin / packagedArtifact).value - val fatJar = - new File(crossTarget.value + "/" + (assembly / assemblyJarName).value) - val _ = assembly.value - IO.copy(List(fatJar -> slimJar), CopyOptions().withOverwrite(true)) - (art, slimJar) + val (artifact, _) = (Compile / packageBin / packagedArtifact).value + (artifact, assembly.value) }, pomPostProcess := { node => new RuleTransformer( From a4eb361640e7fa633adc201b185235e4e5faab3b Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 10 Oct 2024 13:54:33 +0100 Subject: [PATCH 04/13] Handle .srcjar inputs in Bazel aspect (#754) * Unpack .srcjars in Bazel aspect and add them to scip config * Use --verbose_failures when invoking scip-java aspect * Scip buildtool can now handle folders of source files * Improve compatibility with different Bazel versions * remove redundant conversion * Add a srcjar example/test --- .../src/main/java/srcjar_example/BUILD | 13 +++++ .../src/main/java/srcjar_example/Foo.java | 8 +++ .../main/resources/scip-java/scip_java.bzl | 53 ++++++++++++++++--- .../scip_java/buildtools/BazelBuildTool.scala | 3 +- .../scip_java/buildtools/ScipBuildTool.scala | 32 +++++++---- 5 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 examples/bazel-example/src/main/java/srcjar_example/BUILD create mode 100644 examples/bazel-example/src/main/java/srcjar_example/Foo.java diff --git a/examples/bazel-example/src/main/java/srcjar_example/BUILD b/examples/bazel-example/src/main/java/srcjar_example/BUILD new file mode 100644 index 00000000..ff65eb50 --- /dev/null +++ b/examples/bazel-example/src/main/java/srcjar_example/BUILD @@ -0,0 +1,13 @@ +genrule( + name = "generated-srcjar", + outs = ["sources.srcjar"], + cmd = "echo 'package com.testing; public class Bar {};' > Bar.java && jar cf $(@) Bar.java", +) + +java_library( + name = "testing", + srcs = [ + "Foo.java", + ":generated-srcjar", + ], +) diff --git a/examples/bazel-example/src/main/java/srcjar_example/Foo.java b/examples/bazel-example/src/main/java/srcjar_example/Foo.java new file mode 100644 index 00000000..f2122ff2 --- /dev/null +++ b/examples/bazel-example/src/main/java/srcjar_example/Foo.java @@ -0,0 +1,8 @@ +// testing/Foo.java +package com.testing; + +public class Foo { + public Bar foo(Bar value) { + return value; + } +} diff --git a/scip-java/src/main/resources/scip-java/scip_java.bzl b/scip-java/src/main/resources/scip-java/scip_java.bzl index 948ee683..8976d4e6 100644 --- a/scip-java/src/main/resources/scip-java/scip_java.bzl +++ b/scip-java/src/main/resources/scip-java/scip_java.bzl @@ -57,10 +57,36 @@ def _scip_java(target, ctx): annotations = info.annotation_processing source_files = [] + source_jars = [] for src in ctx.rule.files.srcs: - source_files.append(src.path) + if src.path.endswith(".java"): + source_files.append(src.path) + elif src.path.endswith(".srcjar"): + source_jars.append(src) + if len(source_files) == 0: return None + + output_dir = [] + + for source_jar in source_jars: + dir = ctx.actions.declare_directory("extracted_srcjar/" + source_jar.short_path) + output_dir.append(dir) + + ctx.actions.run_shell( + inputs = javac_action.inputs, + outputs = [dir], + mnemonic = "ExtractSourceJars", + command = """ + unzip {input_file} -d {output_dir} + """.format( + output_dir = dir.path, + input_file = source_jar.path, + ), + progress_message = "Extracting source jar {jar}".format(jar = source_jar.path), + ) + + source_files.append(dir.path) classpath = [j.path for j in compilation.compilation_classpath.to_list()] bootclasspath = [j.path for j in compilation.boot_classpath] @@ -73,11 +99,23 @@ def _scip_java(target, ctx): launcher_javac_flags = [] compiler_javac_flags = [] - for value in compilation.javac_options: - if value.startswith("-J"): - launcher_javac_flags.append(value) - else: - compiler_javac_flags.append(value) + + # In different versions of bazel javac options are either a nested set or a depset or a list... + javac_options = [] + if hasattr(compilation, "javac_options_list"): + javac_options = compilation.javac_options_list + else: + javac_options = compilation.javac_options + + for value in javac_options: + # NOTE(Anton): for some bizarre reason I see empty string starting the list of + # javac options - which then gets propagated into the JSON config, and ends up + # crashing the actual javac invokation. + if value != "": + if value.startswith("-J"): + launcher_javac_flags.append(value) + else: + compiler_javac_flags.append(value) build_config = struct(**{ "javaHome": ctx.var["java_home"], @@ -100,6 +138,7 @@ def _scip_java(target, ctx): ) deps = [javac_action.inputs, annotations.processor_classpath] + ctx.actions.run_shell( command = "\"{}\" index --no-cleanup --index-semanticdb.allow-empty-index --cwd \"{}\" --targetroot {} --scip-config \"{}\" --output \"{}\"".format( ctx.var["scip_java_binary"], @@ -113,7 +152,7 @@ def _scip_java(target, ctx): "NO_PROGRESS_BAR": "true", }, mnemonic = "ScipJavaIndex", - inputs = depset([build_config_path], transitive = deps), + inputs = depset([build_config_path] + output_dir, transitive = deps), outputs = [scip_output, targetroot], ) diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BazelBuildTool.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BazelBuildTool.scala index a9918b73..c88ed4cd 100644 --- a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BazelBuildTool.scala +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BazelBuildTool.scala @@ -71,7 +71,8 @@ class BazelBuildTool(index: IndexCommand) extends BuildTool("Bazel", index) { "--output_groups=scip", s"--define=sourceroot=${index.workingDirectory}", s"--define=java_home=$javaHome", - s"--define=scip_java_binary=$scipJavaBinary" + s"--define=scip_java_binary=$scipJavaBinary", + "--verbose_failures" ) ++ targetSpecs val buildExitCode = runBazelBuild(buildCommand) diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ScipBuildTool.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ScipBuildTool.scala index d0477aa8..92726743 100644 --- a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ScipBuildTool.scala +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ScipBuildTool.scala @@ -683,15 +683,8 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) { Files.walkFileTree(targetroot, new DeleteVisitor) } - /** Recursively collects all Java files in the working directory */ - private def collectAllSourceFiles(config: Config, dir: Path): List[Path] = { - if (config.sourceFiles.nonEmpty) { - return config - .sourceFiles - .map(path => AbsolutePath.of(Paths.get(path), dir)) - .filter(path => Files.isRegularFile(path)) - } - val buf = ListBuffer.empty[Path] + private def collectAllSourceFiles(dir: Path) = { + val buf = List.newBuilder[Path] Files.walkFileTree( dir, new SimpleFileVisitor[Path] { @@ -719,7 +712,26 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) { ): FileVisitResult = FileVisitResult.CONTINUE } ) - buf.toList + buf.result() + } + + /** Recursively collects all Java files in the working directory */ + private def collectAllSourceFiles(config: Config, dir: Path): List[Path] = { + if (config.sourceFiles.nonEmpty) { + config + .sourceFiles + .flatMap { relativePath => + val path = AbsolutePath.of(Paths.get(relativePath), dir) + + if (Files.isRegularFile(path) && allPatterns.matches(path)) + List(path) + else if (Files.isDirectory(path)) + collectAllSourceFiles(path) + else + Nil + } + } else + collectAllSourceFiles(dir) } // HACK(olafurpg): I haven't figured out a reliable way to get annotation processor jars on the processorpath. From e3274309f72ace66699c4d0ed50e11a75f895c03 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 17 Oct 2024 03:35:50 +0100 Subject: [PATCH 05/13] Add setup-sbt GH action (#756) --- .github/workflows/ci.yml | 17 +++++++++++++++++ .github/workflows/mdoc.yml | 1 + .github/workflows/release-docker.yml | 1 + .github/workflows/release-maven.yml | 1 + .github/workflows/sourcegraph.yml | 2 ++ 5 files changed, 22 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b16d8577..f2a0b009 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,8 @@ jobs: cache: "sbt" java-version: ${{ matrix.java }} + - uses: sbt/setup-sbt@v1 + - name: Main project tests run: sbt test @@ -43,6 +45,8 @@ jobs: cache: "sbt" java-version: 17 + - uses: sbt/setup-sbt@v1 + - name: Build Dockerised CLI run: sbt cli/docker @@ -84,6 +88,15 @@ jobs: steps: - uses: actions/checkout@v2 - run: yarn global add @bazel/bazelisk + + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + cache: "sbt" + java-version: 17 + + - uses: sbt/setup-sbt@v1 + - run: sbt build - run: echo "$PWD/out/bin" >> $GITHUB_PATH - name: Auto-index scip-java codebase @@ -101,12 +114,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 with: distribution: "temurin" java-version: 11 cache: "sbt" + - uses: sbt/setup-sbt@v1 + - run: sbt --client checkAll - name: Run sample benchmarks @@ -129,6 +145,7 @@ jobs: cache: "sbt" java-version: ${{ matrix.java }} + - uses: sbt/setup-sbt@v1 - run: | sbt build publishM2 publishLocal dumpScipJavaVersion diff --git a/.github/workflows/mdoc.yml b/.github/workflows/mdoc.yml index 63f47555..7d77e257 100644 --- a/.github/workflows/mdoc.yml +++ b/.github/workflows/mdoc.yml @@ -15,6 +15,7 @@ jobs: distribution: 'temurin' java-version: 11 cache: 'sbt' + - uses: sbt/setup-sbt@v1 - run: sbt docs/docusaurusPublishGhpages env: GIT_DEPLOY_KEY: ${{ secrets.GIT_DEPLOY_KEY }} diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index bf6f9c2d..1b2c2ceb 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -16,6 +16,7 @@ jobs: distribution: 'temurin' java-version: 8 cache: 'sbt' + - uses: sbt/setup-sbt@v1 - uses: docker/setup-buildx-action@v1 - name: Login to DockerHub uses: docker/login-action@v1 diff --git a/.github/workflows/release-maven.yml b/.github/workflows/release-maven.yml index 0341ef0f..8bfb29f5 100644 --- a/.github/workflows/release-maven.yml +++ b/.github/workflows/release-maven.yml @@ -15,6 +15,7 @@ jobs: distribution: 'temurin' java-version: 8 cache: 'sbt' + - uses: sbt/setup-sbt@v1 - name: Publish ${{ github.ref }} run: sbt ci-release env: diff --git a/.github/workflows/sourcegraph.yml b/.github/workflows/sourcegraph.yml index 4ffaba70..aa0d436d 100644 --- a/.github/workflows/sourcegraph.yml +++ b/.github/workflows/sourcegraph.yml @@ -21,6 +21,8 @@ jobs: java-version: 8 cache: "sbt" + - uses: sbt/setup-sbt@v1 + - name: Publish CLI locally run: sbt publishLocal dumpScipJavaVersion From 4ce8d87656eba5f55e18148cb670daa8476d74f8 Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Fri, 18 Oct 2024 23:32:25 +0800 Subject: [PATCH 06/13] chore: Remove project board workflow (#755) We no longer use GitHub project boards so this isn't needed --- .github/workflows/project-board.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/workflows/project-board.yml diff --git a/.github/workflows/project-board.yml b/.github/workflows/project-board.yml deleted file mode 100644 index 11007a38..00000000 --- a/.github/workflows/project-board.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Project Board -on: - issues: - types: - - opened -jobs: - # Uses issues beta API - see https://docs.github.com/en/issues/trying-out-the-new-projects-experience/automating-projects#example-workflow - code-intel-board: - runs-on: ubuntu-latest - env: - PROJECT_ID: MDExOlByb2plY3ROZXh0NDI1MA== # https://github.com/orgs/sourcegraph/projects/211 - GITHUB_TOKEN: ${{ secrets.GH_PROJECTS_ACTION_TOKEN }} - steps: - - name: Add to board - env: - NODE_ID: ${{ github.event.issue.node_id }} - run: | - gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query=' - mutation($project:ID!, $node_id:ID!) { - addProjectNextItem(input: {projectId: $project, contentId: $node_id}) { - projectNextItem { - id - } - } - }' -f project=$PROJECT_ID -f node_id=$NODE_ID From dc855d297b05599e09b4cdd404ba14792b9d0249 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:16:12 +0100 Subject: [PATCH 07/13] Update dependency sbt/sbt to v1.10.3 (#752) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- project/build.properties | 2 +- website/project/build.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build.properties b/project/build.properties index ee4c672c..bc739060 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.10.1 +sbt.version=1.10.3 diff --git a/website/project/build.properties b/website/project/build.properties index e8a1e246..bc739060 100644 --- a/website/project/build.properties +++ b/website/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.7 +sbt.version=1.10.3 From 439a0f95019fdf73303de21b20a83fb253adee32 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:10:06 +0100 Subject: [PATCH 08/13] Update dependency net.bytebuddy:byte-buddy-agent to v1.15.7 (#746) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f89e886c..c2d8860a 100644 --- a/build.sbt +++ b/build.sbt @@ -97,7 +97,7 @@ lazy val agent = project libraryDependencies ++= List( "net.bytebuddy" % "byte-buddy" % "1.11.9", - "net.bytebuddy" % "byte-buddy-agent" % "1.11.21" + "net.bytebuddy" % "byte-buddy-agent" % "1.15.7" ), Compile / packageBin / packageOptions += Package.ManifestAttributes( From 6c183d8f4da6c6cf1401295d2a33019106eec6a4 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Tue, 29 Oct 2024 13:08:53 +0000 Subject: [PATCH 09/13] Support cast tree in annotation parameters (#750) --- .../scip_semanticdb/SignatureFormatter.java | 6 +++ .../semanticdb_javac/SemanticdbBuilders.java | 15 ++++++ .../src/main/protobuf/semanticdb.proto | 7 +++ .../semanticdb_javac/SemanticdbTrees.java | 53 ++++++++++--------- .../semanticdb_javac/SemanticdbVisitor.java | 1 + .../java/minimized/AnnotationParameters.java | 13 +++++ .../java/minimized/AnnotationParameters.java | 39 ++++++++++++++ 7 files changed, 110 insertions(+), 24 deletions(-) diff --git a/scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/SignatureFormatter.java b/scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/SignatureFormatter.java index aec78d52..fc306ad2 100644 --- a/scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/SignatureFormatter.java +++ b/scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/SignatureFormatter.java @@ -470,6 +470,12 @@ private String formatTree(Tree tree) { + formatTree(tree.getAssignTree().getRhs()); } else if (tree.hasUnaryopTree()) { return formatUnaryOperation(tree.getUnaryopTree()); + } else if (tree.hasCastTree()) { + return "(" + + formatType(tree.getCastTree().getTpe()) + + ")" + + " " + + formatTree(tree.getCastTree().getValue()); } throw new IllegalArgumentException("tree was of unexpected type " + tree); diff --git a/semanticdb-java/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbBuilders.java b/semanticdb-java/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbBuilders.java index da11befd..d592efaf 100644 --- a/semanticdb-java/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbBuilders.java +++ b/semanticdb-java/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbBuilders.java @@ -150,6 +150,10 @@ public static Semanticdb.Tree tree(Semanticdb.UnaryOperatorTree unaryOperatorTre return Semanticdb.Tree.newBuilder().setUnaryopTree(unaryOperatorTree).build(); } + public static Semanticdb.Tree tree(Semanticdb.CastTree castTree) { + return Semanticdb.Tree.newBuilder().setCastTree(castTree).build(); + } + public static Semanticdb.UnaryOperatorTree unaryOpTree( Semanticdb.UnaryOperator operator, Semanticdb.Tree rhs) { return Semanticdb.UnaryOperatorTree.newBuilder().setOp(operator).setTree(rhs).build(); @@ -163,10 +167,15 @@ public static Semanticdb.AssignTree assignTree(Semanticdb.Tree lhs, Semanticdb.T return Semanticdb.AssignTree.newBuilder().setLhs(lhs).setRhs(rhs).build(); } + public static Semanticdb.CastTree castTree(Semanticdb.Type type, Semanticdb.Tree value) { + return Semanticdb.CastTree.newBuilder().setTpe(type).setValue(value).build(); + } + public static Semanticdb.AnnotationTree annotationTree( Semanticdb.Type type, Iterable parameters) { return Semanticdb.AnnotationTree.newBuilder().setTpe(type).addAllParameters(parameters).build(); } + // SemanticDB Constants public static Semanticdb.Constant stringConst(String value) { @@ -181,6 +190,12 @@ public static Semanticdb.Constant doubleConst(Double value) { .build(); } + public static Semanticdb.Constant nullConst() { + return Semanticdb.Constant.newBuilder() + .setNullConstant(Semanticdb.NullConstant.newBuilder()) + .build(); + } + public static Semanticdb.Constant floatConst(Float value) { return Semanticdb.Constant.newBuilder() .setFloatConstant(Semanticdb.FloatConstant.newBuilder().setValue(value)) diff --git a/semanticdb-java/src/main/protobuf/semanticdb.proto b/semanticdb-java/src/main/protobuf/semanticdb.proto index 5f5ec5b4..2e72263c 100644 --- a/semanticdb-java/src/main/protobuf/semanticdb.proto +++ b/semanticdb-java/src/main/protobuf/semanticdb.proto @@ -298,6 +298,7 @@ message Tree { AssignTree assign_tree = 10; BinaryOperatorTree binop_tree = 11; UnaryOperatorTree unaryop_tree = 12; + CastTree cast_tree = 13; // -- OUT OF SPEC -- // } } @@ -347,6 +348,12 @@ message AnnotationTree { repeated Tree parameters = 2; } + +message CastTree { + Type tpe = 1; + Tree value = 2; +} + message AssignTree { Tree lhs = 1; Tree rhs = 2; diff --git a/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTrees.java b/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTrees.java index a95a74fb..f78b5abe 100644 --- a/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTrees.java +++ b/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTrees.java @@ -1,26 +1,13 @@ package com.sourcegraph.semanticdb_javac; -import com.sun.source.tree.Tree; +import com.sun.source.tree.*; import com.sun.source.util.Trees; import javax.lang.model.element.Element; import javax.lang.model.util.Types; +import javax.lang.model.type.TypeMirror; import com.sun.source.util.TreePath; import com.sun.source.tree.Tree; import com.sun.source.tree.Tree.Kind; -import com.sun.source.tree.BinaryTree; -import com.sun.source.tree.UnaryTree; -import com.sun.source.tree.AssignmentTree; -import com.sun.source.tree.MemberSelectTree; -import com.sun.source.tree.ClassTree; -import com.sun.source.tree.VariableTree; -import com.sun.source.tree.MethodTree; -import com.sun.source.tree.ModifiersTree; -import com.sun.source.tree.IdentifierTree; -import com.sun.source.tree.ExpressionTree; -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; @@ -44,6 +31,7 @@ public SemanticdbTrees( this.types = types; this.trees = trees; this.nodes = nodes; + this.typeVisitor = new SemanticdbTypeVisitor(globals, locals, types); } private final GlobalSymbolsCache globals; @@ -52,6 +40,7 @@ public SemanticdbTrees( private final Types types; private final Trees trees; private final HashMap nodes; + private final SemanticdbTypeVisitor typeVisitor; public List annotations(Tree node) { if (!(node instanceof ClassTree) @@ -100,11 +89,15 @@ public Semanticdb.AnnotationTree annotationBuilder(AnnotationTree annotation) { TreePath annotationTreePath = nodes.get(annotation); Element annotationSym = trees.getElement(annotationTreePath); - Semanticdb.Type type = - new SemanticdbTypeVisitor(globals, locals, types).semanticdbType(annotationSym.asType()); + Semanticdb.Type type = typeVisitor.semanticdbType(annotationSym.asType()); return annotationTree(type, params); } + private TypeMirror getTreeType(Tree tree) { + TreePath path = nodes.get(tree); + return trees.getTypeMirror(path); + } + private Semanticdb.Tree annotationParameter(ExpressionTree expr) { if (expr instanceof MemberSelectTree) { TreePath expressionTreePath = nodes.get(expr); @@ -125,7 +118,12 @@ private Semanticdb.Tree annotationParameter(ExpressionTree expr) { // Literals can either be a primitive or String Object value = ((LiteralTree) expr).getValue(); final Semanticdb.Constant constant; - if (value instanceof String) constant = stringConst((String) value); + // Technically, annotation parameter values cannot be null, + // according to JLS: https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.7.1 + // But this codepath is still possible to hit when compiling invalid code - and + // we should handle the null const case in order to fail more gracefully + if (value == null) constant = nullConst(); + else if (value instanceof String) constant = stringConst((String) value); else if (value instanceof Boolean) constant = booleanConst((Boolean) value); else if (value instanceof Byte) constant = byteConst((Byte) value); else if (value instanceof Short) constant = shortConst((Short) value); @@ -164,13 +162,20 @@ private Semanticdb.Tree annotationParameter(ExpressionTree expr) { } else if (expr instanceof ParenthesizedTree) { ParenthesizedTree parenExpr = (ParenthesizedTree) expr; return annotationParameter(parenExpr.getExpression()); + } else if (expr instanceof TypeCastTree) { + TypeCastTree tree = (TypeCastTree) expr; + return tree( + castTree( + typeVisitor.semanticdbType(getTreeType(tree.getType())), + annotationParameter(tree.getExpression()))); + } else { + throw new IllegalArgumentException( + semanticdbUri + + ": annotation parameter rhs was of unexpected tree node type " + + expr.getClass() + + "\n" + + expr); } - throw new IllegalArgumentException( - semanticdbUri - + ": annotation parameter rhs was of unexpected tree node type " - + expr.getClass() - + "\n" - + expr); } private Semanticdb.BinaryOperator semanticdbBinaryOperator(Tree.Kind kind) { diff --git a/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java b/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java index cebd32f9..f8298532 100644 --- a/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java +++ b/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java @@ -15,6 +15,7 @@ import com.sun.source.tree.ExpressionTree; import com.sun.source.tree.NewClassTree; import com.sun.source.tree.MemberSelectTree; +import com.sun.source.tree.TypeCastTree; import com.sun.source.tree.TypeParameterTree; import com.sun.source.tree.ParameterizedTypeTree; diff --git a/tests/minimized/src/main/java/minimized/AnnotationParameters.java b/tests/minimized/src/main/java/minimized/AnnotationParameters.java index af376dff..1ec1faf3 100644 --- a/tests/minimized/src/main/java/minimized/AnnotationParameters.java +++ b/tests/minimized/src/main/java/minimized/AnnotationParameters.java @@ -12,6 +12,11 @@ String value() default ""; } + +@interface BarRef{ + SuppressWarnings value(); +} + interface Foo { @Bar(-1d) double test(); @@ -25,4 +30,12 @@ interface Foo { @Nullable(("what")) Foo test4(); + + @Bar((double) -1) + double testCast(); +} + +interface TestRef { + @BarRef(@SuppressWarnings(value = "unchecked")) + abstract double testCase(); } diff --git a/tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/AnnotationParameters.java b/tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/AnnotationParameters.java index d2c068fa..8dc8786f 100644 --- a/tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/AnnotationParameters.java +++ b/tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/AnnotationParameters.java @@ -40,6 +40,21 @@ // kind AbstractMethod } + +@interface BarRef{ +// ^^^^^^ definition semanticdb maven . . minimized/BarRef# +// display_name BarRef +// signature_documentation java @interface BarRef +// kind Interface +// relationship is_implementation semanticdb maven jdk 11 java/lang/annotation/Annotation# +→SuppressWarnings value(); +//^^^^^^^^^^^^^^^ reference semanticdb maven jdk 11 java/lang/SuppressWarnings# +// ^^^^^ definition semanticdb maven . . minimized/BarRef#value(). +// display_name value +// signature_documentation java public abstract SuppressWarnings value() +// kind AbstractMethod +} + interface Foo { // ^^^ definition semanticdb maven . . minimized/Foo# // display_name Foo @@ -80,4 +95,28 @@ interface Foo { // display_name test4 // signature_documentation java @Nullable("what")\npublic abstract Foo test4() // kind AbstractMethod + +→@Bar((double) -1) +//^^^ reference semanticdb maven . . minimized/Bar# +→double testCast(); +// ^^^^^^^^ definition semanticdb maven . . minimized/Foo#testCast(). +// display_name testCast +// signature_documentation java @Bar((double) -1)\npublic abstract double testCast() +// kind AbstractMethod +} + +interface TestRef { +// ^^^^^^^ definition semanticdb maven . . minimized/TestRef# +// display_name TestRef +// signature_documentation java interface TestRef +// kind Interface +→@BarRef(@SuppressWarnings(value = "unchecked")) +//^^^^^^ reference semanticdb maven . . minimized/BarRef# +// ^^^^^^^^^^^^^^^^ reference semanticdb maven jdk 11 java/lang/SuppressWarnings# +// ^^^^^ reference semanticdb maven jdk 11 java/lang/SuppressWarnings#value(). +→abstract double testCase(); +// ^^^^^^^^ definition semanticdb maven . . minimized/TestRef#testCase(). +// display_name testCase +// signature_documentation java @BarRef(@SuppressWarnings("unchecked"))\npublic abstract double testCase() +// kind AbstractMethod } From c3ab8eab9494518d1c7ca91e8229266e195ab442 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Wed, 6 Nov 2024 12:05:10 +0000 Subject: [PATCH 10/13] Bazel aspects: allow sharing source jars and allow empty sourcejars (#757) * Use labelname when declaring output for unzipped sourcejar * Handle empty source jars --- .../src/main/java/srcjar_example/BUILD | 15 +++++++++++++++ .../src/main/java/srcjar_example/Baz.java | 7 +++++++ .../src/main/resources/scip-java/scip_java.bzl | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 examples/bazel-example/src/main/java/srcjar_example/Baz.java diff --git a/examples/bazel-example/src/main/java/srcjar_example/BUILD b/examples/bazel-example/src/main/java/srcjar_example/BUILD index ff65eb50..dce48b36 100644 --- a/examples/bazel-example/src/main/java/srcjar_example/BUILD +++ b/examples/bazel-example/src/main/java/srcjar_example/BUILD @@ -4,10 +4,25 @@ genrule( cmd = "echo 'package com.testing; public class Bar {};' > Bar.java && jar cf $(@) Bar.java", ) +genrule( + name = "empty-srcjar", + outs = ["empty.srcjar"], + cmd = "touch test.txt && zip $(@) test.txt && zip -d $(@) test.txt", +) + java_library( name = "testing", srcs = [ "Foo.java", ":generated-srcjar", + ":empty-srcjar" + ], +) + +java_library( + name = "other_library", + srcs = [ + "Baz.java", # create a new file in source at test/Baz.java, alongside test/Foo.java + ":generated-srcjar", ], ) diff --git a/examples/bazel-example/src/main/java/srcjar_example/Baz.java b/examples/bazel-example/src/main/java/srcjar_example/Baz.java new file mode 100644 index 00000000..d7b7f387 --- /dev/null +++ b/examples/bazel-example/src/main/java/srcjar_example/Baz.java @@ -0,0 +1,7 @@ +package com.testing; + +public class Baz { + public Bar baz(Bar value) { + return value; + } +} diff --git a/scip-java/src/main/resources/scip-java/scip_java.bzl b/scip-java/src/main/resources/scip-java/scip_java.bzl index 8976d4e6..1525597f 100644 --- a/scip-java/src/main/resources/scip-java/scip_java.bzl +++ b/scip-java/src/main/resources/scip-java/scip_java.bzl @@ -70,7 +70,7 @@ def _scip_java(target, ctx): output_dir = [] for source_jar in source_jars: - dir = ctx.actions.declare_directory("extracted_srcjar/" + source_jar.short_path) + dir = ctx.actions.declare_directory(ctx.label.name + "/extracted_srcjar/" + source_jar.short_path) output_dir.append(dir) ctx.actions.run_shell( @@ -78,7 +78,7 @@ def _scip_java(target, ctx): outputs = [dir], mnemonic = "ExtractSourceJars", command = """ - unzip {input_file} -d {output_dir} + [ "$(unzip -q -l {input_file} | wc -l)" -eq 0 ] || unzip {input_file} -d {output_dir} """.format( output_dir = dir.path, input_file = source_jar.path, From 62df280959628882b4faf8bba27a492c45ac430f Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Mon, 9 Dec 2024 16:09:02 +0000 Subject: [PATCH 11/13] Don't create a subpath for extracted_srcjar (#767) This avoids an issue where we declare output to be a prefix of the rule --- .../bazel-example/src/main/java/srcjar_example/BUILD | 9 +++++++++ scip-java/src/main/resources/scip-java/scip_java.bzl | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/examples/bazel-example/src/main/java/srcjar_example/BUILD b/examples/bazel-example/src/main/java/srcjar_example/BUILD index dce48b36..a5afe5fe 100644 --- a/examples/bazel-example/src/main/java/srcjar_example/BUILD +++ b/examples/bazel-example/src/main/java/srcjar_example/BUILD @@ -26,3 +26,12 @@ java_library( ":generated-srcjar", ], ) + +java_test( + name = "testing_test", + srcs = [ + "Foo.java", + ":generated-srcjar", + ], + test_class = "Foo", +) diff --git a/scip-java/src/main/resources/scip-java/scip_java.bzl b/scip-java/src/main/resources/scip-java/scip_java.bzl index 1525597f..93337381 100644 --- a/scip-java/src/main/resources/scip-java/scip_java.bzl +++ b/scip-java/src/main/resources/scip-java/scip_java.bzl @@ -9,7 +9,7 @@ different contents. This aspect is needed for scip-java to inspect the structure of the Bazel build and register actions to index all java_library/java_test/java_binary targets. The result of running this aspect is that your bazel-bin/ directory will contain -many *.scip (https://github.com/sourcegraph/scip) and +many *.scip (https://github.com/sourcegraph/scip) and *.semanticdb (https://scalameta.org/docs/semanticdb/specification.html) files. These files encode information about which symbols are referenced from which locations in your source code. @@ -66,13 +66,13 @@ def _scip_java(target, ctx): if len(source_files) == 0: return None - + output_dir = [] for source_jar in source_jars: - dir = ctx.actions.declare_directory(ctx.label.name + "/extracted_srcjar/" + source_jar.short_path) + dir = ctx.actions.declare_directory(ctx.label.name + ".extracted_srcjar/" + source_jar.short_path) output_dir.append(dir) - + ctx.actions.run_shell( inputs = javac_action.inputs, outputs = [dir], @@ -99,7 +99,7 @@ def _scip_java(target, ctx): launcher_javac_flags = [] compiler_javac_flags = [] - + # In different versions of bazel javac options are either a nested set or a depset or a list... javac_options = [] if hasattr(compilation, "javac_options_list"): @@ -108,7 +108,7 @@ def _scip_java(target, ctx): javac_options = compilation.javac_options for value in javac_options: - # NOTE(Anton): for some bizarre reason I see empty string starting the list of + # NOTE(Anton): for some bizarre reason I see empty string starting the list of # javac options - which then gets propagated into the JSON config, and ends up # crashing the actual javac invokation. if value != "": From c681b3d9d4d635297c70438467ff5b155927dbe5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 11:45:58 +0000 Subject: [PATCH 12/13] Update dependency sbt/sbt to v1.10.10 (#777) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- project/build.properties | 2 +- website/project/build.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build.properties b/project/build.properties index bc739060..e97b2722 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.10.3 +sbt.version=1.10.10 diff --git a/website/project/build.properties b/website/project/build.properties index bc739060..e97b2722 100644 --- a/website/project/build.properties +++ b/website/project/build.properties @@ -1 +1 @@ -sbt.version=1.10.3 +sbt.version=1.10.10 From 95af40078f1cf1659ffd63bc15f2053630d0e476 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Tue, 4 Mar 2025 15:57:49 +0000 Subject: [PATCH 13/13] Fix annotated types in new class expression (#773) --- .../semanticdb_javac/SemanticdbVisitor.java | 26 ++++++-- .../main/java/minimized/TypeAnnotations.java | 17 ++++++ .../main/java/minimized/TypeAnnotations.java | 60 +++++++++++++++++++ 3 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 tests/minimized/src/main/java/minimized/TypeAnnotations.java create mode 100644 tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/TypeAnnotations.java diff --git a/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java b/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java index f8298532..abd02c55 100644 --- a/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java +++ b/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java @@ -18,6 +18,7 @@ import com.sun.source.tree.TypeCastTree; import com.sun.source.tree.TypeParameterTree; import com.sun.source.tree.ParameterizedTypeTree; +import com.sun.source.tree.AnnotatedTypeTree; import javax.tools.Diagnostic; import javax.lang.model.element.Element; @@ -349,12 +350,25 @@ private void resolveNewClassTree(NewClassTree node, TreePath treePath) { if (parentSym == null || parentSym.getKind() != ElementKind.ENUM_CONSTANT) { TreePath identifierTreePath = nodes.get(node.getIdentifier()); Element identifierSym = trees.getElement(identifierTreePath); - emitSymbolOccurrence( - sym, - node, - identifierSym.getSimpleName(), - Role.REFERENCE, - CompilerRange.FROM_TEXT_SEARCH); + // Simplest case, e.g. `new String()` + if (identifierSym != null) { + emitSymbolOccurrence( + sym, + node, + identifierSym.getSimpleName(), + Role.REFERENCE, + CompilerRange.FROM_TEXT_SEARCH); + } + // More complex case, where the type is annotated: `new @TypeParameters String()` + else if (node.getIdentifier().getKind() == Tree.Kind.ANNOTATED_TYPE) { + AnnotatedTypeTree annotatedTypeTree = (AnnotatedTypeTree) node.getIdentifier(); + if (annotatedTypeTree.getUnderlyingType() != null + && annotatedTypeTree.getUnderlyingType().getKind() == Tree.Kind.IDENTIFIER) { + IdentifierTree ident = (IdentifierTree) annotatedTypeTree.getUnderlyingType(); + emitSymbolOccurrence( + sym, ident, ident.getName(), Role.REFERENCE, CompilerRange.FROM_TEXT_SEARCH); + } + } } } } diff --git a/tests/minimized/src/main/java/minimized/TypeAnnotations.java b/tests/minimized/src/main/java/minimized/TypeAnnotations.java new file mode 100644 index 00000000..9ddf6a8d --- /dev/null +++ b/tests/minimized/src/main/java/minimized/TypeAnnotations.java @@ -0,0 +1,17 @@ +package minimized; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE_USE }) +@interface TypeAnnotation { + int integer() default 1; +} + +// FIXME(issue: GRAPH-1122): Definition range for T below is incorrect +class ClassProcessed<@TypeAnnotation T extends Number> { + + public ClassProcessed() { + String s = new @TypeAnnotation String(); + } +} diff --git a/tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/TypeAnnotations.java b/tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/TypeAnnotations.java new file mode 100644 index 00000000..4bc4407e --- /dev/null +++ b/tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/TypeAnnotations.java @@ -0,0 +1,60 @@ +package minimized; + +import java.lang.annotation.ElementType; +// ^^^^ reference semanticdb maven . . java/ +// ^^^^ reference semanticdb maven . . java/lang/ +// ^^^^^^^^^^ reference semanticdb maven . . java/lang/annotation/ +// ^^^^^^^^^^^ reference semanticdb maven jdk 11 java/lang/annotation/ElementType# +import java.lang.annotation.Target; +// ^^^^ reference semanticdb maven . . java/ +// ^^^^ reference semanticdb maven . . java/lang/ +// ^^^^^^^^^^ reference semanticdb maven . . java/lang/annotation/ +// ^^^^^^ reference semanticdb maven jdk 11 java/lang/annotation/Target# + +@Target({ ElementType.TYPE_USE }) +//^^^^^ reference semanticdb maven jdk 11 java/lang/annotation/Target# +// ^^^^^^^^^^^ reference semanticdb maven jdk 11 java/lang/annotation/ElementType# +// ^^^^^^^^ reference semanticdb maven jdk 11 java/lang/annotation/ElementType#TYPE_USE. +@interface TypeAnnotation { +// ^^^^^^^^^^^^^^ definition semanticdb maven . . minimized/TypeAnnotation# +// display_name TypeAnnotation +// signature_documentation java @Target({ElementType.TYPE_USE})\n@interface TypeAnnotation +// kind Interface +// relationship is_implementation semanticdb maven jdk 11 java/lang/annotation/Annotation# + int integer() default 1; +// ^^^^^^^ definition semanticdb maven . . minimized/TypeAnnotation#integer(). +// display_name integer +// signature_documentation java public abstract int integer() +// kind AbstractMethod +} + +// FIXME(issue: GRAPH-1122): Definition range for T below is incorrect +class ClassProcessed<@TypeAnnotation T extends Number> { +// ^^^^^^^^^^^^^^ definition semanticdb maven . . minimized/ClassProcessed# +// display_name ClassProcessed +// signature_documentation java class ClassProcessed +// kind Class +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition semanticdb maven . . minimized/ClassProcessed#[T] +// display_name T +// signature_documentation java T extends Number +// kind TypeParameter +// ^^^^^^^^^^^^^^ reference semanticdb maven . . minimized/TypeAnnotation# +// ^^^^^^ reference semanticdb maven jdk 11 java/lang/Number# + + public ClassProcessed() { +// ^^^^^^^^^^^^^^ definition semanticdb maven . . minimized/ClassProcessed#``(). +// display_name +// signature_documentation java public ClassProcessed() +// kind Constructor + String s = new @TypeAnnotation String(); +// ^^^^^^ reference semanticdb maven jdk 11 java/lang/String# +// ^ definition local 0 +// display_name s +// signature_documentation java String s +// enclosing_symbol semanticdb maven . . minimized/ClassProcessed#``(). +// kind Variable +// ^^^^^^^^^^^^^^ reference semanticdb maven . . minimized/TypeAnnotation# +// ^^^^^^ reference semanticdb maven jdk 11 java/lang/String# +// ^^^^^^ reference semanticdb maven jdk 11 java/lang/String#``(). + } +}