Package org.eclipse.jdt.core.dom

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


                                }
                               
                                String sType = buildFullQualifiedClassname(node.getType(), _imports, classname);

                                for (Object obj : node.fragments()) {
                                    VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
                                   
                                   

                                   
                                    TMLScriptProperty tmlScriptProperty = new TMLScriptProperty(fragment.getName().toString(), sType, classname);
                                    if (org.eclipse.jdt.core.dom.Modifier.isStatic(node.getModifiers())) {
                                        tmlScriptProperty.setStatic(true);
                                    }
                                    properties.add(tmlScriptProperty);
                                }
View Full Code Here


     * @param name field name
     * @param type field type
     * @return field builder
     */
    public FieldBuilder addField(String name, Type type) {
        VariableDeclarationFragment vfrag = getAST().newVariableDeclarationFragment();
        vfrag.setName(getAST().newSimpleName(name));
        FieldDeclaration fdecl = getAST().newFieldDeclaration(vfrag);
        fdecl.setType(type);
        m_fields.add(fdecl);
        return new FieldBuilder(this, fdecl);
    }
View Full Code Here

     * Set initializer expression for field declaration.
     *
     * @param expr
     */
    public void setInitializer(ExpressionBuilderBase expr) {
        VariableDeclarationFragment frag = (VariableDeclarationFragment)m_field.fragments().get(0);
        frag.setInitializer(expr.getExpression());
    }
View Full Code Here

     * Set initializer as a string literal.
     *
     * @param value
     */
    public void setStringInitializer(String value) {
        VariableDeclarationFragment frag = (VariableDeclarationFragment)m_field.fragments().get(0);
        StringLiteral literal = m_ast.newStringLiteral();
        literal.setLiteralValue(value);
        frag.setInitializer(literal);
    }
View Full Code Here

     * Set initializer as a number literal.
     *
     * @param value
     */
    public void setNumberInitializer(String value) {
        VariableDeclarationFragment frag = (VariableDeclarationFragment)m_field.fragments().get(0);
        frag.setInitializer(m_ast.newNumberLiteral(value));
    }
View Full Code Here

     *
     * @param type
     * @param vname
     */
    public void addLocalVariableDeclaration(String type, String vname) {
        VariableDeclarationFragment vfrag = m_ast.newVariableDeclarationFragment();
        vfrag.setName(m_ast.newSimpleName(vname));
        VariableDeclarationStatement stmt = m_ast.newVariableDeclarationStatement(vfrag);
        stmt.setType(m_source.createType(type));
        m_block.statements().add(stmt);
    }
View Full Code Here

     * @param type
     * @param vname
     * @param expr initializer expression
     */
    public void addLocalVariableDeclaration(Type type, String vname, ExpressionBuilderBase expr) {
        VariableDeclarationFragment vfrag = m_ast.newVariableDeclarationFragment();
        vfrag.setName(m_ast.newSimpleName(vname));
        vfrag.setInitializer(expr.getExpression());
        VariableDeclarationStatement stmt = m_ast.newVariableDeclarationStatement(vfrag);
        stmt.setType(type);
        m_block.statements().add(stmt);
    }
View Full Code Here

     * @param block statement body block
     */
    private void addForStatement(String name, Type type, Expression init, Expression test, Expression post,
        BlockBuilder block) {
        ForStatement stmt = m_ast.newForStatement();
        VariableDeclarationFragment declfrag = m_ast.newVariableDeclarationFragment();
        declfrag.setName(m_ast.newSimpleName(name));
        declfrag.setInitializer(init);
        VariableDeclarationExpression varexpr = m_ast.newVariableDeclarationExpression(declfrag);
        varexpr.setType(type);
        stmt.initializers().add(varexpr);
        stmt.setExpression(test);
        if (post != null) {
View Full Code Here

        String fieldtype = field.getType().toString();
        if (collect && (fieldtype.startsWith("List") || fieldtype.startsWith("java.util.List"))) {
           
            // make substitutions in template text
            StringBuffer buff = new StringBuffer(s_classText);
            VariableDeclarationFragment vardecl = (VariableDeclarationFragment)field.fragments().get(0);
            replace("$0", descript, buff);
            replace("$1", vardecl.getName().getIdentifier(), buff);
            replace("$2", NameUtilities.depluralize(NameUtils.toNameWord(basename)), buff);
            replace("$3", holder.getTypeName(type), buff);
            String cast = field.getType().isParameterizedType() ? "" : ("(" + type + ")");
            replace("$4", cast, buff);
            replace("$5", getmeth.getName().getIdentifier().substring(3), buff);
View Full Code Here

    IValueList extendedModifiers = parseExtendedModifiers(node);
    IValue type = visitChild(node.getType());
 
    IValueList fragments = new IValueList(values);
    for (Iterator it = node.fragments().iterator(); it.hasNext();) {
      VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
      fragments.add(visitChild(f));
    }
   
    ownValue = constructDeclarationNode("field", type, fragments.asList());
    setAnnotation("modifiers", extendedModifiers);
View Full Code Here

TOP

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

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.