Now a rule can access the SourceType via the RuleContext

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4715 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-10-20 15:38:09 +00:00
parent 5fb4c57b46
commit 2fb2fcd14d
2 changed files with 11 additions and 2 deletions

View File

@ -56,7 +56,7 @@ public class PMD {
}
/**
* Processes the file read by the reader agains the rule set.
* Processes the file read by the reader against the rule set.
*
* @param reader input stream reader
* @param ruleSets set of rules to process against the file
@ -69,12 +69,12 @@ public class PMD {
SourceType sourceType) throws PMDException {
try {
SourceTypeHandler sourceTypeHandler = sourceTypeHandlerBroker.getVisitorsFactoryForSourceType(sourceType);
ctx.setSourceType(sourceType);
Parser parser = sourceTypeHandler.getParser();
parser.setExcludeMarker(excludeMarker);
Object rootNode = parser.parse(reader);
ctx.excludeLines(parser.getExcludeMap());
Thread.yield();
// TODO - move SymbolFacade traversal inside JavaParser.CompilationUnit()
sourceTypeHandler.getSymbolFacade().start(rootNode);
Language language = SourceTypeToRuleLanguageMapper.getMappedLanguage(sourceType);

View File

@ -9,6 +9,7 @@ public class RuleContext {
private Report report = new Report();
private String sourceCodeFilename;
private SourceType sourceType;
public Report getReport() {
return report;
@ -29,4 +30,12 @@ public class RuleContext {
public void excludeLines(Map lines) {
report.exclude(lines);
}
public SourceType getSourceType() {
return this.sourceType;
}
public void setSourceType(SourceType t) {
this.sourceType = t;
}
}