Package dtool.parser.common

Examples of dtool.parser.common.IToken


    throw assertFail();
  }
 
  public static ParserError createErrorToken(ParserErrorTypes errorTypeTk, MetadataEntry mde,
    LexElementSource lexSource, boolean tokenBefore, Object errorParam) {
    IToken adjacentToken = tokenBefore
      ? findLastEffectiveTokenBeforeOffset(mde.offset, lexSource)
      : findNextEffectiveTokenAfterOffset(mde.offset, lexSource);
     
    SourceRange errorRange = adjacentToken.getSourceRange();
    String errorSource = adjacentToken.getSourceValue();
    return new ParserError(errorTypeTk, errorRange, errorSource, errorParam);
  }
View Full Code Here


 
  public Expression parseStringLiteral() {
    ArrayList<IToken> stringTokens = new ArrayList<IToken>(1);
   
    while(lookAheadGrouped() == DeeTokens.GROUP_STRING) {
      IToken string = consumeLookAhead();
      stringTokens.add(string);
    }
    IToken[] tokenStrings = ArrayUtil.createFrom(stringTokens, IToken.class);
    return conclude(srToPosition(tokenStrings[0].getStartPos(), new ExpLiteralString(tokenStrings)));
  }
View Full Code Here

      IModuleResolver mr) {
   
    assertTrue(isInRange(0, offset, parseResult.source.length()));
   
    TokenAtOffsetResult tokenAtOffsetResult = parseResult.findTokenAtOffset(offset);
    IToken tokenAtOffsetLeft = tokenAtOffsetResult.atLeft;
    IToken tokenAtOffsetRight = tokenAtOffsetResult.atRight;
   
    if(tokenAtOffsetResult.isSingleToken()
      && isInsideRange(tokenAtOffsetLeft.getStartPos(), offset, tokenAtOffsetLeft.getEndPos())
      && canCompleteInsideToken(tokenAtOffsetLeft)
    ) {
      return new CompletionSearchResult(ECompletionResultStatus.INVALID_TOKEN_LOCATION);
    }
    if(tokenAtOffsetLeft != null    
      && tokenAtOffsetLeft.getType().getGroupingToken() == DeeTokens.GROUP_FLOAT
      && tokenAtOffsetLeft.getSourceValue().endsWith(".")) {
      return new CompletionSearchResult(ECompletionResultStatus.INVALID_TOKEN_LOCATION_FLOAT);
    }
   
    final IToken nameToken;
   
    if(tokenAtOffsetLeft != null && tokenAtOffsetLeft.getType().isAlphaNumeric()) {
      nameToken = tokenAtOffsetLeft;
    } else if(tokenAtOffsetRight != null && tokenAtOffsetRight.getType().isAlphaNumeric()) {
      nameToken = tokenAtOffsetRight;
    } else {
      nameToken = null;
    }
   
    Module module = parseResult.getModuleNode();
    ASTNode nodeAtOffset = new ASTNodeFinderExtension(module, offset, true).match;
    assertTrue(nodeAtOffset.getSourceRange().contains(offset));
   
    if(nodeAtOffset instanceof CommonQualifiedReference) {
      CommonQualifiedReference namedRef = (CommonQualifiedReference) nodeAtOffset;
      assertTrue(nameToken == null);
     
      if(offset <= namedRef.getDotOffset()) {
        nodeAtOffset = namedRef.getParent();
      }
      PrefixSearchOptions searchOptions = new PrefixSearchOptions();
      return performCompletionSearch(offset, mr, module, nodeAtOffset, searchOptions);
    } else if(nodeAtOffset instanceof RefModule) {
      RefModule refModule = (RefModule) nodeAtOffset;
      // RefModule has a specialized way to setup prefix len things
     
      String source = parseResult.source;
      PrefixSearchOptions searchOptions = codeCompletionRefModule(offset, tokenAtOffsetRight, source, refModule);
      return performCompletionSearch(offset, mr, module, nodeAtOffset, searchOptions);
    }
   
    if(nameToken != null) {
      assertTrue(nameToken.getSourceRange().contains(offset));
     
      PrefixSearchOptions searchOptions = new PrefixSearchOptions();
     
      String searchPrefix = nameToken.getSourceValue().substring(0, offset - nameToken.getStartPos());
      int rplLen = nameToken.getEndPos() - offset;
      searchOptions.setPrefixSearchOptions(searchPrefix, rplLen);
     
      // Because of some parser limitations, in some cases nodeForNameLookup needs to be corrected,
      // such that it won't be the same as nodeForNameLookup
      ASTNode nodeForNameLookup = getStartingNodeForNameLookup(nameToken.getStartPos(), module);
     
      return performCompletionSearch(offset, mr, module, nodeForNameLookup, searchOptions);
     
    } else {
      PrefixSearchOptions searchOptions = new PrefixSearchOptions();
View Full Code Here

TOP

Related Classes of dtool.parser.common.IToken

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.