Content assist when model is incomplete [message #1724265] |
Mon, 22 February 2016 16:11 |
Nils Kronqvist Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Hi,
I have a problem when wanting to create a proposal based on an incomplete model: If having the code as below (example 1) and invoking Ctrl-space as indicated -- as I have overidden the method
completeModelQuery_Methods(ModelQuery model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor)
in a AbstractQuickSvtProposalProvider subclass, it gets called as expected. The "model" parameter has a rootObject named "point" and one entry in the methods list named "Rectangle" -- makes sense, the parser is doing it's best to resolve the incomplete model. As the "point" variable is defined in the topmost statement (RootVarDefinition), and I want the definition type (varType -- i.e. "Point") - I expected that the rootObject (a VarDefinition cross-reference), would be resolved to the VarDefinition in the RootVarDefinition statement.
BUT for some reason the rootObject of the model parameter is contained in an instance of a GenericVarDefinition with varType value = "rect" , varValue = null - and I can see no reliable way of getting the correct VarDefinition.
What would be the best solution to make the parser less confused in case of example 1 below ..?
BTW: Example 2 below works as expected, as the parser is helped by the statement not including a "point" ..
Example 1: Not working ...
Root: Point point {
if (point.[Ctrl-space]
Rectangle rect = point.bounds;
}
Example 2: Working ...
Root: Point point {
if (point.[Ctrl-space]
int i = 0;
Rectangle rect = point.bounds;
}
Grammar (simplified and abbreviated ..):
ModelRoot:
rootVarDefinition=RootVarDefinition '{'
(contents+=Content)*
'}'
;
RootVarDefinition:
'Root:' varType=ID varDefinition=VarDefinition
;
Content:
GenericVarDefinition | DefIfElseStatement
;
DefIfElseStatement:
'if' '(' booleanStatement=BooleanStatement ')' '{'
(ifValues+=Content)*
'}'
('else' '{'
(elseValues+=Content)*
'}')?
;
GenericVarDefinition:
varType=ID varDefinition=VarDefinition '=' varValue=Operand ';'
;
Operand:
(opAlt1=ModelQuery | opAlt2=SimpleValue) (arithOp=ArithOp nextOp=Operand)?
;
SimpleValue:
valueInt=INT | valueNull='null' | valueString=STRING
;
ModelQuery:
rootObject=[VarDefinition] ('.' methods+=Method)*
;
Method:
methodName=ID ( '(' methodParameter=Operand ')')?
;
VarDefinition:
name=ID
;
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03478 seconds