library

16:38:49.928 INFO  jd.cli.Main - Decompiling library.jar
package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;

class ExternalFileEditorInput$WorkbenchAdapter
  implements IWorkbenchAdapter
{
  private ExternalFileEditorInput$WorkbenchAdapter(ExternalFileEditorInput paramExternalFileEditorInput) {}
  
  public Object[] getChildren(Object o)
  {
    return null;
  }
  
  public ImageDescriptor getImageDescriptor(Object object)
  {
    return null;
  }
  
  public String getLabel(Object o)
  {
    return ((ExternalFileEditorInput)o).getName();
  }
  
  public Object getParent(Object o)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.web.ui.internal.hyperlink.ExternalFileEditorInput.WorkbenchAdapter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;

import java.io.File;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPathEditorInput;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.ui.model.IWorkbenchAdapter;

class ExternalFileEditorInput
  implements IEditorInput, ILocationProvider
{
  private File fFile;
  
  private class WorkbenchAdapter
    implements IWorkbenchAdapter
  {
    private WorkbenchAdapter() {}
    
    public Object[] getChildren(Object o)
    {
      return null;
    }
    
    public ImageDescriptor getImageDescriptor(Object object)
    {
      return null;
    }
    
    public String getLabel(Object o)
    {
      return ((ExternalFileEditorInput)o).getName();
    }
    
    public Object getParent(Object o)
    {
      return null;
    }
  }
  
  private WorkbenchAdapter fWorkbenchAdapter = new WorkbenchAdapter(null);
  
  public ExternalFileEditorInput(File file)
  {
    fFile = file;
    fWorkbenchAdapter = new WorkbenchAdapter(null);
  }
  
  public boolean equals(Object o)
  {
    if (o == this) {
      return true;
    }
    if ((o instanceof ExternalFileEditorInput))
    {
      ExternalFileEditorInput input = (ExternalFileEditorInput)o;
      return fFile.equals(fFile);
    }
    if ((o instanceof IPathEditorInput))
    {
      IPathEditorInput input = (IPathEditorInput)o;
      return getPath().equals(input.getPath());
    }
    return false;
  }
  
  public boolean exists()
  {
    return fFile.exists();
  }
  
  public Object getAdapter(Class adapter)
  {
    if (ILocationProvider.class.equals(adapter)) {
      return this;
    }
    if (IWorkbenchAdapter.class.equals(adapter)) {
      return fWorkbenchAdapter;
    }
    return Platform.getAdapterManager().getAdapter(this, adapter);
  }
  
  public ImageDescriptor getImageDescriptor()
  {
    return null;
  }
  
  public String getName()
  {
    return fFile.getName();
  }
  
  public IPath getPath()
  {
    return Path.fromOSString(fFile.getAbsolutePath());
  }
  
  public IPath getPath(Object element)
  {
    if ((element instanceof ExternalFileEditorInput))
    {
      ExternalFileEditorInput input = (ExternalFileEditorInput)element;
      return Path.fromOSString(fFile.getAbsolutePath());
    }
    return null;
  }
  
  public IPersistableElement getPersistable()
  {
    return null;
  }
  
  public String getToolTipText()
  {
    return fFile.getAbsolutePath();
  }
  
  public int hashCode()
  {
    return fFile.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.web.ui.internal.hyperlink.ExternalFileEditorInput
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;

import java.io.File;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
import org.eclipse.wst.jsdt.web.ui.internal.Logger;

class ExternalFileHyperlink
  implements IHyperlink
{
  private File fHyperlinkFile;
  private IRegion fHyperlinkRegion;
  
  public ExternalFileHyperlink(IRegion region, File file)
  {
    fHyperlinkFile = file;
    fHyperlinkRegion = region;
  }
  
  public IRegion getHyperlinkRegion()
  {
    return fHyperlinkRegion;
  }
  
  public String getHyperlinkText()
  {
    String path = fHyperlinkFile.getPath();
    if (path.length() > 60) {
      path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
    }
    return NLS.bind(HTMLUIMessages.Open, path);
  }
  
  public String getTypeLabel()
  {
    return null;
  }
  
  public void open()
  {
    if (fHyperlinkFile != null)
    {
      IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile);
      try
      {
        IEditorDescriptor descriptor = IDE.getEditorDescriptor(input.getName(), true);
        if (descriptor != null)
        {
          IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
          IDE.openEditor(page, input, descriptor.getId(), true);
        }
      }
      catch (PartInitException e)
      {
        Logger.log(202, e.getMessage(), e);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.web.ui.internal.hyperlink.ExternalFileHyperlink
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;

import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorPart;
import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
import org.eclipse.wst.jsdt.internal.ui.actions.ActionMessages;
import org.eclipse.wst.jsdt.ui.JavaScriptUI;
import org.eclipse.wst.jsdt.web.ui.internal.Logger;

class JSDTHyperlink
  implements IHyperlink
{
  private IJavaScriptElement fElement;
  private IRegion fRegion;
  
  public JSDTHyperlink(IRegion region, IJavaScriptElement element)
  {
    fRegion = region;
    fElement = element;
  }
  
  public IRegion getHyperlinkRegion()
  {
    return fRegion;
  }
  
  public String getHyperlinkText()
  {
    return fElement != null ? NLS.bind(HTMLUIMessages.Open, fElement.getDisplayName()) : ActionMessages.OpenAction_declaration_label;
  }
  
  public String getTypeLabel()
  {
    return null;
  }
  
  public void open()
  {
    try
    {
      IEditorPart editor = JavaScriptUI.openInEditor(fElement);
      if (editor != null) {
        JavaScriptUI.revealInEditor(editor, fElement);
      }
    }
    catch (Exception e)
    {
      Logger.log(202, e.getMessage(), e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.web.ui.internal.hyperlink.JSDTHyperlink
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
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;
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;

public class JSDTHyperlinkDetector
  extends AbstractHyperlinkDetector
{
  /* Error */
  private IHyperlink createHyperlink(IJavaScriptElement element, IRegion region, IDocument document)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore 4
    //   3: aload_2
    //   4: ifnull +527 -> 531
    //   7: aload_1
    //   8: instanceof 16
    //   11: ifeq +504 -> 515
    //   14: aconst_null
    //   15: astore 5
    //   17: aconst_null
    //   18: astore 6
    //   20: iconst_0
    //   21: istore 7
    //   23: aconst_null
    //   24: astore 8
    //   26: invokestatic 18	org/eclipse/wst/sse/core/StructuredModelManager:getModelManager	()Lorg/eclipse/wst/sse/core/internal/provisional/IModelManager;
    //   29: aload_3
    //   30: invokeinterface 24 2 0
    //   35: astore 8
    //   37: aload 8
    //   39: ifnull +40 -> 79
    //   42: aload 8
    //   44: invokeinterface 30 1 0
    //   49: astore 9
    //   51: aload_0
    //   52: aload 9
    //   54: invokespecial 36	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector:getFile	(Ljava/lang/String;)Lorg/eclipse/core/resources/IFile;
    //   57: astore 5
    //   59: goto +20 -> 79
    //   62: astore 10
    //   64: aload 8
    //   66: ifnull +10 -> 76
    //   69: aload 8
    //   71: invokeinterface 40 1 0
    //   76: aload 10
    //   78: athrow
    //   79: aload 8
    //   81: ifnull +10 -> 91
    //   84: aload 8
    //   86: invokeinterface 40 1 0
    //   91: aconst_null
    //   92: astore 9
    //   94: aload_0
    //   95: aload_3
    //   96: invokespecial 43	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector:getJsTranslation	(Lorg/eclipse/jface/text/IDocument;)Lorg/eclipse/wst/jsdt/web/core/javascript/IJsTranslation;
    //   99: astore 10
    //   101: aload 10
    //   103: ifnull +298 -> 401
    //   106: aload_1
    //   107: instanceof 47
    //   110: ifeq +182 -> 292
    //   113: aload_1
    //   114: checkcast 47	org/eclipse/wst/jsdt/core/ILocalVariable
    //   117: invokeinterface 49 1 0
    //   122: astore 9
    //   124: aload_1
    //   125: checkcast 47	org/eclipse/wst/jsdt/core/ILocalVariable
    //   128: invokeinterface 53 1 0
    //   133: astore 11
    //   135: aload 10
    //   137: invokeinterface 57 1 0
    //   142: astore 12
    //   144: goto +13 -> 157
    //   147: aload 11
    //   149: checkcast 63	org/eclipse/wst/jsdt/internal/core/JavaElement
    //   152: invokevirtual 65	org/eclipse/wst/jsdt/internal/core/JavaElement:getParent	()Lorg/eclipse/wst/jsdt/core/IJavaScriptElement;
    //   155: astore 11
    //   157: aload 11
    //   159: instanceof 66
    //   162: ifne +16 -> 178
    //   165: aload 11
    //   167: instanceof 68
    //   170: ifne +8 -> 178
    //   173: aload 11
    //   175: ifnonnull -28 -> 147
    //   178: aload 11
    //   180: instanceof 66
    //   183: ifeq +52 -> 235
    //   186: aload 11
    //   188: checkcast 66	org/eclipse/wst/jsdt/core/IJavaScriptUnit
    //   191: astore 13
    //   193: aload 13
    //   195: aload 12
    //   197: if_acmpeq +204 -> 401
    //   200: aload_0
    //   201: aload 13
    //   203: invokeinterface 70 1 0
    //   208: invokeinterface 74 1 0
    //   213: invokespecial 36	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector:getFile	(Ljava/lang/String;)Lorg/eclipse/core/resources/IFile;
    //   216: astore 5
    //   218: aload 5
    //   220: ifnonnull +181 -> 401
    //   223: aload 13
    //   225: invokeinterface 70 1 0
    //   230: astore 6
    //   232: goto +169 -> 401
    //   235: aload 11
    //   237: instanceof 68
    //   240: ifeq +161 -> 401
    //   243: aload 11
    //   245: checkcast 68	org/eclipse/wst/jsdt/core/IClassFile
    //   248: astore 13
    //   250: aload 13
    //   252: aload 12
    //   254: if_acmpeq +147 -> 401
    //   257: aload_0
    //   258: aload 13
    //   260: invokeinterface 79 1 0
    //   265: invokeinterface 74 1 0
    //   270: invokespecial 36	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector:getFile	(Ljava/lang/String;)Lorg/eclipse/core/resources/IFile;
    //   273: astore 5
    //   275: aload 5
    //   277: ifnonnull +124 -> 401
    //   280: aload 13
    //   282: invokeinterface 79 1 0
    //   287: astore 6
    //   289: goto +112 -> 401
    //   292: aload_1
    //   293: invokeinterface 80 1 0
    //   298: bipush 8
    //   300: if_icmpne +48 -> 348
    //   303: aload_1
    //   304: checkcast 86	org/eclipse/wst/jsdt/core/IField
    //   307: invokeinterface 88 1 0
    //   312: astore 11
    //   314: aload 11
    //   316: ifnull +85 -> 401
    //   319: aload 11
    //   321: aload 10
    //   323: invokeinterface 57 1 0
    //   328: invokevirtual 91	java/lang/Object:equals	(Ljava/lang/Object;)Z
    //   331: ifeq +70 -> 401
    //   334: aload_1
    //   335: checkcast 97	org/eclipse/wst/jsdt/core/IMember
    //   338: invokeinterface 99 1 0
    //   343: astore 9
    //   345: goto +56 -> 401
    //   348: aload_1
    //   349: invokeinterface 80 1 0
    //   354: bipush 9
    //   356: if_icmpne +45 -> 401
    //   359: aload_1
    //   360: checkcast 100	org/eclipse/wst/jsdt/core/IFunction
    //   363: invokeinterface 102 1 0
    //   368: astore 11
    //   370: aload 11
    //   372: ifnull +29 -> 401
    //   375: aload 11
    //   377: aload 10
    //   379: invokeinterface 57 1 0
    //   384: invokevirtual 91	java/lang/Object:equals	(Ljava/lang/Object;)Z
    //   387: ifeq +14 -> 401
    //   390: aload_1
    //   391: checkcast 97	org/eclipse/wst/jsdt/core/IMember
    //   394: invokeinterface 99 1 0
    //   399: astore 9
    //   401: aload 9
    //   403: ifnull +53 -> 456
    //   406: aload 5
    //   408: ifnull +48 -> 456
    //   411: aload 9
    //   413: invokeinterface 103 1 0
    //   418: istore 7
    //   420: iload 7
    //   422: iflt +93 -> 515
    //   425: new 108	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink
    //   428: dup
    //   429: aload_2
    //   430: aload 5
    //   432: new 110	org/eclipse/jface/text/Region
    //   435: dup
    //   436: iload 7
    //   438: aload 9
    //   440: invokeinterface 112 1 0
    //   445: invokespecial 115	org/eclipse/jface/text/Region:<init>	(II)V
    //   448: invokespecial 118	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink:<init>	(Lorg/eclipse/jface/text/IRegion;Lorg/eclipse/core/resources/IFile;Lorg/eclipse/jface/text/IRegion;)V
    //   451: astore 4
    //   453: goto +62 -> 515
    //   456: aload 9
    //   458: ifnull +57 -> 515
    //   461: aload 6
    //   463: ifnull +52 -> 515
    //   466: aload 9
    //   468: invokeinterface 103 1 0
    //   473: istore 7
    //   475: iload 7
    //   477: iflt +38 -> 515
    //   480: new 121	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink
    //   483: dup
    //   484: aload_2
    //   485: aload 6
    //   487: invokeinterface 123 1 0
    //   492: invokespecial 127	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink:<init>	(Lorg/eclipse/jface/text/IRegion;Ljava/io/File;)V
    //   495: astore 4
    //   497: goto +18 -> 515
    //   500: astore 9
    //   502: sipush 202
    //   505: aload 9
    //   507: invokevirtual 130	org/eclipse/wst/jsdt/core/JavaScriptModelException:getMessage	()Ljava/lang/String;
    //   510: aload 9
    //   512: invokestatic 135	org/eclipse/wst/jsdt/web/ui/internal/Logger:log	(ILjava/lang/String;Ljava/lang/Throwable;)V
    //   515: aload 4
    //   517: ifnonnull +14 -> 531
    //   520: new 141	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink
    //   523: dup
    //   524: aload_2
    //   525: aload_1
    //   526: invokespecial 143	org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink:<init>	(Lorg/eclipse/jface/text/IRegion;Lorg/eclipse/wst/jsdt/core/IJavaScriptElement;)V
    //   529: astore 4
    //   531: aload 4
    //   533: areturn
    // Line number table:
    //   Java source line #56	-> byte code offset #0
    //   Java source line #57	-> byte code offset #3
    //   Java source line #59	-> byte code offset #7
    //   Java source line #60	-> byte code offset #14
    //   Java source line #61	-> byte code offset #17
    //   Java source line #62	-> byte code offset #20
    //   Java source line #63	-> byte code offset #23
    //   Java source line #66	-> byte code offset #26
    //   Java source line #67	-> byte code offset #37
    //   Java source line #71	-> byte code offset #42
    //   Java source line #72	-> byte code offset #51
    //   Java source line #75	-> byte code offset #62
    //   Java source line #76	-> byte code offset #64
    //   Java source line #77	-> byte code offset #69
    //   Java source line #79	-> byte code offset #76
    //   Java source line #76	-> byte code offset #79
    //   Java source line #77	-> byte code offset #84
    //   Java source line #82	-> byte code offset #91
    //   Java source line #83	-> byte code offset #94
    //   Java source line #84	-> byte code offset #101
    //   Java source line #86	-> byte code offset #106
    //   Java source line #87	-> byte code offset #113
    //   Java source line #88	-> byte code offset #124
    //   Java source line #89	-> byte code offset #135
    //   Java source line #91	-> byte code offset #144
    //   Java source line #92	-> byte code offset #147
    //   Java source line #91	-> byte code offset #157
    //   Java source line #94	-> byte code offset #178
    //   Java source line #95	-> byte code offset #186
    //   Java source line #96	-> byte code offset #193
    //   Java source line #97	-> byte code offset #200
    //   Java source line #98	-> byte code offset #218
    //   Java source line #99	-> byte code offset #223
    //   Java source line #102	-> byte code offset #235
    //   Java source line #103	-> byte code offset #243
    //   Java source line #104	-> byte code offset #250
    //   Java source line #105	-> byte code offset #257
    //   Java source line #106	-> byte code offset #275
    //   Java source line #107	-> byte code offset #280
    //   Java source line #114	-> byte code offset #292
    //   Java source line #115	-> byte code offset #303
    //   Java source line #116	-> byte code offset #314
    //   Java source line #119	-> byte code offset #334
    //   Java source line #123	-> byte code offset #348
    //   Java source line #124	-> byte code offset #359
    //   Java source line #125	-> byte code offset #370
    //   Java source line #128	-> byte code offset #390
    //   Java source line #132	-> byte code offset #401
    //   Java source line #133	-> byte code offset #411
    //   Java source line #134	-> byte code offset #420
    //   Java source line #135	-> byte code offset #425
    //   Java source line #137	-> byte code offset #456
    //   Java source line #138	-> byte code offset #466
    //   Java source line #139	-> byte code offset #475
    //   Java source line #140	-> byte code offset #480
    //   Java source line #143	-> byte code offset #500
    //   Java source line #144	-> byte code offset #502
    //   Java source line #147	-> byte code offset #515
    //   Java source line #148	-> byte code offset #520
    //   Java source line #151	-> byte code offset #531
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	534	0	this	JSDTHyperlinkDetector
    //   0	534	1	element	IJavaScriptElement
    //   0	534	2	region	IRegion
    //   0	534	3	document	IDocument
    //   1	531	4	link	IHyperlink
    //   15	416	5	file	IFile
    //   18	468	6	outsidePath	org.eclipse.core.runtime.IPath
    //   21	455	7	jspOffset	int
    //   24	61	8	sModel	org.eclipse.wst.sse.core.internal.provisional.IStructuredModel
    //   49	4	9	uriString	String
    //   92	375	9	range	org.eclipse.wst.jsdt.core.ISourceRange
    //   500	11	9	jme	org.eclipse.wst.jsdt.core.JavaScriptModelException
    //   62	15	10	localObject1	Object
    //   99	279	10	jspTranslation	IJsTranslation
    //   133	111	11	unit	IJavaScriptElement
    //   312	8	11	cu	Object
    //   368	8	11	cu	Object
    //   142	111	12	myUnit	org.eclipse.wst.jsdt.core.IJavaScriptUnit
    //   191	33	13	cu	org.eclipse.wst.jsdt.core.IJavaScriptUnit
    //   248	33	13	cu	org.eclipse.wst.jsdt.core.IClassFile
    // Exception table:
    //   from	to	target	type
    //   26	62	62	finally
    //   91	497	500	org/eclipse/wst/jsdt/core/JavaScriptModelException
  }
  
  public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks)
  {
    List hyperlinks = new ArrayList(0);
    if ((region != null) && (textViewer != null))
    {
      IDocument document = textViewer.getDocument();
      IJsTranslation jsTranslation = getJsTranslation(document);
      if (jsTranslation != null)
      {
        IJavaScriptElement[] elements = jsTranslation.getElementsFromJsRange(region.getOffset(), region.getOffset() + region.getLength());
        if ((elements != null) && (elements.length > 0)) {
          for (int i = 0; i < elements.length; i++)
          {
            IJavaScriptElement element = elements[i];
            
            IRegion hyperlinkRegion = selectWord(document, region.getOffset());
            IHyperlink link = createHyperlink(element, hyperlinkRegion, document);
            if (link != null) {
              hyperlinks.add(link);
            }
          }
        }
      }
    }
    if (hyperlinks.size() == 0) {
      return null;
    }
    return (IHyperlink[])hyperlinks.toArray(new IHyperlink[0]);
  }
  
  private IFile getFile(String fileString)
  {
    IFile file = null;
    if (fileString != null)
    {
      IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(fileString);
      if ((resource != null) && ((resource instanceof IFile))) {
        file = (IFile)resource;
      }
    }
    return file;
  }
  
  /* Error */
  private IJsTranslation getJsTranslation(IDocument document)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aconst_null
    //   3: astore_3
    //   4: invokestatic 18	org/eclipse/wst/sse/core/StructuredModelManager:getModelManager	()Lorg/eclipse/wst/sse/core/internal/provisional/IModelManager;
    //   7: aload_1
    //   8: invokeinterface 24 2 0
    //   13: checkcast 259	org/eclipse/wst/xml/core/internal/provisional/document/IDOMModel
    //   16: astore_3
    //   17: aload_3
    //   18: ifnull +55 -> 73
    //   21: aload_3
    //   22: invokeinterface 261 1 0
    //   27: astore 4
    //   29: aload 4
    //   31: ldc 58
    //   33: invokeinterface 264 2 0
    //   38: checkcast 270	org/eclipse/wst/jsdt/web/core/javascript/JsTranslationAdapter
    //   41: astore 5
    //   43: aload 5
    //   45: ifnull +28 -> 73
    //   48: aload 5
    //   50: iconst_1
    //   51: invokevirtual 272	org/eclipse/wst/jsdt/web/core/javascript/JsTranslationAdapter:getJsTranslation	(Z)Lorg/eclipse/wst/jsdt/web/core/javascript/IJsTranslation;
    //   54: astore_2
    //   55: goto +18 -> 73
    //   58: astore 6
    //   60: aload_3
    //   61: ifnull +9 -> 70
    //   64: aload_3
    //   65: invokeinterface 275 1 0
    //   70: aload 6
    //   72: athrow
    //   73: aload_3
    //   74: ifnull +9 -> 83
    //   77: aload_3
    //   78: invokeinterface 275 1 0
    //   83: aload_2
    //   84: areturn
    // Line number table:
    //   Java source line #212	-> byte code offset #0
    //   Java source line #213	-> byte code offset #2
    //   Java source line #215	-> byte code offset #4
    //   Java source line #216	-> byte code offset #17
    //   Java source line #217	-> byte code offset #21
    //   Java source line #218	-> byte code offset #29
    //   Java source line #219	-> byte code offset #43
    //   Java source line #220	-> byte code offset #48
    //   Java source line #223	-> byte code offset #58
    //   Java source line #224	-> byte code offset #60
    //   Java source line #225	-> byte code offset #64
    //   Java source line #227	-> byte code offset #70
    //   Java source line #224	-> byte code offset #73
    //   Java source line #225	-> byte code offset #77
    //   Java source line #228	-> byte code offset #83
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	85	0	this	JSDTHyperlinkDetector
    //   0	85	1	document	IDocument
    //   1	83	2	translation	IJsTranslation
    //   3	75	3	xmlModel	org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel
    //   27	3	4	xmlDoc	org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument
    //   41	8	5	adapter	org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter
    //   58	13	6	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   4	58	58	finally
  }
  
  private IRegion selectWord(IDocument document, int anchor)
  {
    try
    {
      int offset = anchor;
      while (offset >= 0)
      {
        char c = document.getChar(offset);
        if (!Character.isJavaIdentifierPart(c)) {
          break;
        }
        offset--;
      }
      int start = offset;
      offset = anchor;
      int length = document.getLength();
      while (offset < length)
      {
        char c = document.getChar(offset);
        if (!Character.isJavaIdentifierPart(c)) {
          break;
        }
        offset++;
      }
      int end = offset;
      if (start == end) {
        return new Region(start, 0);
      }
      return new Region(start + 1, end - start - 1);
    }
    catch (BadLocationException localBadLocationException) {}
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.web.ui.internal.hyperlink.JSDTHyperlinkDetector
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
import org.eclipse.wst.jsdt.web.ui.internal.Logger;
import org.eclipse.wst.sse.ui.StructuredTextEditor;

class WorkspaceFileHyperlink
  implements IHyperlink
{
  private IFile fFile;
  private IRegion fHighlightRange;
  private IRegion fRegion;
  
  public WorkspaceFileHyperlink(IRegion region, IFile file)
  {
    fRegion = region;
    fFile = file;
  }
  
  public WorkspaceFileHyperlink(IRegion region, IFile file, IRegion range)
  {
    fRegion = region;
    fFile = file;
    fHighlightRange = range;
  }
  
  public IRegion getHyperlinkRegion()
  {
    return fRegion;
  }
  
  public String getHyperlinkText()
  {
    String path = fFile.getFullPath().toString();
    if (path.length() > 60) {
      path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
    }
    return NLS.bind(HTMLUIMessages.Open, path);
  }
  
  public String getTypeLabel()
  {
    return null;
  }
  
  public void open()
  {
    if ((fFile != null) && (fFile.exists())) {
      try
      {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IEditorPart editor = IDE.openEditor(page, fFile, true);
        if ((fHighlightRange != null) && ((editor instanceof ITextEditor)))
        {
          ((ITextEditor)editor).selectAndReveal(fHighlightRange.getOffset(), fHighlightRange.getLength());
        }
        else
        {
          Object ste = editor.getAdapter(StructuredTextEditor.class);
          if ((fHighlightRange != null) && ((ste instanceof ITextEditor))) {
            ((ITextEditor)ste).selectAndReveal(fHighlightRange.getOffset(), fHighlightRange.getLength());
          }
        }
      }
      catch (PartInitException pie)
      {
        Logger.log(202, pie.getMessage(), pie);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.web.ui.internal.hyperlink.WorkspaceFileHyperlink
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;

import com.ibm.icu.util.StringTokenizer;
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
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.IHyperlink;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.URLHyperlink;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.utils.StringUtils;
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.w3c.dom.Attr;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class XMLHyperlinkDetector
  implements IHyperlinkDetector
{
  private final String HTTP_PROTOCOL = "http://";
  private final String NO_NAMESPACE_SCHEMA_LOCATION = "noNamespaceSchemaLocation";
  private final String SCHEMA_LOCATION = "schemaLocation";
  private final String XMLNS = "xmlns";
  private final String XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance";
  
  private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node)
  {
    IHyperlink link = null;
    if (isHttp(uriString))
    {
      link = new URLHyperlink(hyperlinkRegion, uriString);
    }
    else
    {
      File systemFile = getFileFromUriString(uriString);
      if (systemFile != null)
      {
        String systemPath = systemFile.getPath();
        IFile file = getFile(systemPath);
        if (file != null) {
          link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
        } else {
          link = new ExternalFileHyperlink(hyperlinkRegion, systemFile);
        }
      }
    }
    return link;
  }
  
  public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks)
  {
    List hyperlinks = new ArrayList(0);
    if ((region != null) && (textViewer != null))
    {
      IDocument document = textViewer.getDocument();
      Node currentNode = getCurrentNode(document, region.getOffset());
      if (currentNode != null)
      {
        String uriString = null;
        if (currentNode.getNodeType() == 10)
        {
          uriString = getURIString(currentNode, document);
        }
        else if (currentNode.getNodeType() == 1)
        {
          Attr currentAttr = getCurrentAttrNode(currentNode, region.getOffset());
          if (currentAttr != null)
          {
            uriString = getURIString(currentAttr, document);
            if ((uriString == null) || (!isValidURI(uriString))) {
              currentAttr = null;
            }
          }
          if (currentAttr == null)
          {
            currentAttr = getLinkableAttr((Element)currentNode);
            if (currentAttr != null) {
              uriString = getURIString(currentAttr, document);
            }
          }
          currentNode = currentAttr;
        }
        if ((uriString != null) && (currentNode != null) && (isValidURI(uriString)))
        {
          IRegion hyperlinkRegion = getHyperlinkRegion(currentNode);
          IHyperlink hyperlink = createHyperlink(uriString, hyperlinkRegion, document, currentNode);
          if (hyperlink != null) {
            hyperlinks.add(hyperlink);
          }
        }
      }
    }
    if (hyperlinks.size() == 0) {
      return null;
    }
    return (IHyperlink[])hyperlinks.toArray(new IHyperlink[0]);
  }
  
  /* Error */
  private String getBaseLocation(IDocument document)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aconst_null
    //   3: astore_3
    //   4: invokestatic 183	org/eclipse/wst/sse/core/StructuredModelManager:getModelManager	()Lorg/eclipse/wst/sse/core/internal/provisional/IModelManager;
    //   7: aload_1
    //   8: invokeinterface 189 2 0
    //   13: astore_3
    //   14: aload_3
    //   15: ifnull +126 -> 141
    //   18: new 195	org/eclipse/core/runtime/Path
    //   21: dup
    //   22: aload_3
    //   23: invokeinterface 197 1 0
    //   28: invokespecial 201	org/eclipse/core/runtime/Path:<init>	(Ljava/lang/String;)V
    //   31: astore 4
    //   33: aload 4
    //   35: invokeinterface 204 1 0
    //   40: invokevirtual 210	java/io/File:exists	()Z
    //   43: ifeq +14 -> 57
    //   46: aload 4
    //   48: invokeinterface 214 1 0
    //   53: astore_2
    //   54: goto +87 -> 141
    //   57: aload 4
    //   59: invokeinterface 217 1 0
    //   64: iconst_1
    //   65: if_icmple +32 -> 97
    //   68: invokestatic 220	org/eclipse/core/resources/ResourcesPlugin:getWorkspace	()Lorg/eclipse/core/resources/IWorkspace;
    //   71: invokeinterface 226 1 0
    //   76: aload 4
    //   78: invokeinterface 232 2 0
    //   83: invokeinterface 237 1 0
    //   88: invokeinterface 214 1 0
    //   93: astore_2
    //   94: goto +47 -> 141
    //   97: invokestatic 220	org/eclipse/core/resources/ResourcesPlugin:getWorkspace	()Lorg/eclipse/core/resources/IWorkspace;
    //   100: invokeinterface 226 1 0
    //   105: invokeinterface 241 1 0
    //   110: aload 4
    //   112: invokeinterface 242 2 0
    //   117: invokeinterface 214 1 0
    //   122: astore_2
    //   123: goto +18 -> 141
    //   126: astore 5
    //   128: aload_3
    //   129: ifnull +9 -> 138
    //   132: aload_3
    //   133: invokeinterface 246 1 0
    //   138: aload 5
    //   140: athrow
    //   141: aload_3
    //   142: ifnull +9 -> 151
    //   145: aload_3
    //   146: invokeinterface 246 1 0
    //   151: aload_2
    //   152: areturn
    // Line number table:
    //   Java source line #154	-> byte code offset #0
    //   Java source line #156	-> byte code offset #2
    //   Java source line #158	-> byte code offset #4
    //   Java source line #159	-> byte code offset #14
    //   Java source line #160	-> byte code offset #18
    //   Java source line #161	-> byte code offset #33
    //   Java source line #162	-> byte code offset #46
    //   Java source line #164	-> byte code offset #57
    //   Java source line #165	-> byte code offset #68
    //   Java source line #167	-> byte code offset #97
    //   Java source line #171	-> byte code offset #126
    //   Java source line #172	-> byte code offset #128
    //   Java source line #173	-> byte code offset #132
    //   Java source line #175	-> byte code offset #138
    //   Java source line #172	-> byte code offset #141
    //   Java source line #173	-> byte code offset #145
    //   Java source line #176	-> byte code offset #151
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	153	0	this	XMLHyperlinkDetector
    //   0	153	1	document	IDocument
    //   1	151	2	baseLoc	String
    //   3	143	3	sModel	org.eclipse.wst.sse.core.internal.provisional.IStructuredModel
    //   31	80	4	location	org.eclipse.core.runtime.IPath
    //   126	13	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   4	126	126	finally
  }
  
  private CMElementDeclaration getCMElementDeclaration(Element element)
  {
    CMElementDeclaration ed = null;
    ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
    if (mq != null) {
      ed = mq.getCMElementDeclaration(element);
    }
    return ed;
  }
  
  private Attr getCurrentAttrNode(Node node, int offset)
  {
    if (((node instanceof IndexedRegion)) && (((IndexedRegion)node).contains(offset)) && (node.hasAttributes()))
    {
      NamedNodeMap attrs = node.getAttributes();
      for (int i = 0; i < attrs.getLength(); i++)
      {
        IndexedRegion attRegion = (IndexedRegion)attrs.item(i);
        if (attRegion.contains(offset)) {
          return (Attr)attrs.item(i);
        }
      }
    }
    return null;
  }
  
  /* Error */
  private Node getCurrentNode(IDocument document, int offset)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_3
    //   2: aconst_null
    //   3: astore 4
    //   5: invokestatic 183	org/eclipse/wst/sse/core/StructuredModelManager:getModelManager	()Lorg/eclipse/wst/sse/core/internal/provisional/IModelManager;
    //   8: aload_1
    //   9: invokeinterface 189 2 0
    //   14: astore 4
    //   16: aload 4
    //   18: iload_2
    //   19: invokeinterface 309 2 0
    //   24: astore_3
    //   25: aload_3
    //   26: ifnonnull +34 -> 60
    //   29: aload 4
    //   31: iload_2
    //   32: iconst_1
    //   33: isub
    //   34: invokeinterface 309 2 0
    //   39: astore_3
    //   40: goto +20 -> 60
    //   43: astore 5
    //   45: aload 4
    //   47: ifnull +10 -> 57
    //   50: aload 4
    //   52: invokeinterface 246 1 0
    //   57: aload 5
    //   59: athrow
    //   60: aload 4
    //   62: ifnull +10 -> 72
    //   65: aload 4
    //   67: invokeinterface 246 1 0
    //   72: aload_3
    //   73: instanceof 123
    //   76: ifeq +8 -> 84
    //   79: aload_3
    //   80: checkcast 123	org/w3c/dom/Node
    //   83: areturn
    //   84: aconst_null
    //   85: areturn
    // Line number table:
    //   Java source line #228	-> byte code offset #0
    //   Java source line #229	-> byte code offset #2
    //   Java source line #231	-> byte code offset #5
    //   Java source line #232	-> byte code offset #16
    //   Java source line #233	-> byte code offset #25
    //   Java source line #234	-> byte code offset #29
    //   Java source line #236	-> byte code offset #43
    //   Java source line #237	-> byte code offset #45
    //   Java source line #238	-> byte code offset #50
    //   Java source line #240	-> byte code offset #57
    //   Java source line #237	-> byte code offset #60
    //   Java source line #238	-> byte code offset #65
    //   Java source line #241	-> byte code offset #72
    //   Java source line #242	-> byte code offset #79
    //   Java source line #244	-> byte code offset #84
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	86	0	this	XMLHyperlinkDetector
    //   0	86	1	document	IDocument
    //   0	86	2	offset	int
    //   1	79	3	inode	IndexedRegion
    //   3	63	4	sModel	org.eclipse.wst.sse.core.internal.provisional.IStructuredModel
    //   43	15	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   5	43	43	finally
  }
  
  private IFile getFile(String fi
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd