Analyzed AST != Code completion AST?
I have the following rule for code completion:
// shows all completions requests
editor-complete =
debug(!"Editor complete: "); faileditor-complete:
(FieldAccess(_, COMPLETION(prefix)), position, ast, path, project-path) -> [prop*, method*]
where position’ := <desugar-position(normalize|ast); debug(!"New position: ")> position
where FieldAccess(e, _) := <term-at-position(|position’); debug(!"Term at position: ")>
<+ FieldAccess(e, _) := <parent-at-position(|position’); debug(!"Term at parent: ")>
where …and the following (mobl) code:
screen editTask(t : Task) {
topRightButton(“Done”, onclick={ screen return; })
basicView(“Edit”) {
inputs {
inputString(t.name, placeholder=“Task name”)
inputString(t.description, placeholder=“Task description”)
}
button(“Delete”, onclick={
remove(t);
t.;
screen return;
})
}
}My cursor is before the
;
after theremove
statement. When I push Ctrl+space my debug message says something like:Editor complete: (FieldAccess(Var("t"),COMPLETION("")),[2,3,3,1,2,1,1,1,1,0,1,0], ...)
So it detected it as a FieldAccess, as it should at this point. But then, when I do a
term-at-position
or evenparent-at-position
I get:
New position: [2,3,4,1,2,1,1,1,1,0,1,0]
Term at position: Var(“t”{“t240”})
Term at parent: ExpStat(Var(“t”{“t240”}))i.e. there is no FieldAccess there. In other locations of the program I get similar results. It’s as if the AST I analyzed and saved in
Submitted by Zef Hemel on 1 April 2010 at 10:41ResultingAST
is different (older?) than the one I get when auto-completing.
Issue Log
This is by design. The interface for content completion follows the following design:
1) Semantic analysis is performed as the program is edited
2) When content completion is triggered, a new AST is created with the special COMPLETION() constructor. A full re-analysis should not be necessary at this point (all imports etc. remain the same)
3) For languages with scoped identifiers, content completion should trigger a local analysis that combines the name analysis and content proposal analysis. The old AST from step #1 should not be used for this.
Log in to post comments