KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > RubyParseResult


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.ruby;
20
21 import java.util.List JavaDoc;
22 import java.util.Set JavaDoc;
23 import org.jruby.ast.Node;
24 import org.jruby.ast.RootNode;
25 import org.jruby.parser.RubyParserResult;
26 import org.netbeans.api.gsf.Element;
27 import org.netbeans.api.gsf.ParserFile;
28 import org.netbeans.api.gsf.ParserResult;
29 import org.netbeans.modules.ruby.elements.AstElement;
30 import org.netbeans.modules.ruby.elements.AstRootElement;
31
32
33 /**
34  *
35  * @author Tor Norbye
36  */

37 public class RubyParseResult extends ParserResult {
38     //private Iterable<?extends ComFile> files;
39
private AstTreeNode ast;
40     private Node root;
41     private RootNode realRoot;
42     private AstRootElement rootElement;
43     private String JavaDoc source;
44     private boolean sanitizedSource;
45     private List JavaDoc<Element> structureList;
46     private Set JavaDoc<String JavaDoc> requires;
47     private RubyParserResult jrubyResult;
48     private boolean commentsAdded;
49
50     /** Result used for failed compilation
51      * @todo Provide errors too?
52      */

53     public RubyParseResult(ParserFile file) {
54         super(file);
55     }
56
57     /**
58      * Result used for successful compilation
59      */

60     public RubyParseResult(ParserFile file, AstRootElement rootElement, AstTreeNode ast, Node root,
61         RootNode realRoot, RubyParserResult jrubyResult) {
62         super(file);
63         this.rootElement = rootElement;
64         this.ast = ast;
65         this.root = root;
66         this.realRoot = realRoot;
67         this.jrubyResult = jrubyResult;
68     }
69
70     public ParserResult.AstTreeNode getAst() {
71         return ast;
72     }
73
74     public void setAst(AstTreeNode ast) {
75         this.ast = ast;
76     }
77
78     @Override JavaDoc
79     public Element getRoot() {
80         return rootElement;
81     }
82
83     /** The root node of the AST produced by the parser.
84      * Later, rip out the getAst part etc.
85      */

86     public Node getRootNode() {
87         return root;
88     }
89
90     public Node getRealRoot() {
91         return realRoot;
92     }
93
94     public String JavaDoc getSource() {
95         return source;
96     }
97
98     public void setSource(String JavaDoc source) {
99         this.source = source;
100     }
101
102     /**
103      * Return whether the source code for the parse result was "cleaned"
104      * or "sanitized" (modified to reduce chance of parser errors) or not
105      */

106     public boolean isSanitizedSource() {
107         return sanitizedSource;
108     }
109
110     /**
111      * Set whether the source code for the parse result was "cleaned"
112      * or sanitized (modified to reduce chance of parser errors) or not
113      */

114     public void setSanitizedSource(boolean sanitizedSource) {
115         this.sanitizedSource = sanitizedSource;
116     }
117     
118     public RubyParserResult getJRubyResult() {
119         return jrubyResult;
120     }
121
122     public void setStructure(List JavaDoc<Element> structureList) {
123         this.structureList = structureList;
124     }
125
126     public List JavaDoc<?extends Element> getStructure() {
127         return structureList;
128     }
129
130     public Set JavaDoc<String JavaDoc> getRequires() {
131         return requires;
132     }
133
134     public void setRequires(Set JavaDoc<String JavaDoc> requires) {
135         this.requires = requires;
136     }
137     
138     public boolean isCommentsAdded() {
139         return commentsAdded;
140     }
141     
142     public void setCommentsAdded(boolean commentsAdded) {
143         this.commentsAdded = commentsAdded;
144     }
145 }
146
Popular Tags