Package org.eclipse.cdt.core.dom.ast

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


      @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
        if (ast == null) {
          return CANCEL_STATUS;
        }
        IASTNodeSelector nodeSelector= ast.getNodeSelector(null);
        IASTNode selectedNode = nodeSelector.findEnclosingNode(offset, 1);
        if (selectedNode instanceof IASTName) {
          IASTName selectedName = (IASTName) selectedNode;
          IBinding binding = selectedName.resolveBinding();
          CppToProtobufMapping info = delegate.createMappingFrom(binding);
          mappingReference.set(info);
View Full Code Here


        body += "#error the file: " + curResource.getName() + " is not found in the indexer though it exists on the file system.\n";
        body += "#error this is probably due to a bad eclipse configuration : ino and pde are not marked as c++ file.\n";
        body += "#error please check wether *.ino and *.pde are marked as C++ source code in windows->preferences->C/C++->file types.\n";
    } else {
        IASTTranslationUnit asttu = tu.getAST(index, ITranslationUnit.AST_SKIP_FUNCTION_BODIES | ITranslationUnit.AST_SKIP_ALL_HEADERS);
        IASTNode astNodes[] = asttu.getChildren();
        for (IASTNode astNode : astNodes) {
      if (astNode instanceof CPPASTFunctionDefinition) {
          String addString = astNode.getRawSignature();
          addString = addString.replaceAll("\r\n", "\n");
          addString = addString.replaceAll("\r", "\n");
View Full Code Here

        }
      }
    } else {
      for (final ASTModification parentModification : modificationHelper.modificationsForNode(newExp)) {
        if (parentModification.getKind() == ModificationKind.APPEND_CHILD) {
          final IASTNode newNode = parentModification.getNewNode();
          if (newNode instanceof IASTInitializer) {
            return (IASTInitializer) newNode;
          }
        }
      }
View Full Code Here

    final ArrayList<T> modifiedChildren = new ArrayList<T>(Arrays.asList(unmodifiedChildren));

    for (final ASTModification parentModification : modificationsForNode(parent)) {
      switch (parentModification.getKind()) {
      case APPEND_CHILD:
        IASTNode newNode = parentModification.getNewNode();
        final T appendedTNode = cast(newNode, clazz);
        if (appendedTNode != null) {
          modifiedChildren.add(appendedTNode);
        } else if (newNode instanceof ContainerNode) {
          final ContainerNode nodeContainer = (ContainerNode) newNode;
View Full Code Here

        }
      }
    } else {
      for (final ASTModification parentModification : modificationsForNode(decl)) {
        if (parentModification.getKind() == ModificationKind.APPEND_CHILD) {
          final IASTNode newNode = parentModification.getNewNode();
          if (newNode instanceof IASTInitializer) {
            return (IASTInitializer) newNode;
          }
        }
      }
View Full Code Here

    }
    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

    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

          }
        } 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

      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

    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

TOP

Related Classes of org.eclipse.cdt.core.dom.ast.IASTNode

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.