Skip to content

Commit

Permalink
Use consistent naming convention in SemanticDB schema
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg committed Aug 29, 2018
1 parent f5d9f77 commit 54f5397
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 185 deletions.
Expand Up @@ -39,19 +39,19 @@ trait SyntheticPrinter extends BasePrinter with RangePrinter with SymbolInformat
def pprint(tree: Tree): Unit = {
tree match {
case tree: ApplyTree =>
pprint(tree.fn)
pprint(tree.function)
out.print("(")
rep(tree.args, ", ")(pprint)
rep(tree.arguments, ", ")(pprint)
out.print(")")
case tree: FunctionTree =>
out.print("{")
rep("(", tree.params, ", ", ") => ")(pprint)
pprint(tree.term)
rep("(", tree.parameters, ", ", ") => ")(pprint)
pprint(tree.body)
out.print("}")
case tree: IdTree =>
pprint(tree.sym, Reference)
pprint(tree.symbol, Reference)
case tree: LiteralTree =>
pprint(tree.const)
pprint(tree.constant)
case tree: MacroExpansionTree =>
out.print("(`macro-expandee` : ")
pprint(tree.tpe)
Expand All @@ -65,13 +65,13 @@ trait SyntheticPrinter extends BasePrinter with RangePrinter with SymbolInformat
out.print(")")
}
case tree: SelectTree =>
pprint(tree.qual)
pprint(tree.qualifier)
out.print(".")
opt(tree.id)(pprint)
case tree: TypeApplyTree =>
pprint(tree.fn)
pprint(tree.function)
out.print("[")
rep(tree.targs, ", ")(pprint)
rep(tree.typeArguments, ", ")(pprint)
out.print("]")
case NoTree =>
out.print("<?>")
Expand Down
Expand Up @@ -12,31 +12,31 @@ trait SyntheticOps { self: SemanticdbOps =>
def toSemanticTree: s.Tree = gTree match {
case gTree: g.Apply =>
s.ApplyTree(
fn = gTree.fun.toSemanticId,
args = gTree.args.map(_.toSemanticTree)
function = gTree.fun.toSemanticId,
arguments = gTree.args.map(_.toSemanticTree)
)
case gTree: g.TypeApply =>
s.TypeApplyTree(
fn = gTree.fun.toSemanticTree,
targs = gTree.args.map(_.tpe.toSemanticTpe)
function = gTree.fun.toSemanticTree,
typeArguments = gTree.args.map(_.tpe.toSemanticTpe)
)
case gTree: g.Select => gTree.toSemanticId
case gTree: g.Ident => gTree.toSemanticId
case gTree: g.This => gTree.toSemanticId
case gTree: g.Typed if gTree.hasAttachment[g.analyzer.MacroExpansionAttachment] =>
val expandeeTree = gTree.attachments.get[g.analyzer.MacroExpansionAttachment].get.expandee
val expandee =
val beforeExpansion =
if (expandeeTree.pos.isRange) expandeeTree.toSemanticOriginal
else expandeeTree.toSemanticTree
s.MacroExpansionTree(
expandee = expandee,
beforeExpansion = beforeExpansion,
tpe = gTree.tpt.tpe.toSemanticTpe
)
case _ =>
s.NoTree
}

def toSemanticId: s.IdTree = s.IdTree(sym = gTree.symbol.toSemantic)
def toSemanticId: s.IdTree = s.IdTree(symbol = gTree.symbol.toSemantic)

def toSemanticOriginal: s.Tree = s.OriginalTree(
range = Some(gTree.pos.toMeta.toRange)
Expand Down
Expand Up @@ -397,16 +397,16 @@ trait TextDocumentOps { self: SemanticdbOps =>
isVisitedParent += gtree
gtree match {
case gtree: g.TypeApply =>
val targs = gtree.args.map(_.tpe.toSemanticTpe)
val typeArguments = gtree.args.map(_.tpe.toSemanticTpe)
val innerTree = forMethodSelect(gtree.fun)
s.TypeApplyTree(
fn = innerTree,
targs = targs
function = innerTree,
typeArguments = typeArguments
)
case gtree: g.Select if isForSynthetic(gtree) =>
val qual = forSyntheticOrOrig(gtree.qualifier)
val qualifier = forSyntheticOrOrig(gtree.qualifier)
s.SelectTree(
qual = qual,
qualifier = qualifier,
id = Some(gtree.toSemanticId)
)
}
Expand All @@ -428,15 +428,15 @@ trait TextDocumentOps { self: SemanticdbOps =>
val implicitArgs = gtree.args.map(_.toSemanticTree)
val innerTree = forSyntheticOrOrig(gtree.fun)
s.ApplyTree(
fn = innerTree,
args = implicitArgs
function = innerTree,
arguments = implicitArgs
)
case gtree: g.Apply if isForSynthetic(gtree) =>
val fun = forMethodSelect(gtree.fun)
val body = forMethodBody(gtree.args.head)
s.ApplyTree(
fn = fun,
args = List(body)
function = fun,
arguments = List(body)
)
case gtree => gtree.toSemanticOriginal
}
Expand All @@ -449,8 +449,8 @@ trait TextDocumentOps { self: SemanticdbOps =>
synthetics += s.Synthetic(
range = Some(pos.toRange),
tree = s.ApplyTree(
fn = gview.fun.toSemanticTree,
args = List(
function = gview.fun.toSemanticTree,
arguments = List(
s.OriginalTree(
range = Some(pos.toRange)
))
Expand All @@ -465,14 +465,14 @@ trait TextDocumentOps { self: SemanticdbOps =>
synthetics += s.Synthetic(
range = Some(range),
tree = s.ApplyTree(
fn = s.ApplyTree(
fn = gview.fun.toSemanticTree,
args = List(
function = s.ApplyTree(
function = gview.fun.toSemanticTree,
arguments = List(
s.OriginalTree(
range = Some(range)
))
),
args = gimpl.args.map(_.toSemanticTree)
arguments = gimpl.args.map(_.toSemanticTree)
)
)
case gfun if isForSynthetic(gfun) =>
Expand All @@ -486,10 +486,10 @@ trait TextDocumentOps { self: SemanticdbOps =>
synthetics += s.Synthetic(
range = Some(gfun.pos.toMeta.toRange),
tree = s.ApplyTree(
fn = s.OriginalTree(
function = s.OriginalTree(
range = Some(gfun.pos.toMeta.toRange)
),
args = gimpl.args.map(_.toSemanticTree)
arguments = gimpl.args.map(_.toSemanticTree)
)
)
}
Expand All @@ -502,8 +502,8 @@ trait TextDocumentOps { self: SemanticdbOps =>
isVisitedParent += fun
val symbol = select.symbol.toSemantic
s.SelectTree(
qual = s.OriginalTree(range = Some(qual.pos.toMeta.toRange)),
id = Some(s.IdTree(sym = symbol))
qualifier = s.OriginalTree(range = Some(qual.pos.toMeta.toRange)),
id = Some(s.IdTree(symbol = symbol))
)
case _ =>
s.OriginalTree(
Expand All @@ -513,8 +513,8 @@ trait TextDocumentOps { self: SemanticdbOps =>
synthetics += s.Synthetic(
range = Some(fun.pos.toMeta.toRange),
tree = s.TypeApplyTree(
fn = fnTree,
targs = targs.map(_.tpe.toSemanticTpe)
function = fnTree,
typeArguments = targs.map(_.tpe.toSemanticTpe)
)
)
case ApplySelect(select @ g.Select(qual, nme)) if isSyntheticName(select) =>
Expand All @@ -523,8 +523,8 @@ trait TextDocumentOps { self: SemanticdbOps =>
synthetics += s.Synthetic(
range = Some(qual.pos.toMeta.toRange),
tree = s.SelectTree(
qual = s.OriginalTree(range = Some(qual.pos.toMeta.toRange)),
id = Some(s.IdTree(sym = symbol))
qualifier = s.OriginalTree(range = Some(qual.pos.toMeta.toRange)),
id = Some(s.IdTree(symbol = symbol))
)
)
case gtree if isForSynthetic(gtree) =>
Expand Down
110 changes: 55 additions & 55 deletions semanticdb/semanticdb/semanticdb.proto
Expand Up @@ -51,20 +51,20 @@ message Scope {
message Type {
reserved 1, 3, 4, 5, 6, 11, 12, 15, 16;
oneof sealed_value {
TypeRef typeRef = 2;
SingleType singleType = 20;
ThisType thisType = 21;
SuperType superType = 22;
ConstantType constantType = 23;
IntersectionType intersectionType = 17;
UnionType unionType = 18;
WithType withType = 19;
StructuralType structuralType = 7;
AnnotatedType annotatedType = 8;
ExistentialType existentialType = 9;
UniversalType universalType = 10;
ByNameType byNameType = 13;
RepeatedType repeatedType = 14;
TypeRef type_ref = 2;
SingleType single_type = 20;
ThisType this_type = 21;
SuperType super_type = 22;
ConstantType constant_type = 23;
IntersectionType intersection_type = 17;
UnionType union_type = 18;
WithType with_type = 19;
StructuralType structural_type = 7;
AnnotatedType annotated_type = 8;
ExistentialType existential_type = 9;
UniversalType universal_type = 10;
ByNameType by_name_type = 13;
RepeatedType repeated_type = 14;
}
}

Expand Down Expand Up @@ -138,17 +138,17 @@ message RepeatedType {

message Constant {
oneof sealed_value {
UnitConstant unitConstant = 1;
BooleanConstant booleanConstant = 2;
ByteConstant byteConstant = 3;
ShortConstant shortConstant = 4;
CharConstant charConstant = 5;
IntConstant intConstant = 6;
LongConstant longConstant = 7;
FloatConstant floatConstant = 8;
DoubleConstant doubleConstant = 9;
StringConstant stringConstant = 10;
NullConstant nullConstant = 11;
UnitConstant unit_constant = 1;
BooleanConstant boolean_constant = 2;
ByteConstant byte_constant = 3;
ShortConstant short_constant = 4;
CharConstant char_constant = 5;
IntConstant int_constant = 6;
LongConstant long_constant = 7;
FloatConstant float_constant = 8;
DoubleConstant double_constant = 9;
StringConstant string_constant = 10;
NullConstant null_constant = 11;
}
}

Expand Down Expand Up @@ -196,10 +196,10 @@ message NullConstant {

message Signature {
oneof sealed_value {
ClassSignature classSignature = 1;
MethodSignature methodSignature = 2;
TypeSignature typeSignature = 3;
ValueSignature valueSignature = 4;
ClassSignature class_signature = 1;
MethodSignature method_signature = 2;
TypeSignature type_signature = 3;
ValueSignature value_signature = 4;
}
}

Expand All @@ -212,7 +212,7 @@ message ClassSignature {

message MethodSignature {
Scope type_parameters = 1;
repeated Scope parameterLists = 2;
repeated Scope parameter_lists = 2;
Type return_type = 3;
}

Expand Down Expand Up @@ -282,13 +282,13 @@ message Annotation {

message Access {
oneof sealed_value {
PrivateAccess privateAccess = 1;
PrivateThisAccess privateThisAccess = 2;
PrivateWithinAccess privateWithinAccess = 3;
ProtectedAccess protectedAccess = 4;
ProtectedThisAccess protectedThisAccess = 5;
ProtectedWithinAccess protectedWithinAccess = 6;
PublicAccess publicAccess = 7;
PrivateAccess private_access = 1;
PrivateThisAccess private_this_access = 2;
PrivateWithinAccess private_within_access = 3;
ProtectedAccess protected_access = 4;
ProtectedThisAccess protected_this_access = 5;
ProtectedWithinAccess protected_within_access = 6;
PublicAccess public_access = 7;
}
}

Expand Down Expand Up @@ -346,37 +346,37 @@ message Synthetic {

message Tree {
oneof sealed_value {
ApplyTree applyTree = 1;
FunctionTree functionTree = 2;
IdTree idTree = 3;
LiteralTree literalTree = 4;
MacroExpansionTree macroExpansionTree = 5;
OriginalTree originalTree = 6;
SelectTree selectTree = 7;
TypeApplyTree typeApplyTree = 8;
ApplyTree apply_tree = 1;
FunctionTree function_tree = 2;
IdTree id_tree = 3;
LiteralTree literal_tree = 4;
MacroExpansionTree macro_expansion_tree = 5;
OriginalTree original_tree = 6;
SelectTree select_tree = 7;
TypeApplyTree type_apply_tree = 8;
}
}

message ApplyTree {
Tree fn = 1;
repeated Tree args = 2;
Tree function = 1;
repeated Tree arguments = 2;
}

message FunctionTree {
repeated IdTree params = 1;
Tree term = 2;
repeated IdTree parameters = 1;
Tree body = 2;
}

message IdTree {
string sym = 1;
string symbol = 1;
}

message LiteralTree {
Constant const = 1;
Constant constant = 1;
}

message MacroExpansionTree {
Tree expandee = 1;
Tree before_expansion = 1;
Type tpe = 2;
}

Expand All @@ -385,11 +385,11 @@ message OriginalTree {
}

message SelectTree {
Tree qual = 1;
Tree qualifier = 1;
IdTree id = 2;
}

message TypeApplyTree {
Tree fn = 1;
repeated Type targs = 2;
Tree function = 1;
repeated Type type_arguments = 2;
}

0 comments on commit 54f5397

Please sign in to comment.