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

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


        }
        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);
          return OK_STATUS;
        }
        return CANCEL_STATUS;
View Full Code Here


   * @param binding describes the name of a C++ element.
   * @return a {@code ProtobufElementLookupInfo}, or {@code null} if the given binding does not correspond to a C++
   * element that can be traced back to a protocol buffer element.
   */
  public CppToProtobufMapping createMappingFrom(IBinding binding) {
    IBinding bindingToUse = binding;
    if (binding instanceof ProblemBinding) {
      ProblemBinding problemBinding = (ProblemBinding) binding;
      IBinding[] candidates = problemBinding.getCandidateBindings();
      if (candidates != null && candidates.length == 1) {
        bindingToUse = candidates[0];
      }
    }
    IBindingMappingStrategy<?> strategy = strategies.get(bindingToUse.getClass());
    if (strategy != null) {
      return strategy.createMappingFrom(bindingToUse);
    }
    return null;
  }
View Full Code Here

class TypeDefMappingStrategy implements IBindingMappingStrategy<CPPTypedef> {
  @Inject private IBindings bindings;

  @Override public CppToProtobufMapping createMappingFrom(IBinding binding) {
    CPPTypedef typeDef = typeOfSupportedBinding().cast(binding);
    IBinding owner = binding.getOwner();
    if (!bindings.isMessage(owner)) {
      return null;
    }
    String typeName = typeNameOf(typeDef);
    String typeNameSuffix = owner.getName() + "_" + typeDef.getName();
    if (typeName == null || !typeName.endsWith(typeNameSuffix)) {
      return null;
    }
    return new CppToProtobufMapping(bindings.qualifiedNameOf(typeDef), MESSAGE);
  }
View Full Code Here

          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);
View Full Code Here

      return false;
    }
    if (qname.getNames()[i - 1] instanceof ICPPASTTemplateId) {
      return true;
    }
    final IBinding binding = qname.getNames()[i - 1].resolveBinding();
    if (binding instanceof CPPTemplateTypeParameter) {
      return true;
    }
    return isDependentName(qname, tempId, i - 1);
  }
View Full Code Here

TOP

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

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.