1 package org.netbeans.modules.ruby.elements; 2 3 import java.util.Set ; 4 import org.jruby.ast.ClassNode; 5 import org.jruby.ast.Colon2Node; 6 import org.jruby.ast.Node; 7 import org.netbeans.api.gsf.ElementKind; 8 9 10 public class AstClassElement extends AstElement implements ClassElement { 11 private String fqn; 12 private Set <String > includes; 13 14 public AstClassElement(Node node) { 15 super(node); 16 } 17 18 @Override 19 public String getName() { 20 if (name == null) { 21 if (node instanceof ClassNode) { 22 Node n = ((ClassNode)node).getCPath(); 23 24 if (n instanceof Colon2Node) { 25 Colon2Node c2n = (Colon2Node)n; 26 name = c2n.getName(); 27 } else { 28 name = n.toString(); 29 } 30 } 31 32 if (name == null) { 33 name = node.toString(); 34 } 35 } 36 37 return name; 38 } 39 40 public String getFqn() { 41 if (fqn == null) { 42 return getName(); 43 } 44 return fqn; 45 } 46 47 public void setFqn(String fqn) { 48 this.fqn = fqn; 49 } 50 51 public void setIncludes(Set <String > includes) { 52 this.includes = includes; 53 } 54 55 public Set <String > getIncludes() { 56 return includes; 57 } 58 59 @Override 60 public ElementKind getKind() { 61 return ElementKind.CLASS; 62 } 63 } 64 | Popular Tags |