Examples of IIndex


Examples of org.eclipse.cdt.core.index.IIndex

  }

  private void initEmptyMacros(final IASTTranslationUnit unit) {
    if (unit != null) {
      ast = unit;
      final IIndex index = ast.getIndex();
      if (index != null) {
        macroExpansion = new TreeMap<String, List<IIndexName>>();
        final IASTPreprocessorMacroDefinition[] md = ast.getMacroDefinitions();

        final TreeSet<String> paths = new TreeSet<String>();
        for (final IASTPreprocessorIncludeStatement is : ast.getIncludeDirectives()) {
          if (!is.isSystemInclude()) {
            paths.add(is.getContainingFilename());
          }
        }
        paths.add(ast.getContainingFilename());

        for (final IASTPreprocessorMacroDefinition iastPreprocessorMacroDefinition : md) {
          if (iastPreprocessorMacroDefinition.getExpansion().length() == 0) {
            try {
              final IIndexMacro[] macroBinding = index.findMacros(iastPreprocessorMacroDefinition.getName().toCharArray(), IndexFilter.ALL, null);
              if (macroBinding.length > 0) {
                final IIndexName[] refs = index.findReferences(macroBinding[0]);
                for (final IIndexName iIndexName : refs) {
                  final String filename = iIndexName.getFileLocation().getFileName();
                  List<IIndexName> fileList = macroExpansion.get(filename);
                  if (paths.contains(filename)) {
                    if (fileList == null) {
View Full Code Here

Examples of org.eclipse.cdt.core.index.IIndex

          }
        }
        scope = cprojects.toArray(new ICProject[cprojects.size()]);
      }

      IIndex index = CCorePlugin.getIndexManager().getIndex(
          scope, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
      index.acquireReadLock();
      try{
        int offset = getOffset(commandLine);
        int length = commandLine.getIntValue(Options.LENGTH_OPTION);
        IName[] names = findElement(src, scope, context, offset, length);
        for (IName iname : names){
          IASTFileLocation loc = iname.getFileLocation();
          String filename = loc.getFileName().replace('\\', '/');
          results.add(
              Position.fromOffset(filename, null, loc.getNodeOffset(), 0));
        }
      }finally{
        index.releaseReadLock();
      }
    }

    return results;
  }
View Full Code Here

Examples of org.eclipse.cdt.core.index.IIndex

      ICProject[] scope, int context,
      int offset, int length)
    throws Exception
  {
    LinkedHashSet<IName> names = new LinkedHashSet<IName>();
    IIndex index = CCorePlugin.getIndexManager().getIndex(
        scope,
        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) {
              ICElement element = IndexUI.getCElementForMacro(
                  src.getCProject(), index, macro);
              if (element != null) {
                ISourceReference ref = (ISourceReference)element;
                FileLocation location = new FileLocation(
                    ref.getTranslationUnit().getPath().toPortableString(),
                    ref.getSourceRange().getStartPos(),
                    ref.getSourceRange().getLength(),
                    ref.getSourceRange().getStartLine());
                names.add(new Name(location));
              }
            }
          }
        }
      }
    }finally{
      index.releaseReadLock();
    }

    return names.toArray(new IName[names.size()]);
  }
View Full Code Here

Examples of org.eclipse.cdt.core.index.IIndex

  }

  private List<IProblem> getProblems(ITranslationUnit src)
    throws Exception
  {
    IIndex index = null;
    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){
        index.releaseReadLock();
      }
    }
  }
View Full Code Here

Examples of org.eclipse.cdt.core.index.IIndex

      if (elements != null && elements.length > 0) {
        ICElement element = elements[0];
        Set<ICElement> seen = new HashSet<ICElement>();
        ICProject project = element.getCProject();
        ICProject[] scope = getScope(SCOPE_PROJECT, project);
        IIndex index = CCorePlugin.getIndexManager().getIndex(
            scope, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
        index.acquireReadLock();
        try{
          IIndexName name = IndexUI.elementToName(index, element);
          result = formatElement(index, new Call(name, element), seen, callees);
        }finally{
          index.releaseReadLock();
        }
      }
    }finally{
      manager.removeWorkingCopy(input);
      manager.disconnect(input);
View Full Code Here

Examples of org.eclipse.cdt.core.index.IIndex

  header += "//This file has been generated on ";
  header += new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
  header += "\n";
  header += "\n";
  ICProject tt = CoreModel.getDefault().create(iProject);
  IIndex index = CCorePlugin.getIndexManager().getIndex(tt);

  IResource allResources[] = iProject.members(0);// .getFolder("").members(0);
  int numInoFiles = 0;
  for (IResource curResource : allResources) {
      String extension = curResource.getFileExtension();
View Full Code Here

Examples of org.eclipse.help.IIndex

          }
          else {
            IndexContribution contribution = new IndexContribution();
            contribution.setId(contrib[j].getId());
            contribution.setLocale(contrib[j].getLocale());
            IIndex index = contrib[j].getIndex();
            contribution.setIndex(index instanceof Index ? (Index)index : (Index)UAElementFactory.newElement(index));
            contributions.add(contribution);
          }
        }
      }
View Full Code Here

Examples of org.eclipse.m2e.core.internal.index.IIndex

      Assert.isNotNull(groupId, Messages.MavenPluginUtils_GroupId_Cant_Be_Null);
      Assert.isNotNull(artifactId, Messages.MavenPluginUtils_ArtifactId_Cant_Be_Null);
      String version = referenceVersion;
      String partialKey = artifactId + " : " + groupId; //$NON-NLS-1$
      try {
        IIndex index = MavenPlugin.getIndexManager().getAllIndexes();
        SearchExpression a = new SourcedSearchExpression(artifactId);

        //For some reason, an exact search using :
        //ISearchEngine searchEngine  = M2EUIPluginActivator.getDefault().getSearchEngine(null)
        //searchEngine.findVersions(groupId, artifactId, searchExpression, packaging)
        //
        //doesn't yield the expected results (the latest versions are not returned), so we rely on a fuzzier search
        //and refine the results.
        Map<String, IndexedArtifact> values = index.search(a, IIndex.SEARCH_PLUGIN);
        if(!values.isEmpty()) {
          SortedSet<ComparableVersion> versions = new TreeSet<ComparableVersion>();
          ComparableVersion referenceComparableVersion = referenceVersion == null ? null : new ComparableVersion(
              referenceVersion);
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.