Examples of IASTNode


Examples of org.eclipse.cdt.core.dom.ast.IASTNode

    }
    return false;
  }

  private boolean nodeIsChildOfModification(final ASTModification modification, final IASTNode actualNode) {
    IASTNode nodeToTest = actualNode;
    while (nodeToTest != null) {
      if (modification.getNewNode() == nodeToTest) {
        return true;
      } else {
        nodeToTest = nodeToTest.getParent();
      }
    }
    return false;
  }
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

    final List<ASTModification> modifications = getModifications(anchorNode, ModificationKind.INSERT_BEFORE);
    if (modifications.isEmpty()) {
      return;
    }
    final ChangeGeneratorWriterVisitor writer = new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
    IASTNode newNode = null;
    for (final ASTModification modification : modifications) {
      final boolean first = newNode == null;
      newNode = modification.getNewNode();
      if (first) {
        final IASTNode prevNode = getPreviousSiblingOrPreprocessorNode(anchorNode);
        if (prevNode != null) {
          if (ASTWriter.requireBlankLineInBetween(prevNode, newNode)) {
            writer.newLine();
          }
        } else if (anchorNode.getParent() instanceof ICPPASTNamespaceDefinition) {
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

          }
        } else if (node.getPropertyInParent() == ICPPASTFunctionDefinition.MEMBER_INITIALIZER) {
          offset = skipToPrecedingDelimiter(source, ':', offset);
        }
      }
      final IASTNode prevNode = getPreviousSiblingOrPreprocessorNode(node);
      final IASTNode nextNode = getNextSiblingOrPreprocessorNode(node);
      if ((prevNode != null) && (nextNode != null)) {
        if (ASTWriter.requireBlankLineInBetween(prevNode, nextNode)) {
          writer.newLine();
        }
      } else if (node.getParent() instanceof ICPPASTNamespaceDefinition) {
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

      return;
    }
    final ChangeGeneratorWriterVisitor writer = new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
    final ReplaceEdit anchor = getAppendAnchor(node);
    Assert.isNotNull(anchor);
    IASTNode precedingNode = getLastNodeBeforeAppendPoint(node);
    for (final ASTModification modification : modifications) {
      final IASTNode newNode = modification.getNewNode();
      if (precedingNode != null) {
        if (ASTWriter.requireBlankLineInBetween(precedingNode, newNode)) {
          writer.newLine();
        }
      } else if (node instanceof ICPPASTNamespaceDefinition) {
        writer.newLine();
      }
      precedingNode = null;
      newNode.accept(writer);
    }
    if (node instanceof ICPPASTNamespaceDefinition) {
      writer.newLine();
    }
    addToRootEdit(node);
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

    final List<ASTModification> modifications = getModifications(node, ModificationKind.APPEND_CHILD);
    if (modifications.isEmpty()) {
      return;
    }

    IASTNode prevNode = null;
    final IASTDeclaration[] declarations = node.getDeclarations();
    if (declarations.length != 0) {
      prevNode = declarations[declarations.length - 1];
    } else {
      final IASTPreprocessorStatement[] preprocessorStatements = node.getAllPreprocessorStatements();
      if (preprocessorStatements.length != 0) {
        prevNode = preprocessorStatements[preprocessorStatements.length - 1];
      }
    }
    final int offset = prevNode != null ? getEndOffsetIncludingComments(prevNode) : 0;
    final String source = node.getRawSignature();
    final int endOffset = skipTrailingBlankLines(source, offset);

    addToRootEdit(node);
    final ChangeGeneratorWriterVisitor writer = new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
    IASTNode newNode = null;
    for (final ASTModification modification : modifications) {
      final boolean first = newNode == null;
      newNode = modification.getNewNode();
      if (first) {
        if (prevNode != null) {
          writer.newLine();
          if (ASTWriter.requireBlankLineInBetween(prevNode, newNode)) {
            writer.newLine();
          }
        }
      }
      newNode.accept(writer);
      // TODO(sprigogin): Temporary workaround for invalid handling of line breaks in
      // StatementWriter
      if (!writer.toString().endsWith("\n")) {
        writer.newLine();
      }

    }
    if (prevNode != null) {
      final IASTNode nextNode = getNextSiblingOrPreprocessorNode(prevNode);
      if ((nextNode != null) && ASTWriter.requireBlankLineInBetween(newNode, nextNode)) {
        writer.newLine();
      }
    }
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

      children = ((IASTCompositeTypeSpecifier) node).getDeclarations(true);
    } else {
      children = node.getChildren();
    }
    for (int i = children.length; --i >= 0;) {
      final IASTNode child = getReplacementNode(children[i]);
      if (child != null) {
        return child;
      }
    }
    return null;
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

    }
    return node;
  }

  private IASTNode getPreviousSiblingNode(final IASTNode node) {
    final IASTNode parent = node.getParent();
    IASTNode[] siblings;
    if (parent instanceof ICPPASTNamespaceDefinition) {
      siblings = ((ICPPASTNamespaceDefinition) parent).getDeclarations(true);
    } else if (parent instanceof IASTCompositeTypeSpecifier) {
      siblings = ((IASTCompositeTypeSpecifier) parent).getDeclarations(true);
    } else {
      siblings = parent.getChildren();
    }
    boolean beforeNode = false;
    for (int i = siblings.length; --i >= 0;) {
      final IASTNode sibling = siblings[i];
      if (sibling == node) {
        beforeNode = true;
      } else if (beforeNode && (getReplacementNode(sibling) != null)) {
        return sibling;
      }
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

    final IASTPreprocessorStatement[] preprocessorStatements = ast.getAllPreprocessorStatements();
    int low = 0;
    int high = preprocessorStatements.length;
    while (low < high) {
      final int mid = (low + high) / 2;
      final IASTNode statement = preprocessorStatements[mid];
      if (statement.isPartOfTranslationUnitFile() && (endOffset(statement) > offset)) {
        high = mid;
      } else {
        low = mid + 1;
      }
    }
    final IASTNode statement = --low >= 0 ? preprocessorStatements[low] : null;

    final IASTNode originalSibling = getPreviousSiblingNode(node);
    final IASTNode sibling = originalSibling == null ? null : getReplacementNode(originalSibling);
    if ((statement == null) || !statement.isPartOfTranslationUnitFile()) {
      return sibling;
    }
    if (sibling == null) {
      final IASTNode parent = node.getParent();
      if (offset(parent) >= endOffset(statement)) {
        return null;
      }
      return statement;
    }
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

    return endOffset(originalSibling) >= endOffset(statement) ? sibling : statement;
  }

  private IASTNode getNextSiblingNode(final IASTNode node) {
    final IASTNode parent = node.getParent();
    IASTNode[] siblings;
    if (parent instanceof ICPPASTNamespaceDefinition) {
      siblings = ((ICPPASTNamespaceDefinition) parent).getDeclarations(true);
    } else if (parent instanceof IASTCompositeTypeSpecifier) {
      siblings = ((IASTCompositeTypeSpecifier) parent).getDeclarations(true);
    } else {
      siblings = parent.getChildren();
    }
    boolean beforeNode = false;
    for (final IASTNode sibling : siblings) {
      if (sibling == node) {
        beforeNode = true;
View Full Code Here

Examples of org.eclipse.cdt.core.dom.ast.IASTNode

    final IASTPreprocessorStatement[] preprocessorStatements = ast.getAllPreprocessorStatements();
    int low = 0;
    int high = preprocessorStatements.length;
    while (low < high) {
      final int mid = (low + high) / 2;
      final IASTNode statement = preprocessorStatements[mid];
      if (statement.isPartOfTranslationUnitFile() && (offset(statement) > endOffset)) {
        high = mid;
      } else {
        low = mid + 1;
      }
    }
    final IASTNode statement = high < preprocessorStatements.length ? preprocessorStatements[high] : null;

    final IASTNode originalSibling = getNextSiblingNode(node);
    final IASTNode sibling = originalSibling == null ? null : getReplacementNode(originalSibling);
    if ((statement == null) || !statement.isPartOfTranslationUnitFile()) {
      return sibling;
    }
    if (sibling == null) {
      final IASTNode parent = node.getParent();
      if (endOffset(parent) <= offset(statement)) {
        return null;
      }
      return statement;
    }
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.