myProcess = process;
}
@Override
public SourcePosition getSourcePosition(@Nullable Location location) throws NoDataException {
if (true) throw new NoDataException();
if (location == null) throw new NoDataException();
final ReferenceType refType = location.declaringType();
if (refType == null) throw new NoDataException();
int dollar = refType.name().indexOf("$");
String qname = dollar == -1? refType.name() : refType.name().substring(0, dollar);
final String name = location.method().name();
int lineNumber = location.lineNumber() - 1;
for (PsiFile file : myGrammars.get(qname)) {
BnfExpression expression = findExpression(file, name);
BnfRule rule = PsiTreeUtil.getParentOfType(expression, BnfRule.class);
if (expression != null && qname.equals(ParserGeneratorUtil.getAttribute(rule, KnownAttribute.PARSER_CLASS))) {
for (BnfExpression expr : ParserGeneratorUtil.getChildExpressions(expression)) {
int line = getLineNumber(expr, qname, lineNumber);
if (line == lineNumber) {
return SourcePosition.createFromElement(expr);
}
}
if (lineNumber == getLineNumber(expression, qname, lineNumber)) {
return SourcePosition.createFromElement(expression);
}
return SourcePosition.createFromElement(rule);
}
}
throw new NoDataException();
}