Skip to content

Commit a76c25f

Browse files
committed
skeleton code to build symbols while iterating over owners
1 parent d43c87a commit a76c25f

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

semanticdb/src/dotty/semanticdb/SemanticdbConsumer.scala

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,32 @@ class SemanticdbConsumer extends TastyConsumer {
4141
return stack.head + id + "/"
4242
}
4343

44+
def iterateParent(symbol: Symbol): String = {
45+
if (symbol.name == "<none>") then {
46+
// TODO had a "NoDenotation" test to avoid
47+
// relying on the name itself
48+
""
49+
} else {
50+
val previous_symbol = iterateParent(symbol.owner)
51+
val next_atom =
52+
symbol match {
53+
case IsPackageSymbol(symbol) => symbol.name + "/"
54+
case IsClassSymbol(symbol) => symbol.name + "#"
55+
case IsDefSymbol(symbol) => symbol.name + "."
56+
case IsValSymbol(symbol) => symbol.name + "."
57+
case owner => {
58+
""
59+
}
60+
}
61+
previous_symbol + next_atom
62+
}
63+
}
64+
4465
override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = {
4566
val previous_path = stack.head
4667

4768
tree match {
48-
case IsClassDef(body) =>
69+
/*case IsClassDef(body) =>
4970
val ClassDef(name, _, _, _, _) = body
5071
//println("[classdef] ", body)
5172
val path = stack.head + name + "#"
@@ -81,11 +102,12 @@ class SemanticdbConsumer extends TastyConsumer {
81102
stack = stack.tail
82103
case IsPackageDef(body) =>
83104
println("[packagedef] ", body)
84-
super.traverseTree(body)
105+
super.traverseTree(body)*/
85106
case IsDefinition(body) =>
86-
println("[definition] ", body)
107+
//println("[definition] ", body)
108+
println(iterateParent(tree.symbol))
87109
super.traverseTree(body)
88-
case IsPackageClause(body) =>
110+
/*case IsPackageClause(body) =>
89111
//println(body.pos.start, body.pos.end)
90112
val PackageClause(name, list_tree : List[Tree]) = body
91113
//println(tree)
@@ -100,7 +122,7 @@ class SemanticdbConsumer extends TastyConsumer {
100122
super.traverseTree(body)*/
101123
// iterating this way will probably make us see terms we don't want
102124
super.traverseTree(body)
103-
stack = stack.tail
125+
stack = stack.tail*/
104126
case tree =>
105127
super.traverseTree(tree)
106128
}

0 commit comments

Comments
 (0)