1 19 package org.netbeans.modules.ruby.elements; 20 21 import java.io.IOException ; 22 import java.util.Set ; 23 24 import javax.swing.text.Document ; 25 26 import org.netbeans.api.gsf.ParserFile; 27 import org.netbeans.api.gsf.Modifier; 28 import org.netbeans.modules.ruby.AstUtilities; 29 import org.netbeans.modules.ruby.RubyIndex; 30 import org.netbeans.spi.gsf.DefaultParserFile; 31 import org.openide.filesystems.FileObject; 32 33 34 39 public abstract class IndexedElement extends RubyElement { 40 protected final String signature; 41 protected String fileUrl; 42 protected final String clz; 43 protected final String fqn; 44 protected final RubyIndex index; 45 protected final String require; 46 protected final Set <Modifier> modifiers; 47 private Document document; 48 private FileObject fileObject; 49 50 protected IndexedElement(String signature, RubyIndex index, String fileUrl, String fqn, 51 String clz, String require, Set <Modifier> modifiers) { 52 this.signature = signature; 53 this.index = index; 54 this.fileUrl = fileUrl; 55 this.fqn = fqn; 56 this.require = require; 57 this.modifiers = modifiers; 58 this.clz = clz; 60 } 61 62 public String getSignature() { 63 return signature; 64 } 65 66 public final String getFileUrl() { 67 return fileUrl; 68 } 69 70 public final String getRequire() { 71 return require; 72 } 73 74 public final String getFqn() { 75 return fqn; 76 } 77 78 @Override 79 public String toString() { 80 return getSignature() + ":" + getFileUrl(); 81 } 82 83 public final String getClz() { 84 return clz; 85 } 86 87 public RubyIndex getIndex() { 88 return index; 89 } 90 91 public String getIn() { 92 return getClz(); 93 } 94 95 public String getFilenameUrl() { 96 return fileUrl; 97 } 98 99 public Document getDocument() throws IOException { 100 if (document == null) { 101 FileObject fo = getFileObject(); 102 103 if (fo == null) { 104 return null; 105 } 106 107 document = AstUtilities.getBaseDocument(fileObject, true); 108 } 109 110 return document; 111 } 112 113 public ParserFile getFile() { 114 boolean platform = false; 116 return new DefaultParserFile(getFileObject(), null, platform); 117 } 118 119 public FileObject getFileObject() { 120 if ((fileObject == null) && (fileUrl != null)) { 121 fileObject = RubyIndex.getFileObject(fileUrl); 122 123 if (fileObject == null) { 124 fileUrl = null; 126 } 127 } 128 129 return fileObject; 130 } 131 132 public Set <Modifier> getModifiers() { 133 return modifiers; 134 } 135 } 136 | Popular Tags |