Search in sources :

Example 31 with IErlProject

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

the class ModelInternalUtils method getIncludeLibPath.

private String getIncludeLibPath(final IErlModule module) {
    String s = module.getName();
    String prevS = s;
    IErlElement e = module;
    for (; ; ) {
        final IParent p = e.getParent();
        if (p instanceof IErlProject) {
            break;
        }
        e = (IErlElement) p;
        prevS = s;
        s = e.getName() + "/" + s;
    }
    return prevS;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlProject(org.erlide.engine.model.root.IErlProject) IParent(org.erlide.engine.model.IParent)

Example 32 with IErlProject

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

the class DialyzerPreferencePage method doLinkActivated.

void doLinkActivated(final Link widget) {
    if (isProjectPreferencePage()) {
        openWorkspacePreferences(null);
    } else {
        final List<IProject> erlProjects = new ArrayList<>();
        final Set<IProject> projectsWithSpecifics = new HashSet<>();
        final IErlModel model = ErlangEngine.getInstance().getModel();
        try {
            for (final IErlProject ep : model.getErlangProjects()) {
                final IProject p = ep.getWorkspaceProject();
                if (hasProjectSpecificOptions(p)) {
                    projectsWithSpecifics.add(p);
                }
                erlProjects.add(p);
            }
        } catch (final ErlModelException e) {
        }
        final ProjectSelectionDialog dialog = new ProjectSelectionDialog(getShell(), erlProjects, projectsWithSpecifics);
        if (dialog.open() == Window.OK) {
            final IProject res = (IProject) dialog.getFirstResult();
            openProjectProperties(res);
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModel(org.erlide.engine.model.root.IErlModel) ErlModelException(org.erlide.engine.model.ErlModelException) ArrayList(java.util.ArrayList) ProjectSelectionDialog(org.erlide.ui.prefs.ProjectSelectionDialog) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet)

Example 33 with IErlProject

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

the class CoverMainTab method createControl.

@Override
public void createControl(final Composite parent) {
    final ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    final Composite comp = new Composite(scrolled, SWT.NONE);
    scrolled.setContent(comp);
    scrolled.setExpandVertical(true);
    scrolled.setExpandHorizontal(true);
    scrolled.setMinSize(760, 300);
    setControl(scrolled);
    final GridLayout mainLayout = new GridLayout();
    mainLayout.numColumns = 3;
    mainLayout.verticalSpacing = 15;
    mainLayout.horizontalSpacing = 20;
    mainLayout.marginHeight = 15;
    mainLayout.marginHeight = 15;
    comp.setLayout(mainLayout);
    final GridData gData = new GridData();
    gData.horizontalAlignment = GridData.FILL;
    gData.horizontalSpan = 3;
    singleRadio = new Button(comp, SWT.RADIO);
    singleRadio.setText("Run tests for a single module");
    singleRadio.setLayoutData(gData);
    singleRadio.addSelectionListener(radioSelectionListener);
    createModuleGroup(comp);
    allRadio = new Button(comp, SWT.RADIO);
    allRadio.setText("Run all tests in specific project");
    allRadio.setLayoutData(gData);
    allRadio.addSelectionListener(radioSelectionListener);
    createAllTestsGroup(comp);
    final Label testLabel = new Label(comp, SWT.NONE);
    testLabel.setText("Testing framework: ");
    testCombo = new Combo(comp, SWT.NONE);
    testCombo.setItems(new String[] { FrameworkType.EUNIT.getRepr() });
    testCombo.addModifyListener(basicModifyListener);
    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) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ErlModelException(org.erlide.engine.model.ErlModelException) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 34 with IErlProject

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

the class CoverMainTab method createProjectArray.

private Object[] createProjectArray() {
    Object[] array;
    try {
        final List<ProjectElement> res = new LinkedList<>();
        final Collection<IErlProject> projects = ErlangEngine.getInstance().getModel().getErlangProjects();
        for (final IErlProject p : projects) {
            final ProjectElement elem = new ProjectElement(p.getName(), PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT).createImage());
            res.add(elem);
        }
        array = res.toArray();
    } catch (final ErlModelException e) {
        array = new Object[0];
        ErlLogger.error(e);
    }
    return array;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlModelException(org.erlide.engine.model.ErlModelException) ProjectElement(org.erlide.cover.ui.launch.helpers.ProjectElement) LinkedList(java.util.LinkedList)

Example 35 with IErlProject

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

the class MarkerUtils method findResourceForFileName.

private static IResource findResourceForFileName(final IResource resource, final Entry<String, List<OtpErlangTuple>> entry, final String fileName) {
    IResource res = resource;
    if (!ResourceUtil.samePath(resource.getLocation().toString(), fileName)) {
        final IProject project = resource.getProject();
        res = ResourceUtil.findResourceByLocation(project, fileName);
        if (res == null) {
            try {
                final IErlElementLocator model = ErlangEngine.getInstance().getModel();
                final IErlProject erlProject = model.findProject(project);
                if (erlProject != null) {
                    final IErlModule includeFile = model.findIncludeFromProject(erlProject, fileName, fileName, IErlElementLocator.Scope.REFERENCED_PROJECTS);
                    if (includeFile == null) {
                        res = resource;
                    } else {
                        res = includeFile.getResource();
                    }
                } else {
                    res = resource;
                }
            } catch (final Exception e) {
                ErlLogger.warn(e);
            }
        }
    }
    return res;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException)

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