Examples of MethodDefinition


Examples of com.strobel.assembler.metadata.MethodDefinition

        return super.visitFieldDeclaration(node, data);
    }

    @Override
    public Void visitMethodDeclaration(final MethodDeclaration node, final Void _) {
        final MethodDefinition method = node.getUserData(Keys.METHOD_DEFINITION);

        if (method != null) {
            if (AstBuilder.isMemberHidden(method, context)) {
                node.remove();
                return null;
            }

            if (method.isTypeInitializer()) {
                if (node.getBody().getStatements().isEmpty()) {
                    node.remove();
                    return null;
                }
            }
View Full Code Here

Examples of com.strobel.assembler.metadata.MethodDefinition

        );
    }

    @Override
    public Void visitConstructorDeclaration(final ConstructorDeclaration node, final Void _) {
        final MethodDefinition method = node.getUserData(Keys.METHOD_DEFINITION);

        if (method != null) {
            if (AstBuilder.isMemberHidden(method, context)) {
                node.remove();
                return null;
            }

            if (!context.getSettings().getShowSyntheticMembers() &&
                node.getParameters().isEmpty() &&
                DEFAULT_CONSTRUCTOR_BODY.matches(node.getBody())) {

                //
                // Remove redundant default constructors.
                //

                final TypeDefinition declaringType = method.getDeclaringType();

                if (declaringType != null) {
                    final boolean hasOtherConstructors = any(
                        declaringType.getDeclaredMethods(),
                        new Predicate<MethodDefinition>() {
                            @Override
                            public boolean test(final MethodDefinition m) {
                                return m.isConstructor() &&
                                       !m.isSynthetic() &&
                                       !StringUtilities.equals(m.getErasedSignature(), method.getErasedSignature());
                            }
                        }
                    );

                    if (!hasOtherConstructors) {
View Full Code Here

Examples of com.strobel.assembler.metadata.MethodDefinition

        if (method == null) {
            return null;
        }

        final MethodDefinition resolved = method.resolve();

        if (resolved == null || !resolved.isVarArgs()) {
            return null;
        }

        final ResolveResult targetResult = _resolver.apply(target.getTarget());

        if (targetResult == null || targetResult.getType() == null) {
            return null;
        }

        final List<TypeReference> argTypes = new ArrayList<>();

        for (final Expression argument : arguments) {
            final ResolveResult argResult = _resolver.apply(argument);

            if (argResult == null || argResult.getType() == null) {
                return null;
            }

            argTypes.add(argResult.getType());
        }

        final List<MethodReference> candidates = MetadataHelper.findMethods(
            targetResult.getType(),
            MetadataFilters.matchName(resolved.getName())
        );

        final MethodBinder.BindResult c1 = MethodBinder.selectMethod(candidates, argTypes);

        if (c1.isFailure() || c1.isAmbiguous()) {
View Full Code Here

Examples of com.strobel.assembler.metadata.MethodDefinition

        }

        for (AstNode child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
            if (child instanceof TypeDeclaration) {
                final TypeDefinition currentType = context.getCurrentType();
                final MethodDefinition currentMethod = context.getCurrentMethod();

                context.setCurrentType(null);
                context.setCurrentMethod(null);

                try {
View Full Code Here

Examples of com.strobel.assembler.metadata.MethodDefinition

    private boolean isContextWithinTypeInstance(final TypeReference type) {
        final MethodReference method = context.getCurrentMethod();

        if (method != null) {
            final MethodDefinition resolvedMethod = method.resolve();

            if (resolvedMethod != null && resolvedMethod.isStatic()) {
                return false;
            }
        }

        final TypeReference scope = context.getCurrentType();

        for (TypeReference current = scope;
             current != null;
             current = current.getDeclaringType()) {

            if (MetadataResolver.areEquivalent(current, type)) {
                return true;
            }

            final TypeDefinition resolved = current.resolve();

            if (resolved != null && resolved.isLocalClass()) {
                final MethodReference declaringMethod = resolved.getDeclaringMethod();

                if (declaringMethod != null) {
                    final MethodDefinition resolvedDeclaringMethod = declaringMethod.resolve();

                    if (resolvedDeclaringMethod != null && resolvedDeclaringMethod.isStatic()) {
                        break;
                    }
                }
            }
        }
View Full Code Here

Examples of gri.tasks.java.MethodDefinition

    String className = classElem == null ?
        null : classElem.getText();

    //constructor:
    Element constructorElem = elem.getChild("constructor");
    MethodDefinition constructorDef = constructorElem == null ?
        null : parseMethod(constructorElem);

    //target method:
    Element methodElem = elem.getChild("method");
    if (methodElem == null)
      throw new InvalidXMLException("Method invocation missing required <method> element");
    MethodDefinition methodDef = parseMethod(methodElem);

    String methodName = methodElem.getAttributeValue("name");
    if (methodName == null)
      throw new InvalidXMLException("<method> element missing required 'name' parameter");
View Full Code Here

Examples of gri.tasks.java.MethodDefinition

        else
          throw new InvalidXMLException("Only one return type can be specified for a method");
      }
    }

    return new MethodDefinition(
        (ParameterDef [])params.toArray(new ParameterDef [] {}),
        returnType
    );
  }
View Full Code Here

Examples of gri.tasks.java.MethodDefinition

     *  
     */
    public static void test1() throws Exception {
      //define a method of type: 
      //  String method(String text)
        MethodDefinition methodDef = new MethodDefinition();
       
        ParameterDef inDef = new ParameterDef("text", Types.STRING);
        ParameterDef outDef = new ParameterDef("output", Types.STRING);
        methodDef.setParameterDefs(new ParameterDef [] {inDef});
        methodDef.setReturnType(outDef);
       
        //acquire method reference:
        test_java obj = new test_java();
        Method upper = obj.getClass().getMethod("upper", new Class [] {String.class});
        Method lower = test_java.class.getMethod("lower", new Class [] {String.class});
View Full Code Here

Examples of gri.tasks.java.MethodDefinition

        Method targetMethod = targetClass.getMethod("write", new Class [] {String.class});
        Constructor constructor = targetClass.getConstructor(new Class [] {String.class});
       
        //define method:
        //    String write(String message)
        MethodDefinition targetMethodDef = new MethodDefinition();
        ParameterDef inDef = new ParameterDef("message", Types.STRING);
        ParameterDef outDef = new ParameterDef("output", Types.STRING);
        targetMethodDef.setParameterDefs(new ParameterDef [] {inDef});
        targetMethodDef.setReturnType(outDef);
       
        //define constructor:
        //     TestClass(String prefix)
        MethodDefinition constructorDef = new MethodDefinition();
        ParameterDef prefixDef = new ParameterDef("prefix", Types.STRING);
        constructorDef.setParameterDefs(new ParameterDef [] {prefixDef});
       
        //define property bindings:
        //    void   setSuffix(String suffix)
        //    String getValue()
        PropertyBindingDef propertyDef = new PropertyBindingDef();
View Full Code Here

Examples of org.fcrepo.client.objecteditor.types.MethodDefinition

        // Methods
        //
        java.util.List methodDefs = Util.getMethodDefinitions(sDefPID);
        String[] methodSelections = new String[methodDefs.size()];
        for (int i = 0; i < methodDefs.size(); i++) {
            MethodDefinition def = (MethodDefinition) methodDefs.get(i);
            StringBuffer buf = new StringBuffer();
            buf.append(def.getName());
            if (def.getLabel() != null) {
                buf.append(" - ");
                buf.append(def.getLabel());
            }
            methodSelections[i] = buf.toString();
        }
        final JComboBox methodComboBox = new JComboBox(methodSelections);
        Administrator.constrainHeight(methodComboBox);
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.