-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow completion from source #3686
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
Conversation
1498762
to
196c1a4
Compare
*/ | ||
def enterRoots(file: AbstractFile)(implicit ctx: Context): Unit = | ||
if (!files.contains(file)) { | ||
val unit = new CompilationUnit(getSource(file.path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we add the unit to units
at this point ?
@smarter Do you suggest further changes? |
def checkPathMatches(path: List[TermName], what: String, tree: MemberDef): Boolean = { | ||
val ok = filePath == path | ||
if (!ok) | ||
ctx.warning(i"""$what ${tree.name} is in wrong directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"in wrong" -> "in the wrong" ?
@@ -750,7 +758,7 @@ class Namer { typer: Typer => | |||
} | |||
|
|||
/** The completer of a symbol defined by a member def or import (except ClassSymbols) */ | |||
class Completer(val original: Tree)(implicit ctx: Context) extends LazyType { | |||
class Completer(val original: Tree)(implicit ctx: Context) extends LazyType with SymbolLoaders.SecondCompleter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is SecondCompleter
needed here now?
/** Units that are added because of source completers but that are not | ||
* compiled in current run. | ||
*/ | ||
val lateUnits = mutable.ListBuffer[CompilationUnit]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nicer if the mutability was hidden from outside this class, like for units and files.
51b248d
to
9a26f67
Compare
With late source loading we need to access the current run from the current context anyway, so there's no need to separate Run and RunInfo.
This lets us find a class for completion even if its name is not the filename of the containing class.
Store them in `lateUnits` (and `lateFiles` for the associated files). An IDE can inquire about units and persist them to the next runs.
9a26f67
to
4d992ae
Compare
If -sourcepath is set, we now allow completion from sources that are in the canonical place (i.e. fully qualified source name ~ path name of source file relative to source path). If both class and source file exist, the newer one is chosen.
To do: it would be nice to optionally scan all sources so that classes can be found even if their
fully qualified name does not correspond to the file name. Logically, this should be done in
ClassPath.scala
.