use of org.erlide.engine.services.codeassist.CompletionData in project erlide_eclipse by erlang.
the class ErlangCompletionService method getVariables.
List<CompletionData> getVariables(final IOtpRpc b, final int offset, final String prefix) {
final List<CompletionData> result = new ArrayList<>();
final Collection<String> vars = contextAssistService.getVariables(elementBefore, prefix);
for (final String var : vars) {
result.add(new CompletionData(null, var, offset - prefix.length(), prefix.length(), var.length()));
}
return result;
}
use of org.erlide.engine.services.codeassist.CompletionData in project erlide_eclipse by erlang.
the class ErlangCompletionService method getExternalCallCompletions.
List<CompletionData> getExternalCallCompletions(final IOtpRpc b, final String moduleName0, final int offset, final String prefix, final boolean arityOnly) throws CoreException {
final ModelFindService modelFindService = ErlangEngine.getInstance().getModelFindService();
final String moduleName = modelFindService.resolveMacroValue(moduleName0, module);
// we have an external call
final List<CompletionData> result = new ArrayList<>();
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule theModule = modelFindService.findModule(model, project, moduleName, null, IErlElementLocator.Scope.ALL_PROJECTS);
// FIXME or IErlElementLocator.Scope.REFERENCED_PROJECTS
if (theModule != null) {
if (ErlangEngine.getInstance().getModelUtilService().isOtpModule(theModule)) {
final OtpErlangObject res = ErlangEngine.getInstance().getOtpDocService().getProposalsWithDoc(b, moduleName, prefix);
addFunctionProposalsWithDoc(offset, prefix, result, res, null, arityOnly);
} else {
addFunctionsFromModule(offset, prefix, arityOnly, result, theModule);
}
}
return result;
}
use of org.erlide.engine.services.codeassist.CompletionData 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.services.codeassist.CompletionData in project erlide_eclipse by erlang.
the class ErlangCompletionService method getModules.
protected List<CompletionData> getModules(final IOtpRpc backend, final int offset, final String prefix, final CompletionFlag kind, final boolean inString) throws ErlModelException {
final List<String> mods = getModules0(backend, offset, prefix, kind);
final boolean includes = kind == CompletionFlag.INCLUDES || kind == CompletionFlag.INCLUDE_LIBS;
final List<CompletionData> result = Lists.newArrayList();
for (final String m : mods) {
final String suffix = includes ? "" : ":";
final String cpl = quoted(m + suffix, kind, inString);
final int prefixLength = prefix.length();
result.add(new CompletionData(null, cpl, offset - prefixLength, prefixLength, cpl.length()));
}
return result;
}
use of org.erlide.engine.services.codeassist.CompletionData in project erlide_eclipse by erlang.
the class ErlangCompletionService method getMacroOrRecordCompletions.
List<CompletionData> getMacroOrRecordCompletions(final int offset, final String prefix, final ErlElementKind kind) {
if (module == null) {
return ErlangCompletionService.EMPTY_COMPLETIONS;
}
final List<CompletionData> result = new ArrayList<>();
try {
final List<IErlPreprocessorDef> defs = ErlangCompletionService.getAllPreprocessorDefs(module, kind);
for (final IErlPreprocessorDef pd : defs) {
final String name = pd.getDefinedName();
addIfMatches(name, prefix, offset, result);
}
} catch (final CoreException e) {
ErlLogger.error(e);
}
if (kind == ErlElementKind.MACRO_DEF) {
final String[] names = ErlangEngine.getInstance().getModelUtilService().getPredefinedMacroNames();
for (final String name : names) {
addIfMatches(name, prefix, offset, result);
}
}
return result;
}
Aggregations