Search in sources :

Example 86 with IErlElement

use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.

the class ModelInternalUtils method getElementWithExternalName.

private IErlExternal getElementWithExternalName(final IParent parent, final String name) throws ErlModelException {
    System.out.println(" ?? " + name);
    for (final IErlElement e : parent.getChildrenOfKind(ErlElementKind.EXTERNAL_ROOT, ErlElementKind.EXTERNAL_APP, ErlElementKind.EXTERNAL_FOLDER)) {
        final IErlExternal external = (IErlExternal) e;
        final String externalName = external.getName();
        System.out.println("   ? " + externalName);
        if (externalName.equals(name)) {
            return external;
        }
    }
    return null;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlExternal(org.erlide.engine.model.root.IErlExternal)

Example 87 with IErlElement

use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.

the class SourceRefElement method getOpenableParent.

/**
 * Return the first instance of IOpenable in the hierarchy of this type
 * (going up the hierarchy from this type);
 */
@Override
public IOpenable getOpenableParent() {
    IParent parent = getParent();
    while (parent != null) {
        if (parent instanceof IOpenable) {
            return (IOpenable) parent;
        }
        if (parent instanceof IErlElement) {
            final IErlElement parentElement = (IErlElement) parent;
            parent = parentElement.getParent();
        } else {
            break;
        }
    }
    return null;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IOpenable(org.erlide.engine.model.root.IOpenable) IParent(org.erlide.engine.model.IParent)

Example 88 with IErlElement

use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.

the class ErlElement method toStringChildren.

/**
 * Debugging purposes
 */
protected void toStringChildren(final int tab, final StringBuilder buffer, final Object info) {
    if (!(info instanceof ErlElement)) {
        return;
    }
    if (getChildCount() > 0) {
        buffer.append("{");
        int i = 0;
        try {
            for (final IErlElement element : getChildren()) {
                ((ErlElement) element).toString(tab + 1, buffer);
                // $NON-NLS-1$
                buffer.append(",");
                if (++i > 3) {
                    buffer.append("...");
                    break;
                }
            }
        } catch (final ErlModelException e) {
        }
        buffer.deleteCharAt(buffer.length() - 1);
        buffer.append("}");
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlElement(org.erlide.engine.model.IErlElement) ErlModelException(org.erlide.engine.model.ErlModelException)

Example 89 with IErlElement

use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.

the class ErlModel method getLibraries.

@Override
public Collection<IErlLibrary> getLibraries() throws ErlModelException {
    final Collection<IErlElement> list = getChildrenOfKind(ErlElementKind.LIBRARY);
    final Collection<IErlLibrary> result = Lists.newArrayList();
    for (final IErlElement e : list) {
        result.add((IErlLibrary) e);
    }
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlLibrary(org.erlide.engine.model.root.IErlLibrary)

Example 90 with IErlElement

use of org.erlide.engine.model.IErlElement 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;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) CompletionData(org.erlide.engine.services.codeassist.CompletionData) FunctionCompletionData(org.erlide.engine.services.codeassist.FunctionCompletionData) CoreException(org.eclipse.core.runtime.CoreException) IErlRecordDef(org.erlide.engine.model.erlang.IErlRecordDef) ErlModelException(org.erlide.engine.model.ErlModelException) ArrayList(java.util.ArrayList) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) IErlPreprocessorDef(org.erlide.engine.model.erlang.IErlPreprocessorDef) IErlRecordField(org.erlide.engine.model.erlang.IErlRecordField)

Aggregations

IErlElement (org.erlide.engine.model.IErlElement)123 Test (org.junit.Test)36 IErlModule (org.erlide.engine.model.root.IErlModule)35 ErlModelException (org.erlide.engine.model.ErlModelException)28 IParent (org.erlide.engine.model.IParent)17 IFile (org.eclipse.core.resources.IFile)16 ArrayList (java.util.ArrayList)12 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)11 IResource (org.eclipse.core.resources.IResource)11 IErlProject (org.erlide.engine.model.root.IErlProject)10 IOpenable (org.erlide.engine.model.root.IOpenable)10 IProject (org.eclipse.core.resources.IProject)9 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)8 IErlModel (org.erlide.engine.model.root.IErlModel)8 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)8 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)7 IFolder (org.eclipse.core.resources.IFolder)7 CoreException (org.eclipse.core.runtime.CoreException)7 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)6 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)6