Java 类org.eclipse.xtext.parser.IParser 实例源码

项目:xtext-extras    文件:XtextAntlrGeneratorFragment.java   
@Override
public Set<Binding> getGuiceBindingsRt(Grammar grammar) {
    BindFactory factory = new BindFactory()
        .addTypeToType(IParser.class.getName(),getParserClassName(grammar, getNaming()))
        .addTypeToType(ITokenToStringConverter.class.getName(),AntlrTokenToStringConverter.class.getName())
        .addTypeToType(IAntlrTokenFileProvider.class.getName(),getAntlrTokenFileProviderClassName(grammar, getNaming()))
        .addTypeToType(Lexer.class.getName(), getLexerClassName(grammar, getNaming()))
        .addTypeToProviderInstance(getLexerClassName(grammar, getNaming()), "org.eclipse.xtext.parser.antlr.LexerProvider.create(" + getLexerClassName(grammar, getNaming()) + ".class)")
        .addConfiguredBinding("RuntimeLexer",
                "binder.bind(" + Lexer.class.getName() + ".class)"+
                ".annotatedWith(com.google.inject.name.Names.named(" +
                "org.eclipse.xtext.parser.antlr.LexerBindings.RUNTIME" +
                ")).to(" + getLexerClassName(grammar, getNaming()) +".class)")
        .addTypeToType(ITokenDefProvider.class.getName(), AntlrTokenDefProvider.class.getName());
    if (containsUnorderedGroup(grammar))
        factory = factory.addTypeToType(IUnorderedGroupHelper.class.getName(), UnorderedGroupHelper.class.getName());
    return factory.getBindings();
}
项目:xtext-extras    文件:AntlrGeneratorFragment.java   
@Override
public Set<Binding> getGuiceBindingsRt(Grammar grammar) {
    BindFactory factory = new BindFactory()
        .addTypeToType(IParser.class.getName(),getFragmentHelper().getParserClassName(grammar))
        .addTypeToType(ITokenToStringConverter.class.getName(),AntlrTokenToStringConverter.class.getName())
        .addTypeToType(IAntlrTokenFileProvider.class.getName(),getFragmentHelper().getAntlrTokenFileProviderClassName(grammar))
        .addTypeToType(Lexer.class.getName(), getFragmentHelper().getLexerClassName(grammar))
        .addTypeToProviderInstance(getFragmentHelper().getLexerClassName(grammar), "org.eclipse.xtext.parser.antlr.LexerProvider.create(" + getFragmentHelper().getLexerClassName(grammar) + ".class)")
        .addConfiguredBinding("RuntimeLexer",
                "binder.bind(" + Lexer.class.getName() + ".class)"+
                ".annotatedWith(com.google.inject.name.Names.named(" +
                "org.eclipse.xtext.parser.antlr.LexerBindings.RUNTIME" +
                ")).to(" + getFragmentHelper().getLexerClassName(grammar) +".class)")
        .addTypeToType(ITokenDefProvider.class.getName(),AntlrTokenDefProvider.class.getName());
    if (containsUnorderedGroup(grammar))
        factory = factory.addTypeToType(IUnorderedGroupHelper.class.getName(), UnorderedGroupHelper.class.getName());
    if (getOptions().isIgnoreCase()) {
        factory = factory
            .addTypeToType(ITokenSerializer.IKeywordSerializer.class.getName(), IgnoreCaseKeywordSerializer.class.getName())
            .addTypeToType(AbstractIDValueConverter.class.getName(), IgnoreCaseIDValueConverter.class.getName());
    }
    return factory.getBindings();
}
项目:n4js    文件:RegExLiteralConverter.java   
private IParser getRegexParser() {
    if (regexParser == null) {
        // no need for sync since we can also use a new regexParser if concurrent access happens by accident
        IResourceServiceProvider serviceProvider = serviceProviders.getResourceServiceProvider(URI
                .createURI("a.regex"));
        regexParser = serviceProvider.get(IParser.class);
    }
    return regexParser;
}
项目:dsl-devkit    文件:LazyLinkingResource2.java   
/**
 * Initializes the parser with resource related parameters.
 *
 * @param parser
 *          the {@link IParser} to initialize, may be {@code null}
 * @param resourceUri
 *          the resource {@link URI} that the parser should consider, may be {@code null}
 */
