Package org.eclipse.jdt.core.dom

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


  private String generateMethodDeclaration(final IDocument document, final Document recoveredDocument,
      final ASTNode node, final ASTRewrite rewrite, final CodeGenerationSettings settings,
      final MethodDeclaration stub) throws BadLocationException
  {
    ChildListPropertyDescriptor descriptor = getPropDescriptor(node);
    ListRewrite rewriter = rewrite.getListRewrite(node, descriptor);
    rewriter.insertFirst(stub, null);

    ITrackedNodePosition position = rewrite.track(stub);
View Full Code Here


    return settings;
  }

  private ChildListPropertyDescriptor getPropDescriptor(final ASTNode node)
  {
    ChildListPropertyDescriptor descriptor = TypeDeclaration.BODY_DECLARATIONS_PROPERTY;

    if (node instanceof AnonymousClassDeclaration)
    {
      descriptor = AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY;
    }
View Full Code Here

    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(compilationUnit);
   
    ASTRewrite rewrite = ASTRewrite.create(declaration.getAST());
   
    ChildListPropertyDescriptor modifiersProperty = declaration.getModifiersProperty();
   
    ListRewrite listRewrite = rewrite.getListRewrite(declaration, modifiersProperty);
    listRewrite.insertFirst(normalAnnotation, null);

    maintainValuesProperty(normalAnnotation, memberValues, ast, rewrite);
View Full Code Here

    if (!includingModifiers) {
      return new OffsetAndLength(methodName.getStartPosition(), methodName.getLength());
    } else {
      // including modifiers
      int endOfMethodName = methodName.getStartPosition() + methodName.getLength();
      ChildListPropertyDescriptor modifiersProperty = declaration.getModifiersProperty();
      List<ASTNode> methodModifiers =
        Generics.asT(declaration.getStructuralProperty(modifiersProperty));
      if (methodModifiers.size() > 0) {
        int startOfModifiers = methodModifiers.get(0).getStartPosition();
        return new OffsetAndLength(startOfModifiers, endOfMethodName - startOfModifiers);
View Full Code Here

    if (!includingModifiers) {
      return new OffsetAndLength(typeName.getStartPosition(), typeName.getLength());
    } else {
      // including modifiers
      int endOfMethodName = typeName.getStartPosition() + typeName.getLength();
      ChildListPropertyDescriptor modifiersProperty = declaration.getModifiersProperty();
      List<ASTNode> methodModifiers =
        Generics.asT(declaration.getStructuralProperty(modifiersProperty));
      if (methodModifiers.size() > 0) {
        int startOfModifiers = methodModifiers.get(0).getStartPosition();
        return new OffsetAndLength(startOfModifiers, endOfMethodName - startOfModifiers);
View Full Code Here

    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(compilationUnit);
 
    ASTRewrite rewrite = ASTRewrite.create(declaration.getAST());

    ChildListPropertyDescriptor modifiersProperty = declaration.getModifiersProperty();

    ListRewrite listRewrite = rewrite.getListRewrite(declaration, modifiersProperty);
    listRewrite.insertFirst(annotation, null);
   
    TextEdit importEdits = null;
View Full Code Here

        edit.addChild(imports.rewriteImports(null));

        AST ast = cu.getAST();
        ASTRewrite astRewrite = ASTRewrite.create(ast);
        ASTNode node = cu.findDeclaringNode(typeBinding);
        ChildListPropertyDescriptor property = ((AbstractTypeDeclaration)node)
          .getBodyDeclarationsProperty();
        ListRewrite memberRewriter = astRewrite.getListRewrite(node, property);
        HashSet<String> added = new HashSet<String>();
        for (IMethodBinding binding : methodBindings){
          String name = binding.getName();
View Full Code Here

   * @see #createBefore(IJavaElement)
   */
  protected void insertASTNode(ASTRewrite rewriter, ASTNode parent, ASTNode child) throws JavaModelException {
    StructuralPropertyDescriptor propertyDescriptor = getChildPropertyDescriptor(parent);
    if (propertyDescriptor instanceof ChildListPropertyDescriptor) {
      ChildListPropertyDescriptor childListPropertyDescriptor = (ChildListPropertyDescriptor) propertyDescriptor;
       ListRewrite rewrite = rewriter.getListRewrite(parent, childListPropertyDescriptor);
       switch (this.insertionPolicy) {
         case INSERT_BEFORE:
           ASTNode element = ((JavaElement) this.anchorElement).findNode(this.cuAST);
           if (childListPropertyDescriptor.getElementType().isAssignableFrom(element.getClass()))
             rewrite.insertBefore(child, element, null);
           else
             // case of an empty import list: the anchor element is the top level type and cannot be used in insertBefore as it is not the same type
             rewrite.insertLast(child, null);
           break;
         case INSERT_AFTER:
           element = ((JavaElement) this.anchorElement).findNode(this.cuAST);
           if (childListPropertyDescriptor.getElementType().isAssignableFrom(element.getClass()))
             rewrite.insertAfter(child, element, null);
           else
             // case of an empty import list: the anchor element is the top level type and cannot be used in insertAfter as it is not the same type
             rewrite.insertLast(child, null);
           break;
View Full Code Here

   * @see #createBefore(IJavaElement)
   */
  protected void insertASTNode(ASTRewrite rewriter, ASTNode parent, ASTNode child) throws JavaModelException {
    StructuralPropertyDescriptor propertyDescriptor = getChildPropertyDescriptor(parent);
    if (propertyDescriptor instanceof ChildListPropertyDescriptor) {
      ChildListPropertyDescriptor childListPropertyDescriptor = (ChildListPropertyDescriptor) propertyDescriptor;
       ListRewrite rewrite = rewriter.getListRewrite(parent, childListPropertyDescriptor);
       switch (this.insertionPolicy) {
         case INSERT_BEFORE:
           ASTNode element = ((JavaElement) this.anchorElement).findNode(this.cuAST);
           if (childListPropertyDescriptor.getElementType().isAssignableFrom(element.getClass()))
             rewrite.insertBefore(child, element, null);
           else
             // case of an empty import list: the anchor element is the top level type and cannot be used in insertBefore as it is not the same type
             rewrite.insertLast(child, null);
           break;
         case INSERT_AFTER:
           element = ((JavaElement) this.anchorElement).findNode(this.cuAST);
           if (childListPropertyDescriptor.getElementType().isAssignableFrom(element.getClass()))
             rewrite.insertAfter(child, element, null);
           else
             // case of an empty import list: the anchor element is the top level type and cannot be used in insertAfter as it is not the same type
             rewrite.insertLast(child, null);
           break;
View Full Code Here

    // literal.setLiteralValue(qualifier);
    annotation.setValue(literal);
    ITrackedNodePosition position = astRewrite.track(literal);
    addLinkedPosition(new StringLiteralTrackedPosition(position), true, "Qualifier");

    ChildListPropertyDescriptor property;

    if (decl instanceof FieldDeclaration) {
      property = FieldDeclaration.MODIFIERS2_PROPERTY;
    }
    else {
View Full Code Here

TOP

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

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.