Java 类org.eclipse.xtext.linking.impl.DefaultLinkingService 实例源码

项目:dsl-devkit    文件:ParseTreeUtil.java   
/**
 * Returns the source text assigned to the given feature of the given object. Does not work for multi-valued features. Optionally also converts the source
 * text using the corresponding value converter. Conversion is only performed for keywords, rule call or cross reference grammar rules.
 * <p>
 * This method does not perform a check to make sure the feature matches the given object.
 *
 * @param object
 *          the semantic object
 * @param feature
 *          the feature to be considered when parsing the parse tree model
 * @param convert
 *          {@code true} if the parsed string needs conversion using its value converter
 * @return the parsed string from the node model
 */
public static String getParsedStringUnchecked(final EObject object, final EStructuralFeature feature, final boolean convert) {
  INode node = Iterables.getFirst(NodeModelUtils.findNodesForFeature(object, feature), null);
  if (node != null) {
    if (convert) {
      final LazyLinkingResource res = (LazyLinkingResource) object.eResource();
      EObject grammarElement = node.getGrammarElement();
      if (res != null && (grammarElement instanceof Keyword || grammarElement instanceof RuleCall || grammarElement instanceof CrossReference)) {
        final DefaultLinkingService linkingService = (DefaultLinkingService) res.getLinkingService();
        return linkingService.getCrossRefNodeAsString(node);
      }
    }
    // result may contain escape sequences or quotes
    return NodeModelUtils.getTokenText(node);
  }
  return null;
}
项目:xtext-core    文件:PartialLinkingTest.java   
protected void replaceLinker(XtextResource resource) {
    Linker linker = new Linker();
    DefaultLinkingService linkingService = new DefaultLinkingService();
    getInjector().injectMembers(linkingService);
    linkingService.setScopeProvider(this);
    linker.setLinkingService(linkingService);
    linker.setDiagnosticMessageProvider(new LinkingDiagnosticMessageProvider());
    linker.setLinkingHelper(getInjector().getInstance(LinkingHelper.class));
    resource.setLinker(linker);
}
项目:xtext-core    文件:DefaultRuntimeModule.java   
public Class<? extends ILinkingService> bindILinkingService() {
    return DefaultLinkingService.class;
}
项目:dsl-devkit    文件:EObjectUtil.java   
/**
 * Returns a scope provider given a {@link org.eclipse.xtext.linking.lazy.LazyLinkingResource LazyLinkingResource}.
 *
 * @param resource
 *          the resource
 * @return the scope provider by resource
 */
public static IScopeProvider getScopeProviderByResource(final LazyLinkingResource resource) {
  return ((DefaultLinkingService) resource.getLinkingService()).getScopeProvider();
}