private void initializeParser(final IParser parser, final URI resourceUri) {
  if (parser instanceof IResourceAwareParser) {
    final IResourceAwareParser resourceParser = (IResourceAwareParser) parser;
    if (resourceUri == null) {
      resourceParser.setFileExtension(null);
    } else {
      resourceParser.setFileExtension(URI.decode(resourceUri.fileExtension())); // if uri.fileExtension() is null, URI.decode will return null
    }
  }
}
项目:pokemon-tcgo-deck-generator    文件:AbstractPkmntcgoRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return PkmntcgoParser.class;
}
项目:n4js    文件:AbstractTypesRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return TypesParser.class;
}
项目:n4js    文件:AbstractRegularExpressionRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return RegularExpressionParser.class;
}
项目:n4js    文件:AbstractN4JSRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return N4JSParser.class;
}
项目:n4js    文件:AbstractN4MFRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return N4MFParser.class;
}
项目:Xtext_Xtend_HTML_Generator    文件:AbstractMyDslRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return MyDslParser.class;
}
项目:bromium    文件:AbstractBromiumRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return BromiumParser.class;
}
项目:gw4e.project    文件:AbstractDSLPoliciesRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return DSLPoliciesParser.class;
}
项目:lcdsl    文件:AbstractLcDslRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return LcDslParser.class;
}
项目:gemoc-studio    文件:AbstractDslRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return DslParser.class;
}
项目:org.xtext.dsl.restaurante    文件:AbstractRestauranteRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return RestauranteParser.class;
}
项目:OCCI-Studio    文件:AbstractOCCIRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return OCCIParser.class;
}
项目:xtext-extras    文件:AbstractPureXbaseRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return PureXbaseParser.class;
}
项目:xtext-extras    文件:AbstractXbaseRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return XbaseParser.class;
}
项目:xtext-core    文件:AbstractAssignmentFinderTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return AssignmentFinderTestLanguageParser.class;
}
项目:xtext-core    文件:AbstractQualifiedNameTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return QualifiedNameTestLanguageParser.class;
}
项目:xtext-extras    文件:TokenSequencePreservingPartialParsingHelper.java   
@Override
public IParseResult reparse(IParser parser, IParseResult previousParseResult, ReplaceRegion changedRegion) {
    if (isBrokenPreviousState(previousParseResult, changedRegion.getOffset())) {
        return fullyReparse(parser, previousParseResult, changedRegion);
    }
    ICompositeNode oldRootNode = previousParseResult.getRootNode();
    Iterator<ILeafNode> leafNodes = oldRootNode.getLeafNodes().iterator();
    ILeafNode leftNode = getLeftNode(leafNodes, changedRegion.getOffset());
    if (leftNode == null) {
        return fullyReparse(parser, previousParseResult, changedRegion);
    }
    ILeafNode rightNode = getRightNode(leafNodes, changedRegion.getEndOffset());
    if (rightNode == null) {
        return fullyReparse(parser, previousParseResult, changedRegion);
    }
    while(leafNodes.hasNext()) {
        if (leafNodes.next().getSyntaxErrorMessage() != null) {
            return fullyReparse(parser, previousParseResult, changedRegion);
        }
    }
    String originalText = oldRootNode.getText().substring(leftNode.getTotalOffset());
    StringBuilder newTextBuilder = new StringBuilder(originalText);
    changedRegion.shiftBy(-leftNode.getTotalOffset()).applyTo(newTextBuilder);
    String newText = newTextBuilder.toString();
    if (originalText.equals(newText)) {
        // nothing to do
        return previousParseResult;
    }
    int originalLength = rightNode.getTotalEndOffset() - leftNode.getTotalOffset();
    int expectedLength = originalLength - changedRegion.getLength() + changedRegion.getText().length();
    if (!isSameTokenSequence(originalText.substring(0, originalLength), newText, expectedLength)) {
        // different token sequence, cannot perform a partial parse run
        return fullyReparse(parser, previousParseResult, changedRegion);
    }

    PartialParsingPointers parsingPointers = calculatePartialParsingPointers(oldRootNode, leftNode, rightNode);
    ICompositeNode replaceMe = getReplacedNode(parsingPointers);
    if (replaceMe == null || replaceMe == oldRootNode || replaceMe.getOffset() == 0 && replaceMe.getEndOffset() == oldRootNode.getLength()) {
        return fullyReparse(parser, previousParseResult, changedRegion);
    }
    String reparseRegion = insertChangeIntoReplaceRegion(replaceMe, changedRegion);

    EObject oldSemanticElement = getOldSemanticElement(replaceMe, parsingPointers);
    if (oldSemanticElement == null)
        return fullyReparse(parser, previousParseResult, changedRegion);
    if (oldSemanticElement == replaceMe.getParent().getSemanticElement()) {
        throw new IllegalStateException("oldParent == oldElement");
    }

    IParseResult newParseResult = doParseRegion(parser, parsingPointers, replaceMe, reparseRegion);
    if (newParseResult == null) {
        throw new IllegalStateException("Could not perform a partial parse operation");
    }

    replaceOldSemanticElement(oldSemanticElement, previousParseResult, newParseResult);
    nodeModelBuilder.replaceAndTransferLookAhead(replaceMe, newParseResult.getRootNode());
    ((ParseResult) newParseResult).setRootNode(oldRootNode);
    StringBuilder builder = new StringBuilder(oldRootNode.getText());
    changedRegion.applyTo(builder);
    nodeModelBuilder.setCompleteContent(oldRootNode, builder.toString());
    return newParseResult;
}
项目:xtext-core    文件:AbstractXtextGrammarTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return XtextGrammarTestLanguageParser.class;
}
项目:xtext-core    文件:AbstractActionTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return ActionTestLanguageParser.class;
}
项目:xtext-core    文件:AbstractHiddenTokenSequencerTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return HiddenTokenSequencerTestLanguageParser.class;
}
项目:Sparrow    文件:AbstractModelEditorRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return ModelEditorParser.class;
}
项目:xtext-core    文件:AbstractLookaheadTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return LookaheadTestLanguageParser.class;
}
项目:xtext-extras    文件:AbstractRefactoringTestLanguage2RuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return RefactoringTestLanguage2Parser.class;
}
项目:xtext-extras    文件:AbstractBuilderTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return BuilderTestLanguageParser.class;
}
项目:xtext-extras    文件:AbstractBug462047LangRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return Bug462047LangParser.class;
}
项目:xtext-extras    文件:AbstractXImportSectionTestLangRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return XImportSectionTestLangParser.class;
}
项目:xtext-core    文件:AbstractPartialParserTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return PartialParserTestLanguageParser.class;
}
项目:xtext-extras    文件:AbstractGrammarAccessTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return GrammarAccessTestLanguageParser.class;
}
项目:xtext-core    文件:AbstractIndentationAwareTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return IndentationAwareTestLanguageParser.class;
}
项目:xtext-core    文件:AbstractTreeTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return TreeTestLanguageParser.class;
}
项目:xtext-core    文件:AbstractReferenceGrammarTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return ReferenceGrammarTestLanguageParser.class;
}
项目:xtext-core    文件:AbstractBug305397RuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return Bug305397Parser.class;
}
项目:xtext-core    文件:AbstractConcreteTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return ConcreteTestLanguageParser.class;
}
项目:minitl    文件:AbstractMinitlRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return MinitlParser.class;
}
项目:xtext-core    文件:AbstractXtextRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return XtextParser.class;
}
项目:xtext-core    文件:AbstractAbstractTestLanguageRuntimeModule.java   
public Class<? extends IParser> bindIParser() {
    return AbstractTestLanguageParser.class;
}