Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.SingleVariableDeclaration


                            if (org.eclipse.jdt.core.dom.Modifier.isStatic(method.getModifiers())) {
                                tmlScriptMethod.setStatic(true);
                            }                           
                           
                            for (Object param : method.parameters()) {
                                SingleVariableDeclaration varDec = (SingleVariableDeclaration) param;
                                String varType = varDec.getType().toString();
                                if (_imports.containsKey(varType)) {
                                    varType = _imports.get(varType);
                                }
                                de.innovationgate.eclipse.editors.tmlscript.parsing.TMLScriptMethodParameter tmlscriptParam = new de.innovationgate.eclipse.editors.tmlscript.parsing.TMLScriptMethodParameter(varDec.getName().toString(), varType);
                                tmlscriptParam.setVararg(varDec.isVarargs());
                                tmlScriptMethod.getParameters().add(tmlscriptParam);
                            }
                            methods.add(tmlScriptMethod);
                        }
                    }
View Full Code Here


                        if (org.eclipse.jdt.core.dom.Modifier.isPublic(method.getModifiers()) && method.isConstructor()) {
                            String sType = classname;
                            TMLScriptMethod tmlScriptMethod = new TMLScriptMethod(method.getName().toString(), sType, classname);
                            tmlScriptMethod.setDeprecated(isDeprecated(method));
                            for (Object param : method.parameters()) {
                                SingleVariableDeclaration varDec = (SingleVariableDeclaration) param;
                                String varType = varDec.getType().toString();
                                if (_imports.containsKey(varType)) {
                                    varType = _imports.get(varType);
                                }
                                de.innovationgate.eclipse.editors.tmlscript.parsing.TMLScriptMethodParameter tmlscriptParam = new de.innovationgate.eclipse.editors.tmlscript.parsing.TMLScriptMethodParameter(varDec.getName().toString(), varType);
                                tmlScriptMethod.getParameters().add(tmlscriptParam);
                            }
                            constructors.add(tmlScriptMethod);
                        }
                    }
View Full Code Here

            // add list serializer method to class
            String sername = LIST_SERIALIZE_PREFIX + propname;
            MethodBuilder sermeth = builder.addMethod(sername, "java.lang.String");
            sermeth.addParameter("values", (Type)builder.clone(fieldtype));
            if (passctx) {
                SingleVariableDeclaration decl = sermeth.addParameter("ictx", "org.jibx.runtime.IMarshallingContext");
                decl.modifiers().add(decl.getAST().newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD));
                sermeth.addThrows("org.jibx.runtime.JiBXException");
            }
            sermeth.setPublicStatic();
            sermeth.addSourceComment("Serializer for " + descript + ' ' + term + '.');
            sermeth.addSourceComment("");
            sermeth.addSourceComment("@param", " values");
            sermeth.addSourceComment("@return", " text");
           
            // create a simple null return for null parameter string
            BlockBuilder nullblock = builder.newBlock();
            nullblock.addReturnNull();
           
            // create block for actual serialization when parameter non-null
            BlockBuilder serblock = builder.newBlock();
            NewInstanceBuilder newbuff = builder.newInstance("java.lang.StringBuffer");
            serblock.addLocalVariableDeclaration("java.lang.StringBuffer", "buff", newbuff);
           
            // create body of loop to handle the conversion
            BlockBuilder forblock = builder.newBlock();
           
            // append space to buffer unless empty
            InfixExpressionBuilder lengthexpr = builder.buildInfix(Operator.GREATER);
            lengthexpr.addOperand(builder.createNormalMethodCall("buff", "length"));
            lengthexpr.addNumberLiteralOperand("0");
            InvocationBuilder appendcall = builder.createNormalMethodCall("buff", "append");
            appendcall.addCharacterLiteralOperand(' ');
            BlockBuilder spaceblock = builder.newBlock();
            spaceblock.addExpressionStatement(appendcall);
            forblock.addIfStatement(lengthexpr, spaceblock);
           
            // load the current value from array
            if (reptype == SchemaRootBase.REPEAT_TYPED) {
                forblock.addLocalVariableDeclaration(type, "value", builder.createNormalMethodCall("iter", "next"));
            } else if (reptype == SchemaRootBase.REPEAT_LIST) {
                CastBuilder castexpr = builder.buildCast(type);
                castexpr.addOperand(builder.createNormalMethodCall("iter", "next"));
                forblock.addLocalVariableDeclaration(type, "value", castexpr);
            } else {
                forblock.addLocalVariableDeclaration(type, "value", builder.buildArrayIndexAccess("values", "index"));
            }
           
            // append the current value to the buffer
            appendcall = builder.createNormalMethodCall("buff", "append");
            if (valuename != null) {
                appendcall.addOperand(builder.createNormalMethodCall("value", valuename));
            } else if (valdesername != null) {
                InvocationBuilder sercall = builder.createStaticMethodCall(valsername);
                sercall.addVariableOperand("value");
                if (passctx) {
                    sercall.addVariableOperand("ictx");
                }
                appendcall.addOperand(sercall);
            } else {
                appendcall.addVariableOperand("value");
            }
            forblock.addExpressionStatement(appendcall);
           
            // build the for loop around the conversion
            if (reptype == SchemaRootBase.REPEAT_TYPED) {
                Type itertype = builder.createParameterizedType("java.util.Iterator", type);
                serblock.addIteratedForStatement("iter", itertype,
                    builder.createNormalMethodCall("values", "iterator"), forblock);
            } else if (reptype == SchemaRootBase.REPEAT_LIST) {
                serblock.addIteratedForStatement("iter", builder.createType("java.util.Iterator"),
                    builder.createNormalMethodCall("values", "iterator"), forblock);
            } else {
                serblock.addIndexedForStatement("index", "values", forblock);
            }
           
            // finish non-null serialization block with buffer conversion
            serblock.addReturnExpression(builder.createNormalMethodCall("buff", "toString"));
           
            // finish with the if statement that decides which to execute
            InfixExpressionBuilder iftest = builder.buildNameOp("values", Operator.EQUALS);
            iftest.addNullOperand();
            sermeth.createBlock().addIfElseStatement(iftest, nullblock, serblock);
           
            // add list deserializer method to class
            String desername = LIST_DESERIALIZE_PREFIX + propname;
            MethodBuilder desermeth = builder.addMethod(desername, (Type)builder.clone(fieldtype));
            desermeth.addParameter("text", "java.lang.String");
            if (passctx) {
                SingleVariableDeclaration decl = desermeth.addParameter("ictx",
                    "org.jibx.runtime.IUnmarshallingContext");
                decl.modifiers().add(decl.getAST().newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD));
            }
            desermeth.setPublicStatic();
            desermeth.addSourceComment("Deserializer for " + descript + ' ' + term + '.');
            desermeth.addSourceComment("");
            desermeth.addSourceComment("@param", " text");
