本文整理汇总了Java中org.eclipse.jface.text.hyperlink.IHyperlink类的典型用法代码示例。如果您正苦于以下问题:Java IHyperlink类的具体用法?Java IHyperlink怎么用?Java IHyperlink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IHyperlink类属于org.eclipse.jface.text.hyperlink包,在下文中一共展示了IHyperlink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detectHyperlinks
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region,
boolean canShowMultipleHyperlinks) {
SQLEditor editor = getAdapter(SQLEditor.class);
PgDbParser parser = editor.getParser();
int offset = region.getOffset();
List<PgObjLocation> refs = parser.getObjsForEditor(editor.getEditorInput());
for (PgObjLocation obj : refs) {
if (offset > obj.getOffset()
&& offset < (obj.getOffset() + obj.getObjLength())) {
IHyperlink[] links = parser.getDefinitionsForObj(obj)
.map(def -> new SQLEditorHyperLink(
new Region(def.getOffset(), def.getObjLength()),
new Region(obj.getOffset(), obj.getObjLength()),
obj.getObjName(), def.getFilePath(), def.getLineNumber()))
.toArray(IHyperlink[]::new);
if (links.length != 0) {
return links;
}
}
}
return null;
}
示例2: detectKspName
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private IHyperlink[] detectKspName(String currentWord, IRegion targetRegion, FileRegion fileRegion) {
/* Cherche la déclaration. */
KspDeclaration kspDeclaration = KspManager.getInstance().findKspDeclarationByConstantCaseName(currentWord);
if (kspDeclaration == null) {
return null; // NOSONAR
}
/* Vérifie que le focus n'est pas déjà sur la déclaration. */
if (fileRegion.equals(kspDeclaration.getFileRegion())) {
return null; // NOSONAR
}
/* Renvoie un lien vers la déclaration. */
return new IHyperlink[] { new KspDeclarationHyperLink(targetRegion, kspDeclaration) };
}
示例3: handleFileLink
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private IHyperlink[] handleFileLink(IRegion lineInfo, GradleHyperLinkResult result) {
try {
File folder = editorFile.getParentFile();
String fileName = result.linkContent;
File target = new File(folder, fileName);
if (!target.exists()) {
target = new File(fileName);
}
if (!target.exists()) {
return null;
}
IFileStore fileStore = EFS.getLocalFileSystem().getStore(target.toURI());
if (fileStore==null){
return null;
}
IRegion urlRegion = new Region(lineInfo.getOffset() + result.linkOffsetInLine, result.linkLength);
GradleFileHyperlink gradleFileHyperlink = new GradleFileHyperlink(urlRegion, fileStore);
return new IHyperlink[] { gradleFileHyperlink };
} catch (RuntimeException e) {
return null;
}
}
示例4: getHyperlinkDetectors
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
List<IHyperlinkDetector> detectors = new LinkedList<IHyperlinkDetector>();
IHyperlinkDetector[] inheritedDetectors = super.getHyperlinkDetectors(sourceViewer);
if (inheritedDetectors != null) {
for (final IHyperlinkDetector detector : inheritedDetectors) {
detectors.add(new IHyperlinkDetector() {
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region,
boolean canShowMultipleHyperlinks) {
try {
return detector.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
}
catch (Throwable e) {
// fail safe hyperlink detector - prevent others
// from failing
}
return null;
}
});
}
}
detectors.add(detector);
return detectors.toArray(new IHyperlinkDetector[detectors.size()]);
}
示例5: execute
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor != null) {
ITextSelection selection = (ITextSelection) xtextEditor.getSelectionProvider().getSelection();
IRegion region = new Region(selection.getOffset(), selection.getLength());
ISourceViewer internalSourceViewer = xtextEditor.getInternalSourceViewer();
IHyperlink[] hyperlinks = getDetector().detectHyperlinks(internalSourceViewer, region, false);
if (hyperlinks != null && hyperlinks.length > 0) {
IHyperlink hyperlink = hyperlinks[0];
hyperlink.open();
}
}
return null;
}
示例6: createHyperlinksByOffset
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
public IHyperlink[] createHyperlinksByOffset(XtextResource resource,
int offset, boolean createMultipleHyperlinks) {
EObject eObject = helper.resolveElementAt(resource, offset);
if (eObject instanceof StepDefinition ||
eObject instanceof StaticParam ||
eObject instanceof DynamicParam) {
IParseResult parseResult = resource.getParseResult();
INode node = NodeModelUtils.findLeafNodeAtOffset(
parseResult.getRootNode(), offset);
while (!(node instanceof CompositeNode && node.getSemanticElement() instanceof StepDefinition)) {
node = node.getParent();
}
String description = StepUtil.getStepText(node);
if (!openConceptDefinition(eObject, description)) {
openStepDefinition(description);
}
}
return null;
}
示例7: doDetect
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
protected IHyperlink[] doDetect(JsonDocument doc, ITextViewer viewer, HyperlinkInfo info, JsonPointer pointer) {
Model model = doc.getModel();
AbstractNode node = model.find(pointer);
List<AbstractNode> nodes = model.findByType(JsonPointer.compile("/definitions/operation"));
Iterator<AbstractNode> it = nodes.iterator();
AbstractNode found = null;
while (it.hasNext() && found == null) {
AbstractNode current = it.next();
AbstractNode value = current.get("operationId");
if (value != null && Objects.equals(node.asValue().getValue(), value.asValue().getValue())) {
found = value;
}
}
if (found != null) {
IRegion target = doc.getRegion(found.getPointer());
if (target != null) {
return new IHyperlink[] { new SwaggerHyperlink(info.text, viewer, info.region, target) };
}
}
return null;
}
示例8: doDetect
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
protected IHyperlink[] doDetect(JsonDocument doc, ITextViewer viewer, HyperlinkInfo info, JsonPointer pointer) {
Matcher matcher = PATTERN.matcher(pointer.toString());
String link = matcher.find() ? matcher.group(1) : null;
if (link != null) {
Model model = doc.getModel();
AbstractNode securityScheme = model.find("/components/securitySchemes/" + link);
if (securityScheme != null) {
IRegion target = doc.getRegion(securityScheme.getPointer());
if (target != null) {
return new IHyperlink[] { new SwaggerHyperlink(info.text, viewer, info.region, target) };
}
}
}
return null;
}
示例9: doDetect
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
protected IHyperlink[] doDetect(JsonDocument doc, ITextViewer viewer, HyperlinkInfo info, JsonPointer pointer) {
JsonPointer targetPath;
if (pointer.toString().matches(REQUIRED_PATTERN)) {
targetPath = getRequiredPropertyPath(doc, info, pointer);
} else {
targetPath = getTagDefinitionPath(doc, info, pointer);
}
if (targetPath == null) {
return null;
}
IRegion target = doc.getRegion(targetPath);
if (target == null) {
return null;
}
return new IHyperlink[] { new SwaggerHyperlink(info.text, viewer, info.region, target) };
}
示例10: detectHyperlinks
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
JsonDocument document = (JsonDocument) textViewer.getDocument();
JsonPointer basePath = document.getPath(region);
if (!canDetect(basePath)) {
return null;
}
HyperlinkInfo info = getHyperlinkInfo(textViewer, region);
if (info == null) {
return null;
}
return doDetect(document, textViewer, info, basePath);
}
示例11: detectHyperlinks
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
/**
* detectHyperlinks
*
* @param editor
* @param region
* @param canShowMultipleHyperlinks
* @return
*/
public IHyperlink[] detectHyperlinks(AbstractThemeableEditor editor, IRegion region,
boolean canShowMultipleHyperlinks)
{
IHyperlink[] result = null;
if (editor != null && region != null)
{
// grab AST
IParseNode ast = editor.getAST();
if (ast instanceof JSParseRootNode)
{
// gather links
result = processAST(editor, (JSParseRootNode) ast, region.getOffset());
}
}
if (!canShowMultipleHyperlinks && !ArrayUtil.isEmpty(result))
{
result = new IHyperlink[] { result[0] };
}
return result;
}
示例12: run
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
/**
* Open the declaration if possible.
*/
@Override
public void run()
{
ITextEditor textEditor = getTextEditor();
if (textEditor instanceof JSSourceEditor)
{
ITextSelection selection = (ITextSelection) textEditor.getSelectionProvider().getSelection();
IRegion region = new Region(selection.getOffset(), 1);
JSHyperlinkDetector detector = new JSHyperlinkDetector();
IHyperlink[] hyperlinks = detector.detectHyperlinks((AbstractThemeableEditor) textEditor, region, true);
if (!ArrayUtil.isEmpty(hyperlinks))
{
// give first link highest precedence
hyperlinks[0].open();
}
}
}
示例13: createClassMethodLink
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private IHyperlink createClassMethodLink(final IDocument document,
final String elementValue, final IRegion elementRegion,
final String className) {
IHyperlink link = null;
IType clazz = ProjectUtil.findClass(document, className);
if (clazz != null) {
IMethod method = ProjectUtil.findClassParameterlessMethod(clazz,
elementValue);
if (method != null) {
link = new JavaElementHyperlink(elementRegion, method);
}
}
return link;
}
示例14: createPackageExtendsResourcesLink
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private List<IHyperlink> createPackageExtendsResourcesLink(
final IDocument document, final String elementValue,
final IRegion elementRegion) {
List<IHyperlink> links = new ArrayList<IHyperlink>();
IPath currentPath = ProjectUtil.getCurrentDocumentPath(document);
List<ResourceDocument> resources = ProjectUtil
.findStrutsResources(document);
for (ResourceDocument rd : resources) {
if (!rd.getResource().getFullPath().equals(currentPath)) {
IRegion nameRegion = strutsXmlParser.getPackageNameRegion(
rd.getDocument(), elementValue);
if (nameRegion != null) {
if (rd.getResource().getType() == IResource.FILE
&& rd.getResource().exists()) {
links.add(new FileHyperlink(elementRegion, (IFile) rd
.getResource(), nameRegion));
}
}
}
}
return links;
}
示例15: createPackageExtendsJarLinks
import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private List<IHyperlink> createPackageExtendsJarLinks(
final IDocument document, final String elementValue,
final IRegion elementRegion) {
List<IHyperlink> links = new ArrayList<IHyperlink>();
List<JarEntryStorage> jarStorages = ProjectUtil
.findJarEntryStrutsResources(document);
for (JarEntryStorage jarStorage : jarStorages) {
IRegion nameRegion = strutsXmlParser.getPackageNameRegion(
jarStorage.toDocument(), elementValue);
if (nameRegion != null) {
links.add(new StorageHyperlink(elementRegion, jarStorage,
nameRegion));
}
}
return links;
}