1 19 package org.netbeans.api.gsf; 20 21 import java.net.URL ; 22 23 import javax.swing.text.Document ; 24 25 import org.netbeans.api.gsf.CompilationInfo; 26 import org.netbeans.api.gsf.OffsetRange; 27 import org.netbeans.api.gsf.annotations.CheckForNull; 28 import org.netbeans.api.gsf.annotations.NonNull; 29 import org.netbeans.api.lexer.Token; 30 import org.netbeans.api.lexer.TokenId; 31 import org.openide.filesystems.FileObject; 32 33 34 38 public interface DeclarationFinder { 39 47 @NonNull 48 DeclarationLocation findDeclaration(@NonNull 49 CompilationInfo info, int caretOffset); 50 51 65 @NonNull 66 public OffsetRange getReferenceSpan(@NonNull 67 Document doc, int caretOffset); 68 69 73 public final class DeclarationLocation { 74 75 public static final DeclarationLocation NONE = new DeclarationLocation(null, -1); 76 private final FileObject fileObject; 77 private final int offset; 78 private final URL url; 79 80 public DeclarationLocation(final FileObject fileObject, final int offset) { 81 this.fileObject = fileObject; 82 this.offset = offset; 83 this.url = null; 84 } 85 86 public DeclarationLocation(final URL url) { 87 this.url = url; 88 this.fileObject = null; 89 this.offset = -1; 90 } 91 92 public URL getUrl() { 93 return url; 94 } 95 96 public FileObject getFileObject() { 97 return fileObject; 98 } 99 100 public int getOffset() { 101 return offset; 102 } 103 104 public String toString() { 105 if (this == NONE) { 106 return "NONE"; 107 } 108 109 if (url != null) { 110 return url.toExternalForm(); 111 } 112 113 return fileObject.getNameExt() + ":" + offset; 114 } 115 } 116 } 117 | Popular Tags |