Simplify collection expressions
This commit is contained in:
@@ -32,9 +32,7 @@ public abstract class AbstractPropertySource implements PropertySource {
|
|||||||
* @return a copy of the property descriptors.
|
* @return a copy of the property descriptors.
|
||||||
*/
|
*/
|
||||||
protected List<PropertyDescriptor<?>> copyPropertyDescriptors() {
|
protected List<PropertyDescriptor<?>> copyPropertyDescriptors() {
|
||||||
List<PropertyDescriptor<?>> copy = new ArrayList<>(propertyDescriptors.size());
|
return new ArrayList<>(propertyDescriptors);
|
||||||
copy.addAll(propertyDescriptors);
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,10 +41,7 @@ public abstract class AbstractPropertySource implements PropertySource {
|
|||||||
* @return a copy of the values
|
* @return a copy of the values
|
||||||
*/
|
*/
|
||||||
protected Map<PropertyDescriptor<?>, Object> copyPropertyValues() {
|
protected Map<PropertyDescriptor<?>, Object> copyPropertyValues() {
|
||||||
Map<PropertyDescriptor<?>, Object> copy = new HashMap<>(
|
return new HashMap<>(propertyValuesByDescriptor);
|
||||||
propertyValuesByDescriptor.size());
|
|
||||||
copy.putAll(propertyValuesByDescriptor);
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -7,18 +7,22 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import net.sourceforge.pmd.benchmark.Benchmark;
|
import net.sourceforge.pmd.benchmark.Benchmark;
|
||||||
import net.sourceforge.pmd.benchmark.Benchmarker;
|
import net.sourceforge.pmd.benchmark.Benchmarker;
|
||||||
import net.sourceforge.pmd.lang.*;
|
import net.sourceforge.pmd.lang.Language;
|
||||||
|
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||||
|
import net.sourceforge.pmd.lang.LanguageVersionHandler;
|
||||||
|
import net.sourceforge.pmd.lang.Parser;
|
||||||
|
import net.sourceforge.pmd.lang.VisitorStarter;
|
||||||
import net.sourceforge.pmd.lang.ast.Node;
|
import net.sourceforge.pmd.lang.ast.Node;
|
||||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||||
import net.sourceforge.pmd.lang.xpath.Initializer;
|
import net.sourceforge.pmd.lang.xpath.Initializer;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
public class SourceCodeProcessor {
|
public class SourceCodeProcessor {
|
||||||
|
|
||||||
private final PMDConfiguration configuration;
|
private final PMDConfiguration configuration;
|
||||||
@@ -141,13 +145,10 @@ public class SourceCodeProcessor {
|
|||||||
usesDFA(languageVersion, rootNode, ruleSets, language);
|
usesDFA(languageVersion, rootNode, ruleSets, language);
|
||||||
usesTypeResolution(languageVersion, rootNode, ruleSets,language);
|
usesTypeResolution(languageVersion, rootNode, ruleSets,language);
|
||||||
|
|
||||||
List<Node> acus = new ArrayList<>();
|
List<Node> acus = Collections.singletonList(rootNode);
|
||||||
acus.add(rootNode);
|
|
||||||
ruleSets.apply(acus, ctx, language);
|
ruleSets.apply(acus, ctx, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void determineLanguage(RuleContext ctx) {
|
private void determineLanguage(RuleContext ctx) {
|
||||||
// If LanguageVersion of the source file is not known, make a determination
|
// If LanguageVersion of the source file is not known, make a determination
|
||||||
if (ctx.getLanguageVersion() == null) {
|
if (ctx.getLanguageVersion() == null) {
|
||||||
|
@@ -68,15 +68,11 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<String> copyExamples() {
|
private List<String> copyExamples() {
|
||||||
List<String> copy = new ArrayList<>(examples.size());
|
return new ArrayList<>(examples);
|
||||||
copy.addAll(examples);
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> copyRuleChainVisits() {
|
private List<String> copyRuleChainVisits() {
|
||||||
List<String> copy = new ArrayList<>(ruleChainVisits.size());
|
return new ArrayList<>(ruleChainVisits);
|
||||||
copy.addAll(ruleChainVisits);
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user