Examples of IMethod


Examples of org.aspectj.org.eclipse.jdt.core.IMethod

/*
* Create method handle.
* Store occurences for create handle to retrieve possible duplicate ones.
*/
private IJavaElement createMethodHandle(IType type, String methodName, String[] parameterTypeSignatures) {
  IMethod methodHandle = type.getMethod(methodName, parameterTypeSignatures);
  if (methodHandle instanceof SourceMethod) {
    while (this.methodHandles.contains(methodHandle)) {
      ((SourceMethod) methodHandle).occurrenceCount++;
    }
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IMethod

      final String typeVariableName = new String(referenceBinding.sourceName());
      Binding declaringElement = ((TypeVariableBinding) referenceBinding).declaringElement;
      IBinding declaringTypeBinding = null;
      if (declaringElement instanceof MethodBinding) {
        declaringTypeBinding = this.resolver.getMethodBinding((MethodBinding) declaringElement);
        IMethod declaringMethod = (IMethod) declaringTypeBinding.getJavaElement();
        return (JavaElement) declaringMethod.getTypeParameter(typeVariableName);
      } else {
        ITypeBinding typeBinding2 = this.resolver.getTypeBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement);
        if (typeBinding2 == null) return null;
        declaringTypeBinding = typeBinding2;
        IType declaringType = (IType) declaringTypeBinding.getJavaElement();
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IMethod

    IMember member = typeParameter.getDeclaringMember();
    this.declaringMemberName = member.getElementName().toCharArray(); // store type parameter declaring member name
   
    // For method type parameter, store also declaring class name and parameters type names
    if (member instanceof IMethod) {
      IMethod method = (IMethod) member;
      this.methodDeclaringClassName = method.getParent().getElementName().toCharArray();
      String[] parameters = method.getParameterTypes();
      int length = parameters.length;
      this.methodArgumentTypes = new char[length][];
      for (int i=0; i<length; i++) {
        this.methodArgumentTypes[i] = Signature.toCharArray(parameters[i].toCharArray());
      }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IMethod

      if (isInnerBinaryTypeConstructor)
        parameterSignatures[0] = new String(enclosingType.genericTypeSignature()).replace('/', '.');
      for (int i = 0;  i < length; i++) {
        parameterSignatures[declaringIndex + i] = new String(parameters[i].genericTypeSignature()).replace('/', '.');
      }
      IMethod result = declaringType.getMethod(selector, parameterSignatures);
      if (isBinary)
        return (JavaElement) result;
      IMethod[] methods = null;
      try {
        methods = declaringType.getMethods();
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IMethod

      } else {
        this.methodParameterTypes[typeDepth] = parameterTypes;
      }
      this.methodParameterNames[typeDepth] = methodInfo.parameterNames;
     
      IMethod method = currentType.getMethod(
          this.memberName[typeDepth],
          convertTypeNamesToSigs(this.methodParameterTypes[typeDepth]));
     
      // type parameters
      if (methodInfo.typeParameters != null) {
        for (int i = 0, length = methodInfo.typeParameters.length; i < length; i++) {
          TypeParameterInfo typeParameterInfo = methodInfo.typeParameters[i];
          ITypeParameter typeParameter = method.getTypeParameter(new String(typeParameterInfo.name));
          setSourceRange(
            typeParameter,
            new SourceRange(
              typeParameterInfo.declarationStart,
              typeParameterInfo.declarationEnd - typeParameterInfo.declarationStart + 1),
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IMethod

      IType currentType = this.types[typeDepth];
      SourceRange sourceRange =
        new SourceRange(
          this.memberDeclarationStart[typeDepth],
          declarationEnd - this.memberDeclarationStart[typeDepth] + 1);
      IMethod method = currentType.getMethod(
          this.memberName[typeDepth],
          convertTypeNamesToSigs(this.methodParameterTypes[typeDepth]));
      setSourceRange(
        method,
        sourceRange,
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IMethod

        }
        break;
      case IJavaElement.TYPE_PARAMETER :
        IJavaElement parent = element.getParent();
        if (parent.getElementType() == IJavaElement.METHOD) {
          IMethod method = (IMethod) parent;
          if (method.isBinary()) {
            IJavaElement[] el = getUnqualifiedMethodHandle(method, false);
            if(el[1] != null && this.sourceRanges.get(el[0]) == null) {
              method = (IMethod) getUnqualifiedMethodHandle(method, true)[0];
            } else {
              method = (IMethod) el[0];
            }
            element = method.getTypeParameter(element.getElementName());
          }
        }
    }
    SourceRange[] ranges = (SourceRange[]) this.sourceRanges.get(element);
    if (ranges == null) {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IMethod

        }
        break;
      case IJavaElement.TYPE_PARAMETER :
        IJavaElement parent = element.getParent();
        if (parent.getElementType() == IJavaElement.METHOD) {
          IMethod method = (IMethod) parent;
          if (method.isBinary()) {
            IJavaElement[] el = getUnqualifiedMethodHandle(method, false);
            if(el[1] != null && this.sourceRanges.get(el[0]) == null) {
              method = (IMethod) getUnqualifiedMethodHandle(method, true)[0];
            } else {
              method = (IMethod) el[0];
            }
            element = method.getTypeParameter(element.getElementName());
          }
        }
    }
    SourceRange[] ranges = (SourceRange[]) this.sourceRanges.get(element);
    if (ranges == null) {
View Full Code Here

Examples of org.codehaus.janino.IClass.IMethod

        // Check that all methods are implemented.
        if ((cd.getModifiers() & Mod.ABSTRACT) == 0) {
            IMethod[] ms = iClass.getIMethods();
            for (int i = 0; i < ms.length; ++i) {
                IMethod base = ms[i];
                if (base.isAbstract()) {
                    IMethod override = iClass.findIMethod(base.getName(), base.getParameterTypes());
                    if (
                        override == null           // It wasn't overridden
                        || override.isAbstract()   // It was overridden with an abstract method
                                                   // The override does not provide a covariant return type
                        || !base.getReturnType().isAssignableFrom(override.getReturnType())
                    ) {
                        this.compileError(
                            "Non-abstract class \"" + iClass + "\" must implement method \"" + base + "\"",
                            cd.getLocation()
                        );
                    }
                }
            }
        }

        // Create "ClassFile" object.
        ClassFile cf = new ClassFile(
            (short) (cd.getModifiers() | Mod.SUPER),      // accessFlags
            iClass.getDescriptor(),                       // thisClassFD
            iClass.getSuperclass().getDescriptor(),       // superClassFD
            IClass.getDescriptors(iClass.getInterfaces()) // interfaceFDs
        );

        // Add InnerClasses attribute entry for this class declaration.
        if (cd.getEnclosingScope() instanceof Java.CompilationUnit) {
            ;
        } else
        if (cd.getEnclosingScope() instanceof Java.Block) {
            short innerClassInfoIndex = cf.addConstantClassInfo(iClass.getDescriptor());
            short innerNameIndex = (
                this instanceof Java.NamedTypeDeclaration ?
                cf.addConstantUtf8Info(((Java.NamedTypeDeclaration) this).getName()) :
                (short) 0
            );
            cf.addInnerClassesAttributeEntry(new ClassFile.InnerClassesAttribute.Entry(
                innerClassInfoIndex, // innerClassInfoIndex
                (short) 0,           // outerClassInfoIndex
                innerNameIndex,      // innerNameIndex
                cd.getModifiers()    // innerClassAccessFlags
            ));
        } else
        if (cd.getEnclosingScope() instanceof Java.TypeDeclaration) {
            short innerClassInfoIndex = cf.addConstantClassInfo(iClass.getDescriptor());
            short outerClassInfoIndex = cf.addConstantClassInfo(
                this.resolve(((Java.TypeDeclaration) cd.getEnclosingScope())).getDescriptor()
            );
            short innerNameIndex = cf.addConstantUtf8Info(((Java.MemberTypeDeclaration) cd).getName());
            cf.addInnerClassesAttributeEntry(new ClassFile.InnerClassesAttribute.Entry(
                innerClassInfoIndex, // innerClassInfoIndex
                outerClassInfoIndex, // outerClassInfoIndex
                innerNameIndex,      // innerNameIndex
                cd.getModifiers()    // innerClassAccessFlags
            ));
        }

        // Set "SourceFile" attribute.
        if (this.debugSource) {
            String sourceFileName;
            {
                String s = cd.getLocation().getFileName();
                if (s != null) {
                    sourceFileName = new File(s).getName();
                } else if (cd instanceof Java.NamedTypeDeclaration) {
                    sourceFileName = ((Java.NamedTypeDeclaration) cd).getName() + ".java";
                } else {
                    sourceFileName = "ANONYMOUS.java";
                }
            }
            cf.addSourceFileAttribute(sourceFileName);
        }

        // Add "Deprecated" attribute (JVMS 4.7.10)
        if (cd instanceof Java.DocCommentable) {
            if (((Java.DocCommentable) cd).hasDeprecatedDocTag()) cf.addDeprecatedAttribute();
        }

        // Optional: Generate and compile class initialization method.
        {
            List/*<BlockStatement>*/ statements = new ArrayList();
            for (Iterator it = cd.variableDeclaratorsAndInitializers.iterator(); it.hasNext();) {
                Java.TypeBodyDeclaration tbd = (Java.TypeBodyDeclaration) it.next();
                if (tbd.isStatic()) statements.add((Java.BlockStatement) tbd);
            }

            this.maybeCreateInitMethod(cd, cf, statements);
        }

        this.compileDeclaredMethods(cd, cf);

        // Compile declared constructors.
        // As a side effect of compiling methods and constructors, synthetic "class-dollar"
        // methods (which implement class literals) are generated on-the fly.
        // We need to note how many we have here so we can compile the extras.
        int declaredMethodCount = cd.getMethodDeclarations().size();
        {
            int syntheticFieldCount = cd.syntheticFields.size();
            Java.ConstructorDeclarator[] cds = cd.getConstructors();
            for (int i = 0; i < cds.length; ++i) {
                this.compile(cds[i], cf);
                if (syntheticFieldCount != cd.syntheticFields.size()) {
                    throw new JaninoRuntimeException(
                        "SNO: Compilation of constructor \""
                        + cds[i]
                        + "\" ("
                        + cds[i].getLocation()
                        + ") added synthetic fields!?"
                    );
                }
            }
        }

        // A side effect of this call may create synthetic functions to access
        // protected parent variables
        this.compileDeclaredMemberTypes(cd, cf);
       
        // Compile the aforementioned extras.
        this.compileDeclaredMethods(cd, cf, declaredMethodCount);
       
        {
            // for every method look for bridge methods that need to be supplied
            // this is used to correctly dispatch into covariant return types
            // from existing code
            IMethod[] ms = iClass.getIMethods();
            for (int i = 0; i < ms.length; ++i) {
                IMethod base = ms[i];
                if (! base.isStatic()) {
                    IMethod override = iClass.findIMethod(base.getName(), base.getParameterTypes());
                    // if we overrode the method but with a DIFFERENT return type
                    if (override != null &&
                        ! base.getReturnType().equals(override.getReturnType())) {
                        this.compileBridgeMethod(cf, base, override);
                    }
                }
            }
               
View Full Code Here

Examples of org.eclipse.dltk.core.IMethod

    this.method = method;
  }

  public IMethod getFarthestOverriddenMethod() throws CoreException {
    IMethod overriddenMethod = getOverriddenMethod();
    if (overriddenMethod == null) {
      return method;
    } else {
      return new PHPMethod(overriddenMethod).getFarthestOverriddenMethod();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.