use of org.erlide.engine.model.erlang.IErlRecordDef in project erlide_eclipse by erlang.
the class ErlangCompletionService method getRecordFieldCompletions.
List<CompletionData> getRecordFieldCompletions(final String recordName, final int offset, final String prefix, final int hashMarkPos, final List<String> fieldsSoFar) {
if (module == null) {
return ErlangCompletionService.EMPTY_COMPLETIONS;
}
IErlPreprocessorDef pd;
try {
pd = ErlangEngine.getInstance().getModelFindService().findPreprocessorDef(module, recordName, ErlElementKind.RECORD_DEF);
} catch (final CoreException e) {
return ErlangCompletionService.EMPTY_COMPLETIONS;
}
if (pd instanceof IErlRecordDef) {
final List<CompletionData> result = new ArrayList<>();
try {
for (final IErlElement i : pd.getChildren()) {
final IErlRecordField field = (IErlRecordField) i;
final String fieldName = field.getFieldName();
if (!fieldsSoFar.contains(fieldName)) {
addIfMatches(fieldName, prefix, offset, result);
}
}
} catch (final ErlModelException e) {
}
return result;
}
return ErlangCompletionService.EMPTY_COMPLETIONS;
}
use of org.erlide.engine.model.erlang.IErlRecordDef 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