Package org.evolizer.famix.model.entities

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


        assertEquals("FamixInheritance of "  + inheritance.getFrom().getUniqueName() + " - " + inheritance.getTo().getUniqueName() + " must be 'Base'", "Base", extendsStatement);
    }

    @Test
    public void testSourceAnchorMethodInvocation() throws Exception {
        FamixMethod computeAllSums = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.Test.computeAllSums()", null));
        FamixMethod compute = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Sum.compute()", null));

        List<FamixAssociation> invocations = new LinkedList<FamixAssociation>();
        for (FamixAssociation ass : aModel.getAssociations(computeAllSums)) {
            if (ass instanceof FamixInvocation && ass.getTo().equals(compute)) {
                invocations.add(ass);
View Full Code Here


        }
    }

    @Test
    public void testSourceAnchorFieldInitAccess() throws Exception {
        FamixMethod oinitMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.Test.<oinit>()", null));
        FamixAttribute containerSum = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.Test.containerSum", null));

        List<FamixAssociation> accesses = new LinkedList<FamixAssociation>();
        for (FamixAssociation ass : aModel.getAssociations(oinitMethod)) {
            if (ass instanceof FamixAccess && ass.getTo().equals(containerSum)) {
View Full Code Here

        assertEquals("FamixAccess of "  + accesses.get(0).getFrom().getUniqueName() + " - " + accesses.get(0).getTo().getUniqueName() + " must equal 'containerSum = new Vector<Sum>()'", "containerSum = new Vector<Sum>()", accessStatement);
    }

    @Test
    public void testSourceAnchorFieldAccess() throws Exception {
        FamixMethod fooMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.Test.foo()", null));
        FamixAttribute aAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.Test.a", null));

        List<FamixAssociation> accesses = new LinkedList<FamixAssociation>();
        for (FamixAssociation ass : aModel.getAssociations(fooMethod)) {
            if (ass instanceof FamixAccess && ass.getTo().equals(aAttribute)) {
View Full Code Here

       
        try {
            initMethodBinding();
            initArguments();
   
            FamixMethod caller = getCurrMethod();
            FamixMethod callee = createMethodFromInvocation();
   
            if ((caller != null) && (callee != null)) {
                callee = (FamixMethod) getModel().addElement(callee);
                FamixAssociation invocation = getFactory().createInvocation(caller, callee);
                invocation.setSourceAnchor(getSourceAnchor());
View Full Code Here

     *
     * @return The called FAMIX method, otherwise null.
     */
    @Override
    public FamixMethod createMethodFromInvocation() {
        FamixMethod lConstructor = null;
        int successfullResolvingCounter = countResolvedArguments();

        // increment the counter of anonymous classes of the current type
        if (getASTNode().getAnonymousClassDeclaration() != null) {
            getAnonymClassCounter().put(getCurrType(), getAnonymClassCounter().get(getCurrType()) + 1);
        }

        if ((getMethodBinding() != null) && (getMethodBinding().getDeclaringClass() != null) && (successfullResolvingCounter == getArguments().size())) {
            lConstructor = createMethod();
        } else {
            // also consider anonymous class instance creation
            if (getASTNode().getAnonymousClassDeclaration() != null) {
                lConstructor =
                        rememberUnresolvedInvocation(new UnresolvedAnonymousClassInstanceCreationInvocation(
                                getCurrMethod(),
                                this,
                                getAnonymClassCounter().get(getCurrType())));
            } else {
                lConstructor =
                        rememberUnresolvedInvocation(new UnresolvedClassInstanceCreationInvocation(
                                getCurrMethod(),
                                this));
            }
        }

        // add the corresponding constructor to the anonymous class (only for anonymous classes)
        if ((getASTNode().getAnonymousClassDeclaration() != null) && (lConstructor != null)) {
            FamixClass lDeclaringClass = getClass(getASTNode().getAnonymousClassDeclaration().resolveBinding(), null, true);
            lDeclaringClass = (FamixClass) getModel().addElement(lDeclaringClass);
            if (lDeclaringClass.getParent() != null) {
                sLogger.warn("Warn - anoym class " + lDeclaringClass.getUniqueName() + " already has a parent: "
                        + lDeclaringClass.getParent().getUniqueName());
            }

            lDeclaringClass.getMethods().add(lConstructor);
            lConstructor.setParent(lDeclaringClass);
        }

        return lConstructor;
    }
View Full Code Here

     *
     * @return The called FAMIX method, otherwise null.
     */
    @Override
    public FamixMethod createMethodFromInvocation() {
        FamixMethod lSuperMethod = null;
        int successfullResolvingCounter = countResolvedArguments();

        if ((getMethodBinding() != null) && (successfullResolvingCounter == getArguments().size())) {
            lSuperMethod = createMethod();
        } else {
View Full Code Here

        if (Modifier.isStatic(getASTNode().getModifiers())) {
            addCurrMethodToMethodReminder();

            String lMethodID =
                    getCurrType().getUniqueName() + AbstractFamixEntity.NAME_DELIMITER + AbstractFamixEntity.CLASS_INIT_METHOD;
            FamixMethod classInit = getFactory().createMethod(lMethodID, null);
            classInit = (FamixMethod) getModel().addElement(classInit);
            classInit.setParent(getCurrType());
            getCurrType().getMethods().add(classInit);
            classInit.setModifiers(getASTNode().getModifiers());
            classInit.setSourceAnchor(getCurrType().getSourceAnchor());
            setCurrMethod(classInit);
        }
    }
View Full Code Here

            defaultConstructorId.append(AbstractFamixEntity.NAME_DELIMITER);
            defaultConstructorId.append(AbstractFamixEntity.CONSTRUCTOR_PREFIX);
            defaultConstructorId.append(AbstractFamixEntity.METHOD_START_BRACE);
            defaultConstructorId.append(AbstractFamixEntity.METHOD_END_BRACE);
           
            FamixMethod defaultConstructor = getFactory().createMethod(defaultConstructorId.toString(), currentType);
            defaultConstructor = (FamixMethod) getModel().addElement(defaultConstructor);
   
            // if the not explicitly defined default constructor has already been called and is in
            // the model it does not have a parent yet
            if (defaultConstructor.getParent() == null) {
                defaultConstructor.setParent(currentType);
            }
            currentType.getMethods().add(defaultConstructor);
        }
    }
View Full Code Here

     *            Famix class that contains the object init method.
     * @return The object init FAMIX method.
     */
    protected FamixMethod addObjectInitMethod(FamixClass pClass) {
        String lMethodID = pClass.getUniqueName() + AbstractFamixEntity.NAME_DELIMITER + AbstractFamixEntity.OBJECT_INIT_METHOD;
        FamixMethod lObjectInitMethod = getFactory().createMethod(lMethodID, null);
        lObjectInitMethod = (FamixMethod) getModel().addElement(lObjectInitMethod);
        lObjectInitMethod.setModifiers(AbstractFamixEntity.UNKOWN_OR_NO_MODIFIERS);
        lObjectInitMethod.setSourceAnchor(new SourceAnchor(pClass.getSourceAnchor().getFile(), pClass.getSourceAnchor()
                .getStartPos(), pClass.getSourceAnchor().getEndPos()));
        lObjectInitMethod.setParent(pClass);
        pClass.getMethods().add(lObjectInitMethod);

        // initialize unresolved method hash of the oinit FamixMethod
        // getUnresolvedCalls().put(lObjectInitMethod, new LinkedList<UnresolvedMethodInvocation>());

View Full Code Here

  }
 
 
  @Test
  public void testMethodParameters(){
    FamixMethod method = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.Test.myMethod(int,double,<undef>.Warlock)",null));
    assertNotNull(method);
    assertEquals(3, method.getParameters().size());
   
    FamixParameter param = (FamixParameter) aModel.getElement(aFactory.createFormalParameter("testPackage.Test.myMethod(int,double,<undef>.Warlock).i",null,0));
    assertNotNull(param);
    assertEquals(new Integer(0), param.getParamIndex());
   
    FamixClass clazz = (FamixClass) aModel.getElement(aFactory.createClass("int",null));
    assertEquals(clazz, param.getDeclaredClass());
    assertTrue(method.getParameters().contains(param));
    assertEquals(method, param.getParent());
   
    param = (FamixParameter) aModel.getElement(aFactory.createFormalParameter("testPackage.Test.myMethod(int,double,<undef>.Warlock).d",null,1));
    clazz = (FamixClass) aModel.getElement(aFactory.createClass("double",null));
    assertEquals(clazz, param.getDeclaredClass());
    assertNotNull(param);
    assertTrue(method.getParameters().contains(param));
    assertEquals(method, param.getParent());
    assertEquals(new Integer(1), param.getParamIndex());
   
    param = (FamixParameter) aModel.getElement(aFactory.createFormalParameter("testPackage.Test.myMethod(int,double,<undef>.Warlock).zorf",null,2));
    clazz = (FamixClass) aModel.getElement(aFactory.createClass("<undef>.Warlock",null));
    assertEquals(clazz, param.getDeclaredClass());
    assertNotNull(param);
    assertTrue(method.getParameters().contains(param));
    assertEquals(method, param.getParent());
    assertEquals(new Integer(2), param.getParamIndex());
  }
View Full Code Here

TOP

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

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.