01: package org.netbeans.modules.ruby.elements;
02:
03: import java.util.Collections;
04: import java.util.Set;
05: import org.jruby.ast.Node;
06:
07: import org.jruby.ast.SymbolNode;
08: import org.jruby.ast.types.INameNode;
09: import org.netbeans.modules.gsf.api.CompilationInfo;
10: import org.netbeans.modules.gsf.api.ElementKind;
11: import org.netbeans.modules.gsf.api.Modifier;
12:
13: public class AstAttributeElement extends AstElement {
14: SymbolNode symbolNode;
15: Node creationNode;
16:
17: public AstAttributeElement(CompilationInfo info, SymbolNode node,
18: Node creationNode) {
19: super (info, node);
20: this .symbolNode = node;
21: this .creationNode = creationNode;
22: }
23:
24: public boolean isReadOnly() {
25: if (creationNode == null
26: || !(creationNode instanceof INameNode)) {
27: return false;
28: } else {
29: String n = ((INameNode) creationNode).getName();
30: return n.indexOf("writer") == -1
31: && n.indexOf("accessor") == -1; // NOI18N
32: }
33: }
34:
35: public Node getCreationNode() {
36: return creationNode;
37: }
38:
39: @Override
40: public String getName() {
41: return symbolNode.getName();
42: }
43:
44: public Set<Modifier> getModifiers() {
45: // TODO compute!
46: return Collections.emptySet();
47: }
48:
49: @Override
50: public ElementKind getKind() {
51: return ElementKind.ATTRIBUTE;
52: }
53: }
|