/** * Constructor. * * @param pTree The tree node representing any type declaration, i.e. a * a class declaration, for example. Note that it's up to * derived classes to check that the given tree node is of a * valid type. * @param pJSOMType One of the <code>JSOMType.???</code> constants defined * by the interface <code>JSOM</code>. * @param pTokenRewriteStream The token stream the token of the stated * tree node belongs to. */ protected AST2CommonTypeDeclaration( AST2JSOMTree pTree, JSOMType pJSOMType, TokenRewriteStream pTokenRewriteStream) : base(pTree, pJSOMType, pTokenRewriteStream) { if (pTree.GetChild(0).ChildCount == 0) { mHasModifier = false; } mIdentifierTree = (AST2JSOMTree)getTreeNode().GetChild(1); }
/** * Constructor. * <p> * If classes derived from this class should be recognized by another JSOM * type than <code>JSOMType.VARIABLE_DECLARATION</code> they must call * this constructor via the explicit super constructor call. * * @param pTree The tree node representing a variable declaration. * @param pJSOMType The JSOM type of the new instance. * @param pTokenRewriteStream The token stream the token of the stated * tree node belongs to. */ protected AST2CommonVariableDeclaration( AST2JSOMTree pTree, JSOMType pJSOMType, TokenRewriteStream pTokenRewriteStream) : base(pTree, pJSOMType, pTokenRewriteStream) { if (pTree.Type != JavaTreeParser.VAR_DECLARATION) { throw new ArgumentException( CommonErrorMessages.getInvalidArgumentValueMessage( "pTree.Type == " + pTree.Type, "pTree")); } if (pTree.GetChild(0).ChildCount == 0) { mHasModifier = false; } }
/** * Constructor. * <p> * This constructor is used to create a <code>JSOM</code> object * representing a more or less detailed method declaration. An example would * be a method definition, i.e. a method signature followed by a statement * block scope. * * @param pTree The tree node representing a method declaration. * @param pJSOMType One of the <code>JSOMType.???</code> constants defined * by the interface <code>JSOM</code>. * @param pTokenRewriteStream The token stream the token of the stated * tree node belongs to. */ protected AST2MethodDeclaration( AST2JSOMTree pTree, JSOMType pJSOMType, TokenRewriteStream pTokenRewriteStream) : base(pTree, pJSOMType, pTokenRewriteStream) { if (pTree.Type == JavaTreeParser.FUNCTION_METHOD_DECL) { // Get the type child. int offset = 1; AST2JSOMTree child = (AST2JSOMTree)pTree.GetChild(offset); if (child.Type == JavaTreeParser.GENERIC_TYPE_PARAM_LIST) { offset++; child = (AST2JSOMTree)pTree.GetChild(offset); } mReturnTypeTree = child; // Get the identifier. offset++; mIdentifierTree = (AST2JSOMTree)pTree.GetChild(offset); // Is there an array declarator list behind the formal parameter // list? offset += 2; if (offset < pTree.ChildCount) { child = (AST2JSOMTree)pTree.GetChild(offset); if (child.Type == JavaTreeParser.ARRAY_DECLARATOR_LIST) { mNumberOfArrayDeclarators = child.ChildCount; } } } else if (pTree.Type == JavaTreeParser.VOID_METHOD_DECL) { // For void method only the identifier must be fetched. AST2JSOMTree child = (AST2JSOMTree)pTree.GetChild(1); if (child.Type == JavaTreeParser.GENERIC_TYPE_PARAM_LIST) { child = (AST2JSOMTree)pTree.GetChild(2); } mIdentifierTree = child; } else { throw new ArgumentException( CommonErrorMessages.getInvalidArgumentValueMessage( "pTree.Type == " + pTree.Type, "pTree")); } }
/** * Constructor. * <p> * If classes derived from this class should be recognized by another JSOM * type than <code>JSOMType.CLASS_DECLARATION</code> they must call this * constructor via the explicit super constructor call and state the * appropriate <code>JSOMType</code> explicitly. * * @param pTree The tree node representing a class declaration. * @param pJSOMType The JSOM type of the new instance. * @param pTokenRewriteStream The token stream the token of the stated * tree node belongs to. */ protected AST2ClassDeclaration( AST2JSOMTree pTree, JSOMType pJSOMType, TokenRewriteStream pTokenRewriteStream) : base(pTree, pJSOMType, pTokenRewriteStream) { if (pTree.Type != JavaTreeParser.CLASS) { throw new ArgumentException( CommonErrorMessages.getInvalidArgumentValueMessage( "pTree.Type == " + pTree.Type, "pTree")); } int childOffset = 2; AST2JSOMTree child = (AST2JSOMTree)pTree.GetChild(childOffset); if (child.Type == JavaTreeParser.GENERIC_TYPE_PARAM_LIST) { mGenericTypeParamTree = child; childOffset++; child = (AST2JSOMTree)pTree.GetChild(childOffset); } if (child.Type == JavaTreeParser.EXTENDS_CLAUSE) { mExtendsClauseTree = child; childOffset++; child = (AST2JSOMTree)pTree.GetChild(childOffset); } if (child.Type == JavaTreeParser.IMPLEMENTS_CLAUSE) { mImplementsClauseTree = child; childOffset++; child = (AST2JSOMTree)pTree.GetChild(childOffset); } mScopeTree = child; }
/** * Constructor. * <p> * A new object assumes that all children of the stated tree node represent * statement block elements. This constructor calls the method * {@link #setChildTreeNodeValidator(TreeNodeValidator)} automatically with * the passed validator as parameter. * * @param pTree The root node of the statement block elements. * @param pTreeNodeValidator The validator the method * {@link #setChildTreeNodeValidator(TreeNodeValidator)} * should be called with. * @param pJSOMType If a class : this class the JSOM type of the * extending class should be passed for this argument * which will be passed forward to the implementation of * the type <code>JSOM</code>. Otherwise this argument * should be <code>null</code> - in this case the constant * <code>JSOM.JSOMType.XTRA</code> will be passed to the * <code>JSOM</code> super type. * @param pTokenRewriteStream The token stream the token of the stated * tree node belongs to. */ public AST2StatementBlockElementContainerImpl( AST2JSOMTree pTree, TreeNodeValidator pTreeNodeValidator, JSOMType pJSOMType, TokenRewriteStream pTokenRewriteStream) : this(pTree, pJSOMType, pTokenRewriteStream) { setChildTreeNodeValidator(pTreeNodeValidator); }
/** * Constructor. * <p> * A new object assumes that all children of the stated tree node represent * statement block elements. If this is not the case for a certain tree node * an appropriate filter must be added to this via * {@link #setChildTreeNodeValidator(TreeNodeValidator)} or the constructor. * Alternatively the constructor * {@link #AST2StatementBlockElementContainerImpl(AST2JSOMTree, TreeNodeValidator, com.habelitz.jsobjectizer.jsom.JSOM.JSOMType, TokenRewriteStream)} * could be used, of course. * * @see #AST2StatementBlockElementContainerImpl(AST2JSOMTree, TreeNodeValidator, com.habelitz.jsobjectizer.jsom.JSOM.JSOMType, TokenRewriteStream) * @see #setChildTreeNodeValidator(TreeNodeValidator) * * @param pTree The root node of the statement block elements. * @param pJSOMType If a class : this class the JSOM type of the * extending class should be passed for this argument * which will be passed forward to the super type of this * class. Otherwise this argument should be <code>null * </code> - in this case the constant * <code>JSOM.JSOMType.XTRA</code> will be passed to the * super type. * @param pTokenRewriteStream The token stream the token of the stated * tree node belongs to. */ public AST2StatementBlockElementContainerImpl( AST2JSOMTree pTree, JSOMType? pJSOMType, TokenRewriteStream pTokenRewriteStream) : base(pTree, pJSOMType != null ? pJSOMType : JSOMType.XTRA, pTokenRewriteStream) { }
/** * Constructor. * * @param pTree * The tree node representing any type top level scope, i.e. a * class top level scope, for example. Note that it's up to * derived classes to check that the given tree node is of a * valid type. * @param pJSOMType * One of the <code>JSOMType.???</code> constants defined by * the interface <code>JSOM</code>. * @param pTokenRewriteStream * The token stream the token of the stated tree node belongs to. */ protected AST2CommonTypeTopLevelScope( AST2JSOMTree pTree, JSOMType pJSOMType, TokenRewriteStream pTokenRewriteStream) : base(pTree, pJSOMType, pTokenRewriteStream) { }