Skip to content

fix: don't add () to semanticdb symbol for java variables #22573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class SemanticSymbolBuilder:
addName(b, sym.name)
if sym.is(Package) then b.append('/')
else if sym.isType || sym.isAllOf(JavaModule) then b.append('#')
else if sym.isOneOf(Method | Mutable)
else if sym.is(Method) || (sym.is(Mutable) && !sym.is(JavaDefined))
&& (!sym.is(StableRealizable) || sym.isConstructor) then
b.append('('); addOverloadIdx(sym); b.append(").")
else b.append('.')
Expand Down
7 changes: 7 additions & 0 deletions tests/semanticdb/expect/JavaStaticVar.expect.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package example

import com.javacp.JavaStaticVar/*->com::javacp::JavaStaticVar#*/

class ScalaFoo/*<-example::ScalaFoo#*/ {
val javaStaticVarFoo/*<-example::ScalaFoo#javaStaticVarFoo.*/ = JavaStaticVar/*->com::javacp::JavaStaticVar#*/.foo/*->com::javacp::JavaStaticVar#foo.*/
}
7 changes: 7 additions & 0 deletions tests/semanticdb/expect/JavaStaticVar.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package example

import com.javacp.JavaStaticVar

class ScalaFoo {
val javaStaticVarFoo = JavaStaticVar.foo
}
5 changes: 5 additions & 0 deletions tests/semanticdb/javacp/com/javacp/JavaStaticVar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.javacp;

public class JavaStaticVar {
public static int foo = 0;
}
27 changes: 27 additions & 0 deletions tests/semanticdb/metac.expect
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,33 @@ Synthetics:
[8:2..8:10):(x1, x1) => *(Tuple2(Int, Int))
[8:10..8:10): => *(Int, Int)

expect/JavaStaticVar.scala
--------------------------

Summary:
Schema => SemanticDB v4
Uri => JavaStaticVar.scala
Text => empty
Language => Scala
Symbols => 3 entries
Occurrences => 9 entries

Symbols:
example/ScalaFoo# => class ScalaFoo extends Object { self: ScalaFoo => +2 decls }
example/ScalaFoo#`<init>`(). => primary ctor <init> (): ScalaFoo
example/ScalaFoo#javaStaticVarFoo. => val method javaStaticVarFoo Int

Occurrences:
[0:8..0:15): example <- example/
[2:7..2:10): com -> com/
[2:11..2:17): javacp -> com/javacp/
[2:18..2:31): JavaStaticVar -> com/javacp/JavaStaticVar#
[4:6..4:14): ScalaFoo <- example/ScalaFoo#
[5:2..5:2): <- example/ScalaFoo#`<init>`().
[5:6..5:22): javaStaticVarFoo <- example/ScalaFoo#javaStaticVarFoo.
[5:25..5:38): JavaStaticVar -> com/javacp/JavaStaticVar#
[5:39..5:42): foo -> com/javacp/JavaStaticVar#foo.

expect/Local.scala
------------------

Expand Down
Loading