Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
package org.sonar.java.checks.helpers;

import com.google.common.io.Files;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.sonar.java.model.JParser;
import org.sonar.java.model.JParserConfig;
import org.sonar.plugins.java.api.JavaVersion;
import org.sonar.plugins.java.api.tree.*;
Expand Down Expand Up @@ -77,7 +74,7 @@ public static CompilationUnitTree parse(File file) {
public static CompilationUnitTree parse(String source) {
List<File> classpath = Arrays.asList(new File("target/test-classes"), new File("target/classes"));
JavaVersion version = JParserConfig.MAXIMUM_SUPPORTED_JAVA_VERSION;
return JParser.parse(JParserConfig.Mode.FILE_BY_FILE.create(version, classpath).astParser(), version.toString(), "test", source);
return JParserConfig.Mode.FILE_BY_FILE.create(version, classpath).parse("test", source);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.sonar.java.model.JParser;
import org.sonar.java.model.JParserConfig;
import org.sonar.plugins.java.api.JavaVersion;
import org.sonar.plugins.java.api.tree.AssignmentExpressionTree;
Expand Down Expand Up @@ -85,7 +84,7 @@ public static CompilationUnitTree parse(File file) {
public static CompilationUnitTree parse(String source) {
List<File> classpath = Arrays.asList(new File("target/test-classes"), new File("target/classes"));
JavaVersion version = JParserConfig.MAXIMUM_SUPPORTED_JAVA_VERSION;
return JParser.parse(JParserConfig.Mode.FILE_BY_FILE.create(version, classpath).astParser(), version.toString(), "test", source);
return JParserConfig.Mode.FILE_BY_FILE.create(version, classpath).parse("test", source);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.sonar.api.batch.fs.InputFile;
import org.sonar.java.SonarComponents;
import org.sonar.java.checks.verifier.TestUtils;
import org.sonar.java.model.JParser;
import org.sonar.java.model.JParserConfig;
import org.sonar.java.model.VisitorsBridge;
import org.sonar.java.model.springcontext.BeanDefinitionGatherer;
Expand Down Expand Up @@ -174,6 +173,6 @@ private static CompilationUnitTree parse(File file, List<File> classpath) {
throw new IllegalStateException("Unable to read file '" + file.getAbsolutePath() + "'", e);
}
JavaVersion version = JParserConfig.MAXIMUM_SUPPORTED_JAVA_VERSION;
return JParser.parse(JParserConfig.Mode.FILE_BY_FILE.create(version, classpath).astParser(), version.toString(), file.getName(), source);
return JParserConfig.Mode.FILE_BY_FILE.create(version, classpath).parse(file.getName(), source);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private void scanInBatches(BatchModeContext context, List<InputFile> allInputFil
}
}

private <T extends InputFile> void scanBatch(BatchModeContext context, List<T> batchFiles, AnalysisProgress analysisProgress) {
private void scanBatch(BatchModeContext context, List<InputFile> batchFiles, AnalysisProgress analysisProgress) {
analysisProgress.startBatch(batchFiles.size());
Set<Runnable> environmentsCleaners = new HashSet<>();
JParserConfig.Mode.BATCH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void scanForTesting(Iterable<? extends InputFile> inputFiles, Consumer<Co
}

private void scan(Iterable<? extends InputFile> inputFiles, Consumer<CompilationUnitTree> modifyCompilationUnit) {
List<? extends InputFile> filesNames = filterModuleInfo(inputFiles).toList();
List<InputFile> filesNames = filterModuleInfo(inputFiles).collect(Collectors.toList());
AnalysisProgress analysisProgress = new AnalysisProgress(filesNames.size());
try {
boolean shouldIgnoreUnnamedModuleForSplitPacakge = sonarComponents != null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* You should have received a copy of the Sonar Source-Available License
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
package org.sonar.java.model;
package org.sonar.java.jdt;

import java.util.Collections;
import java.util.List;
import org.sonar.java.model.Symbols;
import org.sonar.plugins.java.api.semantic.Symbol;
import org.sonar.plugins.java.api.semantic.SymbolMetadata;
import org.sonar.plugins.java.api.semantic.Type;
Expand All @@ -29,11 +30,11 @@
* defined inside an initializer block can have an owner other than the containing class. This is necessary to properly
* detect them as local variables.
*/
final class JInitializerBlockSymbol implements Symbol.MethodSymbol {
final class JDTInitializerBlockSymbol implements Symbol.MethodSymbol {
private final TypeSymbol owner;
private final boolean isStatic;

public JInitializerBlockSymbol(TypeSymbol owner, boolean isStatic) {
public JDTInitializerBlockSymbol(TypeSymbol owner, boolean isStatic) {
this.owner = owner;
this.isStatic = isStatic;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the Sonar Source-Available License
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
package org.sonar.java.model;
package org.sonar.java.jdt;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -33,7 +33,7 @@
import org.sonar.plugins.java.api.tree.MethodTree;
import org.sonar.plugins.java.api.tree.VariableTree;

final class JMethodSymbol extends JSymbol implements Symbol.MethodSymbol {
final class JDTMethodSymbol extends JDTSymbol implements Symbol.MethodSymbol {

/**
* Cache for {@link #parameterTypes()}.
Expand All @@ -59,7 +59,7 @@ final class JMethodSymbol extends JSymbol implements Symbol.MethodSymbol {

private final String signature;

JMethodSymbol(JSema sema, IMethodBinding methodBinding) {
JDTMethodSymbol(JDTSema sema, IMethodBinding methodBinding) {
super(sema, methodBinding);
this.signature = methodBinding().getDeclaringClass().getBinaryName()
+ "#" + name()
Expand Down Expand Up @@ -93,7 +93,7 @@ public List<Symbol> declarationParameters() {
IMethodBinding methodBinding = methodBinding();
ITypeBinding[] parameterTypeBindings = methodBinding.getParameterTypes();
for (int i = 0; i < parameterTypeBindings.length; i++) {
parameters.add(new JVariableSymbol.ParameterPlaceholderSymbol(i, sema, methodBinding.getMethodDeclaration(), parameterTypeBindings[i]));
parameters.add(new JDTVariableSymbol.ParameterPlaceholderSymbol(i, sema, methodBinding.getMethodDeclaration(), parameterTypeBindings[i]));
}
}
}
Expand Down Expand Up @@ -183,6 +183,12 @@ public boolean isParametrizedMethod() {
return !isUnknown() && (methodBinding().isParameterizedMethod() || methodBinding().isGenericMethod());
}

@Nullable
@Override
public Object annotationElementDefaultValue() {
return isUnknown() ? null : JDTSymbolMetadata.convertAnnotationValue(sema, methodBinding().getDefaultValue());
}

@Override
public boolean isDefaultMethod() {
return !isUnknown() && Modifier.isDefault(binding.getModifiers());
Expand Down
Loading
Loading