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 105561 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]
a hyperlink detector specifically designed for Java
clipboard.txt (text/plain), 5.46 KB, created by
Jingwen 'Owen' Ou
on 2008-06-20 21:37:53 EDT
(
hide
)
Description:
a hyperlink detector specifically designed for Java
Filename:
MIME Type:
Creator:
Jingwen 'Owen' Ou
Created:
2008-06-20 21:37:53 EDT
Size:
5.46 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.java.tasks >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.java.tasks/plugin.xml,v >retrieving revision 1.2 >diff -u -r1.2 plugin.xml >--- plugin.xml 9 Jun 2008 19:32:46 -0000 1.2 >+++ plugin.xml 21 Jun 2008 01:35:16 -0000 >@@ -23,5 +23,14 @@ > menubarPath="org.eclipse.jdt.junit.ResultView"/> > </viewerContribution> > </extension> >+ <extension >+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors"> >+ <hyperlinkDetector >+ class="org.eclipse.mylyn.internal.java.tasks.JavaClassHyperlinkDetector" >+ id="org.eclipse.mylyn.java.hyperlink.detector.java" >+ name="Java Class " >+ targetId="org.eclipse.ui.DefaultTextEditor"> >+ </hyperlinkDetector> >+ </extension> > > </plugin> >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,74 @@ >+/******************************************************************************* >+ * 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); >+ >+ 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()); >+ >+ Matcher m = javaClassPattern.matcher(line); >+ >+ while (m.find()) { >+ // check if its a URL hyperlink >+ if (lineInfo.getOffset() + m.start() - 1 >= 0 >+ && document.get(lineInfo.getOffset() + m.start() - 1, 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("\\s(\\w+\\.)+\\w+", Pattern.CASE_INSENSITIVE); >+ Matcher m = javaClassPattern.matcher(" http:// www.eclipse// \n ww.dd ff."); >+ 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,25 @@ >+/******************************************************************************* >+ * 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; >+ >+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