Search in sources :

Example 66 with IErlProject

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

the class SearchTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ErlideTestUtils.initProjects();
    // We set up projects here, it's quite costly
    final String name1 = "testproject1";
    final IErlProject erlProject1 = ErlideTestUtils.createErlProject(name1);
    final String name2 = "testproject2";
    final IErlProject erlProject2 = ErlideTestUtils.createErlProject(name2);
    SearchTest.projects = new IErlProject[] { erlProject1, erlProject2 };
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) BeforeClass(org.junit.BeforeClass)

Example 67 with IErlProject

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

the class AddRefacHandler method getBinPath.

// gets original binary path
private String getBinPath(final String callbackModule) {
    String path;
    try {
        if (ErlangEngine.getInstance().getModel().findModule(callbackModule) == null) {
            return null;
        }
        final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(ErlangEngine.getInstance().getModel().findModule(callbackModule));
        path = project.getWorkspaceProject().getLocation().append(project.getProperties().getOutputDir()).append(callbackModule + ".beam").toOSString();
        return path;
    } catch (final ErlModelException e) {
        return null;
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlModelException(org.erlide.engine.model.ErlModelException)

Example 68 with IErlProject

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

the class UserAdhocRefactoring method load.

/**
 * Loading user's callback module
 *
 * @return
 */
public boolean load() {
    String callbackPath;
    try {
        if (ErlangEngine.getInstance().getModel().findModule(refac.getCallbackModule()) == null) {
            return false;
        }
        final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(ErlangEngine.getInstance().getModel().findModule(refac.getCallbackModule()));
        callbackPath = project.getWorkspaceProject().getLocation().append(project.getProperties().getOutputDir()).toString();
    } catch (final ErlModelException e) {
        return false;
    }
    final RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("load_callback_mod_eclipse", "ss", refac.getCallbackModule(), callbackPath);
    if (!res.isOk()) {
        return false;
    }
    return true;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlModelException(org.erlide.engine.model.ErlModelException) RpcResult(org.erlide.runtime.rpc.RpcResult)

Example 69 with IErlProject

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

the class CreateHeaderQuickFix method run.

@Override
public void run() {
    final ModelUtilService svc = ErlangEngine.getInstance().getModelUtilService();
    final String name = getQuickFix().getArgs().get(0);
    final IErlProject project = svc.getProject(module);
    final Iterator<IPath> iterator = project.getProperties().getIncludeDirs().iterator();
    final IPath inc;
    if (!iterator.hasNext()) {
        inc = module.getResource().getParent().getProjectRelativePath();
    } else {
        inc = iterator.next();
    // if there are multiple include dirs, let user move file manually
    }
    final IProject wproject = project.getWorkspaceProject();
    final IFolder folder = wproject.getFolder(inc);
    final IFile header = folder.getFile(name);
    try (final EmptyInputStream source = new EmptyInputStream()) {
        header.create(source, true, null);
        folder.refreshLocal(IResource.DEPTH_ONE, null);
        final IFile fileToOpen = header;
        final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IDE.openEditor(page, fileToOpen);
    } catch (final CoreException e) {
        ErlLogger.error(e);
    } catch (final IOException e) {
        ErlLogger.error(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ModelUtilService(org.erlide.engine.services.search.ModelUtilService) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 70 with IErlProject

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

the class ErlangMainTab method createControl.

/**
 * @wbp.parser.entryPoint
 */
@Override
public void createControl(final Composite parent) {
    final Composite comp = new Composite(parent, SWT.NONE);
    setControl(comp);
    final GridLayout topLayout = new GridLayout();
    comp.setLayout(topLayout);
    createProjectsGroup(comp);
    createStartGroup(comp);
    Collection<IErlProject> projects;
    try {
        projects = ErlangEngine.getInstance().getModel().getErlangProjects();
        final List<String> ps = new ArrayList<>();
        for (final IErlProject p : projects) {
            ps.add(p.getName());
        }
    } catch (final ErlModelException e) {
        ErlLogger.warn(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ErlModelException(org.erlide.engine.model.ErlModelException) ArrayList(java.util.ArrayList)

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