Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2017-04-13 21:06:01 +02:00
277 changed files with 1956 additions and 1056 deletions
@@ -28,6 +28,8 @@ import org.intellij.lang.regexp.psi.*;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import java.util.stream.Stream;
/**
* @author Bas Leijdekkers
*/
@@ -60,17 +62,19 @@ public class SingleCharAlternationInspection extends LocalInspectionTool {
if (branches.length < 2) {
return;
}
for (RegExpBranch branch : branches) {
final RegExpAtom[] atoms = branch.getAtoms();
if (atoms.length != 1 || !(atoms[0] instanceof RegExpChar)) {
return;
}
if (!Stream.of(branches).allMatch(SingleCharAlternationVisitor::isSingleChar)) {
return;
}
final String text = buildReplacementText(pattern);
//noinspection DialogTitleCapitalization
myHolder.registerProblem(pattern, "Single character alternation in RegExp", new SingleCharAlternationFix(text));
}
private static boolean isSingleChar(RegExpBranch branch) {
final RegExpAtom[] atoms = branch.getAtoms();
return atoms.length == 1 && atoms[0] instanceof RegExpChar;
}
private static class SingleCharAlternationFix implements LocalQuickFix {
private final String myText;
+2 -2
View File
@@ -1,5 +1,5 @@
#The file might be automatically updated. Comments and empty lines will be removed.
#Mon Apr 10 12:16:24 MSK 2017
#Thu Apr 13 15:04:25 MSK 2017
kotlinPluginBuild=1.1.2-eap-69-IJ2017.2-1:EAP-1.1
jetSignBuild=42.30
jdkBuild=u152b819.1
jdkBuild=u152b819.2
+6 -1
View File
@@ -47,7 +47,12 @@ jrePlatformsToDownload(targetOs).each { platform ->
doFirst { exec { commandLine 'mkdir', '-p', outputDir } }
commandLine 'tar', '-xpf', "${downloadOutputs.singleFile.absolutePath}", '--directory', outputDir
if (platform != 'osx') {
doLast { exec { commandLine 'mv', "$outputDir/lib/tools.jar", "$outputDir/jre/lib/" } }
doLast {
exec {
commandLine 'mv', "$outputDir/lib/tools.jar", "$outputDir/jre/lib/"
ignoreExitValue = true
}
}
}
}
}
@@ -117,7 +117,7 @@ abstract class BaseIdeaProperties extends ProductProperties {
}
}
context.ant.copy(todir: "$targetDirectory/plugins/Kotlin") {
fileset(dir: "$context.paths.communityHome/build/dependencies/build/kotlin/Kotlin")
fileset(dir: "$context.paths.kotlinHome")
}
context.ant.move(file: "$targetDirectory/lib/annotations-java8.jar", tofile: "$targetDirectory/redist/annotations-java8.jar")
}
@@ -15,16 +15,14 @@
*/
package com.intellij.debugger.engine.evaluation.expression;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Couple;
import com.intellij.psi.CommonClassNames;
import com.intellij.psi.impl.PsiJavaParserFacadeImpl;
import com.intellij.util.containers.HashMap;
import com.sun.jdi.ClassType;
import com.sun.jdi.Method;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.Value;
import com.sun.jdi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -35,7 +33,9 @@ import java.util.Map;
* @author Eugene Zhuravlev
* Date: Feb 8, 2010
*/
public class UnBoxingEvaluator implements Evaluator{
public class UnBoxingEvaluator implements Evaluator {
private static final Logger LOG = Logger.getInstance(UnBoxingEvaluator.class);
private final Evaluator myOperand;
private static final Map<String, Couple<String>> TYPES_TO_CONVERSION_METHOD_MAP = new HashMap<>();
static {
@@ -77,14 +77,32 @@ public class UnBoxingEvaluator implements Evaluator{
private static Value convertToPrimitive(EvaluationContextImpl context, ObjectReference value, final String conversionMethodName,
String conversionMethodSignature) throws EvaluateException {
final DebugProcessImpl process = context.getDebugProcess();
final ClassType wrapperClass = (ClassType)value.referenceType();
Method method = wrapperClass.concreteMethodByName(conversionMethodName, conversionMethodSignature);
// for speedup first try value field
Value primitiveValue = getInnerPrimitiveValue(value);
if (primitiveValue != null) {
return primitiveValue;
}
Method method = ((ClassType)value.referenceType()).concreteMethodByName(conversionMethodName, conversionMethodSignature);
if (method == null) {
throw new EvaluateException("Cannot convert to primitive value of type " + value.type() + ": Unable to find method " +
conversionMethodName + conversionMethodSignature);
}
return process.invokeMethod(context, value, method, Collections.emptyList());
return context.getDebugProcess().invokeMethod(context, value, method, Collections.emptyList());
}
@Nullable
public static PrimitiveValue getInnerPrimitiveValue(ObjectReference value) {
ReferenceType type = value.referenceType();
Field valueField = type.fieldByName("value");
if (valueField != null) {
Value primitiveValue = value.getValue(valueField);
if (primitiveValue instanceof PrimitiveValue) {
LOG.assertTrue(type.name().equals(PsiJavaParserFacadeImpl.getPrimitiveType(primitiveValue.type().name()).getBoxedTypeName()));
return (PrimitiveValue)primitiveValue;
}
}
return null;
}
}
@@ -0,0 +1,99 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.tree.render;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContext;
import com.intellij.debugger.engine.evaluation.expression.UnBoxingEvaluator;
import com.intellij.debugger.settings.NodeRendererSettings;
import com.intellij.debugger.ui.tree.ValueDescriptor;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.CommonClassNames;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ReferenceType;
import com.sun.jdi.Type;
/**
* @author egor
*/
public abstract class UnboxableTypeRenderer extends CompoundReferenceRenderer {
public UnboxableTypeRenderer(String className, NodeRendererSettings rendererSettings) {
super(rendererSettings, StringUtil.getShortName(className), new LabelRenderer() {
@Override
public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener)
throws EvaluateException {
return DebuggerUtils.getValueAsString(evaluationContext, UnBoxingEvaluator.getInnerPrimitiveValue((ObjectReference)descriptor.getValue()));
}
}, null);
LOG.assertTrue(UnBoxingEvaluator.isTypeUnboxable(className));
setClassName(className);
setEnabled(true);
}
@Override
public boolean isApplicable(Type type) {
return type instanceof ReferenceType && StringUtil.equals(type.name(), getClassName());
}
public static class BooleanRenderer extends UnboxableTypeRenderer {
public BooleanRenderer(NodeRendererSettings rendererSettings) {
super(CommonClassNames.JAVA_LANG_BOOLEAN, rendererSettings);
}
}
public static class ByteRenderer extends UnboxableTypeRenderer {
public ByteRenderer(NodeRendererSettings rendererSettings) {
super(CommonClassNames.JAVA_LANG_BYTE, rendererSettings);
}
}
public static class CharacterRenderer extends UnboxableTypeRenderer {
public CharacterRenderer(NodeRendererSettings rendererSettings) {
super(CommonClassNames.JAVA_LANG_CHARACTER, rendererSettings);
}
}
public static class ShortRenderer extends UnboxableTypeRenderer {
public ShortRenderer(NodeRendererSettings rendererSettings) {
super(CommonClassNames.JAVA_LANG_SHORT, rendererSettings);
}
}
public static class IntegerRenderer extends UnboxableTypeRenderer {
public IntegerRenderer(NodeRendererSettings rendererSettings) {
super(CommonClassNames.JAVA_LANG_INTEGER, rendererSettings);
}
}
public static class LongRenderer extends UnboxableTypeRenderer {
public LongRenderer(NodeRendererSettings rendererSettings) {
super(CommonClassNames.JAVA_LANG_LONG, rendererSettings);
}
}
public static class FloatRenderer extends UnboxableTypeRenderer {
public FloatRenderer(NodeRendererSettings rendererSettings) {
super(CommonClassNames.JAVA_LANG_FLOAT, rendererSettings);
}
}
public static class DoubleRenderer extends UnboxableTypeRenderer {
public DoubleRenderer(NodeRendererSettings rendererSettings) {
super(CommonClassNames.JAVA_LANG_DOUBLE, rendererSettings);
}
}
}
@@ -72,20 +72,19 @@ public abstract class DebuggerUtils {
return ((StringReference)value).value();
}
if (isInteger(value)) {
long v = ((PrimitiveValue)value).longValue();
return String.valueOf(v);
return String.valueOf(((PrimitiveValue)value).longValue());
}
if (isNumeric(value)) {
double v = ((PrimitiveValue)value).doubleValue();
return String.valueOf(v);
if (value instanceof FloatValue) {
return String.valueOf(((FloatValue)value).floatValue());
}
if (value instanceof DoubleValue) {
return String.valueOf(((DoubleValue)value).doubleValue());
}
if (value instanceof BooleanValue) {
boolean v = ((PrimitiveValue)value).booleanValue();
return String.valueOf(v);
return String.valueOf(((PrimitiveValue)value).booleanValue());
}
if (value instanceof CharValue) {
char v = ((PrimitiveValue)value).charValue();
return String.valueOf(v);
return String.valueOf(((PrimitiveValue)value).charValue());
}
if (value instanceof ObjectReference) {
if (value instanceof ArrayReference) {
@@ -219,7 +219,7 @@ public class JUnitUtil {
return false;
}
public static boolean isJUnit5TestClass(final PsiClass psiClass, boolean checkAbstract) {
public static boolean isJUnit5TestClass(@NotNull final PsiClass psiClass, boolean checkAbstract) {
final PsiModifierList modifierList = psiClass.getModifierList();
if (modifierList == null) return false;
@@ -42,7 +42,6 @@ import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.PairProcessor;
import com.intellij.util.Processor;
import com.intellij.util.concurrency.SequentialTaskExecutor;
import gnu.trove.THashMap;
@@ -67,7 +66,6 @@ import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -96,13 +94,14 @@ public class JarRepositoryManager {
return null;
}
final List<RemoteRepositoryDescription> repositories = dialog.getRepositories();
final String coord = dialog.getCoordinateText();
final boolean attachSources = dialog.getAttachSources();
final boolean attachJavaDoc = dialog.getAttachJavaDoc();
final String copyTo = dialog.getDirectoryPath();
final NewLibraryConfiguration config = resolveAndDownload(project, coord, attachSources, attachJavaDoc, copyTo, repositories);
final NewLibraryConfiguration config = resolveAndDownload(
project, coord, attachSources, attachJavaDoc, copyTo, RemoteRepositoryDescription.DEFAULT_REPOSITORIES
);
if (config == null) {
Messages.showErrorDialog(parentComponent, "No files were downloaded for " + coord, CommonBundle.getErrorTitle());
}
@@ -277,7 +276,7 @@ public class JarRepositoryManager {
Notifications.Bus.notify(new Notification("Repository", title, sb.toString(), NotificationType.INFORMATION), project);
}
public static void searchArtifacts(final Project project, String coord, final PairProcessor<Collection<Pair<RepositoryArtifactDescription, RemoteRepositoryDescription>>, Boolean> resultProcessor) {
public static void searchArtifacts(final Project project, String coord, final Consumer<Collection<Pair<RepositoryArtifactDescription, RemoteRepositoryDescription>>> resultProcessor) {
if (coord == null || coord.length() == 0) {
return;
}
@@ -291,30 +290,18 @@ public class JarRepositoryManager {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Maven", false) {
public void run(@NotNull ProgressIndicator indicator) {
String[] urls = MavenRepositoryServicesManager.getServiceUrls();
boolean tooManyResults = false;
final AtomicBoolean proceedFlag = new AtomicBoolean(true);
for (int i = 0, length = urls.length; i < length; i++) {
if (!proceedFlag.get()) break;
final List<Pair<RepositoryArtifactDescription, RemoteRepositoryDescription>> resultList = new ArrayList<>();
try {
String serviceUrl = urls[i];
final List<RepositoryArtifactDescription> artifacts = MavenRepositoryServicesManager.findArtifacts(template, serviceUrl);
if (!artifacts.isEmpty()) {
if (!proceedFlag.get()) {
break;
}
final List<RemoteRepositoryDescription> repositories = MavenRepositoryServicesManager.getRepositories(serviceUrl);
Map<String, RemoteRepositoryDescription> map = new THashMap<>();
for (RemoteRepositoryDescription repository : repositories) {
map.put(repository.getId(), repository);
}
for (RepositoryArtifactDescription artifact : artifacts) {
if (artifact == null) {
tooManyResults = true;
final List<Pair<RepositoryArtifactDescription, RemoteRepositoryDescription>> resultList = new ArrayList<>();
try {
for (String serviceUrl : MavenRepositoryServicesManager.getServiceUrls()) {
try {
final List<RepositoryArtifactDescription> artifacts = MavenRepositoryServicesManager.findArtifacts(template, serviceUrl);
if (!artifacts.isEmpty()) {
final List<RemoteRepositoryDescription> repositories = MavenRepositoryServicesManager.getRepositories(serviceUrl);
final Map<String, RemoteRepositoryDescription> map = new THashMap<>();
for (RemoteRepositoryDescription repository : repositories) {
map.put(repository.getId(), repository);
}
else {
for (RepositoryArtifactDescription artifact : artifacts) {
final RemoteRepositoryDescription repository = map.get(artifact.getRepositoryId());
// if the artifact is provided by an unsupported repository just skip it
// because it won't be resolved anyway
@@ -324,38 +311,32 @@ public class JarRepositoryManager {
}
}
}
}
catch (Exception e) {
LOG.error(e);
}
finally {
if (!proceedFlag.get()) {
break;
catch (Exception e) {
LOG.error(e);
}
final Boolean aBoolean = i == length - 1 ? tooManyResults : null;
ApplicationManager.getApplication().invokeLater(
() -> proceedFlag.set(resultProcessor.process(resultList, aBoolean)), o -> !proceedFlag.get()
);
}
}
finally {
ApplicationManager.getApplication().invokeLater(() -> resultProcessor.accept(resultList));
}
}
});
}
public static void searchRepositories(final Project project, final Collection<String> nexusUrls, final Processor<Collection<RemoteRepositoryDescription>> resultProcessor) {
public static void searchRepositories(final Project project, final Collection<String> serviceUrls, final Processor<Collection<RemoteRepositoryDescription>> resultProcessor) {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Maven", false) {
public void run(@NotNull ProgressIndicator indicator) {
final Ref<List<RemoteRepositoryDescription>> result = Ref.create(Collections.<RemoteRepositoryDescription>emptyList());
try {
final ArrayList<RemoteRepositoryDescription> repoList = new ArrayList<>();
for (String nexusUrl : nexusUrls) {
for (String url : serviceUrls) {
final List<RemoteRepositoryDescription> repositories;
try {
repositories = MavenRepositoryServicesManager.getRepositories(nexusUrl);
repositories = MavenRepositoryServicesManager.getRepositories(url);
}
catch (Exception ex) {
LOG.warn("Accessing Service at: " + nexusUrl, ex);
LOG.warn("Accessing Service at: " + url, ex);
continue;
}
repoList.addAll(repositories);
@@ -16,7 +16,7 @@
package com.intellij.jarRepository;
import com.intellij.codeInspection.IntentionAndQuickFixAction;
import com.intellij.jarRepository.propertiesEditor.RepositoryLibraryPropertiesDialog;
import com.intellij.jarRepository.settings.RepositoryLibraryPropertiesDialog;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
@@ -27,7 +27,6 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
@@ -56,8 +55,10 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class RepositoryAttachDialog extends DialogWrapper {
@NonNls private static final String PROPERTY_DOWNLOAD_TO_PATH = "Downloaded.Files.Path";
@@ -79,8 +80,7 @@ public class RepositoryAttachDialog extends DialogWrapper {
private final JComboBox myCombobox;
private final Map<String, Pair<RepositoryArtifactDescription, RemoteRepositoryDescription>> myCoordinates = ContainerUtil.newTroveMap();
private final Map<String, RemoteRepositoryDescription> myRepositories = new TreeMap<>();
private final Map<String, RepositoryArtifactDescription> myCoordinates = ContainerUtil.newTroveMap();
private final List<String> myShownItems = ContainerUtil.newArrayList();
private final String myDefaultDownloadFolder;
@@ -203,7 +203,9 @@ public class RepositoryAttachDialog extends DialogWrapper {
main:
for (String coordinate : myCoordinates.keySet()) {
for (String part : parts) {
if (!StringUtil.containsIgnoreCase(coordinate, part)) continue main;
if (!StringUtil.containsIgnoreCase(coordinate, part)) {
continue main;
}
}
myShownItems.add(coordinate);
}
@@ -267,41 +269,22 @@ public class RepositoryAttachDialog extends DialogWrapper {
private boolean performSearch() {
final String text = getCoordinateText();
if (StringUtil.isEmptyOrSpaces(text)) return false;
if (myCoordinates.containsKey(text)) return false;
if (myProgressIcon.isRunning()) return false;
if (myProgressIcon.isRunning() || StringUtil.isEmptyOrSpaces(text) || myCoordinates.containsKey(text)) {
return false;
}
myProgressIcon.resume();
JarRepositoryManager.searchArtifacts(myProject, text, (artifacts, tooMany) -> {
JarRepositoryManager.searchArtifacts(myProject, text, (pairs) -> {
if (myProgressIcon.isDisposed()) {
return false;
}
if (tooMany != null) {
myProgressIcon.suspend(); // finished
return;
}
myProgressIcon.suspend(); // finished
final int prevSize = myCoordinates.size();
for (Pair<RepositoryArtifactDescription, RemoteRepositoryDescription> each : artifacts) {
myCoordinates.put(each.first.getGroupId() + ":" + each.first.getArtifactId() + ":" + each.first.getVersion(), each);
String url = each.second != null? each.second.getUrl() : null;
if (StringUtil.isNotEmpty(url) && !myRepositories.containsKey(url)) {
myRepositories.put(url, each.second);
}
}
String title = getTitle();
String tooManyMessage = ": too many results found";
if (tooMany != null) {
boolean alreadyThere = title.endsWith(tooManyMessage);
if (tooMany.booleanValue() && !alreadyThere) {
setTitle(title + tooManyMessage);
}
else if (!tooMany.booleanValue() && alreadyThere) {
setTitle(title.substring(0, title.length() - tooManyMessage.length()));
}
for (Pair<RepositoryArtifactDescription, RemoteRepositoryDescription> pair : pairs) {
final RepositoryArtifactDescription artifact = pair.first;
myCoordinates.put(artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion(), artifact);
}
updateComboboxSelection(prevSize != myCoordinates.size());
// tooMany != null on last call, so enable OK action to let
// local maven repo a chance even if all remote services failed
setOKActionEnabled(!myRepositories.isEmpty() || tooMany != null);
return true;
setOKActionEnabled(true);
});
return true;
}
@@ -352,13 +335,6 @@ public class RepositoryAttachDialog extends DialogWrapper {
return RepositoryAttachDialog.class.getName();
}
@NotNull
public List<RemoteRepositoryDescription> getRepositories() {
final Pair<RepositoryArtifactDescription, RemoteRepositoryDescription> artifactAndRepo = myCoordinates.get(getCoordinateText());
final RemoteRepositoryDescription repository = artifactAndRepo == null ? null : artifactAndRepo.second;
return repository != null ? Collections.singletonList(repository) : ContainerUtil.findAll(myRepositories.values(), Condition.NOT_NULL);
}
private boolean isValidCoordinateSelected() {
final String text = getCoordinateText();
return text.split(":").length == 3;
@@ -16,7 +16,7 @@
package com.intellij.jarRepository;
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable;
import com.intellij.jarRepository.propertiesEditor.RepositoryLibraryPropertiesEditor;
import com.intellij.jarRepository.settings.RepositoryLibraryPropertiesEditor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModifiableModelsProvider;
@@ -15,7 +15,7 @@
*/
package com.intellij.jarRepository;
import com.intellij.jarRepository.propertiesEditor.RepositoryLibraryPropertiesDialog;
import com.intellij.jarRepository.settings.RepositoryLibraryPropertiesDialog;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.jarRepository.propertiesEditor;
package com.intellij.jarRepository.settings;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.jarRepository.propertiesEditor.RepositoryLibraryPropertiesEditor">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.jarRepository.settings.RepositoryLibraryPropertiesEditor">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.jarRepository.propertiesEditor;
package com.intellij.jarRepository.settings;
import com.google.common.base.Strings;
import com.intellij.jarRepository.JarRepositoryManager;
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInspection.bytecodeAnalysis;
import com.intellij.util.ArrayFactory;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
@@ -90,6 +91,8 @@ final class HKey {
* Represents a lattice product of a constant {@link #value} and all {@link #ids}.
*/
final class HComponent {
static final HComponent[] EMPTY_ARRAY = new HComponent[0];
static final ArrayFactory<HComponent> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new HComponent[count];
@NotNull Value value;
@NotNull final HKey[] ids;
@@ -15,7 +15,6 @@
*/
package com.intellij.codeInspection.bytecodeAnalysis;
import com.intellij.util.ArrayFactory;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException;
@@ -101,7 +100,6 @@ class ResultUtil {
class HResultUtil {
private static final HKey[] EMPTY_PRODUCT = new HKey[0];
private static final ArrayFactory<HComponent> HCOMPONENT_ARRAY_FACTORY = count -> new HComponent[count];
private final ELattice<Value> lattice;
final Value top;
@@ -138,7 +136,7 @@ class HResultUtil {
}
HPending pending1 = (HPending) r1;
HPending pending2 = (HPending) r2;
return new HPending(ArrayUtil.mergeArrays(pending1.delta, pending2.delta, HCOMPONENT_ARRAY_FACTORY));
return new HPending(ArrayUtil.mergeArrays(pending1.delta, pending2.delta, HComponent.ARRAY_FACTORY));
}
}
@@ -39,8 +39,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
public class CanBeFinalInspection extends GlobalJavaBatchInspectionTool {
@@ -70,34 +68,19 @@ public class CanBeFinalInspection extends GlobalJavaBatchInspectionTool {
myReportClassesCheckbox = new JCheckBox(InspectionsBundle.message("inspection.can.be.final.option"));
myReportClassesCheckbox.setSelected(REPORT_CLASSES);
myReportClassesCheckbox.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
REPORT_CLASSES = myReportClassesCheckbox.isSelected();
}
});
myReportClassesCheckbox.getModel().addItemListener(e -> REPORT_CLASSES = myReportClassesCheckbox.isSelected());
gc.gridy = 0;
add(myReportClassesCheckbox, gc);
myReportMethodsCheckbox = new JCheckBox(InspectionsBundle.message("inspection.can.be.final.option1"));
myReportMethodsCheckbox.setSelected(REPORT_METHODS);
myReportMethodsCheckbox.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
REPORT_METHODS = myReportMethodsCheckbox.isSelected();
}
});
myReportMethodsCheckbox.getModel().addItemListener(e -> REPORT_METHODS = myReportMethodsCheckbox.isSelected());
gc.gridy++;
add(myReportMethodsCheckbox, gc);
myReportFieldsCheckbox = new JCheckBox(InspectionsBundle.message("inspection.can.be.final.option2"));
myReportFieldsCheckbox.setSelected(REPORT_FIELDS);
myReportFieldsCheckbox.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
REPORT_FIELDS = myReportFieldsCheckbox.isSelected();
}
});
myReportFieldsCheckbox.getModel().addItemListener(e -> REPORT_FIELDS = myReportFieldsCheckbox.isSelected());
gc.weighty = 1;
gc.gridy++;
@@ -155,21 +155,21 @@ public class DefUseInspectionBase extends BaseJavaBatchLocalInspectionTool {
myReportInitializer = new JCheckBox(InspectionsBundle.message("inspection.unused.assignment.option2"));
myReportInitializer.setSelected(REPORT_REDUNDANT_INITIALIZER);
myReportInitializer.getModel().addChangeListener(e -> REPORT_REDUNDANT_INITIALIZER = myReportInitializer.isSelected());
myReportInitializer.getModel().addItemListener(e -> REPORT_REDUNDANT_INITIALIZER = myReportInitializer.isSelected());
gc.insets = JBUI.insetsBottom(15);
gc.gridy = 0;
add(myReportInitializer, gc);
myReportPrefix = new JCheckBox(InspectionsBundle.message("inspection.unused.assignment.option"));
myReportPrefix.setSelected(REPORT_PREFIX_EXPRESSIONS);
myReportPrefix.getModel().addChangeListener(e -> REPORT_PREFIX_EXPRESSIONS = myReportPrefix.isSelected());
myReportPrefix.getModel().addItemListener(e -> REPORT_PREFIX_EXPRESSIONS = myReportPrefix.isSelected());
gc.insets = JBUI.emptyInsets();
gc.gridy++;
add(myReportPrefix, gc);
myReportPostfix = new JCheckBox(InspectionsBundle.message("inspection.unused.assignment.option1"));
myReportPostfix.setSelected(REPORT_POSTFIX_EXPRESSIONS);
myReportPostfix.getModel().addChangeListener(e -> REPORT_POSTFIX_EXPRESSIONS = myReportPostfix.isSelected());
myReportPostfix.getModel().addItemListener(e -> REPORT_POSTFIX_EXPRESSIONS = myReportPostfix.isSelected());
gc.weighty = 1;
gc.gridy++;
add(myReportPostfix, gc);
@@ -18,6 +18,7 @@ package com.intellij.codeInspection.reference;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.psi.*;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -43,7 +44,7 @@ public class RefJavaModuleImpl extends RefElementImpl implements RefJavaModule {
@Override
protected void initialize() {
((RefModuleImpl)myRefModule).add(this);
}
@Override
@@ -115,7 +116,35 @@ public class RefJavaModuleImpl extends RefElementImpl implements RefJavaModule {
}
}
}
((RefModuleImpl)myRefModule).add(this);
for (PsiProvidesStatement statement : javaModule.getProvides()) {
final PsiJavaCodeReferenceElement interfaceReference = statement.getInterfaceReference();
final PsiReferenceList implementationList = statement.getImplementationList();
if (interfaceReference != null && implementationList != null) {
final PsiElement providerInterface = interfaceReference.resolve();
if (providerInterface instanceof PsiClass) {
final RefElement refInterface = getRefManager().getReference(providerInterface);
if (refInterface instanceof RefJavaElementImpl) {
for (PsiJavaCodeReferenceElement implementationReference : implementationList.getReferenceElements()) {
final PsiElement implementationClass = implementationReference.resolve();
if (implementationClass instanceof PsiClass) {
PsiElement targetElement = getProviderMethod((PsiClass)implementationClass);
if (targetElement == null) {
targetElement = getDefaultConstructor((PsiClass)implementationClass);
if (targetElement == null) {
targetElement = implementationClass;
}
}
final RefElement refTargetElement = getRefManager().getReference(targetElement);
if (refTargetElement != null) {
((RefJavaElementImpl)refInterface)
.addReference(refTargetElement, targetElement, providerInterface, false, true, null);
}
}
}
}
}
}
}
getRefManager().fireBuildReferences(this);
}
}
@@ -150,4 +179,19 @@ public class RefJavaModuleImpl extends RefElementImpl implements RefJavaModule {
}
return !exportedPackages.isEmpty() ? exportedPackages : Collections.emptyMap();
}
@Nullable
private static PsiMethod getProviderMethod(@NotNull PsiClass psiClass) {
final PsiMethod[] methods = psiClass.findMethodsByName("provider", false);
return ContainerUtil.find(methods, m -> m.hasModifierProperty(PsiModifier.PUBLIC) &&
m.hasModifierProperty(PsiModifier.STATIC) &&
m.getParameterList().getParametersCount() == 0);
}
@Nullable
private static PsiMethod getDefaultConstructor(@NotNull PsiClass psiClass) {
final PsiMethod[] constructors = psiClass.getConstructors();
return ContainerUtil.find(constructors, m -> m.hasModifierProperty(PsiModifier.PUBLIC) &&
m.getParameterList().getParametersCount() == 0);
}
}
@@ -84,7 +84,7 @@ public class VisibilityInspection extends GlobalJavaBatchInspectionTool {
myPackageLocalForMembersCheckbox = new JCheckBox(InspectionsBundle.message("inspection.visibility.option"));
myPackageLocalForMembersCheckbox.setSelected(SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS);
myPackageLocalForMembersCheckbox.getModel().addChangeListener(
myPackageLocalForMembersCheckbox.getModel().addItemListener(
e -> SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS = myPackageLocalForMembersCheckbox.isSelected());
gc.gridy = 0;
@@ -92,7 +92,7 @@ public class VisibilityInspection extends GlobalJavaBatchInspectionTool {
myPackageLocalForTopClassesCheckbox = new JCheckBox(InspectionsBundle.message("inspection.visibility.option1"));
myPackageLocalForTopClassesCheckbox.setSelected(SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES);
myPackageLocalForTopClassesCheckbox.getModel().addChangeListener(
myPackageLocalForTopClassesCheckbox.getModel().addItemListener(
e -> SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES = myPackageLocalForTopClassesCheckbox.isSelected());
gc.gridy = 1;
@@ -101,7 +101,7 @@ public class VisibilityInspection extends GlobalJavaBatchInspectionTool {
myPrivateForInnersCheckbox = new JCheckBox(InspectionsBundle.message("inspection.visibility.option2"));
myPrivateForInnersCheckbox.setSelected(SUGGEST_PRIVATE_FOR_INNERS);
myPrivateForInnersCheckbox.getModel().addChangeListener(e -> SUGGEST_PRIVATE_FOR_INNERS = myPrivateForInnersCheckbox.isSelected());
myPrivateForInnersCheckbox.getModel().addItemListener(e -> SUGGEST_PRIVATE_FOR_INNERS = myPrivateForInnersCheckbox.isSelected());
gc.gridy = 2;
add(myPrivateForInnersCheckbox, gc);
@@ -25,8 +25,6 @@ import com.intellij.util.ui.JBUI;
import com.siyeh.ig.fixes.IntroduceVariableFix;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.util.List;
@@ -90,76 +88,39 @@ public class DataFlowInspection extends DataFlowInspectionBase {
mySuggestNullables = new JCheckBox(
InspectionsBundle.message("inspection.data.flow.nullable.quickfix.option"));
mySuggestNullables.setSelected(SUGGEST_NULLABLE_ANNOTATIONS);
mySuggestNullables.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
SUGGEST_NULLABLE_ANNOTATIONS = mySuggestNullables.isSelected();
}
});
mySuggestNullables.getModel().addItemListener(e -> SUGGEST_NULLABLE_ANNOTATIONS = mySuggestNullables.isSelected());
myDontReportTrueAsserts = new JCheckBox(
InspectionsBundle.message("inspection.data.flow.true.asserts.option"));
myDontReportTrueAsserts.setSelected(DONT_REPORT_TRUE_ASSERT_STATEMENTS);
myDontReportTrueAsserts.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
DONT_REPORT_TRUE_ASSERT_STATEMENTS = myDontReportTrueAsserts.isSelected();
}
});
myDontReportTrueAsserts.getModel().addItemListener(e -> DONT_REPORT_TRUE_ASSERT_STATEMENTS = myDontReportTrueAsserts.isSelected());
myIgnoreAssertions = new JCheckBox("Ignore assert statements");
myIgnoreAssertions.setSelected(IGNORE_ASSERT_STATEMENTS);
myIgnoreAssertions.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
IGNORE_ASSERT_STATEMENTS = myIgnoreAssertions.isSelected();
}
});
myIgnoreAssertions.getModel().addItemListener(e -> IGNORE_ASSERT_STATEMENTS = myIgnoreAssertions.isSelected());
myReportConstantReferences = new JCheckBox("Warn when reading a value guaranteed to be constant");
myReportConstantReferences.setSelected(REPORT_CONSTANT_REFERENCE_VALUES);
myReportConstantReferences.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
REPORT_CONSTANT_REFERENCE_VALUES = myReportConstantReferences.isSelected();
}
});
myReportConstantReferences.getModel().addItemListener(
e -> REPORT_CONSTANT_REFERENCE_VALUES = myReportConstantReferences.isSelected());
myTreatUnknownMembersAsNullable = new JCheckBox("Treat non-annotated members and parameters as @Nullable");
myTreatUnknownMembersAsNullable.setSelected(TREAT_UNKNOWN_MEMBERS_AS_NULLABLE);
myTreatUnknownMembersAsNullable.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
TREAT_UNKNOWN_MEMBERS_AS_NULLABLE = myTreatUnknownMembersAsNullable.isSelected();
}
});
myTreatUnknownMembersAsNullable.getModel().addItemListener(
e -> TREAT_UNKNOWN_MEMBERS_AS_NULLABLE = myTreatUnknownMembersAsNullable.isSelected());
myReportNullArguments = new JCheckBox("Report not-null required parameter with null-literal argument usages");
myReportNullArguments.setSelected(REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER);
myReportNullArguments.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER = myReportNullArguments.isSelected();
}
});
myReportNullArguments.getModel().addItemListener(e -> REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER = myReportNullArguments.isSelected());
myReportNullableMethodsReturningNotNull = new JCheckBox("Report nullable methods that always return a non-null value");
myReportNullableMethodsReturningNotNull.setSelected(REPORT_NULLABLE_METHODS_RETURNING_NOT_NULL);
myReportNullableMethodsReturningNotNull.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
REPORT_NULLABLE_METHODS_RETURNING_NOT_NULL = myReportNullableMethodsReturningNotNull.isSelected();
}
});
myReportNullableMethodsReturningNotNull.getModel().addItemListener(
e -> REPORT_NULLABLE_METHODS_RETURNING_NOT_NULL = myReportNullableMethodsReturningNotNull.isSelected());
myReportUncheckedOptionals = new JCheckBox("Report Optional.get() calls without previous isPresent check");
myReportUncheckedOptionals.setSelected(REPORT_UNCHECKED_OPTIONALS);
myReportUncheckedOptionals.getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
REPORT_UNCHECKED_OPTIONALS = myReportUncheckedOptionals.isSelected();
}
});
myReportUncheckedOptionals.getModel().addItemListener(e -> REPORT_UNCHECKED_OPTIONALS = myReportUncheckedOptionals.isSelected());
gc.insets = JBUI.emptyInsets();
gc.gridy = 0;
@@ -98,7 +98,7 @@ public class NexusRepositoryService extends MavenRepositoryService {
final SearchResults results = new Endpoint.DataIndex(url).getArtifactlistAsSearchResults(
name, template.getGroupId(), template.getArtifactId(), template.getVersion(), null, template.getClassNames()
);
boolean tooManyResults = results.isTooManyResults();
//boolean tooManyResults = results.isTooManyResults();
final SearchResults.Data data = results.getData();
final ArrayList<RepositoryArtifactDescription> result = new ArrayList<>();
if (data != null) {
@@ -108,9 +108,9 @@ public class NexusRepositoryService extends MavenRepositoryService {
}
}
}
if (tooManyResults) {
result.add(null);
}
//if (tooManyResults) {
// result.add(null);
//}
return result;
}
catch (UnmarshalException e) {
@@ -511,14 +511,14 @@ public class MoveClassesOrPackagesProcessor extends BaseRefactoringProcessor {
myElementsToMove[idx] = element;
}
myNonCodeUsages = CommonMoveUtil.retargetUsages(usages, oldToNewElementsMapping);
for (PsiElement element : myElementsToMove) {
if (element instanceof PsiClass) {
MoveClassesOrPackagesUtil.finishMoveClass((PsiClass)element);
}
}
myNonCodeUsages = CommonMoveUtil.retargetUsages(usages, oldToNewElementsMapping);
if (myOpenInEditor) {
EditorHelper.openFilesInEditor(myElementsToMove);
}
@@ -31,7 +31,7 @@ import org.jetbrains.annotations.Nullable;
*/
public abstract class PsiClassType extends PsiType {
public static final PsiClassType[] EMPTY_ARRAY = new PsiClassType[0];
public static final ArrayFactory<PsiClassType> ARRAY_FACTORY = count -> new PsiClassType[count];
public static final ArrayFactory<PsiClassType> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiClassType[count];
protected final LanguageLevel myLanguageLevel;
@@ -289,7 +289,7 @@ public abstract class PsiClassType extends PsiType {
};
}
public static abstract class Stub extends PsiClassType {
public abstract static class Stub extends PsiClassType {
protected Stub(LanguageLevel languageLevel, @NotNull PsiAnnotation[] annotations) {
super(languageLevel, annotations);
}
@@ -0,0 +1,8 @@
package my.impl;
import my.api.MyService;
public class MyServiceImpl implements MyService {
public MyServiceImpl() {}
@Override
public void foo() {}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,8 @@
package my.ext;
import my.api.MyService;
public class MyServiceExt implements MyService {
public MyServiceExt() {}
@Override
public void foo() {}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,8 @@
package my.ext;
import my.api.MyService;
public class MyServiceExt implements MyService {
public MyServiceExt() {}
@Override
public void foo() {}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,12 @@
package my.ext;
import my.api.MyService;
public class MyServiceExt {
public static MyService provider() {
return new MyService() {
@Override
public void foo() {
}
};
}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,7 @@
package my.impl;
import my.api.MyService;
public class MyServiceImpl implements MyService {
@Override
public void foo() {}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,12 @@
package my.impl;
import my.api.MyService;
public class MyServiceImpl {
public static MyService provider() {
return new MyService() {
@Override
public void foo() {
}
};
}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,8 @@
package my.impl;
import my.api.MyService;
public class MyServiceImpl implements MyService {
public MyServiceImpl() {}
@Override
public void foo() {}
}
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>MyServiceImpl.java</file>
<line>5</line>
<package>my.impl</package>
<entry_point TYPE="method" FQNAME="my.impl.MyServiceImpl MyServiceImpl()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Constructor has usage(s) but they all belong to calls chain that has no members reachable from entry points.</description>
</problem>
<problem>
<file>MyServiceImpl.java</file>
<line>4</line>
<package>my.impl</package>
<entry_point TYPE="class" FQNAME="my.impl.MyServiceImpl" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Class has one instantiation but it is not reachable from entry points.</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="method" FQNAME="my.api.MyService void foo()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="class" FQNAME="my.api.MyService" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&amp;nbsp;Interface has an implementation but &lt;ul&gt;&lt;li&gt;it is never instantiated OR&lt;/li&gt;&lt;li&gt;no instantiations are reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
</problems>
@@ -0,0 +1,8 @@
package my.ext;
import my.api.MyService;
public class MyServiceExt implements MyService {
public MyServiceExt() {}
@Override
public void foo() {}
}
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>MyServiceExt.java</file>
<line>5</line>
<package>my.ext</package>
<entry_point TYPE="method" FQNAME="my.ext.MyServiceExt MyServiceExt()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Constructor has usage(s) but they all belong to calls chain that has no members reachable from entry points.</description>
</problem>
<problem>
<file>MyServiceExt.java</file>
<line>4</line>
<package>my.ext</package>
<entry_point TYPE="class" FQNAME="my.ext.MyServiceExt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Class has one instantiation but it is not reachable from entry points.</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="method" FQNAME="my.api.MyService void foo()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="class" FQNAME="my.api.MyService" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&amp;nbsp;Interface has an implementation but &lt;ul&gt;&lt;li&gt;it is never instantiated OR&lt;/li&gt;&lt;li&gt;no instantiations are reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
</problems>
@@ -0,0 +1,7 @@
package my.ext;
import my.api.MyService;
public class MyServiceExt implements MyService {
@Override
public void foo() {}
}
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>MyServiceExt.java</file>
<line>4</line>
<package>my.ext</package>
<entry_point TYPE="class" FQNAME="my.ext.MyServiceExt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Class is not instantiated.</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="method" FQNAME="my.api.MyService void foo()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
</problems>
@@ -0,0 +1,12 @@
package my.ext;
import my.api.MyService;
public class MyServiceExt {
public static MyService provider() {
return new MyService() {
@Override
public void foo() {
}
};
}
}
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>MyServiceExt.java</file>
<line>5</line>
<package>my.ext</package>
<entry_point TYPE="method" FQNAME="my.ext.MyServiceExt my.api.MyService provider()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Method has one usage but it is not reachable from entry points.</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="method" FQNAME="my.api.MyService void foo()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="class" FQNAME="my.api.MyService" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&amp;nbsp;Interface has an implementation but &lt;ul&gt;&lt;li&gt;it is never instantiated OR&lt;/li&gt;&lt;li&gt;no instantiations are reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
</problems>
@@ -0,0 +1,7 @@
package my.impl;
import my.api.MyService;
public class MyServiceImpl implements MyService {
@Override
public void foo() {}
}
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>MyServiceImpl.java</file>
<line>4</line>
<package>my.impl</package>
<entry_point TYPE="class" FQNAME="my.impl.MyServiceImpl" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Class is not instantiated.</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="method" FQNAME="my.api.MyService void foo()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
</problems>
@@ -0,0 +1,12 @@
package my.impl;
import my.api.MyService;
public class MyServiceImpl {
public static MyService provider() {
return new MyService() {
@Override
public void foo() {
}
};
}
}
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>MyServiceImpl.java</file>
<line>5</line>
<package>my.impl</package>
<entry_point TYPE="method" FQNAME="my.impl.MyServiceImpl my.api.MyService provider()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Method has one usage but it is not reachable from entry points.</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="method" FQNAME="my.api.MyService void foo()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
<problem>
<file>MyService.java</file>
<line>1</line>
<package>my.api</package>
<entry_point TYPE="class" FQNAME="my.api.MyService" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&amp;nbsp;Interface has an implementation but &lt;ul&gt;&lt;li&gt;it is never instantiated OR&lt;/li&gt;&lt;li&gt;no instantiations are reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
</problems>
@@ -0,0 +1,6 @@
package b;
import b.a.A;
public class B {
A aa;
}
@@ -0,0 +1,2 @@
package b;
class C {}
@@ -0,0 +1,2 @@
package b.a;
public class A {}
@@ -0,0 +1,4 @@
import a.A;
public class B {
A aa;
}
@@ -0,0 +1,2 @@
package a;
public class A {}
@@ -0,0 +1,2 @@
package b;
class C {}
@@ -0,0 +1,114 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInspection
import com.intellij.analysis.AnalysisScope
import com.intellij.openapi.application.ex.PathManagerEx
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.roots.ModuleRootModificationUtil
import com.intellij.openapi.util.io.FileUtil
import com.intellij.testFramework.InspectionTestCase
import com.intellij.testFramework.InspectionTestUtil
import com.intellij.testFramework.createGlobalContextForTool
import com.intellij.testFramework.fixtures.LightJava9ModulesCodeInsightFixtureTestCase
import com.intellij.testFramework.fixtures.MultiModuleJava9ProjectDescriptor.ModuleDescriptor
import com.intellij.testFramework.fixtures.MultiModuleJava9ProjectDescriptor.ModuleDescriptor.*
import org.intellij.lang.annotations.Language
/**
* @author Pavel.Dolgov
*/
class Java9UnusedServiceImplementationsTest : LightJava9ModulesCodeInsightFixtureTestCase() {
override fun getTestDataPath() = PathManagerEx.getTestDataPath() + "/inspection/unusedServiceImplementations/"
override fun setUp() {
super.setUp()
moduleInfo("module MAIN { requires API; }", MAIN)
addFile("my/api/MyService.java", "package my.api; public interface MyService { void foo(); }", M2)
}
fun testImplementation() = doTest()
fun testConstructor() = doTest()
fun testProvider() = doTest()
fun testUnusedImplementation() = doTest(false)
fun testUnusedConstructor() = doTest(false)
fun testUnusedProvider() = doTest(false)
fun testExternalImplementation() = doTest(sameModule = false)
fun testExternalConstructor() = doTest(sameModule = false)
fun testExternalProvider() = doTest(sameModule = false)
fun testUnusedExternalImplementation() = doTest(false, sameModule = false)
fun testUnusedExternalConstructor() = doTest(false, sameModule = false)
fun testUnusedExternalProvider() = doTest(false, sameModule = false)
private fun doTest(withUsage: Boolean = true, sameModule: Boolean = true) {
@Language("JAVA")
val usageText = """
import my.api.MyService;
public class MyApp {
public static void main(String[] args) {
for (MyService service : ServiceLoader.load(MyService.class)) {
service.foo();
}
}
}"""
if (withUsage) addFile("my/app/MyApp.java", usageText, MAIN)
if (sameModule) {
moduleInfo("module API { exports my.api; provides my.api.MyService with my.impl.MyServiceImpl; }", M2)
}
else {
val moduleManager = ModuleManager.getInstance(project)
val m2 = moduleManager.findModuleByName(M2.moduleName)!!
val m4 = moduleManager.findModuleByName(M4.moduleName)!!
ModuleRootModificationUtil.addDependency(m4, m2)
moduleInfo("module API { exports my.api; }", M2)
moduleInfo("module EXT { requires API; provides my.api.MyService with my.ext.MyServiceExt; }", M4)
}
val testPath = testDataPath + "/" + getTestName(true)
val sourceFile = FileUtil.findFirstThatExist("$testPath/MyService${if (sameModule) "Impl" else "Ext"}.java")
assertNotNull("Test data: $testPath", sourceFile)
val implText = String(FileUtil.loadFileText(sourceFile!!))
if (sameModule)
addFile("my/impl/MyServiceImpl.java", implText, M2)
else
addFile("my/ext/MyServiceExt.java", implText, M4)
val toolWrapper = InspectionTestCase.getUnusedDeclarationWrapper()
val scope = AnalysisScope(project)
val globalContext = createGlobalContextForTool(scope, project, listOf(toolWrapper))
InspectionTestUtil.runTool(toolWrapper, scope, globalContext)
InspectionTestUtil.compareToolResults(globalContext, toolWrapper, true, testPath)
}
private fun moduleInfo(@Language("JAVA") moduleInfoText: String, descriptor: ModuleDescriptor) {
addFile("module-info.java", moduleInfoText, descriptor)
}
}
@@ -15,14 +15,16 @@
*/
package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.project.Project;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesProcessor;
import com.intellij.refactoring.move.moveClassesOrPackages.SingleSourceRootMoveDestination;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
public class MovePackageTest extends MultiFileTestCase {
@@ -49,6 +51,12 @@ public class MovePackageTest extends MultiFileTestCase {
doTest(new String[]{"a"}, "a.b");
}
public void testPackageAndReferencedClass() throws Exception {
Project project = myPsiManager.getProject();
JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
doTest((rootDir, rootAfter) -> performAction(new PsiElement[]{facade.findPackage("a"), facade.findClass("B", GlobalSearchScope.allScope(project))}, "b"));
}
@NotNull
@Override
protected String getTestRoot() {
@@ -67,12 +75,16 @@ public class MovePackageTest extends MultiFileTestCase {
assertNotNull("Package " + packageName + " not found", packages[i]);
}
performAction(packages, newPackageName);
}
private void performAction(PsiElement[] packagesAndClasses, String newPackageName) {
PsiPackage newParentPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage(newPackageName);
assertNotNull(newParentPackage);
final PsiDirectory[] dirs = newParentPackage.getDirectories();
assertEquals(dirs.length, 1);
new MoveClassesOrPackagesProcessor(myProject, packages,
new MoveClassesOrPackagesProcessor(myProject, packagesAndClasses,
new SingleSourceRootMoveDestination(PackageWrapper.create(newParentPackage), dirs[0]),
true, false, null).run();
FileDocumentManager.getInstance().saveAllDocuments();
@@ -28,7 +28,7 @@ public class RemoteRepositoryDescription {
public static final RemoteRepositoryDescription MAVEN_CENTRAL = new RemoteRepositoryDescription(
"central",
"Maven Central repository",
"http://repo1.maven.org/maven2"
"https://repo1.maven.org/maven2"
);
public static final RemoteRepositoryDescription JBOSS_COMMUNITY = new RemoteRepositoryDescription(
"jboss.community",
+17
View File
@@ -0,0 +1,17 @@
package icons;
import com.intellij.openapi.util.IconLoader;
import javax.swing.*;
/**
* NOTE THIS FILE IS AUTO-GENERATED
* DO NOT EDIT IT BY HAND, run build/scripts/icons.gant instead
*/
public class OpenapiIcons {
private static Icon load(String path) {
return IconLoader.getIcon(path, OpenapiIcons.class);
}
public static final Icon RepositoryLibraryLogo = load("/icons/repositoryLibraryLogo.png"); // 16x16
}
@@ -18,8 +18,8 @@ package org.jetbrains.idea.maven.utils.library;
import com.intellij.jarRepository.RemoteRepositoryDescription;
import com.intellij.jarRepository.RepositoryLibraryDefinition;
import com.intellij.openapi.roots.DependencyScope;
import com.intellij.openapi.util.IconLoader;
import com.intellij.util.containers.HashMap;
import icons.OpenapiIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.library.JpsMavenRepositoryLibraryDescriptor;
@@ -43,7 +43,7 @@ public class RepositoryLibraryDescription {
@NotNull
public static final String SnapshotVersionSuffix = "-SNAPSHOT";
public static final Icon DEFAULT_ICON = IconLoader.getIcon("/icons/repositoryLibraryLogo.png");
public static final Icon DEFAULT_ICON = OpenapiIcons.RepositoryLibraryLogo;
private static volatile Map<String, RepositoryLibraryDescription> ourStaticallyDefinedLibraries;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInsight.template.JavaCodeContextType;
import com.intellij.codeInsight.template.TemplateContextType;
import com.intellij.dupLocator.iterators.NodeIterator;
import com.intellij.dupLocator.util.NodeFilter;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.lang.Language;
import com.intellij.lang.java.JavaLanguage;
@@ -39,8 +40,6 @@ import com.intellij.structuralsearch.impl.matcher.*;
import com.intellij.structuralsearch.impl.matcher.compiler.GlobalCompilingVisitor;
import com.intellij.structuralsearch.impl.matcher.compiler.JavaCompilingVisitor;
import com.intellij.structuralsearch.impl.matcher.compiler.PatternCompiler;
import com.intellij.structuralsearch.impl.matcher.filters.JavaLexicalNodesFilter;
import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter;
import com.intellij.structuralsearch.plugin.replace.ReplaceOptions;
import com.intellij.structuralsearch.plugin.replace.impl.ParameterInfo;
import com.intellij.structuralsearch.plugin.replace.impl.ReplacementBuilder;
@@ -51,6 +50,7 @@ import com.intellij.structuralsearch.plugin.ui.SearchContext;
import com.intellij.structuralsearch.plugin.ui.UIUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -60,9 +60,16 @@ import java.util.*;
* @author Eugene.Kudelevsky
*/
public class JavaStructuralSearchProfile extends StructuralSearchProfile {
private JavaLexicalNodesFilter myJavaLexicalNodesFilter;
public String getText(PsiElement match, int start,int end) {
private static final Set<String> PRIMITIVE_TYPES = new THashSet<>(Arrays.asList(
PsiKeyword.SHORT, PsiKeyword.BOOLEAN,
PsiKeyword.DOUBLE, PsiKeyword.LONG,
PsiKeyword.INT, PsiKeyword.FLOAT,
PsiKeyword.CHAR, PsiKeyword.BYTE
));
@Override
public String getText(PsiElement match, int start, int end) {
if (match instanceof PsiIdentifier) {
PsiElement parent = match.getParent();
if (parent instanceof PsiJavaCodeReferenceElement && !(parent instanceof PsiExpression)) {
@@ -74,6 +81,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
return matchText.substring(start,end == -1? matchText.length():end);
}
@Override
public Class getElementContextByPsi(PsiElement element) {
if (element instanceof PsiIdentifier) {
element = element.getParent();
@@ -86,6 +94,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
}
}
@Override
@NotNull
public String getTypedVarString(final PsiElement element) {
String text;
@@ -187,10 +196,12 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
return element;
}
@Override
public void compile(PsiElement[] elements, @NotNull GlobalCompilingVisitor globalVisitor) {
elements[0].getParent().accept(new JavaCompilingVisitor(globalVisitor));
}
@Override
@NotNull
public PsiElementVisitor createMatchingVisitor(@NotNull GlobalMatchingVisitor globalVisitor) {
return new JavaMatchingVisitor(globalVisitor);
@@ -198,18 +209,30 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
@NotNull
@Override
public PsiElementVisitor getLexicalNodesFilter(@NotNull LexicalNodesFilter filter) {
if (myJavaLexicalNodesFilter == null) {
myJavaLexicalNodesFilter = new JavaLexicalNodesFilter(filter);
}
return myJavaLexicalNodesFilter;
public NodeFilter getLexicalNodesFilter() {
return element -> isLexicalNode(element);
}
private static boolean isLexicalNode(PsiElement element) {
if (element instanceof PsiWhiteSpace) {
return true;
}
else if (element instanceof PsiJavaToken) {
// do not filter out type keyword of new primitive arrays (e.g. int in new int[10])
return !(element instanceof PsiKeyword &&
PRIMITIVE_TYPES.contains(element.getText()) &&
element.getParent() instanceof PsiNewExpression);
}
return false;
}
@Override
@NotNull
public CompiledPattern createCompiledPattern() {
return new JavaCompiledPattern();
}
@Override
public boolean isMyLanguage(@NotNull Language language) {
return language == JavaLanguage.INSTANCE;
}
@@ -385,6 +408,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
return JavaCodeContextType.class;
}
@Override
public PsiCodeFragment createCodeFragment(Project project, String text, PsiElement context) {
final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(project);
return factory.createCodeBlockCodeFragment(text, context, true);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.structuralsearch.MatchOptions;
import com.intellij.structuralsearch.MatchResult;
import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter;
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler;
import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler;
@@ -1547,12 +1546,8 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
final PsiElement element = PsiTreeUtil.getNextSiblingOfType(newKeyword, PsiWhiteSpace.class);
if (element != null && element.getNextSibling() instanceof PsiKeyword) {
((LexicalNodesFilter)LexicalNodesFilter.getInstance()).setCareKeyWords(true);
myMatchingVisitor.setResult(myMatchingVisitor.match(classReference, element.getNextSibling()) &&
myMatchingVisitor.matchSons(new1.getArrayInitializer(), new2.getArrayInitializer()));
((LexicalNodesFilter)LexicalNodesFilter.getInstance()).setCareKeyWords(false);
if (myMatchingVisitor.getResult()) {
// matching dims
matchArrayDims(new1, new2);
@@ -1565,9 +1560,7 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
if (classReference == new2.getClassReference()) {
// probably anonymous class or array of primitive type
((LexicalNodesFilter)LexicalNodesFilter.getInstance()).setCareKeyWords(true);
myMatchingVisitor.setResult(myMatchingVisitor.matchSons(new1, new2));
((LexicalNodesFilter)LexicalNodesFilter.getInstance()).setCareKeyWords(false);
}
else if (new1.getAnonymousClass() == null &&
classReference != null &&
@@ -1,51 +0,0 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.structuralsearch.impl.matcher.filters;
import com.intellij.psi.*;
import com.intellij.psi.javadoc.PsiDocComment;
/**
* @author Eugene.Kudelevsky
*/
public class JavaLexicalNodesFilter extends JavaElementVisitor {
private final LexicalNodesFilter myLexicalNodesFilter;
public JavaLexicalNodesFilter(LexicalNodesFilter lexicalNodesFilter) {
this.myLexicalNodesFilter = lexicalNodesFilter;
}
@Override public void visitJavaToken(final PsiJavaToken t) {
myLexicalNodesFilter.setResult(true);
}
@Override public void visitComment(final PsiComment comment) {
}
@Override public void visitDocComment(final PsiDocComment comment) {
}
@Override public void visitKeyword(PsiKeyword keyword) {
myLexicalNodesFilter.setResult(!myLexicalNodesFilter.isCareKeyWords());
}
@Override public void visitWhiteSpace(final PsiWhiteSpace space) {
myLexicalNodesFilter.setResult(true);
}
@Override public void visitErrorElement(final PsiErrorElement element) {
}
}
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.structuralsearch.impl.matcher.filters;
import com.intellij.dupLocator.util.NodeFilter;
@@ -10,24 +25,14 @@ import com.intellij.psi.*;
* Time: 17:46:10
* To change this template use Options | File Templates.
*/
public class StatementFilter extends JavaElementVisitor implements NodeFilter {
protected boolean result;
@Override public void visitReferenceExpression(PsiReferenceExpression psiReferenceExpression) {
result = false;
}
@Override public void visitStatement(PsiStatement psiStatement) {
result = true;
}
@Override public void visitComment(PsiComment comment) {
result = true;
}
public class StatementFilter implements NodeFilter {
@Override
public boolean accepts(PsiElement element) {
result = false;
if (element!=null) element.accept(this);
return result;
if (element instanceof PsiComment && element.getParent() instanceof PsiCodeBlock) {
// only allow comments in statement context
return true;
}
return element instanceof PsiStatement;
}
}
@@ -62,7 +62,7 @@ public abstract class InspectionTestCase extends PsiTestCase {
private EntryPoint myUnusedCodeExtension;
private VirtualFile ext_src;
protected static GlobalInspectionToolWrapper getUnusedDeclarationWrapper() {
public static GlobalInspectionToolWrapper getUnusedDeclarationWrapper() {
InspectionEP ep = new InspectionEP();
ep.presentation = UnusedDeclarationPresentation.class.getName();
ep.implementationClass = UnusedDeclarationInspection.class.getName();
@@ -58,4 +58,9 @@ abstract class BuildPaths {
* Path to a directory containing JDK (currently Java 8) which is used to compile the project
*/
String jdkHome
/**
* Path to a directory containing Kotlin plugin with compiler which is used to compile the project
*/
String kotlinHome
}
@@ -48,7 +48,6 @@ class BuildContextImpl extends BuildContext {
def context = new BuildContextImpl(compilationContext, productProperties,
windowsDistributionCustomizer, linuxDistributionCustomizer, macDistributionCustomizer,
proprietaryBuildTools)
setupDependencies(context.messages, communityHome)
return context
}
@@ -76,13 +75,6 @@ class BuildContextImpl extends BuildContext {
bootClassPathJarNames = ["bootstrap.jar", "extensions.jar", "util.jar", "jdom.jar", "log4j.jar", "trove4j.jar", "jna.jar"]
}
private static void setupDependencies(BuildMessages messages, String communityHome) {
messages.info("Setting up installer dependencies")
if (!BuildUtils.gradle(new File(communityHome, 'build/dependencies/'), 'setupDependencies')) {
messages.error("Cannot setup installer dependencies")
}
}
private String readSnapshotBuildNumber() {
new File(paths.communityHome, "build.txt").text.trim()
}
@@ -17,11 +17,7 @@ package org.jetbrains.intellij.build.impl
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.intellij.build.BuildContext
import org.jetbrains.intellij.build.BuildOptions
import org.jetbrains.intellij.build.BuildTasks
import org.jetbrains.intellij.build.CompilationTasks
import org.jetbrains.intellij.build.ProductModulesLayout
import org.jetbrains.intellij.build.*
import org.jetbrains.jps.model.java.JavaResourceRootType
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.jps.model.module.JpsModule
@@ -277,7 +273,7 @@ idea.fatal.error.notification=disabled
if (buildContext.productProperties.scrambleMainJar) {
scramble()
}
setupJbreDependencies()
layoutShared()
def propertiesFile = patchIdeaPropertiesFile()
@@ -308,6 +304,13 @@ idea.fatal.error.notification=disabled
}
}
}
private void setupJbreDependencies() {
buildContext.messages.info("Setting up installer dependencies")
if (!BuildUtils.runDependenciesGradle(buildContext.paths.communityHome, 'setupJbre')) {
buildContext.messages.error("Cannot setup installer dependencies")
}
}
private void scramble() {
if (buildContext.proprietaryBuildTools.scrambleTool != null) {
@@ -84,7 +84,11 @@ class BuildUtils {
}
}
static boolean gradle(File projectDir, String... tasks) {
static boolean runDependenciesGradle(String communityHome, String... tasks) {
return runGradle(new File(communityHome, 'build/dependencies/'), tasks)
}
private static boolean runGradle(File projectDir, String... tasks) {
def gradleScript = SystemInfo.isWindows ? "gradlew.bat" : "gradlew"
List<String> command = new ArrayList()
command.add("${projectDir.absolutePath}/$gradleScript".toString())
@@ -66,26 +66,30 @@ class CompilationContextImpl implements CompilationContext {
messages.error("communityHome ($communityHome) doesn't point to a directory containing IntelliJ Community sources")
}
if (!options.isInDevelopmentMode) {
setupCompilationDependencies(messages, communityHome)
}
projectHome = toCanonicalPath(projectHome)
def jdk8Home = toCanonicalPath(JdkUtils.computeJdkHome(messages, "jdk8Home", "$projectHome/build/jdk/1.8", "JDK_18_x64"))
def kotlinHome = toCanonicalPath("$communityHome/build/dependencies/build/kotlin/Kotlin")
setupDependencies(messages, communityHome)
if (project.modules.isEmpty()) {
loadProject(communityHome, projectHome, jdk8Home, project, global, messages)
loadProject(projectHome, jdk8Home, kotlinHome, project, global, messages)
}
else {
//todo[nik] currently we need this to build IDEA CE from IDEA UI build scripts. It would be better to create a separate JpsProject instance instead
messages.info("Skipping loading project because it's already loaded")
}
def context = new CompilationContextImpl(ant, projectBuilder, project, global, communityHome, projectHome, jdk8Home, messages,
def context = new CompilationContextImpl(ant, projectBuilder, project, global, communityHome, projectHome, jdk8Home, kotlinHome, messages,
buildOutputRootEvaluator, options)
context.prepareForBuild()
return context
}
private CompilationContextImpl(AntBuilder ant, JpsGantProjectBuilder projectBuilder, JpsProject project, JpsGlobal global,
String communityHome, String projectHome, String jdk8Home, BuildMessages messages,
String communityHome, String projectHome, String jdk8Home, String kotlinHome, BuildMessages messages,
BiFunction<JpsProject, BuildMessages, String> buildOutputRootEvaluator, BuildOptions options) {
this.ant = ant
this.project = project
@@ -94,23 +98,18 @@ class CompilationContextImpl implements CompilationContext {
this.projectBuilder = projectBuilder
this.messages = messages
String buildOutputRoot = options.outputRootPath ?: buildOutputRootEvaluator.apply(project, messages)
this.paths = new BuildPathsImpl(communityHome, projectHome, buildOutputRoot, jdk8Home)
this.paths = new BuildPathsImpl(communityHome, projectHome, buildOutputRoot, jdk8Home, kotlinHome)
}
CompilationContextImpl createCopy(AntBuilder ant, BuildMessages messages, BuildOptions options,
BiFunction<JpsProject, BuildMessages, String> buildOutputRootEvaluator) {
return new CompilationContextImpl(ant, projectBuilder, project, global, paths.communityHome, paths.projectHome, paths.jdkHome,
messages, buildOutputRootEvaluator, options)
return new CompilationContextImpl(ant, projectBuilder, project, global, paths.communityHome, paths.projectHome, paths.jdkHome,
paths.kotlinHome, messages, buildOutputRootEvaluator, options)
}
private static void loadProject(String communityHome, String projectHome, String jdkHome, JpsProject project, JpsGlobal global,
private static void loadProject(String projectHome, String jdkHome, String kotlinHome, JpsProject project, JpsGlobal global,
BuildMessages messages) {
def bundledKotlinPath = "$communityHome/build/dependencies/build/kotlin/Kotlin/kotlinc"
if (!new File(bundledKotlinPath, "lib/kotlin-runtime.jar").exists()) {
messages.error(
"Could not find Kotlin runtime at $bundledKotlinPath/lib/kotlin-runtime.jar: run `./gradlew setupKotlin` in dependencies module to download Kotlin JARs")
}
JpsModelSerializationDataService.getOrCreatePathVariablesConfiguration(global).addPathVariable("KOTLIN_BUNDLED", bundledKotlinPath)
JpsModelSerializationDataService.getOrCreatePathVariablesConfiguration(global).addPathVariable("KOTLIN_BUNDLED", "$kotlinHome/kotlinc")
JdkUtils.defineJdk(global, "IDEA jdk", JdkUtils.computeJdkHome(messages, "jdkHome", "$projectHome/build/jdk/1.6", "JDK_16_x64"))
JdkUtils.defineJdk(global, "1.8", jdkHome)
@@ -120,9 +119,12 @@ class CompilationContextImpl implements CompilationContext {
messages.info("Loaded project $projectHome: ${project.modules.size()} modules, ${project.libraryCollection.libraries.size()} libraries")
}
private static void setupDependencies(BuildMessages messages, String communityHome) {
static boolean dependenciesInstalled
static void setupCompilationDependencies(BuildMessages messages, String communityHome) {
if (dependenciesInstalled) return
dependenciesInstalled = true
messages.info("Setting up compilation dependencies")
if (!BuildUtils.gradle(new File(communityHome, 'build/dependencies/'), 'setupJdks', 'setupKotlinPlugin')) {
if (!BuildUtils.runDependenciesGradle(communityHome, 'setupJdks', 'setupKotlinPlugin')) {
messages.error("Cannot setup compilation dependencies")
}
}
@@ -240,17 +242,18 @@ class CompilationContextImpl implements CompilationContext {
messages.artifactBuild(relativePath)
}
private static String toCanonicalPath(String communityHome) {
FileUtil.toSystemIndependentName(new File(communityHome).canonicalPath)
private static String toCanonicalPath(String path) {
FileUtil.toSystemIndependentName(new File(path).canonicalPath)
}
}
class BuildPathsImpl extends BuildPaths {
BuildPathsImpl(String communityHome, String projectHome, String buildOutputRoot, String jdkHome) {
BuildPathsImpl(String communityHome, String projectHome, String buildOutputRoot, String jdkHome, String kotlinHome) {
this.communityHome = communityHome
this.projectHome = projectHome
this.buildOutputRoot = buildOutputRoot
this.jdkHome = jdkHome
this.kotlinHome = kotlinHome
artifacts = "$buildOutputRoot/artifacts"
distAll = "$buildOutputRoot/dist.all"
temp = "$buildOutputRoot/temp"
@@ -40,6 +40,7 @@ class CompilationTasksImpl extends CompilationTasks {
return
}
CompilationContextImpl.setupCompilationDependencies(context.messages, context.paths.communityHome)
ensureKotlinCompilerAddedToClassPath()
context.messages.progress("Compiling project")
@@ -81,7 +82,7 @@ class CompilationTasksImpl extends CompilationTasks {
return
}
def kotlinPluginLibPath = "$context.paths.communityHome/build/dependencies/build/kotlin/Kotlin/lib"
def kotlinPluginLibPath = "$context.paths.kotlinHome/lib"
if (new File(kotlinPluginLibPath).exists()) {
["jps/kotlin-jps-plugin.jar", "kotlin-plugin.jar", "kotlin-runtime.jar", "kotlin-reflect.jar"].each {
BuildUtils.addToJpsClassPath("$kotlinPluginLibPath/$it", context.ant)
@@ -50,6 +50,7 @@ class TestingTasksImpl extends TestingTasks {
else {
compilationTasks.compileAllModulesAndTests()
}
setupTestingDependencies()
def mainModule = options.mainModule ?: defaultMainModule
List<String> testsClasspath = context.projectBuilder.moduleRuntimeClasspath(context.findRequiredModule(mainModule), true)
@@ -171,6 +172,18 @@ class TestingTasksImpl extends TestingTasks {
test(name: 'com.intellij.tests.BootstrapTests')
}
}
static boolean dependenciesInstalled
private def setupTestingDependencies() {
if (dependenciesInstalled) return
dependenciesInstalled = true
context.messages.info("Setting up testing dependencies")
if (!BuildUtils.runDependenciesGradle(context.paths.communityHome, 'setupKotlinPlugin')) {
context.messages.error("Cannot setup testing dependencies")
}
dependenciesInstalled = true
}
static boolean taskDefined
@@ -40,24 +40,21 @@ public class IElementType {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.tree.IElementType");
public static final IElementType[] EMPTY_ARRAY = new IElementType[0];
public static final ArrayFactory<IElementType> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new IElementType[count];
/**
* Default enumeration predicate which matches all token types.
*
* @see #enumerate(Predicate)
*/
public static final Predicate TRUE = new Predicate() {
@Override
public boolean matches(@NotNull IElementType type) {
return true;
}
};
public static final Predicate TRUE = type -> true;
public static final short FIRST_TOKEN_INDEX = 1;
private static final short MAX_INDEXED_TYPES = 15000;
private static short size; // guarded by lock
private static volatile IElementType[] ourRegistry = EMPTY_ARRAY; // writes are guarded by lock
@SuppressWarnings("RedundantStringConstructorCall")
private static final Object lock = new String("registry lock");
static {
@@ -91,7 +88,6 @@ public class IElementType {
this(debugName, language, true);
}
private static final ArrayFactory<IElementType> FACTORY = count -> new IElementType[count];
/**
* Allows to construct element types for some temporary purposes without registering them.
@@ -107,7 +103,7 @@ public class IElementType {
myIndex = size++;
LOG.assertTrue(myIndex < MAX_INDEXED_TYPES, "Too many element types registered. Out of (short) range.");
IElementType[] newRegistry =
myIndex >= ourRegistry.length ? ArrayUtil.realloc(ourRegistry, ourRegistry.length * 3 / 2 + 1, FACTORY) : ourRegistry;
myIndex >= ourRegistry.length ? ArrayUtil.realloc(ourRegistry, ourRegistry.length * 3 / 2 + 1, ARRAY_FACTORY) : ourRegistry;
newRegistry[myIndex] = this;
ourRegistry = newRegistry;
}
@@ -189,6 +185,7 @@ public class IElementType {
*
* @see IElementType#enumerate(Predicate)
*/
@FunctionalInterface
public interface Predicate {
boolean matches(@NotNull IElementType type);
}
@@ -35,7 +35,7 @@ public class UsageInfo {
public final boolean isNonCodeUsage;
protected boolean myDynamicUsage;
public UsageInfo(@NotNull PsiElement element, int startOffset, int endOffset, boolean isNonCodeUsage) {
public UsageInfo(@NotNull PsiElement element, final int startOffset, final int endOffset, boolean isNonCodeUsage) {
element = element.getNavigationElement();
PsiFile file = element.getContainingFile();
PsiElement topElement = file == null ? element : file;
@@ -45,30 +45,32 @@ public class UsageInfo {
if (elementRange == null) {
throw new IllegalArgumentException("text range null for " + element + "; " + element.getClass());
}
int effectiveStart;
int effectiveEnd;
if (startOffset == -1 && endOffset == -1) {
// calculate natural element range
startOffset = element.getTextOffset() - elementRange.getStartOffset();
endOffset = elementRange.getEndOffset() - elementRange.getStartOffset();
effectiveStart = element.getTextOffset() - elementRange.getStartOffset();
effectiveEnd = elementRange.getLength();
}
else {
effectiveStart = startOffset;
effectiveEnd = endOffset;
}
if (startOffset < 0) {
throw new IllegalArgumentException("element " + element + "; startOffset " +startOffset);
}
if (startOffset > endOffset) {
throw new IllegalArgumentException("element " + element + "; diff " + (endOffset-startOffset));
if (effectiveStart < 0 || effectiveStart > effectiveEnd) {
throw new IllegalArgumentException("element " + element + "; startOffset " +startOffset+"; endOffset="+endOffset+
"; effectiveStart="+effectiveStart+"; effectiveEnd="+effectiveEnd+
"; elementRange="+elementRange+"; element.getTextOffset()="+element.getTextOffset());
}
Project project = topElement.getProject();
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(project);
mySmartPointer = smartPointerManager.createSmartPsiElementPointer(element, file);
if (startOffset != element.getTextOffset() - elementRange.getStartOffset() || endOffset != elementRange.getLength()) {
TextRange rangeToStore;
if (file != null && InjectedLanguageManager.getInstance(project).isInjectedFragment(file)) {
rangeToStore = elementRange;
}
else {
rangeToStore = TextRange.create(startOffset, endOffset).shiftRight(elementRange.getStartOffset());
}
if (file != null &&
(effectiveStart != element.getTextOffset() - elementRange.getStartOffset() || effectiveEnd != elementRange.getLength())) {
TextRange rangeToStore = InjectedLanguageManager.getInstance(project).isInjectedFragment(file)
? elementRange
: TextRange.create(effectiveStart, effectiveEnd).shiftRight(elementRange.getStartOffset());
myPsiFileRange = smartPointerManager.createSmartPsiFileRangePointer(file, rangeToStore);
}
else {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -126,8 +126,6 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
doneMarker.clean();
}
});
private static final ArrayFactory<IElementType> myElementTypeArrayFactory =
count -> count == 0 ? IElementType.EMPTY_ARRAY : new IElementType[count];
public static void registerWhitespaceToken(@NotNull IElementType type) {
ourAnyLanguageWhitespaceTokens = TokenSet.orSet(ourAnyLanguageWhitespaceTokens, TokenSet.create(type));
@@ -266,9 +264,10 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
int i = 0;
int offset = 0;
while (true) {
ProgressIndicatorProvider.checkCanceled();
IElementType type = myLexer.getTokenType();
if (type == null) break;
if (i % 20 == 0) ProgressIndicatorProvider.checkCanceled();
if (i >= myLexTypes.length - 1) {
resizeLexemes(i * 3 / 2);
@@ -918,7 +917,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
private void resizeLexemes(final int newSize) {
myLexStarts = ArrayUtil.realloc(myLexStarts, newSize+1);
myLexTypes = ArrayUtil.realloc(myLexTypes, newSize, myElementTypeArrayFactory);
myLexTypes = ArrayUtil.realloc(myLexTypes, newSize, IElementType.ARRAY_FACTORY);
clearCachedTokenType();
}
@@ -43,7 +43,6 @@ class CachedValueLeakChecker {
private static final Logger LOG = Logger.getInstance("#com.intellij.util.CachedValueChecker");
private static final boolean DO_CHECKS = ApplicationManager.getApplication().isUnitTestMode();
private static final Set<String> ourCheckedKeys = ContainerUtil.newConcurrentSet();
private static final boolean JAVA9 = SystemInfo.isJavaVersionAtLeast("9");
static void checkProvider(@NotNull final CachedValueProvider provider,
@NotNull final Key key,
@@ -51,7 +50,7 @@ class CachedValueLeakChecker {
if (!DO_CHECKS || ApplicationInfoImpl.isInStressTest()) return;
if (!ourCheckedKeys.add(key.toString())) return; // store strings because keys are created afresh in each (test) project
if (!JAVA9) {
if (!SystemInfo.IS_AT_LEAST_JAVA9) {
findReferencedPsi(provider, userDataHolder, 5);
}
}
@@ -243,10 +243,10 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
group.add(myEditorSettingsAction);
DefaultActionGroup diffGroup = new DefaultActionGroup("Compare With", true);
diffGroup.getTemplatePresentation().setIcon(AllIcons.Diff.Diff);
diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_MIDDLE));
diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.RIGHT_MIDDLE));
diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_RIGHT));
diffGroup.getTemplatePresentation().setIcon(AllIcons.Actions.Diff);
diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_MIDDLE, true));
diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.RIGHT_MIDDLE, true));
diffGroup.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_RIGHT, true));
diffGroup.add(new ShowDiffWithBaseAction(ThreeSide.LEFT));
diffGroup.add(new ShowDiffWithBaseAction(ThreeSide.BASE));
diffGroup.add(new ShowDiffWithBaseAction(ThreeSide.RIGHT));
@@ -64,9 +64,9 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewerEx {
group.add(myEditorSettingsAction);
group.add(Separator.getInstance());
group.add(new TextShowPartialDiffAction(PartialDiffMode.MIDDLE_LEFT));
group.add(new TextShowPartialDiffAction(PartialDiffMode.MIDDLE_RIGHT));
group.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_RIGHT));
group.add(new TextShowPartialDiffAction(PartialDiffMode.MIDDLE_LEFT, false));
group.add(new TextShowPartialDiffAction(PartialDiffMode.MIDDLE_RIGHT, false));
group.add(new TextShowPartialDiffAction(PartialDiffMode.LEFT_RIGHT, false));
group.add(Separator.getInstance());
group.addAll(super.createToolbarActions());
@@ -30,6 +30,7 @@ import com.intellij.diff.tools.util.SimpleDiffPanel;
import com.intellij.diff.tools.util.base.ListenerDiffViewerBase;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.util.ThreeSide;
import com.intellij.icons.AllIcons;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
@@ -196,39 +197,46 @@ public abstract class ThreesideDiffViewer<T extends EditorHolder> extends Listen
@NotNull protected final ThreeSide mySide1;
@NotNull protected final ThreeSide mySide2;
public ShowPartialDiffAction(@NotNull PartialDiffMode mode) {
public ShowPartialDiffAction(@NotNull PartialDiffMode mode, boolean hasFourSides) {
String id;
Icon icon = null;
switch (mode) {
case LEFT_MIDDLE:
mySide1 = ThreeSide.LEFT;
mySide2 = ThreeSide.BASE;
id = "Diff.ComparePartial.Base.Left";
if (!hasFourSides) icon = AllIcons.Diff.LeftDiff;
break;
case RIGHT_MIDDLE:
mySide1 = ThreeSide.RIGHT;
mySide2 = ThreeSide.BASE;
id = "Diff.ComparePartial.Base.Right";
if (!hasFourSides) icon = AllIcons.Diff.RightDiff;
break;
case MIDDLE_LEFT:
mySide1 = ThreeSide.BASE;
mySide2 = ThreeSide.LEFT;
id = "Diff.ComparePartial.Base.Left";
if (!hasFourSides) icon = AllIcons.Diff.LeftDiff;
break;
case MIDDLE_RIGHT:
mySide1 = ThreeSide.BASE;
mySide2 = ThreeSide.RIGHT;
id = "Diff.ComparePartial.Base.Right";
if (!hasFourSides) icon = AllIcons.Diff.RightDiff;
break;
case LEFT_RIGHT:
mySide1 = ThreeSide.LEFT;
mySide2 = ThreeSide.RIGHT;
id = "Diff.ComparePartial.Left.Right";
if (!hasFourSides) icon = AllIcons.Diff.BranchDiff;
break;
default:
throw new IllegalArgumentException();
}
String text = ActionsBundle.message("action.Diff.ComparePartial.Generic", mySide1.getIndex(), mySide2.getIndex());
getTemplatePresentation().setText(text);
getTemplatePresentation().setIcon(icon);
ActionUtil.mergeFrom(this, id);
}
@@ -364,8 +364,8 @@ public abstract class ThreesideTextDiffViewer extends ThreesideDiffViewer<TextEd
}
protected class TextShowPartialDiffAction extends ShowPartialDiffAction {
public TextShowPartialDiffAction(@NotNull PartialDiffMode mode) {
super(mode);
public TextShowPartialDiffAction(@NotNull PartialDiffMode mode, boolean hasFourSides) {
super(mode, hasFourSides);
}
@NotNull
@@ -16,8 +16,7 @@
package com.intellij.ide.ui;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.util.ui.UIUtil;
import sun.swing.SwingUtilities2;
import com.intellij.util.ui.GraphicsUtil;
import java.awt.*;
@@ -54,8 +53,8 @@ public enum AntialiasingType {
isEnabled = enabled;
}
public SwingUtilities2.AATextInfo getTextInfo() {
return !isEnabled ? null : new SwingUtilities2.AATextInfo(myHint, UIUtil.getLcdContrastValue());
public Object getTextInfo() {
return isEnabled ? GraphicsUtil.createAATextInfo(myHint) : null;
}
@Override
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.externalSystem.service.execution;
import com.intellij.diagnostic.logging.LogConfigurationPanel;
@@ -53,8 +68,7 @@ import java.io.OutputStream;
* @since 23.05.13 18:30
*/
public class ExternalSystemRunConfiguration extends LocatableConfigurationBase {
private static final Logger LOG = Logger.getInstance("#" + ExternalSystemRunConfiguration.class.getName());
private static final Logger LOG = Logger.getInstance(ExternalSystemRunConfiguration.class);
private ExternalSystemTaskExecutionSettings mySettings = new ExternalSystemTaskExecutionSettings();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Some files were not shown because too many files have changed in this diff Show More