Skip to content
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

Add context / implicit params to synthetics #13279

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
dcfa717
Add Singature information for Semanticdb
tanishiking Jun 20, 2021
e168538
Reset local symbol index for each TextDocument, updateExpect
tanishiking Jun 24, 2021
e0a6da7
PrettyPrint signature and update metac.expect
tanishiking Jun 24, 2021
ae5590b
Integrate SymbolInformationOps into Scala3#SymbolOps
tanishiking Jun 24, 2021
d9577d7
Model WithType for AndType
tanishiking Jun 24, 2021
0233aac
Resolve ParamRef by constructing SymbolTable
tanishiking Jun 29, 2021
9d46a0f
Lookup symbols for refinements in RefinedType and RecType
tanishiking Jun 29, 2021
e47a7f9
Re-insert assertion to localIdx
tanishiking Jun 29, 2021
b2985ed
Convert AndType to IntersectionType
tanishiking Jul 2, 2021
80271a8
Refactor enterRefined
tanishiking Jul 3, 2021
7c0b14a
Refactor: move all extension (of Symbol) method into Scala3
tanishiking Jul 3, 2021
ebb0ede
Don't add type parameters as parameters to MethodSignature
tanishiking Jul 3, 2021
af84cad
Refactor not to use isInstanceOf for designator of TypeRef and TermRef
tanishiking Jul 6, 2021
b8c6c12
Use intersection type for the parent of RefinedType
tanishiking Jul 6, 2021
60aac59
Convert wildcard type as ExistentialType
tanishiking Jul 6, 2021
2ee5d4c
Use finalResultType for MethodSignature to get actual return type.
tanishiking Jul 7, 2021
bb4c9eb
Register the symbol of nested method with "actual" binder
tanishiking Jul 7, 2021
4a69a43
Remove unused parameter sym from toSemanticType
tanishiking Jul 7, 2021
ce730cc
Fix pprint issue for SingleType
tanishiking Jul 7, 2021
bccc78d
Convert symbols to local index for funParamSymbol
tanishiking Jul 7, 2021
ab4ba37
Refactor style of if
tanishiking Jul 8, 2021
e633017
Fix printing upper type bounds
tanishiking Jul 8, 2021
6c887e1
Add evidence params to SemanticDB
tanishiking Jul 8, 2021
855407b
Add refinements to RefinedType generated by opaque types
tanishiking Jul 9, 2021
dfeaab4
Fix empty refinement for RefinedType for the result of polymorphic me…
tanishiking Jul 9, 2021
b581e45
Print definition of ExistentialType instead of displaySymbol
tanishiking Jul 9, 2021
3b144a7
Update comment
tanishiking Jul 9, 2021
2f13751
None for empty decls
tanishiking Jul 9, 2021
17c06dc
Warn if symbol lookup failed for paramRef and RefinedType
tanishiking Jul 11, 2021
a276ec0
Workaround symbol not found for higher kinded type param
tanishiking Jul 11, 2021
cfa4378
Suppress warning for known issue of exporting Polymorphic type
tanishiking Jul 11, 2021
8d8777e
Support multiple type param clauses for extension method
tanishiking Jul 12, 2021
21e39e0
Exclude synthetic symbols from occurrences
tanishiking Jul 13, 2021
a69cc97
Fallback to Type.member for refinements who can't access to the tree
tanishiking Jul 14, 2021
1fdf650
Fallback to Type.member for ParamRef
tanishiking Jul 14, 2021
aad48ea
Workaround symbol not found for HKTypeLambda in upper bounds
tanishiking Jul 14, 2021
c111a49
Remove unnecessary comment
tanishiking Jul 14, 2021
5f9ce74
Do not create newSymbol for wildcard type symbol
tanishiking Jul 14, 2021
c489415
Warn if unexpected type appear while converting type to SemanticDB type
tanishiking Jul 14, 2021
326e43e
Dealias LazyRef while converting types to SemanticDB
tanishiking Jul 14, 2021
9f0063d
Do not emit warning for unexpected type
tanishiking Jul 14, 2021
45c8cc1
Do not create a newSymbol for ParamRef
tanishiking Jul 14, 2021
fd75b36
Make wildcard type symbol global
tanishiking Jul 14, 2021
4e97e76
Hardlink fake symbols
tanishiking Jul 14, 2021
fef5be0
Excude symbols that doesn't present in source from occurrence
tanishiking Jul 22, 2021
adae1ff
Make namePresenInSource safe for IndexOutOfRange
tanishiking Jul 26, 2021
c3bd0d5
Make package objects present in source
tanishiking Jul 26, 2021
0e3c8ad
Fallback to fake symbol for refinements in RefinedType of upper bound
tanishiking Jul 28, 2021
c3548a1
Add occurrences of secondary constructors
tanishiking Jul 28, 2021
4af72b9
Add fakeSymbols to symbol section and don't hardlink fake syms
tanishiking Jul 28, 2021
d9838df
Convert tp <:< FromJavaObject to tp <:< Any
tanishiking Jul 28, 2021
a82605f
Do not add wildcard symbol of existential type to symbol section
tanishiking Jul 28, 2021
056f4a4
Refactor styles
tanishiking Aug 9, 2021
1fb37b8
Add implicit or context param apply to synthetics
tanishiking Aug 11, 2021
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
25 changes: 25 additions & 0 deletions compiler/src/dotty/tools/dotc/semanticdb/ConstantOps.scala
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 compiler/src/dotty/tools/dotc/semanticdb/Descriptor.scala
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
}
Loading