1 19 package org.netbeans.modules.ruby.elements; 20 21 import java.util.Set ; 22 import org.netbeans.api.gsf.ElementKind; 23 import org.netbeans.api.gsf.Modifier; 24 import org.netbeans.modules.ruby.RubyIndex; 25 import org.netbeans.modules.ruby.elements.IndexedElement; 26 27 28 34 public final class IndexedClass extends IndexedElement implements ClassElement { 35 boolean isModule; 36 private String in; 37 private String attributes; 38 private int docLength = -1; 39 40 protected IndexedClass(String signature, RubyIndex index, String fileUrl, String fqn, String clz, 41 String require, boolean isModule, Set <Modifier> modifiers, String attributes) { 42 super(signature, index, fileUrl, fqn, clz, require, modifiers); 43 this.isModule = isModule; 44 this.attributes = attributes; 45 } 46 47 public static IndexedClass create(RubyIndex index, String clz, String fqn, String fileUrl, 48 String require, boolean isModule, Set <Modifier> modifiers, String attributes) { 49 IndexedClass c = new IndexedClass(fqn, index, fileUrl, fqn, clz, 50 require, isModule, modifiers, attributes); 51 52 return c; 53 } 54 55 public String getIn() { 56 if (in == null) { 57 if (fqn.endsWith("::" + clz)) { 58 in = fqn.substring(0, fqn.length() - (clz.length() + 2)); 59 } else if ((require != null) && (require.length() > 0)) { 60 in = require; 62 } 63 } 64 65 return in; 66 } 67 68 public String getSignature() { 70 return fqn; 71 } 72 73 public String getName() { 74 return getClz(); 75 } 76 77 public ElementKind getKind() { 78 return isModule ? ElementKind.MODULE : ElementKind.CLASS; 79 } 80 81 public Set <String > getIncludes() { 82 return null; 83 } 84 85 86 public int getDocumentationLength() { 87 if (docLength == -1) { 88 docLength = 0; 89 if (attributes != null) { 90 int index = attributes.indexOf('('); 91 if (index != -1) { 92 docLength = Integer.parseInt(attributes.substring(index+1, attributes.indexOf(')',index+1))); 93 } 94 } 95 } 96 97 return docLength; 98 } 99 } 100 | Popular Tags |