Hi,
I follow the tutorial http://wiki.eclipse.org/DLTK_IDE_Guide:Step_3._Towards_an_IDE to implement the search feature for my language.
I use DLTK version 1.0 (up-zip from the zip file dltk-sdk-I-I200811251145-200811251145-incubation.zip - I don't remember the build number! ) with Eclipse 3.4.
The search for declarations (method, type) works fine. The search for field references works fine. But the search for method references doesn't work.
Below are some of the code :
1. The field references and method references are reported in the SourceElementRequestor :
public class GamlSourceElementRequestor extends SourceElementRequestVisitor {
public GamlSourceElementRequestor(ISourceElementRequestor requesor) {
super(requesor);
}
@Override
public boolean visit(_expression_ _expression_) throws Exception {
if (_expression_ instanceof VariableReference) {
// report field reference this.fRequestor.acceptFieldReference(((VariableReference) _expression_).getName().toCharArray(), _expression_.sourceStart());
} else if (_expression_ instanceof CallExpression) {
CallExpression actionRef = (CallExpression) _expression_;
// report method reference this.fRequestor.acceptMethodReference(actionRef.getName().toCharArray(), 0, actionRef.sourceStart(), actionRef.sourceEnd());
}
this.fNodes.push(_expression_);
return true;
}
}
2. The MathLocatorParser
public class GamlMatchLocationParser extends MatchLocatorParser {
protected GamlMatchLocationParser(MatchLocator locator) {
super(locator);
}
protected void processStatement(ASTNode node, PatternLocator locator) {
super.processStatement(node, locator);
if (node instanceof VariableReference) { // match the field reference
locator.match((VariableReference)node, getNodeSet());
} else if (node instanceof CallExpression) {
CallExpression call = new CallExpression(null, ((CallExpression) node).getName(), null);
call.setStart(node.sourceStart());
call.setEnd(node.sourceEnd()); // match the method reference
locator.match(call, getNodeSet());
}
}
}
3. The SearchFactory
public class GamlSearchFactory extends AbstractSearchFactory {
public IMatchLocatorParser createMatchParser(MatchLocator locator) {
return new GamlMatchLocationParser(locator);
}
}
I guess this may be the cause of this problem?
I put a break point in the line "return new GamlMatchLocationParser(locator);"
When I search for the field references, the method "createMatchParser" of GamlSearchFactory is invoked to create an instance of GamlMathLocationParser. And DLTK returns the result of field references correctly.
But when I search for method references, the method "createMatchParser" is not invoked.
Would you please help me have a look at the code above to see if I make mistakes somewhere?
Thanks and regards,
An. |