Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2847a1c
Add Singature information for Semanticdb
tanishiking Jun 20, 2021
d21fe59
Reset local symbol index for each TextDocument, updateExpect
tanishiking Jun 24, 2021
9c6015e
PrettyPrint signature and update metac.expect
tanishiking Jun 24, 2021
90177c6
Integrate SymbolInformationOps into Scala3#SymbolOps
tanishiking Jun 24, 2021
de36d34
Model WithType for AndType
tanishiking Jun 24, 2021
7dd91ad
Resolve ParamRef by constructing SymbolTable
tanishiking Jun 29, 2021
226e26f
Lookup symbols for refinements in RefinedType and RecType
tanishiking Jun 29, 2021
58fd3d5
Re-insert assertion to localIdx
tanishiking Jun 29, 2021
0325a22
Convert AndType to IntersectionType
tanishiking Jul 2, 2021
3cad5f3
Refactor enterRefined
tanishiking Jul 3, 2021
a3e1f53
Refactor: move all extension (of Symbol) method into Scala3
tanishiking Jul 3, 2021
75bc739
Don't add type parameters as parameters to MethodSignature
tanishiking Jul 3, 2021
e99daa7
TypeLambda
tanishiking Jul 1, 2021
f13b2d1
MatchType
tanishiking Jul 2, 2021
233c851
Update the protobuf schema for TypeLambda and MatchType
tanishiking Jul 5, 2021
56f8fc8
updateExpect
tanishiking Jul 5, 2021
fa167bc
Refactor not to use isInstanceOf for designator of TypeRef and TermRef
tanishiking Jul 6, 2021
5af0737
Use intersection type for the parent of RefinedType
tanishiking Jul 6, 2021
f509613
Convert wildcard type as ExistentialType
tanishiking Jul 6, 2021
139491b
Use finalResultType for MethodSignature to get actual return type.
tanishiking Jul 7, 2021
a8a137c
Register the symbol of nested method with "actual" binder
tanishiking Jul 7, 2021
5b0a549
Remove unused parameter sym from toSemanticType
tanishiking Jul 7, 2021
5359f22
Fix pprint issue for SingleType
tanishiking Jul 7, 2021
9a0d3ac
Convert symbols to local index for funParamSymbol
tanishiking Jul 7, 2021
a524093
Merge branch 'master' into semanticdb-signature
tanishiking Jul 7, 2021
c32df73
Merge branch 'semanticdb-signature' into typelambda-match
tanishiking Jul 7, 2021
b63ae56
Embed bound information of MatchType to TypeSignature
tanishiking Jul 7, 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
27 changes: 27 additions & 0 deletions compiler/src/dotty/tools/dotc/semanticdb/ConstantOps.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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()
// ConstantType(_: Type, ClazzTag) should be converted as it's type
// NoTag => it shouldn't happen
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