Fix some details
This commit is contained in:
@@ -32,7 +32,7 @@ public final class ASTApexFile extends AbstractApexNode<AstNode> implements Root
|
||||
Map<Integer, String> suppressMap,
|
||||
@NonNull ApexLanguageProcessor apexLang) {
|
||||
super(jorjeNode);
|
||||
this.astInfo = new AstInfo<>(task, this, suppressMap);
|
||||
this.astInfo = new AstInfo<>(task, this).withSuppressMap(suppressMap);
|
||||
this.multifileAnalysis = apexLang.getMultiFileState();
|
||||
this.setRegion(TextRegion.fromOffsetLength(0, task.getTextDocument().getLength()));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import net.sourceforge.pmd.RuleSets;
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.cache.AnalysisCache;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
@@ -68,6 +69,11 @@ public interface LanguageProcessor extends AutoCloseable {
|
||||
private final LanguageProcessorRegistry lpRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new task. This constructor is internal and will be
|
||||
* called by PMD.
|
||||
*/
|
||||
@InternalApi
|
||||
public AnalysisTask(RuleSets rulesets,
|
||||
List<TextFile> files,
|
||||
GlobalAnalysisListener listener,
|
||||
|
||||
@@ -7,6 +7,7 @@ package net.sourceforge.pmd.lang;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -68,18 +69,29 @@ public final class LanguageRegistry implements Iterable<Language> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a language registry containing the given languages and
|
||||
* their dependencies, fetched from this language registry or the
|
||||
* Creates a language registry containing the given language and
|
||||
* its dependencies, fetched from this language registry or the
|
||||
* parameter.
|
||||
*
|
||||
* @throws IllegalStateException If dependencies cannot be fulfilled.
|
||||
*/
|
||||
public LanguageRegistry getDependenciesOf(Language lang) {
|
||||
Set<Language> dependencies =
|
||||
lang.getDependencies().stream()
|
||||
.map(this::getLanguageById)
|
||||
.collect(CollectionUtil.toMutableSet());
|
||||
dependencies.add(lang);
|
||||
Set<Language> result = new HashSet<>();
|
||||
addDepsOrThrow(lang, result);
|
||||
return new LanguageRegistry(result);
|
||||
}
|
||||
|
||||
return new LanguageRegistry(dependencies);
|
||||
private void addDepsOrThrow(Language l, Set<Language> languages) {
|
||||
for (String depId : l.getDependencies()) {
|
||||
Language dep = getLanguageById(depId);
|
||||
if (dep == null) {
|
||||
throw new IllegalStateException(
|
||||
"Cannot find language " + depId + " in " + this);
|
||||
}
|
||||
if (languages.add(dep)) {
|
||||
addDepsOrThrow(dep, languages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,11 +30,7 @@ public final class AstInfo<T extends RootNode> {
|
||||
|
||||
|
||||
public AstInfo(ParserTask task, T rootNode) {
|
||||
this(task, rootNode, Collections.emptyMap());
|
||||
}
|
||||
|
||||
public AstInfo(ParserTask task, T rootNode, Map<Integer, String> suppressionComments) {
|
||||
this(task.getTextDocument(), rootNode, task.getLpRegistry(), suppressionComments);
|
||||
this(task.getTextDocument(), rootNode, task.getLpRegistry(), Collections.emptyMap());
|
||||
}
|
||||
|
||||
private AstInfo(TextDocument textDocument,
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class ASTHtmlDocument extends ASTHtmlElement implements RootNode {
|
||||
Parser.ParserTask task,
|
||||
Map<Integer, String> suppressMap) {
|
||||
super(document);
|
||||
this.astInfo = new AstInfo<>(task, this, suppressMap);
|
||||
this.astInfo = new AstInfo<>(task, this).withSuppressMap(suppressMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,7 +55,7 @@ public class JavaParser extends JjtreeParserAdapter<ASTCompilationUnit> {
|
||||
parser.setPreview(preview);
|
||||
|
||||
ASTCompilationUnit root = parser.CompilationUnit();
|
||||
root.setAstInfo(new AstInfo<>(task, root, parser.getSuppressMap()));
|
||||
root.setAstInfo(new AstInfo<>(task, root).withSuppressMap(parser.getSuppressMap()));
|
||||
|
||||
LanguageLevelChecker<?> levelChecker =
|
||||
new LanguageLevelChecker<>(jdkVersion,
|
||||
|
||||
@@ -70,7 +70,7 @@ public final class EcmascriptParser implements net.sourceforge.pmd.lang.ast.Pars
|
||||
}
|
||||
}
|
||||
}
|
||||
tree.setAstInfo(new AstInfo<>(task, tree, suppressMap));
|
||||
tree.setAstInfo(new AstInfo<>(task, tree).withSuppressMap(suppressMap));
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user