Package dtool.ast.definitions

Examples of dtool.ast.definitions.DefUnit$ProtoDefSymbol


    return ReferenceResolver.findModuleUnchecked(moduleResolver, getModuleFullyQualifiedName());
  }
 
  @Override
  public Ddoc resolveDDoc() {
    DefUnit resolvedModule = resolveDefUnit();
    if(resolvedModule != null) {
      return resolveDefUnit().getDDoc();
    }
    return null;
  }
View Full Code Here


    return null;
  }
 
  @Override
  public void resolveSearchInMembersScope(CommonDefUnitSearch search) {
    DefUnit resolvedModule = resolveDefUnit();
    if(resolvedModule != null) {
      resolvedModule.resolveSearchInMembersScope(search);
    }
  }
View Full Code Here

      return new FindDefinitionResult(FIND_DEF_ReferenceResolveFailed + ref.toStringAsCode());
    }
   
    List<FindDefinitionResultEntry> results = new ArrayList<>();
    for (INamedElement namedElement : defElements) {
      final DefUnit defUnit = namedElement.resolveDefUnit();
     
      Path compilationUnitPath = null;
      SourceRange sourceRange = null;
     
      if(defUnit != null) { // This can happen with intrinsic elements
       
        compilationUnitPath = defUnit.getModuleNode().compilationUnitPath;
        sourceRange = defUnit.defname.getSourceRangeOrNull();
        if(defUnit.getArcheType() == EArcheType.Module && sourceRange == null) {
          sourceRange = new SourceRange(0, 0);
        }
      }
     
      results.add(new FindDefinitionResultEntry(
View Full Code Here

 
  protected void test_resolveTypeForValueContext(String source, String expectedFullName, boolean isError) {
    int offset = source.indexOf("XXX");
    offset = offset == -1 ? source.indexOf("xxx") : offset;
    assertTrue(offset != -1);
    DefUnit defElem = parseSourceAndPickNode(source, offset, DefUnit.class);
   
    INamedElement resolvedType = defElem.resolveTypeForValueContext(new NullModuleResolver());
    if(expectedFullName == null) {
      assertTrue(resolvedType == null);
      assertTrue(isError);
      return;
    }
View Full Code Here

    ISourceModule srcModule = getModule(searchProj, "srcB", "", "search2");
    Path filePath = DLTKUtils.getFilePath(srcModule.getResource().getLocation());
    ParsedModule parseModule = DToolClient.getDefaultModuleCache().getParsedModuleOrNull(filePath);
    Module module = parseModule.module;
   
    DefUnit defUnit = MiscNodeUtils.getDefUniFromScope(module.getChildren(), "xxxTestUnboundRef");
    IModuleResolver mr = DToolClient.getDefault().getResolvedModule(filePath).getModuleResolver();
    DefinitionVariable defVar = assertInstance(defUnit, DefinitionVariable.class);
    assertTrue(defVar.type.findTargetDefElement(mr) == null);
  }
View Full Code Here

     
      @Override
      protected void visitNode(ASTNode node, ISourceModule sourceModule) {
        if(node instanceof DefUnit) {
          // All DefUnits must be searchable
          DefUnit defUnit = (DefUnit) node;
          try {
            IMember element = DeeModelEngine.findCorrespondingModelElement(defUnit, sourceModule);
            if(element != null) {
              testSearchForElement(element);
            }
View Full Code Here

          if(targetDefElements == null || targetDefElements.isEmpty()) {
            return;
          }
         
          for (INamedElement defElement : targetDefElements) {
            DefUnit defUnit = defElement.resolveDefUnit();
            if(defUnit == null) {
              continue;
            }
            Module moduleNode = defUnit.getModuleNode();
            if(moduleNode == null) {
              continue; // consider this case more
            }
             
            ISourceModule defUnitSrcModule = findSourceModule(moduleNode, searchProj);
           
            ArrayList<Integer> nodeTreePath = DeeSearchEngineTestUtils.getNodeTreePath(defUnit);
            Pair<ISourceModule, ?> key = Pair.create(defUnitSrcModule, nodeTreePath);
           
            if(defUnitToReferencesMap.get(key) == null) {
              defUnitToReferencesMap.put(key, new HashSet<Reference>());
            }
           
            defUnitToReferencesMap.get(key).add(reference);
          }
        }
      }
    }.visitElementsAndNodes(getSrcFolder(searchProj, "srcA"), 10);
   
   
   
    for (Pair<ISourceModule, ?> key : defUnitToReferencesMap.keySet()) {
      ISourceModule sourceModule = key.getFirst();
      ArrayList<Integer> nodeTreePath = blindCast(key.getSecond());
     
      Path filePath = DLTKUtils.getFilePath(sourceModule);
     
      ParsedModule parseModule = DToolClient.getDefaultModuleCache().getParsedModuleOrNull(filePath);
      Module deeModule = parseModule == null ? null : parseModule.module;
      ASTNode node = DeeSearchEngineTestUtils.getNodeFromPath(deeModule, nodeTreePath);
     
      final DefUnit defUnit = (DefUnit) node;
      final HashSet<Reference> expectedReferences = defUnitToReferencesMap.get(key);
     
      IMember element = DeeModelEngine.findCorrespondingModelElement(defUnit, sourceModule);
//      if(element == null) {
//        // TODO: consider this case
View Full Code Here

    return ElementIconsStyle.fromString(iconStyleStr, ElementIconsStyle.DDT);
  }
 
  public static ImageDescriptor getNodeImageDescriptor(ASTNode node, ElementIconsStyle iconStyle) {
    if(node instanceof DefUnit) {
      DefUnit defUnit = (DefUnit) node;
      return getDefUnitImageDescriptor(defUnit, iconStyle);
    }
   
    return getNodeImageDescriptorKey(node).getDescriptor();
  }
View Full Code Here

      break;
    }
   
    // We should NOT try to resolve namedElement to its true defUnit because that can be a costly operation,
    // and want to calculate a label quickly, without the need for parsing or other semantic operations
    DefUnit defUnit = tryCast(namedElement, DefUnit.class);
    if(defUnit == null) {
      return namedElement.getName();
    }
   
    ASTCodePrinter cp = new ASTCodePrinter();
   
    switch (defUnit.getNodeType()) {
    case DEFINITION_VARIABLE: {
      DefinitionVariable elem = (DefinitionVariable) defUnit;
      return elem.getName() + getTypeSegment(elem.type) + getDefUnitContainerSuffix(defUnit);
    }
    case DEFINITION_VAR_FRAGMENT: {
      DefVarFragment elem = (DefVarFragment) defUnit;
      Reference type = elem.getDeclaredType();
      return elem.getName() + getTypeSegment(type) + getDefUnitContainerSuffix(defUnit);
    }
   
    case FUNCTION_PARAMETER: {
      FunctionParameter elem = (FunctionParameter) defUnit;
      return elem.getName() + getTypeSegment(elem.type) + getDefUnitContainerSuffix(defUnit);
    }
   
    case DEFINITION_FUNCTION: {
      DefinitionFunction elem = (DefinitionFunction) defUnit;
      cp.append(elem.getName());
      cp.appendList("(", elem.tplParams, ",", ") ");
      cp.append(elem.toStringParametersForSignature());
      cp.append(getTypeSegment(elem.retType));
      cp.append(getDefUnitContainerSuffix(defUnit));
      return cp.toString();
    }
   
    case DEFINITION_ALIAS_FRAGMENT: {
      DefinitionAliasFragment elem = (DefinitionAliasFragment) defUnit;
      return elem.getName() + getAliasSegment(elem.target) + getDefUnitContainerSuffix(defUnit);
    }
    case DEFINITION_ALIAS_VAR_DECL: {
      DefinitionAliasVarDecl elem = (DefinitionAliasVarDecl) defUnit;
      return elem.getName() + getAliasSegment(elem.target) + getDefUnitContainerSuffix(defUnit);
    }
    case DEFINITION_ALIAS_FUNCTION_DECL: {
      DefinitionAliasFunctionDecl elem = (DefinitionAliasFunctionDecl) defUnit;
      // TODO: print a proper alias segment
      return elem.getName() + getAliasSegment(elem.target) + getDefUnitContainerSuffix(defUnit);
    }
   
   
    default: break;
    }
   
    if(defUnit instanceof DefinitionAggregate) {
      return defUnit.getName() + getDefUnitContainerSuffix(defUnit);
    }
   
    return defUnit.getName() + getDefUnitContainerSuffix(defUnit);
  }
View Full Code Here

   
    // TODO: adapt test to more than one defUnit returned?
    Iterator<INamedElement> iterator = resolveResult.getResolvedDefUnits().iterator();
    INamedElement defElement = iterator.hasNext() ? iterator.next() : null;
    if(defElement instanceof DefUnit) {
      DefUnit defUnit = (DefUnit) defElement;
      SelectionEngineSourceTests.testDeeSelectionEngine(sourceModule, mde.offset, defUnit);
    }
  }
View Full Code Here

TOP

Related Classes of dtool.ast.definitions.DefUnit$ProtoDefSymbol

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.