Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 105570 Details for
Bug 237974
[wikitext] implement a hyperlink detector specifically designed for Java. e.g. detecting org.eclipse.mylyn.internal.java.tasks.JavaClassHyperlinkDetector
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
all-in-one patch that fixed the tooltip problem
clipboard.txt (text/plain), 5.24 KB, created by
Jingwen 'Owen' Ou
on 2008-06-21 04:03:46 EDT
(
hide
)
Description:
all-in-one patch that fixed the tooltip problem
Filename:
MIME Type:
Creator:
Jingwen 'Owen' Ou
Created:
2008-06-21 04:03:46 EDT
Size:
5.24 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.java.tasks >Index: src/org/eclipse/mylyn/internal/java/tasks/JavaClassHyperlinkDetector.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/java/tasks/JavaClassHyperlinkDetector.java >diff -N src/org/eclipse/mylyn/internal/java/tasks/JavaClassHyperlinkDetector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/java/tasks/JavaClassHyperlinkDetector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,84 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.java.tasks; >+ >+import java.util.ArrayList; >+import java.util.List; >+import java.util.regex.Matcher; >+import java.util.regex.Pattern; >+ >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector; >+import org.eclipse.jface.text.hyperlink.IHyperlink; >+ >+/** >+ * Java Class Hyperlink Dectector, e.g. detecting org.eclipse.mylyn.internal.java.tasks.JavaClassHyperlinkDetector >+ * >+ * @author Jingwen Ou >+ */ >+public class JavaClassHyperlinkDetector extends AbstractHyperlinkDetector { >+ >+ private static final Pattern javaClassPattern = Pattern.compile("(\\w+\\.)+\\w+", Pattern.CASE_INSENSITIVE); >+ >+ private static final Pattern stackTracePattern = Pattern.compile("\\S*\\.java:\\d*\\)", Pattern.CASE_INSENSITIVE); >+ >+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { >+ List<IHyperlink> hyperLinks = new ArrayList<IHyperlink>(); >+ >+ try { >+ IDocument document = textViewer.getDocument(); >+ if (document == null) { >+ return null; >+ } >+ int offset = region.getOffset(); >+ >+ IRegion lineInfo = document.getLineInformationOfOffset(offset); >+ String line = document.get(lineInfo.getOffset(), lineInfo.getLength()); >+ >+ // try not to conflict with JavaStackTraceHyperlinkDetector, eclipse 3.4 can display multiple links >+ if (stackTracePattern.matcher(line).find()) { >+ return null; >+ } >+ >+ Matcher m = javaClassPattern.matcher(line); >+ >+ while (m.find()) { >+ // ignore URL hyperlinks and words like "i.e." >+ int beforeStart = lineInfo.getOffset() + m.start() - 1; >+ int afterEnd = lineInfo.getOffset() + m.end(); >+ if ((beforeStart >= 0 && document.get(beforeStart, 1).equalsIgnoreCase("/")) >+ || ((afterEnd <= lineInfo.getOffset() + lineInfo.getLength()) && document.get(afterEnd, 1) >+ .equalsIgnoreCase("."))) { >+ continue; >+ } >+ >+ IRegion urlRegion = new Region(lineInfo.getOffset() + m.start(), m.end() - m.start()); >+ hyperLinks.add(new JavaClassFileHyperlink(urlRegion, m.group())); >+ } >+ >+ } catch (BadLocationException e) { >+ return null; >+ } >+ >+ return hyperLinks.size() > 0 ? hyperLinks.toArray(new IHyperlink[hyperLinks.size()]) : null; >+ } >+ >+ public static void main(String str[]) { >+ Pattern javaClassPattern = Pattern.compile("(\\w+\\.)+\\w+", Pattern.CASE_INSENSITIVE); >+ Matcher m = javaClassPattern.matcher(" http:// www.eclipse// \n ww.dd ff. e.g."); >+ while (m.find()) { >+ System.out.println(m.group()); >+ } >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/java/tasks/JavaClassFileHyperlink.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/java/tasks/JavaClassFileHyperlink.java >diff -N src/org/eclipse/mylyn/internal/java/tasks/JavaClassFileHyperlink.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/java/tasks/JavaClassFileHyperlink.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.java.tasks; >+ >+import org.eclipse.jface.text.IRegion; >+ >+/** >+ * Take advantage of JavaStackTraceFileHyperlink to open link to a certain class >+ * >+ * @author Jingwen Ou >+ */ >+public class JavaClassFileHyperlink extends JavaStackTraceFileHyperlink { >+ private final String traceLine; >+ >+ public JavaClassFileHyperlink(IRegion region, String traceLine) { >+ super(region, traceLine); >+ this.traceLine = traceLine; >+ } >+ >+ @Override >+ public void open() { >+ startSourceSearch(traceLine, 0); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 237974
:
105534
|
105546
|
105561
|
105564
| 105570