Package org.evolizer.famix.model.entities

Examples of org.evolizer.famix.model.entities.SourceAnchor


  @Test
  public void testMethodLocalVariableContainsSimple() {
    FamixMethod simpleMethod = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Test3.gather()",null));
    assertNotNull("FamixModel most contain method testPackage.Test3.gather()", simpleMethod);
    FamixLocalVariable simpleLocal = fFactory.createLocalVariable("testPackage.Test3.gather().a", null);
    simpleLocal.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test3.java", 203, 204));
    simpleLocal = (FamixLocalVariable) fModel.getElement(simpleLocal);
    assertNotNull("FamixModel must contain local variable testPackage.Test3.gather().a", simpleLocal);
   
    assertTrue("FamixMethod must contain local variable", simpleMethod.getLocalVariables().size() > 0);
    boolean containsLocal = containsLocalVariable(simpleMethod, simpleLocal);
View Full Code Here


  public void testMethodLocalVariableContainsMulti() {
    FamixMethod simpleMethod = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Test3.gather()",null));
    assertNotNull("FamixModel must contain method testPackage.Test3.gather()", simpleMethod);
   
    FamixLocalVariable multiLocal1 = fFactory.createLocalVariable("testPackage.Test3.gather().gigs1",simpleMethod);
    multiLocal1.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test3.java", 249, 254));
    multiLocal1 = (FamixLocalVariable) fModel.getElement(multiLocal1);
    FamixLocalVariable multiLocal2 = fFactory.createLocalVariable("testPackage.Test3.gather().gigs2",simpleMethod);
    multiLocal2.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test3.java", 257, 262));
    multiLocal2 = (FamixLocalVariable) fModel.getElement(multiLocal2);
   
    assertNotNull("FamixModel must contain local variable testPackage.Test3.gather().gigs1", multiLocal1);
    assertNotNull("FamixModel must contain local variable testPackage.Test3.gather().gigs2", multiLocal2);
   
View Full Code Here

  public void testMethodLocalVariableContainsWithinFor() {
    FamixMethod simpleMethod = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Test4.iterate()",null));
    assertNotNull("FamixModel must contain method testPackage.Test4.iterate()", simpleMethod);
   
    FamixLocalVariable withinFor = fFactory.createLocalVariable("testPackage.Test4.iterate().iter",simpleMethod);
    withinFor.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test4.java", 152, 173));
    withinFor = (FamixLocalVariable) fModel.getElement(withinFor);
    assertNotNull("FamixModel must contain local variable testPackage.Test4.iterate().iter", withinFor);
   
    assertTrue("FamixMethod must contain local variable", simpleMethod.getLocalVariables().size() > 0);
View Full Code Here

  @Test
  public void testArrayLocalVariable(){
    FamixMethod simpleMethod = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Test3.gather()",null));
    assertNotNull("FamixModel must contain method testPackage.Test3.gather()", simpleMethod);
    FamixLocalVariable lVar = fFactory.createLocalVariable("testPackage.Test3.gather().items", simpleMethod);
    lVar.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test3.java", 216, 235));
    lVar = (FamixLocalVariable)fModel.getElement(lVar);
    assertNotNull("FamixModel must contain local variable testPackage.Test3.gather().items", lVar);
    FamixClass declClass = (FamixClass) fModel.getElement(fFactory.createClass(AbstractFamixEntity.ARRAY_TYPE_NAME, null));
    assertNotNull("FamixModel must contain class " + AbstractFamixEntity.ARRAY_TYPE_NAME, declClass);
   
View Full Code Here

     *
     * @param entity the entity
     * @param highlight True, if the source of the entity should be selected.
     */
    private void openInEditor(AbstractFamixEntity entity, boolean highlight) {
        SourceAnchor sourceAnchor = entity.getSourceAnchor();
        if (sourceAnchor != null) {
            String filePath = sourceAnchor.getFile();
            try {
                IEditorPart editor = openInEditor(filePath);
                if (highlight) {
                    Integer start = sourceAnchor.getStartPos();
                    Integer end = sourceAnchor.getEndPos();
                    if (start != 0 && end != null) {
                        highlightSource(editor, start, end);
                    }
                }
            } catch (final PartInitException e) {
View Full Code Here

    @Test
    public void testMethodLocalVariableContainsSimple() {
        FamixMethod simpleMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Variables.m(int,int[])", null));
        FamixLocalVariable simpleLocal = aFactory.createLocalVariable("testPackage.Variables.m(int,int[]).local", null);
        simpleLocal.setSourceAnchor(new SourceAnchor("/TestProject1/src/testPackage/Variables.java", 0, 436));
        simpleLocal = (FamixLocalVariable) aModel.getElement(simpleLocal);

        assertNotNull("FamixModel must contain local variable testPackage.Variables.m(int,int[]).local", simpleLocal);
        assertTrue("FamixMethod must contain local variable", simpleMethod.getLocalVariables().size() > 0);
        boolean containsLocal = TestHelper.containsLocalVariable(simpleMethod, simpleLocal);
View Full Code Here

    @Test
    public void testMethodLocalVariableContainsMulti() {
        FamixMethod simpleMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Variables.m(int,int[])", null));
        FamixLocalVariable multiLocal1 = aFactory.createLocalVariable("testPackage.Variables.m(int,int[]).multi1", null);
        multiLocal1.setSourceAnchor(new SourceAnchor("/TestProject1/src/testPackage/Variables.java", 0, 450));
        multiLocal1 = (FamixLocalVariable) aModel.getElement(multiLocal1);
        FamixLocalVariable multiLocal2 = aFactory.createLocalVariable("testPackage.Variables.m(int,int[]).multi2", null);
        multiLocal2.setSourceAnchor(new SourceAnchor("/TestProject1/src/testPackage/Variables.java", 0, 458));
        multiLocal2 = (FamixLocalVariable) aModel.getElement(multiLocal2);

        assertNotNull("FamixModel must contain local variable testPackage.Variables.m(int,int[]).multi1", multiLocal1);
        assertNotNull("FamixModel must contain local variable testPackage.Variables.m(int,int[]).multi2", multiLocal2);
        assertTrue("FamixMethod must contain local variable", simpleMethod.getLocalVariables().size() > 0);
View Full Code Here

    @Test
    public void testMethodLocalVariableContainsWithinFor() {
        FamixMethod simpleMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Variables.m(int,int[])", null));
        FamixLocalVariable withinFor = aFactory.createLocalVariable("testPackage.Variables.m(int,int[]).inFor", null);
        withinFor.setSourceAnchor(new SourceAnchor("/TestProject1/src/testPackage/Variables.java", 0, 563));
        withinFor = (FamixLocalVariable) aModel.getElement(withinFor);

        assertNotNull("FamixModel must contain method testPackage.Variables.m(int,int[])", simpleMethod);
        assertNotNull("FamixModel must contain local variable testPackage.Variables.m(int,int[]).inFor", withinFor);
View Full Code Here

    @Test
    public void testMethodLocalVariableContainsWithinCatchClause() {
        FamixMethod simpleMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Variables.m(int,int[])", null));
        FamixLocalVariable withinCatch = aFactory.createLocalVariable("testPackage.Variables.m(int,int[]).aiob", null);
        withinCatch.setSourceAnchor(new SourceAnchor("/TestProject1/src/testPackage/Variables.java", 0, 667));
        withinCatch = (FamixLocalVariable) aModel.getElement(withinCatch);

        assertNotNull("FamixModel must contain method testPackage.Variables.m(int,int[])", simpleMethod);
        assertNotNull("FamixModel must contain local variable testPackage.Variables.m(int,int[]).aiob", withinCatch);
View Full Code Here

    @Test
    public void testSourceAnchorClass() throws Exception {
        FamixClass classSum = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.Sum", null));
       
        SourceAnchor anchor = classSum.getSourceAnchor();
        assertNotNull("Source anchor file of class " + classSum.getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of class " + classSum.getUniqueName() + " must be", "/TestProject1/src/testPackage/Sum.java", anchor.getFile());
        assertTrue("The start must be before the end position", anchor.getStartPos() <= anchor.getEndPos());
        InputStream fileStream = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromPortableString(anchor.getFile())).getContents();
        String fileContent = TestHelper.getFileContent(fileStream);
        String classSumDecl = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertTrue("Declaration of class must start with 'public class Sum'", classSumDecl.startsWith("public class Sum"));
        assertEquals("Declaration in source file must equal the source attribute ", classSumDecl, classSum.getSource());
    }
View Full Code Here

TOP

Related Classes of org.evolizer.famix.model.entities.SourceAnchor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.