Package melnorme.lang.tooling.ast

Examples of melnorme.lang.tooling.ast.SourceRange


  public void testALL() throws Exception { testALL$(); }
  public void testALL$() throws Exception {
   
    testFindDefinition(BASIC_FOO_FilePath, indexOf(BASIC_FOO_Contents, "/*defA_REF1*/"),
      new FindDefinitionResultEntry(
        "defA", false, BASIC_FOO_FilePath, new SourceRange(indexOf(BASIC_FOO_Contents, "defA/*DEF*/"), 4))
    );
   
    // Test implicit source module
    testFindDefinition(BASIC_FOO_FilePath, indexOf(BASIC_FOO_Contents, "implicit_name/*MARKER*/"),
      new FindDefinitionResultEntry(
        "implicit_name", false, BUNDLE_FOO__SRC_FOLDER.resolve("basic_pack/implicit_name.d"),
        new SourceRange(0, 0))
    );
   
    // Test intrinsic
    testFindDefinition(BASIC_FOO_FilePath, indexOf(BASIC_FOO_Contents, "int/*int_ref*/"),
      new FindDefinitionResultEntry(
View Full Code Here


      this.parentScopeMDE = parentScopeMDE;
      this.sourceWasIncluded = sourceWasIncluded;
    }
   
    public SourceRange getSourceRange() {
      return new SourceRange(offset, sourceValue == null ? 0 : sourceValue.length());
    }
View Full Code Here

    return sourceEnd - sourceStart;
  }
 
  public final SourceRange getSourceRange() {
    assertTrue(hasSourceRangeInfo());
    return new SourceRange(getStartPos(), getLength());
  }
View Full Code Here

       
        ParserError error = decodeError(lexSource, mde);
        expectedErrors.add(error);
       
        if(getErrorTypeFromMDE(mde) == ParserErrorTypes.INVALID_TOKEN_CHARACTERS) {
          SourceRange sr = error.sourceRange;
          errorCorrectionMetadata.add(new StringCorrection(sr.getOffset(), sr.getLength(), ""));
        } else if(getErrorTypeFromMDE(mde) == ParserErrorTypes.EXPECTED_TOKEN) {
          assertTrue(mde.sourceValue == null || mde.sourceValue.isEmpty() || !mde.sourceWasIncluded);
         
          String rpl = mde.sourceValue;
          if(rpl == null) {
View Full Code Here

 
  public static ParserError decodeError(LexElementSource lexSource, MetadataEntry mde) {
    String errorTypeStr = StringUtil.substringUntilMatch(mde.value, "_");
    String errorParam = StringUtil.segmentAfterMatch(mde.value, "_");
   
    SourceRange errorRange = mde.getSourceRange();
    String errorSource = null;
   
    ParserErrorTypes errorType = getErrorTypeFromMDE(mde);
    switch (errorType) {
    case INVALID_TOKEN_CHARACTERS:
View Full Code Here

    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

  @Test
  public void testInit() throws Exception { testInit$(); }
  public void testInit$() throws Exception {
    LexElementSource lexSource = LexElementProducer.createFromLexer(new TestsInstrumentedLexer("abcdefgh"));
   
    assertEquals(lexSource.lastLexElement.getSourceRange(), new SourceRange(0, 0));
   
    assertTrue(lexSource.lexElementList.size() == 5);
    assertEquals(lexSource.lookAheadElement(4).type, DeeTokens.EOF);
    assertEquals(lexSource.lookAheadElement(5).type, DeeTokens.EOF); // Test index beyond first EOF
  }
View Full Code Here

    assertTrue(lookAhead() == DeeTokens.EOF);
    advanceSubChannelTokens(); // Ensure pending whitespace is consumed as well
    assertTrue(getSourcePosition() == lookAheadElement().getStartPos());
    //assertTrue(getSourcePosition() == getSource().length()); //This is not true if explicit EOF token is present
   
    SourceRange modRange = new SourceRange(0, getSourcePosition());
   
    if(md != null) {
      return result(false, conclude(modRange,
        new Module(md.getModuleSymbol(), md, members, compilationUnitPath)));
    } else {
View Full Code Here

    jsonWriter.writeProperty("extendedName", result.extendedName);
    jsonWriter.writeProperty("isIntrinsic", result.isLanguageIntrinsic);
    if(result.modulePath != null) {
      jsonWriter.writeProperty("modulePath", result.modulePath.toString());
    }
    SourceRange sourceRange = result.sourceRange;
    if(sourceRange != null) {
      jsonWriter.writeProperty("offset", sourceRange.getOffset());
      jsonWriter.writeProperty("length", sourceRange.getLength());
    }
    jsonWriter.endObject();
  }
View Full Code Here

    ParseRuleDescription expectedRule = reportMissingError ? RULE_REFERENCE : null;
    return parseMissingTypeReference(expectedRule);
  }
 
  public Reference parseMissingTypeReference(ParseRuleDescription expectedRule) {
    SourceRange sourceRange = consumeSubChannelTokensNoError().getSourceRange();
    ParserError error = expectedRule != null ? createErrorExpectedRule(expectedRule) : null;
    return createMissingTypeReferenceNode(sourceRange, error);
  }
View Full Code Here

TOP

Related Classes of melnorme.lang.tooling.ast.SourceRange

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.