Skip to content

Commit 5f0b5ec

Browse files
AmitKumarDeoghoriaromani
authored andcommitted
minor: Added Noncompilable RootNode Abstract method
1 parent 296a360 commit 5f0b5ec

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/java/com/puppycrawl/tools/checkstyle/AbstractModuleTestSupport.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@
4545
import com.puppycrawl.tools.checkstyle.LocalizedMessage.Utf8Control;
4646
import com.puppycrawl.tools.checkstyle.api.AuditListener;
4747
import com.puppycrawl.tools.checkstyle.api.Configuration;
48+
import com.puppycrawl.tools.checkstyle.api.DetailAST;
4849
import com.puppycrawl.tools.checkstyle.bdd.InlineConfigParser;
4950
import com.puppycrawl.tools.checkstyle.bdd.TestInputConfiguration;
5051
import com.puppycrawl.tools.checkstyle.bdd.TestInputViolation;
5152
import com.puppycrawl.tools.checkstyle.internal.utils.BriefUtLogger;
5253
import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
5354
import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
5455
import com.puppycrawl.tools.checkstyle.utils.ModuleReflectionUtil;
56+
import com.puppycrawl.tools.checkstyle.xpath.RootNode;
5557

5658
public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport {
5759

@@ -180,6 +182,19 @@ protected final String getNonCompilablePath(String filename) throws IOException
180182
+ filename).getCanonicalPath();
181183
}
182184

185+
/**
186+
* Creates a RootNode for non-compilable test files.
187+
*
188+
* @param fileName name of the test file
189+
* @return RootNode for the parsed AST
190+
* @throws Exception if file parsing fails
191+
*/
192+
protected RootNode getRootNodeForNonCompilable(String fileName) throws Exception {
193+
final File file = new File(getNonCompilablePath(fileName));
194+
final DetailAST rootAst = JavaParser.parseFile(file, JavaParser.Options.WITHOUT_COMMENTS);
195+
return new RootNode(rootAst);
196+
}
197+
183198
/**
184199
* Returns URI-representation of the path for the given file name.
185200
* The path is formed base on the root location.

0 commit comments

Comments
 (0)