Skip to content

Commit 38154ba

Browse files
committed
fix: don't add () to semanticdb symbol for java variables
1 parent 7ac31d0 commit 38154ba

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

compiler/src/dotty/tools/dotc/semanticdb/SemanticSymbolBuilder.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class SemanticSymbolBuilder:
111111
addName(b, sym.name)
112112
if sym.is(Package) then b.append('/')
113113
else if sym.isType || sym.isAllOf(JavaModule) then b.append('#')
114-
else if sym.isOneOf(Method | Mutable)
114+
else if sym.is(Method) || (sym.is(Mutable) && !sym.is(JavaDefined))
115115
&& (!sym.is(StableRealizable) || sym.isConstructor) then
116116
b.append('('); addOverloadIdx(sym); b.append(").")
117117
else b.append('.')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package example
2+
3+
import com.javacp.JavaStaticVar/*->com::javacp::JavaStaticVar#*/
4+
5+
class ScalaFoo/*<-example::ScalaFoo#*/ {
6+
val javaStaticVarFoo/*<-example::ScalaFoo#javaStaticVarFoo.*/ = JavaStaticVar/*->com::javacp::JavaStaticVar#*/.foo/*->com::javacp::JavaStaticVar#foo.*/
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package example
2+
3+
import com.javacp.JavaStaticVar
4+
5+
class ScalaFoo {
6+
val javaStaticVarFoo = JavaStaticVar.foo
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.javacp;
2+
3+
public class JavaStaticVar {
4+
public static int foo = 0;
5+
}

tests/semanticdb/metac.expect

+27
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,33 @@ Synthetics:
22762276
[8:2..8:10):(x1, x1) => *(Tuple2(Int, Int))
22772277
[8:10..8:10): => *(Int, Int)
22782278

2279+
expect/JavaStaticVar.scala
2280+
--------------------------
2281+
2282+
Summary:
2283+
Schema => SemanticDB v4
2284+
Uri => JavaStaticVar.scala
2285+
Text => empty
2286+
Language => Scala
2287+
Symbols => 3 entries
2288+
Occurrences => 9 entries
2289+
2290+
Symbols:
2291+
example/ScalaFoo# => class ScalaFoo extends Object { self: ScalaFoo => +2 decls }
2292+
example/ScalaFoo#`<init>`(). => primary ctor <init> (): ScalaFoo
2293+
example/ScalaFoo#javaStaticVarFoo. => val method javaStaticVarFoo Int
2294+
2295+
Occurrences:
2296+
[0:8..0:15): example <- example/
2297+
[2:7..2:10): com -> com/
2298+
[2:11..2:17): javacp -> com/javacp/
2299+
[2:18..2:31): JavaStaticVar -> com/javacp/JavaStaticVar#
2300+
[4:6..4:14): ScalaFoo <- example/ScalaFoo#
2301+
[5:2..5:2): <- example/ScalaFoo#`<init>`().
2302+
[5:6..5:22): javaStaticVarFoo <- example/ScalaFoo#javaStaticVarFoo.
2303+
[5:25..5:38): JavaStaticVar -> com/javacp/JavaStaticVar#
2304+
[5:39..5:42): foo -> com/javacp/JavaStaticVar#foo.
2305+
22792306
expect/Local.scala
22802307
------------------
22812308

0 commit comments

Comments
 (0)