-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
237 additions
and
145 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
44 changes: 0 additions & 44 deletions
44
compiler-plugin/src/main/scala/org/canve/compilerPlugin/QualiferID.scala
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
compiler-plugin/src/main/scala/org/canve/compilerPlugin/QualifyingPath.scala
This file contains 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,60 @@ | ||
package org.canve.compilerPlugin | ||
import tools.nsc.Global | ||
import Util._ | ||
|
||
/* | ||
* A Qualified Identification of a symbol, that does not rely on its compiler assigned id, | ||
* is useful for correlating symbols across project boundaries. Here we provide the necessary class | ||
* for creating and using such an identification, which we will call for brevity QI. | ||
*/ | ||
|
||
/* The class and factory */ | ||
|
||
case class QualifyingPath(value: List[QualificationUnit]) { | ||
|
||
/* | ||
* if any anonymous object is part of the qualification chain, then (by definition) the | ||
* chain cannot be considered by any means unique - anonymous objects may sit side-by-side | ||
* under the same program context, and having no name, cannot be easily differentiated. | ||
*/ | ||
val fullyNamed: Boolean = value.forall(_.name.isDefined) | ||
|
||
def pickle = value.map(kindAndName => "(" + kindAndName.kind + "|" + kindAndName.name + ")").mkString(".") | ||
} | ||
|
||
/* | ||
* companion object providing both a constructor from a global.symbol and | ||
* a constructor from string-pickled input | ||
*/ | ||
object QualifyingPath { | ||
|
||
def apply(s: String): QualifyingPath = | ||
QualifyingPath(s.split('.').toList.map(s => | ||
QualificationUnit( | ||
s.takeWhile(_!='|').drop(1), | ||
deSerializeOption[String](s) match { | ||
case None => None | ||
case Some(s) => Some(s.dropWhile(_!='|').drop(1).dropRight(1)) | ||
}))) | ||
|
||
def apply(global: Global)(s: global.Symbol): QualifyingPath = { | ||
val kindNameList: List[QualificationUnit] = | ||
s.ownerChain.reverse.map(owner => QualificationUnit(global)(owner)) | ||
|
||
assert(kindNameList.head.kind == "package") | ||
assert(kindNameList.head.name.get == "<root>") | ||
|
||
QualifyingPath(kindNameList.drop(1)) | ||
} | ||
} | ||
|
||
|
||
/* auxiliary class and factory */ | ||
|
||
case class QualificationUnit(kind: String, name: Option[String]) | ||
|
||
object QualificationUnit { | ||
def apply(global: Global)(s: global.Symbol): QualificationUnit = { | ||
new QualificationUnit(s.kindString, maybeName(global)(s)) | ||
} | ||
} |
This file contains 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
Oops, something went wrong.