use of org.erlide.engine.model.ErlElementKind in project erlide_eclipse by erlang.
the class ErlangCompareUtilities method getErlElementID.
/**
* Returns a name for the given Erlang element
*/
static String getErlElementID(final IErlElement e) {
final StringBuilder sb = new StringBuilder();
final ErlElementKind kind = e.getKind();
sb.append(kind);
if (kind == ErlElementKind.FUNCTION) {
final IErlFunction f = (IErlFunction) e;
sb.append(f.getNameWithArity());
} else if (kind == ErlElementKind.CLAUSE) {
final IErlFunctionClause fc = (IErlFunctionClause) e;
sb.append(fc.getHead());
} else if (kind == ErlElementKind.ATTRIBUTE) {
final IErlAttribute a = (IErlAttribute) e;
sb.append(a.getName());
if (a.getValue() != null) {
sb.append(a.getValue().toString());
}
} else if (kind == ErlElementKind.RECORD_DEF || kind == ErlElementKind.MACRO_DEF) {
final IErlPreprocessorDef pd = (IErlPreprocessorDef) e;
sb.append(pd.getDefinedName());
}
return sb.toString();
}
use of org.erlide.engine.model.ErlElementKind in project erlide_eclipse by erlang.
the class OpenUtils method findOpenResult.
public Object findOpenResult(final ITextEditor editor, final IErlModule module, final IErlProject project, final OpenResult openResult, final IErlElement element) throws CoreException, ErlModelException, OtpErlangRangeException, RpcException, BadLocationException {
final IErlElementLocator.Scope scope = NavigationPreferencePage.getCheckAllProjects() ? IErlElementLocator.Scope.ALL_PROJECTS : IErlElementLocator.Scope.REFERENCED_PROJECTS;
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
Object found = null;
if (openResult.isExternalCall()) {
found = findExternalCallOrType(module, openResult, project, element, scope);
} else if (openResult.isInclude()) {
found = modelFindService.findInclude(model, project, module, openResult.getName(), openResult.getPath());
} else if (openResult.isLocalCall()) {
found = findLocalCall(module, project, openResult, element, scope);
} else if (openResult.isVariable() && element instanceof ISourceReference) {
final ISourceReference sref = (ISourceReference) element;
final ISourceRange range = sref.getSourceRange();
final String elementText = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get(range.getOffset(), range.getLength());
found = modelFindService.findVariable(range, openResult.getName(), elementText);
} else if (openResult.isRecord() || openResult.isMacro()) {
final ErlElementKind kind = openResult.isMacro() ? ErlElementKind.MACRO_DEF : ErlElementKind.RECORD_DEF;
found = modelFindService.findPreprocessorDef(module, openResult.getName(), kind);
} else if (openResult.isField()) {
final IErlRecordDef def = (IErlRecordDef) modelFindService.findPreprocessorDef(module, openResult.getFun(), ErlElementKind.RECORD_DEF);
if (def != null) {
found = def.getFieldNamed(openResult.getName());
}
}
return found;
}
Aggregations