Search in sources :

Example 21 with IErlProject

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

the class ErlangCompletionService method addCompletions.

List<CompletionData> addCompletions(final IOtpRpc backend, final Set<CompletionFlag> flags, final int offset, final String prefix, final String moduleOrRecord, final int pos, final List<String> fieldsSoFar, final boolean inString) throws CoreException {
    final List<CompletionData> result = new ArrayList<>();
    final IErlProject aProject = project;
    if (aProject == null) {
        return result;
    }
    addSorted(prefix, result, addDeclaredFunctionsCompletions(flags, offset, prefix));
    if (flags.contains(CompletionFlag.VARIABLES)) {
        addSorted(prefix, result, getVariables(backend, offset, prefix));
    }
    if (flags.contains(CompletionFlag.IMPORTED_FUNCTIONS)) {
        addSorted(prefix, result, getImportedFunctions(backend, offset, prefix));
    }
    if (flags.contains(CompletionFlag.AUTO_IMPORTED_FUNCTIONS)) {
        addSorted(prefix, result, getAutoImportedFunctions(backend, offset, prefix));
    }
    if (flags.contains(CompletionFlag.MODULES)) {
        addSorted(prefix, result, getModules(backend, offset, prefix, CompletionFlag.MODULES, inString));
    }
    if (flags.contains(CompletionFlag.INCLUDES)) {
        addSorted(prefix, result, getModules(backend, offset, prefix, CompletionFlag.INCLUDES, inString));
    }
    if (flags.contains(CompletionFlag.INCLUDE_LIBS)) {
        addSorted(prefix, result, getModules(backend, offset, prefix, CompletionFlag.INCLUDE_LIBS, inString));
    }
    if (flags.contains(CompletionFlag.RECORD_DEFS)) {
        addSorted(prefix, result, getMacroOrRecordCompletions(offset, prefix, ErlElementKind.RECORD_DEF));
    }
    if (flags.contains(CompletionFlag.RECORD_FIELDS)) {
        addSorted(prefix, result, getRecordFieldCompletions(moduleOrRecord, offset, prefix, pos, fieldsSoFar));
    }
    if (flags.contains(CompletionFlag.MACRO_DEFS)) {
        addSorted(prefix, result, getMacroOrRecordCompletions(offset, prefix, ErlElementKind.MACRO_DEF));
    }
    if (flags.contains(CompletionFlag.EXTERNAL_FUNCTIONS)) {
        addSorted(prefix, result, getExternalCallCompletions(backend, moduleOrRecord, offset, prefix, flags.contains(CompletionFlag.ARITY_ONLY)));
    }
    if (flags.contains(CompletionFlag.TYPES)) {
        addSorted(prefix, result, getTypeCompletions(backend, moduleOrRecord, offset, prefix));
    }
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) CompletionData(org.erlide.engine.services.codeassist.CompletionData) FunctionCompletionData(org.erlide.engine.services.codeassist.FunctionCompletionData) ArrayList(java.util.ArrayList)

Example 22 with IErlProject

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

the class ErlFolder method isSourcePathParent.

@Override
public boolean isSourcePathParent() {
    final IProject project = folder.getProject();
    final IErlProject erlProject = modelUtilService.getProject(this);
    final Collection<IPath> sourcePaths = erlProject.getProperties().getSourceDirs();
    final IPath path = folder.getFullPath();
    for (final IPath i : sourcePaths) {
        if (path.isPrefixOf(project.getFolder(i).getFullPath())) {
            return true;
        }
    }
    return false;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) IProject(org.eclipse.core.resources.IProject)

Example 23 with IErlProject

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

the class ErlideTestUtils method createErlProject.

public static IErlProject createErlProject(final IProject project) throws CoreException {
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().findProject(project);
    erlProject.getBuilderProperties().setBuilderTool(BuilderTool.INTERNAL);
    final ErlangProjectProperties prefs = erlProject.getProperties();
    final List<IPath> srcDirs = new ArrayList<>();
    srcDirs.add(new Path("src"));
    prefs.setSourceDirs(srcDirs);
    ErlideTestUtils.buildPaths(root, project, srcDirs);
    final List<IPath> includeDirs = new ArrayList<>();
    includeDirs.add(new Path("include"));
    ErlideTestUtils.buildPaths(root, project, includeDirs);
    prefs.setIncludeDirs(includeDirs);
    final IPath ebinDir = new Path("ebin");
    ErlideTestUtils.buildPaths(root, project, Lists.newArrayList(ebinDir));
    prefs.setOutputDir(ebinDir);
    ErlideTestUtils.projects.add(erlProject);
    return erlProject;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) ArrayList(java.util.ArrayList)

Example 24 with IErlProject

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

the class ErlideTestUtils method initProjects.

public static void initProjects() throws CoreException {
    ErlideTestUtils.projects = Lists.newArrayList();
    final IErlModel model = ErlangEngine.getInstance().getModel();
    model.open(null);
    final List<IErlElement> children = model.getChildren();
    for (final IErlElement child : children) {
        if (child instanceof IErlProject) {
            final IErlProject project = (IErlProject) child;
            if (project.getName().startsWith("testproject")) {
                ErlideTestUtils.deleteProject(project);
            }
        }
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlProject(org.erlide.engine.model.root.IErlProject) IErlModel(org.erlide.engine.model.root.IErlModel)

Example 25 with IErlProject

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

the class ErlModel method tryFindModule.

private IErlModule tryFindModule(final Collection<IErlProject> projects, final String moduleName, final String modulePath, final List<IErlModule> allModules, final Set<String> paths, final boolean externalModules) throws ErlModelException {
    IErlModule module;
    for (final IErlProject project : projects) {
        final Collection<IErlModule> modules = Lists.newArrayList();
        final Collection<IErlModule> modulesOrExternals = externalModules ? project.getExternalModules() : project.getModules();
        ErlModel.getAllModulesAux(modulesOrExternals, modules, paths);
        allModules.addAll(modules);
        module = findModule(modules, moduleName, modulePath);
        if (module != null) {
            return module;
        }
    }
    return null;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule)

Aggregations

IErlProject (org.erlide.engine.model.root.IErlProject)123 IErlModule (org.erlide.engine.model.root.IErlModule)57 Test (org.junit.Test)47 IPath (org.eclipse.core.runtime.IPath)30 IProject (org.eclipse.core.resources.IProject)29 ErlProject (org.erlide.engine.internal.model.root.ErlProject)25 File (java.io.File)19 Path (org.eclipse.core.runtime.Path)16 CoreException (org.eclipse.core.runtime.CoreException)13 ErlModelException (org.erlide.engine.model.ErlModelException)13 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)13 IErlModel (org.erlide.engine.model.root.IErlModel)13 ArrayList (java.util.ArrayList)11 IErlElement (org.erlide.engine.model.IErlElement)10 IFile (org.eclipse.core.resources.IFile)9 IResource (org.eclipse.core.resources.IResource)9 HashSet (java.util.HashSet)7 IProjectDescription (org.eclipse.core.resources.IProjectDescription)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)6 IErlPreprocessorDef (org.erlide.engine.model.erlang.IErlPreprocessorDef)6