Examples of IASTTranslationUnit


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

    }
    return false;
  }

  protected boolean checkisMacroExpansionNode(IASTNode node, final boolean write) {
    final IASTTranslationUnit unit = node.getTranslationUnit();
    if ((ast == null) || !ast.equals(unit)) {
      initEmptyMacros(unit);
    }
    final IASTNodeLocation[] locs = getNodeLocations(node);
    if ((locs != null) && (locs.length == 1)) {
View Full Code Here

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

        IIndexManager.ADD_DEPENDENCIES |
        IIndexManager.ADD_DEPENDENT |
        IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
    index.acquireReadLock();
    try{
      IASTTranslationUnit ast = src.getAST(index,
          ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT |
          ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
      IASTNodeSelector selector = ast.getNodeSelector(null);
      IASTName name = selector.findEnclosingName(offset, length);
      if (name != null){
        IBinding binding = name.resolveBinding();

        int flags = IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES;
        if (context == FIND_CONTEXT){
          if (!name.isDeclaration() && !name.isDefinition()){
            flags |= IIndex.FIND_DEFINITIONS;
          } else {
            // if on the declaration, search for the definition and vice verca
            flags |= (name.isDefinition() ?
                IIndex.FIND_DECLARATIONS : IIndex.FIND_DEFINITIONS);
          }
        } else if (context == CSearchQuery.FIND_ALL_OCCURRENCES){
          flags |= IIndex.FIND_ALL_OCCURRENCES;
        } else if (context == CSearchQuery.FIND_REFERENCES){
          flags |= IIndex.FIND_REFERENCES;
        } else if (context == CSearchQuery.FIND_DECLARATIONS_DEFINITIONS) {
          flags |= IIndex.FIND_DECLARATIONS_DEFINITIONS;
        } else if (context == CSearchQuery.FIND_DECLARATIONS) {
          flags |= IIndex.FIND_DECLARATIONS;
        } else if (context == CSearchQuery.FIND_DEFINITIONS) {
          flags |= IIndex.FIND_DEFINITIONS;
        }

        CollectionUtils.addAll(names, index.findNames(binding, flags));

        // kind of hacky.  if we issued a context search and found no
        // definitions, we'll try a declarations search (useful for system
        // library references).
        if (names.size() == 0 &&
            context == FIND_CONTEXT &&
            (flags & IIndex.FIND_DEFINITIONS) != 0)
        {
          CollectionUtils.addAll(names, index.findNames(
                binding,
                IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES |
                IIndex.FIND_DECLARATIONS));
        }

        if (names.size() == 0){
          // alternate search that finds some things that index.findNames may
          // not.
          if ((flags & IIndex.FIND_DECLARATIONS) != 0){
            CollectionUtils.addAll(names, ast.getDeclarations(binding));
          }
          if ((flags & IIndex.FIND_DEFINITIONS) != 0){
            CollectionUtils.addAll(names, ast.getDefinitions(binding));
          }
          if ((flags & IIndex.FIND_REFERENCES) != 0){
            CollectionUtils.addAll(names, ast.getReferences(binding));
          }

          if ((flags & IIndex.FIND_DECLARATIONS) != 0 ||
              (flags & IIndex.FIND_DEFINITIONS) != 0)
          {
            // also try to find macros (now required for stdlib EXIT_SUCCESS)
            // gleaned from navigationFallBack in
            // org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationJob
            IndexFilter filter = IndexFilter.getDeclaredBindingFilter(
                ast.getLinkage().getLinkageID(), false);
            IIndexMacro[] macros = index.findMacros(
                binding.getName().toCharArray(),
                filter,
                new NullProgressMonitor());
            for (IIndexMacro macro : macros) {
View Full Code Here

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

    try {
      ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
      index = CCorePlugin.getIndexManager().getIndex(projects);
      index.acquireReadLock();

      IASTTranslationUnit ast = src.getAST(index, AST_STYLE);
      ArrayList<IProblem> problems = new ArrayList<IProblem>();
      CollectionUtils.addAll(problems, ast.getPreprocessorProblems());
      CollectionUtils.addAll(problems, CPPVisitor.getProblems(ast));

      return problems;
    } finally {
      if (index != null){
View Full Code Here

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

        body += "\n";
        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

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

    classifyModifications();
    rootNode.accept(pathProvider);
    if (rootEdit == null) {
      return;
    }
    final IASTTranslationUnit ast = rootNode.getTranslationUnit();
    final String source = ast.getRawSignature();
    final ITranslationUnit tu = ast.getOriginatingTranslationUnit();
    formatChangedCode(source, tu);
    final TextFileChange subchange = ASTRewriteAnalyzer.createCTextFileChange((IFile) tu.getResource());
    subchange.setEdit(rootEdit);
    change.add(subchange);
  }
View Full Code Here

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

    return null;
  }

  private IASTNode getPreviousSiblingOrPreprocessorNode(final IASTNode node) {
    final int offset = offset(node);
    final IASTTranslationUnit ast = node.getTranslationUnit();
    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];
View Full Code Here

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

    return null;
  }

  private IASTNode getNextSiblingOrPreprocessorNode(final IASTNode node) {
    final int endOffset = endOffset(node);
    final IASTTranslationUnit ast = node.getTranslationUnit();
    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];
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.