Package dtool.ast.references

Examples of dtool.ast.references.Reference


  public NodeResult<? extends Expression> parseIsExpression() {
    if(!tryConsume(DeeTokens.KW_IS))
      return null;
    ParseHelper parse = new ParseHelper();
   
    Reference typeRef = null;
    StaticIfExpIsDefUnit isExpDefUnit = null;
    ExpIsSpecialization specKind = null;
    Reference specTypeRef = null;
    ArrayView<TemplateParameter> tplParams = null;
   
    parsing: {
      if(parse.consumeRequired(DeeTokens.OPEN_PARENS).ruleBroken) break parsing;
     
View Full Code Here


    Expression prefixExp;
    Resolvable prefixExpResolvable = parsePrimaryExpression();
    if(prefixExpResolvable == null || prefixExpResolvable instanceof Expression) {
      prefixExp = (Expression) prefixExpResolvable;
    } else {
      Reference ref = (Reference) prefixExpResolvable;
      boolean isTypeAsExpError = !refIsAllowedInExp(ref, breakRule || lookAhead() == DeeTokens.OPEN_PARENS);
      prefixExp = createExpReference(ref, isTypeAsExpError);
    }
   
    if(prefixExp == null || shouldReturnToParseRuleTopLevel(prefixExp)) {
View Full Code Here

      if(lookAhead(1) == DeeTokens.LAMBDA) {
        return expConclude(parseSimpleLambdaLiteral_start());
      } // else fallthrough to TypeReference:
    default:
      NodeResult<Reference> typeRefResult = parseTypeReference_start(RefParseRestrictions.EXP_ONLY);
      Reference ref = typeRefResult.node;
      if(!(ref instanceof RefQualified || ref instanceof RefModuleQualified)) {
        setToEParseBroken(typeRefResult.ruleBroken);
      }
      return ref;
    }
View Full Code Here

        } else if(expReference.ref instanceof RefTemplateInstance) {
        } else {
          assertFail(); // ...otherwise refqualified would have been parsed already
        }
      }
      Reference ref = parseRefQualified(parse, qualifier);
      if(!parse.ruleBroken) {
        ref = parseTypeReference_withLeftReference(ref, RefParseRestrictions.TEMPLATE_ONLY).node;
      }
      return parsePostfixExpression(conclude(createExpReference(ref)));
    }
View Full Code Here

    ParserState savedState = saveParserState();
   
    successfulParsing: {
      ParseHelper parse = new ParseHelper(lookAheadElement());
     
      Reference type;
      ProtoDefSymbol defId;
     
      if(lookAhead() == DeeTokens.KW_AUTO) {
        type = parseAutoReference();
        defId = parseDefId(); // Parse a SimpleVariableDef even if id is missing
View Full Code Here

      effectiveType.resolveSearchInMembersScope(search);
    }
  }
 
  public INamedElement resolveEffectiveType(IModuleResolver mr) {
    Reference declaredType = varDef.getDeclaredType();
    if(declaredType != null) {
      return getFirstElementOrNull(declaredType.findTargetDefElements(mr, true));
    }
    IInitializer initializer = varDef.getDeclaredInitializer();
    if(initializer instanceof IValueNode) {
      IValueNode initializerR = (IValueNode) initializer;
      return getFirstElementOrNull(initializerR.resolveTypeOfUnderlyingValue(mr));
View Full Code Here

   
    new DeeSearchEngineTestUtils.ElementsAndDefUnitVisitor() {
      @Override
      protected void visitNode(ASTNode node, ISourceModule sourceModule) {
        if(node instanceof Reference) {
          Reference reference = (Reference) node;
          Path filePath = DToolClient_Bad.getFilePathOrNull(sourceModule);
          if(filePath == null) {
            return;
          }
         
          IModuleResolver mr = DToolClient_Bad.getResolverFor(filePath);
          Collection<INamedElement> targetDefElements = reference.findTargetDefElements(mr, false);
          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
//        continue;
//      }
     
      final String keyIdentifier = DeeSearchEngineTestUtils.getModelElementFQName(element);
     
      doTestSearchForElementReferences(element, new MatchChecker(){
        @Override
        public void checkMatch(SearchMatch match) throws CoreException {
          IMember refElement = assertInstance(match.getElement(), IMember.class);
          ISourceModule module = getSourceModule(refElement);
          checkKey(module, match.getOffset(), keyIdentifier);
         
          checkReferences(expectedReferences, match);
        }
       
        private void checkReferences(final HashSet<Reference> expectedReferences, SearchMatch referenceMatch) {
          // Search for referenceMatch in expectedReferences, then remove it
         
          for (Reference pair : expectedReferences) {
            Reference reference = pair;
           
            String refModuleName = reference.getModuleNode().getModuleFullyQualifiedName();
           
            IModelElement modelElement = downCast(referenceMatch.getElement());
            ISourceModule matchSrcModule = DeeSearchEngineTestUtils.getSourceModule(modelElement);
           
            String matchModuleName = DeeSearchEngineTestUtils.getSourceModuleFQName(matchSrcModule);
           
            if(areEqual(refModuleName, matchModuleName) &&
              reference.getOffset() == referenceMatch.getOffset() &&
              reference.getLength() == referenceMatch.getLength()
            ) {
              expectedReferences.remove(pair);
              return;
            }
          }
View Full Code Here

 
  /* ================================== */
 
  @Override
  public boolean visit(NamedReference elem) {
    Reference topReference = elem;
   
    ASTNode parent = topReference.getParent();
    if(parent instanceof ExpReference) {
      parent = parent.getParent();
    }
    if(parent instanceof ExpCall) {
      ExpCall expCall = (ExpCall) parent;
View Full Code Here

    }
   
    if(!(node instanceof Reference)) {
      return new IModelElement[0];
    }
    Reference ref = (Reference) node;
   
    IModuleResolver moduleResolver = DToolClient_Bad.getResolverFor(filePath);
    Collection<INamedElement> defElements = ref.findTargetDefElements(moduleResolver, false);
    // We assume namespace Parent is the same
    if(defElements == null) {
      return new IModelElement[0];
    }
   
View Full Code Here

TOP

Related Classes of dtool.ast.references.Reference

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.