View Full Code Here

     * @param name
     * @param type
     * @return declaration
     */
    public SingleVariableDeclaration addParameter(String name, Type type) {
        SingleVariableDeclaration vdecl = m_ast.newSingleVariableDeclaration();
        vdecl.setType(type);
        vdecl.setName(m_ast.newSimpleName(name));
        m_method.parameters().add(vdecl);
        return vdecl;
    }
View Full Code Here

     * @param block statement body block
     */
    public void addSugaredForStatement(String name, String type, ExpressionBuilderBase expr, BlockBuilder block) {
        EnhancedForStatement stmt = m_ast.newEnhancedForStatement();
        stmt.setExpression(expr.getExpression());
        SingleVariableDeclaration decl = m_ast.newSingleVariableDeclaration();
        decl.setName(m_ast.newSimpleName(name));
        decl.setType(m_source.createType(type));
        stmt.setParameter(decl);
        stmt.setBody(block.getStatement());
        m_block.statements().add(stmt);
    }
View Full Code Here

      }
      method.setCodeBlock(d.toString());
      List param = dec.parameters();
      ListIterator paramList = param.listIterator();
      while (paramList.hasNext()) {
        SingleVariableDeclaration sin = (SingleVariableDeclaration) paramList.next();
        method.getParameters().add(sin.getType().toString());
      }

      cls.getMethodDeclarations().add(method);
    }
  }
View Full Code Here

        @SuppressWarnings("unchecked")
        List<SingleVariableDeclaration> params = method.parameters();
        for (Iterator<SingleVariableDeclaration> iter = params.iterator(); iter.hasNext();) {
            String paramType;
            SingleVariableDeclaration param = iter.next();
            ITypeBinding typeBinding = param.getType().resolveBinding();
            if (typeBinding != null)
                paramType = typeBinding.getBinaryName();
            else
                paramType = param.getName().getIdentifier();

            builder.append(paramType);
            if (iter.hasNext())
                builder.append(",");
        }
View Full Code Here

   
    IValue name = values.string(node.getName().getFullyQualifiedName());
 
    IValueList parameters = new IValueList(values);
    for (Iterator it = node.parameters().iterator(); it.hasNext();) {
      SingleVariableDeclaration v = (SingleVariableDeclaration) it.next();
      parameters.add(visitChild(v));
    }
 
    IValueList possibleExceptions = new IValueList(values);
    if (!node.thrownExceptions().isEmpty()) {
View Full Code Here

 

  protected boolean processListenerMethod(WidgetAdapter adapter, EventSetDescriptor esd, MethodDescriptor mListener, MethodDeclaration methoddec) {
    if (methoddec.getName().getFullyQualifiedName().equals(mListener.getName())) {
      Block mbody = methoddec.getBody();
      SingleVariableDeclaration var = (SingleVariableDeclaration) methoddec.parameters().get(0);
      IEventMethod content = getDelegatingContent(adapter, esd, mListener, mbody, var);
      methods.put(mListener, content);
      return true;
    } else {
      return false;
View Full Code Here

  private List<Type> getMethodParamTypes(MethodDeclaration method) {
    List params = method.parameters();
    List<Type> types = new ArrayList<Type>();
    for (int i = 0; i < params.size(); i++) {
      SingleVariableDeclaration svd = (SingleVariableDeclaration) params
          .get(i);
      types.add(svd.getType());
    }
    return types;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.SingleVariableDeclaration

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.