Java 类org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor 实例源码

项目:dsl-devkit    文件:FormatHyperlinkHelper.java   
/** {@inheritDoc} */
@Override
public void createHyperlinksByOffset(final XtextResource resource, final int offset, final IHyperlinkAcceptor acceptor) {
  final IParseResult parseResult = resource.getParseResult();
  if (parseResult == null || parseResult.getRootNode() == null) {
    return; // Return, no need to call in super.createAdditionalHyperlinks
  }

  // Check if the current parse tree node represents an override keyword, in which case we want to link
  // to the overridden rule
  INode node = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), offset);
  if (node != null && isOverrideKeyword(node.getGrammarElement())) {
    Rule rule = (Rule) eObjectAtOffsetHelper.resolveElementAt(resource, offset);
    Region region = new Region(node.getOffset(), node.getLength());
    List<Rule> extendedRules = getExtendedRules(rule);
    for (Rule extendedRule : extendedRules) {
      createHyperlinksTo(resource, region, extendedRule, acceptor);
    }
  }
  super.createHyperlinksByOffset(resource, offset, acceptor);
}
项目:dsl-devkit    文件:CheckHyperlinkHelper.java   
@Override
public void createHyperlinksByOffset(final XtextResource resource, final int offset, final IHyperlinkAcceptor acceptor) {
  IEditorPart activeEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
  if (activeEditor.getEditorInput() instanceof XtextReadonlyEditorInput) {
    INode crossRefNode = eObjectAtOffsetHelper.getCrossReferenceNode(resource, new TextRegion(offset, 0));
    if (crossRefNode == null) {
      return;
    }
    EObject crossLinkedEObject = eObjectAtOffsetHelper.getCrossReferencedElement(crossRefNode);
    if (crossLinkedEObject != null && crossLinkedEObject.eClass().getEPackage() != CheckPackage.eINSTANCE) {
      return;
    }
    // if EPackage of referenced object is CheckPackage, try to provide hyperlinks: works for included catalogs
  }
  super.createHyperlinksByOffset(resource, offset, acceptor);
}
项目:statecharts    文件:PackageImportHyperlinkHelper.java   
protected void createPackageImportHyperlinksByOffset(XtextResource resource, int offset,
        IHyperlinkAcceptor acceptor) {
    INode node = NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset);
    if (node != null && node.getGrammarElement() instanceof RuleCall
            && node.getSemanticElement() instanceof ImportScope) {
        NodeModelUtils.findNodesForFeature(node.getSemanticElement(), TypesPackage.Literals.PACKAGE__IMPORT);
        ImportScope importScope = (ImportScope) node.getSemanticElement();
        EList<String> imports = importScope.getImports();
        for (String pkgImport : imports) {
            PackageImport mappedImport = mapper.findPackageImport(resource, pkgImport);
            final URI targetURI = mappedImport.getUri();
            XtextHyperlink result = getHyperlinkProvider().get();
            result.setURI(targetURI);
            Region region = new Region(node.getOffset(), node.getLength());
            result.setHyperlinkRegion(region);
            result.setHyperlinkText(targetURI.toString());
            acceptor.accept(result);
        }

    }

}
项目:EASyProducer    文件:GenericHyperlinkHelper.java   
@Override
public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
    ICompositeNode rootNode = modelQuery.getRootNode(resource);
    P correspondingIvmlProject = modelQuery.getProject(rootNode);
    if (rootNode != null) {
        ILeafNode leafNodeAtOffset = NodeModelUtils.findLeafNodeAtOffset(rootNode, offset);
        if (leafNodeAtOffset != null) {

            /*
             * Create an IvmlHyperlink for the element at the given offset.
             * What happens when opening this hyperlink is handled by the
             * IvmlHyperlink-class, see:
             * 
             * IvmlHyperlink.open()
             */
            AbstractHyperlink hyperlink = hyperlinkFactory.createHyperlink(leafNodeAtOffset, 
                correspondingIvmlProject);
            // Currently not used: hyperlink.setHyperlinkText("A hyperlink
            // text");
            hyperlink.setHyperlinkRegion(new Region(leafNodeAtOffset.getOffset(), leafNodeAtOffset.getLength()));

            acceptor.accept(hyperlink);
        }
    }
}
项目:sadlos2    文件:SadlHyperlinkHelper.java   
@Override
public void createHyperlinksByOffset(XtextResource resource, int offset,
        IHyperlinkAcceptor acceptor) {
    super.createHyperlinksByOffset(resource, offset, acceptor);
    EObject element = eObjectAtOffsetHelper.resolveElementAt(resource, offset);
    if (element!=null && element instanceof Import) {
        Import imp = (Import) element;
        INode node = NodeModelUtils.getNode(element);


        URI publicUri = URI.createURI(imp.getImportURI());
        URI uriForPublicUri = getUriForPublicUri(publicUri, resource.getResourceSet());
        if (uriForPublicUri!=null) {
            XtextHyperlink hyperlink = getHyperlinkProvider().get();
            Region region = new Region(node.getOffset(), node.getLength());
            hyperlink.setHyperlinkRegion(region);
            hyperlink.setURI(uriForPublicUri);
            hyperlink.setHyperlinkText(uriForPublicUri.toString());
            acceptor.accept(hyperlink);
        }
    }

}
项目:n4js    文件:ComposedMemberAwareHyperlinkHelper.java   
@Override
public void createHyperlinksTo(XtextResource from, Region region, EObject target, IHyperlinkAcceptor acceptor) {
    if (target instanceof TMember) {
        TMember member = (TMember) target;
        if (member.isComposed()) {
            List<TMember> constituentMembers = member.getConstituentMembers();
            for (TMember constituentMember : constituentMembers) {
                super.createHyperlinksTo(from, region, constituentMember, acceptor);
            }
            return;
        }
    }
    super.createHyperlinksTo(from, region, target, acceptor);
}
项目:solidity-ide    文件:SolidityHyperlinkHelper.java   
@Override
public void createHyperlinksTo(XtextResource from, Region region, EObject target, IHyperlinkAcceptor acceptor) {
    if (((AbstractTypeSystem)typeSystem).getResource() == target.eResource()) {
        // build-in elements are defined in the resource of the type system
        // don't create hyperlinks to them
        return;
    }
    super.createHyperlinksTo(from, region, target, acceptor);
}
项目:statecharts    文件:PackageImportHyperlinkHelper.java   
public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
    createPackageImportHyperlinksByOffset(resource, offset, acceptor);
    super.createHyperlinksByOffset(resource, offset, acceptor);
}