-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Signature information in Semanticdb #12885
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
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
dcfa717
Add Singature information for Semanticdb
tanishiking e168538
Reset local symbol index for each TextDocument, updateExpect
tanishiking e0a6da7
PrettyPrint signature and update metac.expect
tanishiking ae5590b
Integrate SymbolInformationOps into Scala3#SymbolOps
tanishiking d9577d7
Model WithType for AndType
tanishiking 0233aac
Resolve ParamRef by constructing SymbolTable
tanishiking 9d46a0f
Lookup symbols for refinements in RefinedType and RecType
tanishiking e47a7f9
Re-insert assertion to localIdx
tanishiking b2985ed
Convert AndType to IntersectionType
tanishiking 80271a8
Refactor enterRefined
tanishiking 7c0b14a
Refactor: move all extension (of Symbol) method into Scala3
tanishiking ebb0ede
Don't add type parameters as parameters to MethodSignature
tanishiking af84cad
Refactor not to use isInstanceOf for designator of TypeRef and TermRef
tanishiking b8c6c12
Use intersection type for the parent of RefinedType
tanishiking 60aac59
Convert wildcard type as ExistentialType
tanishiking 2ee5d4c
Use finalResultType for MethodSignature to get actual return type.
tanishiking bb4c9eb
Register the symbol of nested method with "actual" binder
tanishiking 4a69a43
Remove unused parameter sym from toSemanticType
tanishiking ce730cc
Fix pprint issue for SingleType
tanishiking bccc78d
Convert symbols to local index for funParamSymbol
tanishiking ab4ba37
Refactor style of if
tanishiking e633017
Fix printing upper type bounds
tanishiking 6c887e1
Add evidence params to SemanticDB
tanishiking 855407b
Add refinements to RefinedType generated by opaque types
tanishiking dfeaab4
Fix empty refinement for RefinedType for the result of polymorphic me…
tanishiking b581e45
Print definition of ExistentialType instead of displaySymbol
tanishiking 3b144a7
Update comment
tanishiking 2f13751
None for empty decls
tanishiking 17c06dc
Warn if symbol lookup failed for paramRef and RefinedType
tanishiking a276ec0
Workaround symbol not found for higher kinded type param
tanishiking cfa4378
Suppress warning for known issue of exporting Polymorphic type
tanishiking 8d8777e
Support multiple type param clauses for extension method
tanishiking 21e39e0
Exclude synthetic symbols from occurrences
tanishiking a69cc97
Fallback to Type.member for refinements who can't access to the tree
tanishiking 1fdf650
Fallback to Type.member for ParamRef
tanishiking aad48ea
Workaround symbol not found for HKTypeLambda in upper bounds
tanishiking c111a49
Remove unnecessary comment
tanishiking 5f9ce74
Do not create newSymbol for wildcard type symbol
tanishiking c489415
Warn if unexpected type appear while converting type to SemanticDB type
tanishiking 326e43e
Dealias LazyRef while converting types to SemanticDB
tanishiking 9f0063d
Do not emit warning for unexpected type
tanishiking 45c8cc1
Do not create a newSymbol for ParamRef
tanishiking fd75b36
Make wildcard type symbol global
tanishiking 4e97e76
Hardlink fake symbols
tanishiking fef5be0
Excude symbols that doesn't present in source from occurrence
tanishiking adae1ff
Make namePresenInSource safe for IndexOutOfRange
tanishiking c3bd0d5
Make package objects present in source
tanishiking 0e3c8ad
Fallback to fake symbol for refinements in RefinedType of upper bound
tanishiking c3548a1
Add occurrences of secondary constructors
tanishiking 4af72b9
Add fakeSymbols to symbol section and don't hardlink fake syms
tanishiking d9838df
Convert tp <:< FromJavaObject to tp <:< Any
tanishiking a82605f
Do not add wildcard symbol of existential type to symbol section
tanishiking 056f4a4
Refactor styles
tanishiking File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
compiler/src/dotty/tools/dotc/semanticdb/ConstantOps.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dotty.tools | ||
package dotc | ||
package semanticdb | ||
|
||
import dotty.tools.dotc.{semanticdb => s} | ||
|
||
import core.Contexts.Context | ||
import core.Constants._ | ||
|
||
object ConstantOps: | ||
extension (const: Constant) | ||
def toSemanticConst(using Context): s.Constant = const.tag match { | ||
case UnitTag => s.UnitConstant() | ||
case BooleanTag => s.BooleanConstant(const.booleanValue) | ||
case ByteTag => s.ByteConstant(const.byteValue) | ||
case ShortTag => s.ShortConstant(const.shortValue) | ||
case CharTag => s.CharConstant(const.charValue) | ||
case IntTag => s.IntConstant(const.intValue) | ||
case LongTag => s.LongConstant(const.longValue) | ||
case FloatTag => s.FloatConstant(const.floatValue) | ||
case DoubleTag => s.DoubleConstant(const.doubleValue) | ||
case StringTag => s.StringConstant(const.stringValue) | ||
case NullTag => s.NullConstant() | ||
case _ => throw new Error(s"Constant ${const} can't be converted to Semanticdb Constant.") | ||
} |
120 changes: 120 additions & 0 deletions
120
compiler/src/dotty/tools/dotc/semanticdb/Descriptor.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package dotty.tools.dotc.semanticdb | ||
|
||
import java.lang.System.{lineSeparator => EOL} | ||
import dotty.tools.dotc.semanticdb.{Descriptor => d} | ||
|
||
class DescriptorParser(s: String) { | ||
var i = s.length | ||
def fail() = { | ||
val message = "invalid symbol format" | ||
val caret = " " * i + "^" | ||
sys.error(s"$message$EOL$s$EOL$caret") | ||
} | ||
|
||
val BOF = '\u0000' | ||
val EOF = '\u001A' | ||
var currChar = EOF | ||
def readChar(): Char = { | ||
if (i <= 0) { | ||
if (i == 0) { | ||
i -= 1 | ||
currChar = BOF | ||
currChar | ||
} else { | ||
fail() | ||
} | ||
} else { | ||
i -= 1 | ||
currChar = s(i) | ||
currChar | ||
} | ||
} | ||
|
||
def parseValue(): String = { | ||
if (currChar == '`') { | ||
val end = i | ||
while (readChar() != '`') {} | ||
readChar() | ||
s.substring(i + 2, end) | ||
} else { | ||
val end = i + 1 | ||
if (!Character.isJavaIdentifierPart(currChar)) fail() | ||
while (Character.isJavaIdentifierPart(readChar()) && currChar != BOF) {} | ||
s.substring(i + 1, end) | ||
} | ||
} | ||
|
||
def parseDisambiguator(): String = { | ||
val end = i + 1 | ||
if (currChar != ')') fail() | ||
while (readChar() != '(') {} | ||
readChar() | ||
s.substring(i + 1, end) | ||
} | ||
|
||
def parseDescriptor(): Descriptor = { | ||
if (currChar == '.') { | ||
readChar() | ||
if (currChar == ')') { | ||
val disambiguator = parseDisambiguator() | ||
val value = parseValue() | ||
d.Method(value, disambiguator) | ||
} else { | ||
d.Term(parseValue()) | ||
} | ||
} else if (currChar == '#') { | ||
readChar() | ||
d.Type(parseValue()) | ||
} else if (currChar == '/') { | ||
readChar() | ||
d.Package(parseValue()) | ||
} else if (currChar == ')') { | ||
readChar() | ||
val value = parseValue() | ||
if (currChar != '(') fail() | ||
else readChar() | ||
d.Parameter(value) | ||
} else if (currChar == ']') { | ||
readChar() | ||
val value = parseValue() | ||
if (currChar != '[') fail() | ||
else readChar() | ||
d.TypeParameter(value) | ||
} else { | ||
fail() | ||
} | ||
} | ||
|
||
def entryPoint(): (Descriptor, String) = { | ||
readChar() | ||
val desc = parseDescriptor() | ||
(desc, s.substring(0, i + 1)) | ||
} | ||
} | ||
|
||
object DescriptorParser { | ||
def apply(symbol: String): (Descriptor, String) = { | ||
val parser = new DescriptorParser(symbol) | ||
parser.entryPoint() | ||
} | ||
} | ||
|
||
sealed trait Descriptor { | ||
def isNone: Boolean = this == d.None | ||
def isTerm: Boolean = this.isInstanceOf[d.Term] | ||
def isMethod: Boolean = this.isInstanceOf[d.Method] | ||
def isType: Boolean = this.isInstanceOf[d.Type] | ||
def isPackage: Boolean = this.isInstanceOf[d.Package] | ||
def isParameter: Boolean = this.isInstanceOf[d.Parameter] | ||
def isTypeParameter: Boolean = this.isInstanceOf[d.TypeParameter] | ||
def value: String | ||
} | ||
object Descriptor { | ||
case object None extends Descriptor { def value: String = "" } | ||
final case class Term(value: String) extends Descriptor | ||
final case class Method(value: String, disambiguator: String) extends Descriptor | ||
final case class Type(value: String) extends Descriptor | ||
final case class Package(value: String) extends Descriptor | ||
final case class Parameter(value: String) extends Descriptor | ||
final case class TypeParameter(value: String) extends Descriptor | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.