Search in sources :

Example 31 with IErlElementLocator

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

the class IErlElementTest method getResource.

// IResource getResource();
@Test
public void getResource() throws Exception {
    project.open(null);
    final IProject workspaceProject = project.getWorkspaceProject();
    final IFolder srcFolder = workspaceProject.getFolder("src");
    final IFile file = srcFolder.getFile("xx.erl");
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    final IErlModule otpFile = model.findModuleFromProject(project, "file.erl", null, IErlElementLocator.Scope.PROJECT_ONLY);
    module.open(null);
    final IErlElement element = module.getElementAtLine(3);
    assertEquals(file, module.getResource());
    assertNull(otpFile.getResource());
    assertEquals(module.getResource(), element.getResource());
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IFile(org.eclipse.core.resources.IFile) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 32 with IErlElementLocator

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

the class IErlElementTest method getModel.

// IErlModel getModel();
@Test
public void getModel() throws Exception {
    module.open(null);
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    assertEquals(model, ErlangEngine.getInstance().getModel());
}
Also used : IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) Test(org.junit.Test)

Example 33 with IErlElementLocator

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

the class IErlElementTest method isStructureKnown.

// boolean isReadOnly();
// Empty method
// boolean isStructureKnown() throws ErlModelException;
@Test
public void isStructureKnown() throws Exception {
    ((ErlProject) project).setSourceDirs(project.getProperties().getSourceDirs());
    // this sets structureKnown to false
    final boolean structureKnown = project.isStructureKnown();
    project.open(null);
    final boolean structureKnown2 = project.isStructureKnown();
    final boolean structureKnown3 = module.isStructureKnown();
    module.open(null);
    final boolean structureKnown4 = module.isStructureKnown();
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    final IErlModule otpFile = model.findModuleFromProject(project, "file.erl", null, IErlElementLocator.Scope.PROJECT_ONLY);
    final IErlExternal external = (IErlExternal) otpFile.getParent();
    final boolean structureKnown5 = external.isStructureKnown();
    final IErlModule module2 = ErlideTestUtils.createModule(project, "yy.erl", "-module(yy).\n% comment\n% same\nf(x) -> y.\n% last");
    final boolean structureKnown6 = module2.isStructureKnown();
    module2.open(null);
    final boolean structureKnown7 = module2.isStructureKnown();
    assertFalse(structureKnown);
    assertTrue(structureKnown2);
    assertFalse(structureKnown3);
    assertTrue(structureKnown4);
    assertTrue(structureKnown5);
    assertFalse(structureKnown6);
    assertTrue(structureKnown7);
}
Also used : IErlExternal(org.erlide.engine.model.root.IErlExternal) ErlProject(org.erlide.engine.internal.model.root.ErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) Test(org.junit.Test)

Aggregations

IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)33 IErlModule (org.erlide.engine.model.root.IErlModule)26 Test (org.junit.Test)17 IErlProject (org.erlide.engine.model.root.IErlProject)13 ErlProject (org.erlide.engine.internal.model.root.ErlProject)8 File (java.io.File)7 IFile (org.eclipse.core.resources.IFile)7 IErlElement (org.erlide.engine.model.IErlElement)6 IProject (org.eclipse.core.resources.IProject)5 IPath (org.eclipse.core.runtime.IPath)5 Path (org.eclipse.core.runtime.Path)5 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)3 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)3 IFolder (org.eclipse.core.resources.IFolder)3 CoreException (org.eclipse.core.runtime.CoreException)3 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)3 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)2 ArrayList (java.util.ArrayList)2 IMarker (org.eclipse.core.resources.IMarker)2 IResource (org.eclipse.core.resources.IResource)2