Search in sources :

Example 1 with IErlModel

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

the class ParserDB method create.

public static void create() {
    final Runnable x = new Runnable() {

        @Override
        public void run() {
            ParserDB.running = true;
            try {
                ParserDB.db = new ParserDB();
                // out = new PrintStream(
                // new File("/home/qvladum/parserDB.txt"));
                ParserDB.out = System.out;
                final IErlModel model = ErlangEngine.getInstance().getModel();
                final Collection<SourcePathProvider> sourcePathProviders = SourcePathUtils.getSourcePathProviders();
                final long time = System.currentTimeMillis();
                ParserDB.db.run(model, sourcePathProviders, false);
                System.out.println(" took " + (System.currentTimeMillis() - time) / 1000);
            } catch (final Exception e) {
                ErlLogger.error(e);
            }
            ParserDB.running = false;
        }
    };
    if (!ParserDB.running) {
        new Thread(x).start();
    }
}
Also used : IErlModel(org.erlide.engine.model.root.IErlModel) SourcePathProvider(org.erlide.engine.model.root.SourcePathProvider) ErlModelException(org.erlide.engine.model.ErlModelException)

Example 2 with IErlModel

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

the class ErlProjectTest method findFunctionInExternalFilesTest.

@Test
public void findFunctionInExternalFilesTest() throws Exception {
    // given
    // a module with calls to the lists module
    final IErlProject project = ErlProjectTest.projects[0];
    final IErlModule moduleE = ErlideTestUtils.createModule(project, "e.erl", "-module(e).\n-export([f/0]).\nf() ->\n    lists:reverse([1, 0]),\n    lists:reverse([1, 0], [2]).\n");
    final ScannerService scanner = moduleE.getScanner();
    try {
        moduleE.open(null);
        // when
        // looking for lists:reverse/2 and lists:reverse/1
        final IErlModel model = ErlangEngine.getInstance().getModel();
        final OpenResult res = ErlangEngine.getInstance().getOpenService().open(moduleE.getScannerName(), 49, ErlangEngine.getInstance().getModelUtilService().getImportsAsList(moduleE), project.getProperties().getExternalModules(), model.getPathVars());
        final IErlFunction function = ErlangEngine.getInstance().getModelFindService().findFunction(model, project, moduleE, res.getName(), res.getPath(), res.getFunction(), IErlElementLocator.Scope.PROJECT_ONLY);
        assertNotNull(function);
        final IErlElement module = model.findModuleFromProject(project, function.getModuleName(), res.getPath(), IErlElementLocator.Scope.PROJECT_ONLY);
        // then
        // the function should be returned and the module, in External Files
        assertNotNull(module);
        assertEquals(function.getParent(), module);
        assertEquals(ErlangEngine.getInstance().getModelUtilService().getProject(function), project);
    } finally {
        scanner.dispose();
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlElement(org.erlide.engine.model.IErlElement) IErlModel(org.erlide.engine.model.root.IErlModel) OpenResult(org.erlide.engine.services.search.OpenResult) IErlModule(org.erlide.engine.model.root.IErlModule) ScannerService(org.erlide.engine.services.parsing.ScannerService) Test(org.junit.Test)

Example 3 with IErlModel

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

the class ErlangDebugTarget method getProjectDirs.

private OtpErlangList getProjectDirs(final IProject project) {
    final IErlModel model = ErlangEngine.getInstance().getModel();
    final ErlangProjectProperties properties = model.findProject(project).getProperties();
    final String ebin = properties.getOutputDir().toPortableString();
    final Collection<IPath> srcs = properties.getSourceDirs();
    try {
        return (OtpErlangList) OtpErlang.format("[{ebin_dir, ~s}, {src_dirs, ~ls}]", ebin, srcs);
    } catch (final OtpParserException e) {
        ErlLogger.warn(e);
    } catch (final SignatureException e) {
        ErlLogger.warn(e);
    }
    return new OtpErlangList();
}
Also used : IErlModel(org.erlide.engine.model.root.IErlModel) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) SignatureException(org.erlide.util.erlang.SignatureException)

Example 4 with IErlModel

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

the class ErlangQuickFixCollector method getFixes.

public IMarkerResolution[] getFixes(final IMarker marker) {
    final IResource resource = marker.getResource();
    final IErlModel model = ErlangEngine.getInstance().getModel();
    IErlModule module;
    if (resource == null) {
        return new IMarkerResolution[0];
    }
    if (resource instanceof IProject) {
        return getFixesForProject((IProject) resource, marker);
    }
    if (resource instanceof IFile) {
        module = model.findModule((IFile) resource);
        if (module != null) {
            return getFixesForModule(module, marker);
        }
    }
    return new IMarkerResolution[0];
}
Also used : IFile(org.eclipse.core.resources.IFile) IErlModel(org.erlide.engine.model.root.IErlModel) IMarkerResolution(org.eclipse.ui.IMarkerResolution) IErlModule(org.erlide.engine.model.root.IErlModule) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 5 with IErlModel

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

the class MarkerQuickFixExecutor method setMarker.

@Override
public void setMarker(final IMarker marker) {
    super.setMarker(marker);
    final IErlModel model = ErlangEngine.getInstance().getModel();
    module = model.findModule((IFile) marker.getResource());
}
Also used : IFile(org.eclipse.core.resources.IFile) IErlModel(org.erlide.engine.model.root.IErlModel)

Aggregations

IErlModel (org.erlide.engine.model.root.IErlModel)36 IErlModule (org.erlide.engine.model.root.IErlModule)18 IErlProject (org.erlide.engine.model.root.IErlProject)13 IFile (org.eclipse.core.resources.IFile)11 ErlModelException (org.erlide.engine.model.ErlModelException)11 IProject (org.eclipse.core.resources.IProject)10 CoreException (org.eclipse.core.runtime.CoreException)8 IErlElement (org.erlide.engine.model.IErlElement)8 IResource (org.eclipse.core.resources.IResource)7 IPath (org.eclipse.core.runtime.IPath)5 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)4 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)3 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 IBackend (org.erlide.backend.api.IBackend)3 OpenResult (org.erlide.engine.services.search.OpenResult)3 File (java.io.File)2 IOException (java.io.IOException)2 IContainer (org.eclipse.core.resources.IContainer)2