mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CPP-16098 - Lags during inplace rename typing
- reverted some of the changes GitOrigin-RevId: c7c07b80a76c29794ef31e0e916e62f7f302917a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e1bb280f82
commit
c33e69a545
+3
-3
@@ -1,12 +1,12 @@
|
||||
<component name="libraryTable">
|
||||
<library name="completion-ranking-java" type="repository">
|
||||
<properties maven-id="org.jetbrains.intellij.deps.completion.ranking:java:0.0.3" />
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.intellij.deps.completion:completion-ranking-java:0.0.6" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/completion/ranking/java/0.0.3/java-0.0.3.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/completion/completion-ranking-java/0.0.6/completion-ranking-java-0.0.6.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/completion/ranking/java/0.0.3/java-0.0.3-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/completion/completion-ranking-java/0.0.6/completion-ranking-java-0.0.6-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<component name="libraryTable">
|
||||
<library name="completion-ranking-python" type="repository">
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.intellij.deps.completion:completion-ranking-python:0.0.2" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/completion/completion-ranking-python/0.0.2/completion-ranking-python-0.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/completion/completion-ranking-python/0.0.2/completion-ranking-python-0.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
Generated
+3
-3
@@ -1,12 +1,12 @@
|
||||
<component name="libraryTable">
|
||||
<library name="jediterm-pty" type="repository">
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.jediterm:jediterm-pty:2.14" />
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.jediterm:jediterm-pty:2.15" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/jediterm/jediterm-pty/2.14/jediterm-pty-2.14.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/jediterm/jediterm-pty/2.15/jediterm-pty-2.15.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/jediterm/jediterm-pty/2.14/jediterm-pty-2.14-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/jediterm/jediterm-pty/2.15/jediterm-pty-2.15-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
Generated
+5
-5
@@ -1,14 +1,14 @@
|
||||
<component name="libraryTable">
|
||||
<library name="jna" type="repository">
|
||||
<properties maven-id="net.java.dev.jna:jna-platform:4.5.0" />
|
||||
<properties maven-id="net.java.dev.jna:jna-platform:5.3.1" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna-platform/4.5.0/jna-platform-4.5.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna/4.5.0/jna-4.5.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna-platform/5.3.1/jna-platform-5.3.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna/5.3.1/jna-5.3.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna-platform/4.5.0/jna-platform-4.5.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna/4.5.0/jna-4.5.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna-platform/5.3.1/jna-platform-5.3.1-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna/5.3.1/jna-5.3.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.intellij.lang.regexp;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -28,7 +14,6 @@ import java.util.EnumSet;
|
||||
public interface RegExpLanguageHost {
|
||||
|
||||
EnumSet<RegExpGroup.Type> EMPTY_NAMED_GROUP_TYPES = EnumSet.noneOf(RegExpGroup.Type.class);
|
||||
@SuppressWarnings("SSBasedInspection")
|
||||
String[][] EMPTY_COMPLETION_ITEMS_ARRAY = new String[0][];
|
||||
|
||||
boolean characterNeedsEscaping(char c);
|
||||
@@ -121,6 +106,10 @@ public interface RegExpLanguageHost {
|
||||
return EMPTY_COMPLETION_ITEMS_ARRAY;
|
||||
}
|
||||
|
||||
default boolean supportsPropertySyntax(@NotNull PsiElement context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
enum Lookbehind {
|
||||
/** Lookbehind not supported. */
|
||||
NOT_SUPPORTED,
|
||||
|
||||
@@ -94,6 +94,11 @@ public final class RegExpLanguageHosts extends ClassExtension<RegExpLanguageHost
|
||||
return host != null && host.supportsLiteralBackspace(regExpChar);
|
||||
}
|
||||
|
||||
public boolean supportsPropertySyntax(@NotNull PsiElement context) {
|
||||
RegExpLanguageHost host = findRegExpHost(context);
|
||||
return host != null && host.supportsPropertySyntax(context);
|
||||
}
|
||||
|
||||
public boolean supportsNamedGroupSyntax(@Nullable final RegExpGroup group) {
|
||||
final RegExpLanguageHost host = findRegExpHost(group);
|
||||
return host != null && host.supportsNamedGroupSyntax(group);
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ public class EcmaScriptRegexpParserDefinition extends RegExpParserDefinition {
|
||||
private final EnumSet<RegExpCapability> CAPABILITIES = EnumSet.of(RegExpCapability.OCTAL_NO_LEADING_ZERO,
|
||||
RegExpCapability.DANGLING_METACHARACTERS,
|
||||
RegExpCapability.ALLOW_EMPTY_CHARACTER_CLASS,
|
||||
RegExpCapability.PROPERTY_VALUES,
|
||||
RegExpCapability.MAX_OCTAL_377);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -219,6 +219,10 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
|
||||
if (category == null) {
|
||||
return;
|
||||
}
|
||||
if (!myLanguageHosts.supportsPropertySyntax(property)) {
|
||||
myHolder.createErrorAnnotation(property, "Property escape sequences are not supported in this regex dialect");
|
||||
return;
|
||||
}
|
||||
String propertyName = category.getText();
|
||||
if(!myLanguageHosts.isValidCategory(category.getPsi(), propertyName)) {
|
||||
final Annotation a = myHolder.createErrorAnnotation(category, "Unknown character category");
|
||||
|
||||
@@ -49,9 +49,8 @@ public enum ArtifactKind {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static EnumSet<ArtifactKind> kindsOf(boolean sources, boolean javadoc) {
|
||||
|
||||
public static EnumSet<ArtifactKind> kindsOf(boolean sources, boolean javadoc, String... artifactPackaging) {
|
||||
EnumSet<ArtifactKind> result = EnumSet.noneOf(ArtifactKind.class);
|
||||
if (sources) {
|
||||
result.add(SOURCES);
|
||||
@@ -59,6 +58,17 @@ public enum ArtifactKind {
|
||||
if (javadoc) {
|
||||
result.add(JAVADOC);
|
||||
}
|
||||
if (artifactPackaging.length == 0 || artifactPackaging.length == 1 && artifactPackaging[0] == null) {
|
||||
result.add(ARTIFACT);
|
||||
}
|
||||
else {
|
||||
for (String packaging : artifactPackaging) {
|
||||
final ArtifactKind artifact = find(ARTIFACT.getClassifier(), packaging);
|
||||
if (artifact != null) {
|
||||
result.add(artifact);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -27,4 +27,4 @@ LangString uninstall_previous_installations_prompt ${LANG_ENGLISH} "Select the $
|
||||
LangString uninstaller_relocated ${LANG_ENGLISH} "Uninstall hasn't detected folder of ${MUI_PRODUCT} installation. Probably uninstall.exe was moved from the installation folder."
|
||||
LangString empty_or_upgrade_folder ${LANG_ENGLISH} "Please select an empty folder."
|
||||
LangString application_running ${LANG_ENGLISH} "$INSTDIR is running. Close the application and retry the installation."
|
||||
LangString download_jre_32bit_version ${LANG_ENGLISH} "Download and install JBR x86"
|
||||
LangString download_jre_32bit_version ${LANG_ENGLISH} "Download and install 32-bit JetBrains Runtime"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# The file might be automatically updated. Comments and empty lines will be removed.
|
||||
# kotlinPluginBuild format: <plugin-version>[:<channel>], e.g. 1.3.20-release-IJ2018.3-1 or 1.3.20-eap-100-IJ2018.3-1:EAP
|
||||
kotlinPluginBuild=1.3.30-release-IJ2019.1-1
|
||||
kotlinPluginBuild=1.3.31-release-IJ2019.1-1
|
||||
jetSignBuild=42.30
|
||||
secondJreVersion=11
|
||||
secondJreBuild=11_0_2b226.5
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url "https://cache-redirector.jetbrains.com/plugins.gradle.org" }
|
||||
@@ -8,9 +7,8 @@ buildscript {
|
||||
classpath "de.undercouch:gradle-download-task:3.2.0"
|
||||
}
|
||||
}
|
||||
apply plugin: "de.undercouch.download"
|
||||
|
||||
import de.undercouch.gradle.tasks.download.Download
|
||||
apply plugin: "de.undercouch.download"
|
||||
|
||||
configurations {
|
||||
mavenServer3CommonLibs
|
||||
@@ -34,7 +32,7 @@ def communityPluginsDir = project.file("../../plugins")
|
||||
def mavenServerLibDir = "$communityPluginsDir/maven/maven36-server-impl/lib/"
|
||||
def mavenDistName = "apache-maven-$bundledMavenVersion"
|
||||
|
||||
task unpackMavenDistribution( type: Copy) {
|
||||
task unpackMavenDistribution(type: Copy) {
|
||||
from zipTree(project.configurations.maven3Distribution.singleFile)
|
||||
into "$mavenServerLibDir/maven3"
|
||||
onlyIf { (!destinationDir.exists()) || destinationDir.list() == null || destinationDir.list().length == 0 }
|
||||
@@ -45,7 +43,7 @@ task setupCommonLibs(type: Copy) {
|
||||
into "$communityPluginsDir/maven/maven3-server-common/lib"
|
||||
}
|
||||
|
||||
//there is no frienly way to unpack gradle zip without parent dir
|
||||
//there is no friendly way to unpack gradle zip without parent dir
|
||||
task setupBundledMaven(dependsOn: [unpackMavenDistribution, setupCommonLibs], type: Copy) {
|
||||
def unzippedDir = new File("$mavenServerLibDir/maven3/$mavenDistName")
|
||||
from fileTree(unzippedDir)
|
||||
@@ -54,4 +52,4 @@ task setupBundledMaven(dependsOn: [unpackMavenDistribution, setupCommonLibs], ty
|
||||
doLast() {
|
||||
unzippedDir.deleteDir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package com.intellij.compiler.actions;
|
||||
|
||||
import com.intellij.lang.IdeLanguageCustomization;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonShortcuts;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -67,7 +70,15 @@ public class BuildArtifactAction extends DumbAwareAction {
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
final Project project = getEventProject(e);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabledAndVisible(project != null && !ArtifactUtil.getArtifactWithOutputPaths(project).isEmpty());
|
||||
boolean enabled = project != null && !ArtifactUtil.getArtifactWithOutputPaths(project).isEmpty();
|
||||
if (IdeLanguageCustomization.getInstance().getPrimaryIdeLanguages().contains(StdFileTypes.JAVA.getLanguage())
|
||||
&& ActionPlaces.MAIN_MENU.equals(e.getPlace())) {
|
||||
//building artifacts is a valuable functionality for Java IDEs, let's not hide 'Build Artifacts' item from the main menu
|
||||
presentation.setEnabled(enabled);
|
||||
}
|
||||
else {
|
||||
presentation.setEnabledAndVisible(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.compiler.*;
|
||||
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
|
||||
import com.intellij.openapi.deployment.DeploymentUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
@@ -473,7 +472,7 @@ public class CompileDriver {
|
||||
|
||||
if (_status != ExitStatus.UP_TO_DATE && _status != ExitStatus.CANCELLED) {
|
||||
// have to refresh in case of errors too, because run configuration may be set to ignore errors
|
||||
Collection<String> affectedRoots = ContainerUtil.newHashSet(CompilerPathsEx.getOutputPaths(affectedModules));
|
||||
Collection<String> affectedRoots = ContainerUtil.newHashSet(CompilerPaths.getOutputPaths(affectedModules));
|
||||
if (!affectedRoots.isEmpty()) {
|
||||
ProgressIndicator indicator = compileContext.getProgressIndicator();
|
||||
indicator.setText("Synchronizing output directories...");
|
||||
|
||||
+3
-18
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.compiler.impl.javaCompiler;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
@@ -26,8 +12,7 @@ import java.util.Set;
|
||||
public interface BackendCompiler {
|
||||
ExtensionPointName<BackendCompiler> EP_NAME = ExtensionPointName.create("com.intellij.java.compiler");
|
||||
|
||||
CompilerOptions EMPTY_OPTIONS = new CompilerOptions() {
|
||||
};
|
||||
CompilerOptions EMPTY_OPTIONS = new CompilerOptions() { };
|
||||
|
||||
@NotNull
|
||||
String getId(); // used for externalization
|
||||
@@ -45,4 +30,4 @@ public interface BackendCompiler {
|
||||
default CompilerOptions getOptions() {
|
||||
return EMPTY_OPTIONS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.compiler.options;
|
||||
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
@@ -19,12 +19,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -38,41 +35,39 @@ public class JavaCompilersTab extends CompositeConfigurable<Configurable> implem
|
||||
private final CardLayout myCardLayout;
|
||||
|
||||
private final Project myProject;
|
||||
private final BackendCompiler myDefaultCompiler;
|
||||
private BackendCompiler mySelectedCompiler;
|
||||
private final CompilerConfigurationImpl myCompilerConfiguration;
|
||||
private final BackendCompiler myDefaultCompiler;
|
||||
private final TargetOptionsComponent myTargetLevelComponent;
|
||||
private final List<Configurable> myConfigurables;
|
||||
private BackendCompiler mySelectedCompiler;
|
||||
|
||||
public JavaCompilersTab(final Project project) {
|
||||
this(project, ((CompilerConfigurationImpl)CompilerConfiguration.getInstance(project)).getDefaultCompiler());
|
||||
}
|
||||
|
||||
private JavaCompilersTab(final Project project, BackendCompiler defaultCompiler) {
|
||||
public JavaCompilersTab(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myDefaultCompiler = defaultCompiler;
|
||||
myCompilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(project);
|
||||
myDefaultCompiler = myCompilerConfiguration.getDefaultCompiler();
|
||||
myTargetLevelComponent = new TargetOptionsComponent(project);
|
||||
|
||||
myCardLayout = new CardLayout();
|
||||
myContentPanel.setLayout(myCardLayout);
|
||||
|
||||
myTargetOptionsPanel.setLayout(new BorderLayout());
|
||||
myTargetLevelComponent = new TargetOptionsComponent(project);
|
||||
myTargetOptionsPanel.add(myTargetLevelComponent, BorderLayout.CENTER);
|
||||
|
||||
final List<BackendCompiler> compilers = getCompilers();
|
||||
final List<Configurable> configurables = getConfigurables();
|
||||
for (int i = 0; i < configurables.size(); i++) {
|
||||
myContentPanel.add(configurables.get(i).createComponent(), compilers.get(i).getId());
|
||||
Collection<BackendCompiler> compilers = myCompilerConfiguration.getRegisteredJavaCompilers();
|
||||
myConfigurables = new ArrayList<>(compilers.size());
|
||||
for (BackendCompiler compiler : compilers) {
|
||||
Configurable configurable = compiler.createConfigurable();
|
||||
myConfigurables.add(configurable);
|
||||
JComponent component = configurable.createComponent();
|
||||
assert component != null : configurable.getClass();
|
||||
myContentPanel.add(component, compiler.getId());
|
||||
}
|
||||
myCompiler.setModel(new DefaultComboBoxModel<>(new Vector<>(compilers)));
|
||||
|
||||
myCompiler.setModel(new DefaultComboBoxModel<>(compilers.toArray(new BackendCompiler[0])));
|
||||
myCompiler.setRenderer(SimpleListCellRenderer.create("", BackendCompiler::getPresentableName));
|
||||
myCompiler.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final BackendCompiler compiler = (BackendCompiler)myCompiler.getSelectedItem();
|
||||
if (compiler != null) {
|
||||
selectCompiler(compiler);
|
||||
}
|
||||
myCompiler.addActionListener(e -> {
|
||||
BackendCompiler compiler = (BackendCompiler)myCompiler.getSelectedItem();
|
||||
if (compiler != null) {
|
||||
selectCompiler(compiler);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -82,13 +77,15 @@ public class JavaCompilersTab extends CompositeConfigurable<Configurable> implem
|
||||
return CompilerBundle.message("java.compiler.description");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public String getHelpTopic() {
|
||||
return "reference.projectsettings.compiler.javacompiler";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@Override
|
||||
public String getId() {
|
||||
return getHelpTopic();
|
||||
}
|
||||
@@ -100,35 +97,23 @@ public class JavaCompilersTab extends CompositeConfigurable<Configurable> implem
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
if (!Comparing.equal(mySelectedCompiler, myCompilerConfiguration.getDefaultCompiler())) {
|
||||
return true;
|
||||
}
|
||||
if (myCbUseReleaseOption.isSelected() != myCompilerConfiguration.useReleaseOption()) {
|
||||
return true;
|
||||
}
|
||||
if (super.isModified()) {
|
||||
return true;
|
||||
}
|
||||
if (!Comparing.equal(myTargetLevelComponent.getProjectBytecodeTarget(), myCompilerConfiguration.getProjectBytecodeTarget())) {
|
||||
return true;
|
||||
}
|
||||
if (!Comparing.equal(myTargetLevelComponent.getModulesBytecodeTargetMap(), myCompilerConfiguration.getModulesBytecodeTargetMap())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !Comparing.equal(mySelectedCompiler, myCompilerConfiguration.getDefaultCompiler()) ||
|
||||
myCbUseReleaseOption.isSelected() != myCompilerConfiguration.useReleaseOption() ||
|
||||
!Comparing.equal(myTargetLevelComponent.getProjectBytecodeTarget(), myCompilerConfiguration.getProjectBytecodeTarget()) ||
|
||||
!Comparing.equal(myTargetLevelComponent.getModulesBytecodeTargetMap(), myCompilerConfiguration.getModulesBytecodeTargetMap()) ||
|
||||
super.isModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
try {
|
||||
myCompilerConfiguration.setUseReleaseOption(myCbUseReleaseOption.isSelected());
|
||||
|
||||
super.apply();
|
||||
|
||||
myCompilerConfiguration.setDefaultCompiler(mySelectedCompiler);
|
||||
myCompilerConfiguration.setUseReleaseOption(myCbUseReleaseOption.isSelected());
|
||||
myCompilerConfiguration.setProjectBytecodeTarget(myTargetLevelComponent.getProjectBytecodeTarget());
|
||||
myCompilerConfiguration.setModulesBytecodeTargetMap(myTargetLevelComponent.getModulesBytecodeTargetMap());
|
||||
|
||||
super.apply();
|
||||
|
||||
myTargetLevelComponent.setProjectBytecodeTargetLevel(myCompilerConfiguration.getProjectBytecodeTarget());
|
||||
myTargetLevelComponent.setModuleTargetLevels(myCompilerConfiguration.getModulesBytecodeTargetMap());
|
||||
}
|
||||
@@ -140,17 +125,15 @@ public class JavaCompilersTab extends CompositeConfigurable<Configurable> implem
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
myCbUseReleaseOption.setSelected(myCompilerConfiguration.useReleaseOption());
|
||||
|
||||
super.reset();
|
||||
|
||||
selectCompiler(myCompilerConfiguration.getDefaultCompiler());
|
||||
myCbUseReleaseOption.setSelected(myCompilerConfiguration.useReleaseOption());
|
||||
myTargetLevelComponent.setProjectBytecodeTargetLevel(myCompilerConfiguration.getProjectBytecodeTarget());
|
||||
myTargetLevelComponent.setModuleTargetLevels(myCompilerConfiguration.getModulesBytecodeTargetMap());
|
||||
}
|
||||
|
||||
private void selectCompiler(BackendCompiler compiler) {
|
||||
if(compiler == null) {
|
||||
if (compiler == null) {
|
||||
compiler = myDefaultCompiler;
|
||||
}
|
||||
myCompiler.setSelectedItem(compiler);
|
||||
@@ -163,17 +146,6 @@ public class JavaCompilersTab extends CompositeConfigurable<Configurable> implem
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<Configurable> createConfigurables() {
|
||||
final Collection<BackendCompiler> compilers = getCompilers();
|
||||
final List<Configurable> configurables = new ArrayList<>(compilers.size());
|
||||
for (final BackendCompiler compiler : compilers) {
|
||||
configurables.add(compiler.createConfigurable());
|
||||
}
|
||||
return configurables;
|
||||
return myConfigurables;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<BackendCompiler> getCompilers() {
|
||||
final CompilerConfigurationImpl configuration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
|
||||
return (List<BackendCompiler>)configuration.getRegisteredJavaCompilers();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.compiler.Compiler;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.compiler.Validator;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompiler;
|
||||
import com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable;
|
||||
import com.intellij.openapi.compiler.options.ExcludesConfiguration;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
@@ -159,13 +158,7 @@ public class ValidationConfigurable implements SearchableConfigurable, Configura
|
||||
|
||||
private List<Compiler> getValidators() {
|
||||
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
|
||||
final List<Compiler> validators = new SmartList<>(compilerManager.getCompilers(Validator.class));
|
||||
for (GenericCompiler compiler : compilerManager.getCompilers(GenericCompiler.class)) {
|
||||
if (compiler.getOrderPlace() == GenericCompiler.CompileOrderPlace.VALIDATING) {
|
||||
validators.add(compiler);
|
||||
}
|
||||
}
|
||||
return validators;
|
||||
return new SmartList<>(compilerManager.getCompilers(Validator.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,24 +1,10 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.macro;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
|
||||
import com.intellij.openapi.compiler.CompilerPaths;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -65,7 +51,7 @@ public final class OutputPathMacro extends Macro {
|
||||
if (allModules.length == 0) {
|
||||
return null;
|
||||
}
|
||||
String[] paths = CompilerPathsEx.getOutputPaths(allModules);
|
||||
String[] paths = CompilerPaths.getOutputPaths(allModules);
|
||||
final StringBuilder outputPath = new StringBuilder();
|
||||
for (int idx = 0; idx < paths.length; idx++) {
|
||||
String path = paths[idx];
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.compiler.generic;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated this class is part of the old deprecated build infrastructure; plug into the external build process instead (see {@link org.jetbrains.jps.builders.BuildTarget})
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
public abstract class BuildTarget {
|
||||
public static final BuildTarget DEFAULT = new BuildTarget() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getId() {
|
||||
return "<default>";
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
public abstract String getId();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Build Target: " + getId();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.compiler.generic;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated this class is part of the old deprecated build infrastructure; plug into the external build process instead (see {@link org.jetbrains.jps.builders.BuildTarget})
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
public abstract class CompileItem<Key, SourceState, OutputState> {
|
||||
@NotNull
|
||||
public abstract Key getKey();
|
||||
|
||||
public abstract boolean isSourceUpToDate(@NotNull SourceState state);
|
||||
|
||||
@NotNull
|
||||
public abstract SourceState computeSourceState();
|
||||
|
||||
|
||||
public abstract boolean isOutputUpToDate(@NotNull OutputState state);
|
||||
|
||||
@NotNull
|
||||
public abstract OutputState computeOutputState();
|
||||
|
||||
public boolean isExcluded() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.compiler.generic;
|
||||
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @deprecated this class is part of the old deprecated build infrastructure; plug into the external build process instead (see {@link org.jetbrains.jps.builders.BuildTarget})
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
public class DummyPersistentState {
|
||||
public static final DummyPersistentState INSTANCE = new DummyPersistentState();
|
||||
public static final DataExternalizer<DummyPersistentState> EXTERNALIZER = new DummyPersistentStateExternalizer();
|
||||
|
||||
private DummyPersistentState() {
|
||||
}
|
||||
|
||||
private static class DummyPersistentStateExternalizer implements DataExternalizer<DummyPersistentState> {
|
||||
@Override
|
||||
public void save(@NotNull DataOutput out, DummyPersistentState value) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DummyPersistentState read(@NotNull DataInput in) throws IOException {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.Compiler;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import com.intellij.util.io.EnumeratorStringDescriptor;
|
||||
import com.intellij.util.io.KeyDescriptor;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated this class is part of the old deprecated build infrastructure; plug into the external build process instead
|
||||
* (see {@link org.jetbrains.jps.incremental.TargetBuilder})
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
public abstract class GenericCompiler<Key, SourceState, OutputState> implements Compiler {
|
||||
protected static final KeyDescriptor<String> STRING_KEY_DESCRIPTOR = EnumeratorStringDescriptor.INSTANCE;
|
||||
private final String myId;
|
||||
private final int myVersion;
|
||||
private final CompileOrderPlace myOrderPlace;
|
||||
|
||||
protected GenericCompiler(@NotNull String id, int version, @NotNull CompileOrderPlace orderPlace) {
|
||||
myId = id;
|
||||
myVersion = version;
|
||||
myOrderPlace = orderPlace;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract KeyDescriptor<Key> getItemKeyDescriptor();
|
||||
@NotNull
|
||||
public abstract DataExternalizer<SourceState> getSourceStateExternalizer();
|
||||
@NotNull
|
||||
public abstract DataExternalizer<OutputState> getOutputStateExternalizer();
|
||||
|
||||
@NotNull
|
||||
public abstract GenericCompilerInstance<?, ? extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState> createInstance(@NotNull CompileContext context);
|
||||
|
||||
public final String getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
public final int getVersion() {
|
||||
return myVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateConfiguration(CompileScope scope) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public CompileOrderPlace getOrderPlace() {
|
||||
return myOrderPlace;
|
||||
}
|
||||
|
||||
public enum CompileOrderPlace {
|
||||
CLASS_INSTRUMENTING, CLASS_POST_PROCESSING, PACKAGING, VALIDATING
|
||||
}
|
||||
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.compiler.generic;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated this class is part of the old deprecated build infrastructure; plug into the external build process instead
|
||||
* (see {@link org.jetbrains.jps.incremental.TargetBuilder})
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
public class GenericCompilerCacheState<Key, SourceState, OutputState> {
|
||||
private final Key myKey;
|
||||
private final SourceState mySourceState;
|
||||
private final OutputState myOutputState;
|
||||
|
||||
public GenericCompilerCacheState(@NotNull Key key, @NotNull SourceState sourceState, @NotNull OutputState outputState) {
|
||||
myKey = key;
|
||||
mySourceState = sourceState;
|
||||
myOutputState = outputState;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Key getKey() {
|
||||
return myKey;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SourceState getSourceState() {
|
||||
return mySourceState;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OutputState getOutputState() {
|
||||
return myOutputState;
|
||||
}
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @deprecated this class is part of the old deprecated build infrastructure; plug into the external build process instead
|
||||
* (see {@link org.jetbrains.jps.incremental.TargetBuilder})
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
public abstract class GenericCompilerInstance<T extends BuildTarget, Item extends CompileItem<Key, SourceState, OutputState>, Key, SourceState, OutputState> {
|
||||
protected final CompileContext myContext;
|
||||
|
||||
protected GenericCompilerInstance(CompileContext context) {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
protected Project getProject() {
|
||||
return myContext.getProject();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract List<T> getAllTargets();
|
||||
|
||||
@NotNull
|
||||
public abstract List<T> getSelectedTargets();
|
||||
|
||||
public abstract void processObsoleteTarget(@NotNull String targetId, @NotNull List<GenericCompilerCacheState<Key, SourceState, OutputState>> obsoleteItems);
|
||||
|
||||
|
||||
@NotNull
|
||||
public abstract List<Item> getItems(@NotNull T target);
|
||||
|
||||
public abstract void processItems(@NotNull T target, @NotNull List<? extends GenericCompilerProcessingItem<Item, SourceState, OutputState>> changedItems, @NotNull List<GenericCompilerCacheState<Key, SourceState, OutputState>> obsoleteItems,
|
||||
@NotNull OutputConsumer<? super Item> consumer);
|
||||
|
||||
public interface OutputConsumer<Item extends CompileItem<?,?,?>> {
|
||||
void addFileToRefresh(@NotNull File file);
|
||||
|
||||
void addDirectoryToRefresh(@NotNull File dir);
|
||||
|
||||
void addProcessedItem(@NotNull Item sourceItem);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.compiler.generic;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @deprecated this class is part of the old deprecated build infrastructure; plug into the external build process instead (see {@link org.jetbrains.jps.builders.BuildTarget})
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
public class GenericCompilerProcessingItem<Item extends CompileItem<?, SourceState, OutputState>, SourceState, OutputState> {
|
||||
private final Item myItem;
|
||||
private final SourceState myCachedSourceState;
|
||||
private final OutputState myCachedOutputState;
|
||||
|
||||
public GenericCompilerProcessingItem(@NotNull Item item, @Nullable SourceState cachedSourceState, @Nullable OutputState cachedOutputState) {
|
||||
myItem = item;
|
||||
myCachedSourceState = cachedSourceState;
|
||||
myCachedOutputState = cachedOutputState;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Item getItem() {
|
||||
return myItem;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SourceState getCachedSourceState() {
|
||||
return myCachedSourceState;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public OutputState getCachedOutputState() {
|
||||
return myCachedOutputState;
|
||||
}
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.compiler.generic;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import com.intellij.util.io.IOUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @deprecated this class is part of the old deprecated build infrastructure; plug into the external build process instead (see {@link org.jetbrains.jps.builders.BuildTarget})
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
public class VirtualFileWithDependenciesState {
|
||||
public static final DataExternalizer<VirtualFileWithDependenciesState> EXTERNALIZER = new VirtualFileWithDependenciesExternalizer();
|
||||
private final long mySourceTimestamp;
|
||||
private final Map<String, Long> myDependencies = new HashMap<>();
|
||||
|
||||
public VirtualFileWithDependenciesState(long sourceTimestamp) {
|
||||
mySourceTimestamp = sourceTimestamp;
|
||||
}
|
||||
|
||||
public void addDependency(@NotNull VirtualFile file) {
|
||||
myDependencies.put(file.getUrl(), file.getTimeStamp());
|
||||
}
|
||||
|
||||
public boolean isUpToDate(@NotNull VirtualFile sourceFile) {
|
||||
if (sourceFile.getTimeStamp() != mySourceTimestamp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VirtualFileManager manager = VirtualFileManager.getInstance();
|
||||
for (Map.Entry<String, Long> entry : myDependencies.entrySet()) {
|
||||
final VirtualFile file = manager.findFileByUrl(entry.getKey());
|
||||
if (file == null || file.getTimeStamp() != entry.getValue()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static class VirtualFileWithDependenciesExternalizer implements DataExternalizer<VirtualFileWithDependenciesState> {
|
||||
@Override
|
||||
public void save(@NotNull DataOutput out, VirtualFileWithDependenciesState value) throws IOException {
|
||||
out.writeLong(value.mySourceTimestamp);
|
||||
final Map<String, Long> dependencies = value.myDependencies;
|
||||
out.writeInt(dependencies.size());
|
||||
for (Map.Entry<String, Long> entry : dependencies.entrySet()) {
|
||||
IOUtil.writeUTF(out, entry.getKey());
|
||||
out.writeLong(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFileWithDependenciesState read(@NotNull DataInput in) throws IOException {
|
||||
final VirtualFileWithDependenciesState state = new VirtualFileWithDependenciesState(in.readLong());
|
||||
int size = in.readInt();
|
||||
while (size-- > 0) {
|
||||
final String url = IOUtil.readUTF(in);
|
||||
final long timestamp = in.readLong();
|
||||
state.myDependencies.put(url, timestamp);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +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.task.impl;
|
||||
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.task.ArtifactBuildTask;
|
||||
import com.intellij.task.ProjectModelBuildTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated to be removed, use {@link ProjectModelBuildTask}
|
||||
*
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
@Deprecated
|
||||
public class ArtifactBuildTaskImpl extends AbstractBuildTask implements ArtifactBuildTask {
|
||||
private final Artifact myArtifact;
|
||||
|
||||
public ArtifactBuildTaskImpl(Artifact artifact, boolean isIncrementalBuild) {
|
||||
super(isIncrementalBuild);
|
||||
myArtifact = artifact;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Artifact getArtifact() {
|
||||
return myArtifact;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return "Artifact '" + myArtifact.getName() + "' build task";
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.compiler;
|
||||
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
@@ -25,15 +11,22 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderEnumerationHandler;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.OrderedSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.java.compiler.AnnotationProcessingConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A set of utility methods for working with paths
|
||||
@@ -155,4 +148,35 @@ public class CompilerPaths {
|
||||
return StringUtil.isEmpty(sourceDirName)? path : path + "/" + sourceDirName;
|
||||
}
|
||||
|
||||
}
|
||||
@NotNull
|
||||
public static String[] getOutputPaths(@NotNull Module[] modules) {
|
||||
Set<String> outputPaths = new OrderedSet<>();
|
||||
for (Module module : modules) {
|
||||
CompilerModuleExtension compilerModuleExtension = !module.isDisposed()? CompilerModuleExtension.getInstance(module) : null;
|
||||
if (compilerModuleExtension == null) continue;
|
||||
|
||||
String outputPathUrl = compilerModuleExtension.getCompilerOutputUrl();
|
||||
if (outputPathUrl != null) {
|
||||
outputPaths.add(VirtualFileManager.extractPath(outputPathUrl).replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
String outputPathForTestsUrl = compilerModuleExtension.getCompilerOutputUrlForTests();
|
||||
if (outputPathForTestsUrl != null) {
|
||||
outputPaths.add(VirtualFileManager.extractPath(outputPathForTestsUrl).replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
for (OrderEnumerationHandler.Factory handlerFactory : OrderEnumerationHandler.EP_NAME.getExtensions()) {
|
||||
if (handlerFactory.isApplicable(module)) {
|
||||
OrderEnumerationHandler handler = handlerFactory.createHandler(module);
|
||||
List<String> outputUrls = new SmartList<>();
|
||||
handler.addCustomModuleRoots(OrderRootType.CLASSES, moduleRootManager, outputUrls, true, true);
|
||||
for (String outputUrl : outputUrls) {
|
||||
outputPaths.add(VirtualFileManager.extractPath(outputUrl).replace('/', File.separatorChar));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ArrayUtil.toStringArray(outputPaths);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +1,8 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.compiler.ex;
|
||||
|
||||
import com.intellij.openapi.compiler.CompilerPaths;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderEnumerationHandler;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.OrderedSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CompilerPathsEx extends CompilerPaths {
|
||||
@NotNull
|
||||
public static String[] getOutputPaths(@NotNull Module[] modules) {
|
||||
Set<String> outputPaths = new OrderedSet<>();
|
||||
for (Module module : modules) {
|
||||
CompilerModuleExtension compilerModuleExtension = !module.isDisposed()? CompilerModuleExtension.getInstance(module) : null;
|
||||
if (compilerModuleExtension == null) continue;
|
||||
|
||||
String outputPathUrl = compilerModuleExtension.getCompilerOutputUrl();
|
||||
if (outputPathUrl != null) {
|
||||
outputPaths.add(VirtualFileManager.extractPath(outputPathUrl).replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
String outputPathForTestsUrl = compilerModuleExtension.getCompilerOutputUrlForTests();
|
||||
if (outputPathForTestsUrl != null) {
|
||||
outputPaths.add(VirtualFileManager.extractPath(outputPathForTestsUrl).replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
for (OrderEnumerationHandler.Factory handlerFactory : OrderEnumerationHandler.EP_NAME.getExtensions()) {
|
||||
if (handlerFactory.isApplicable(module)) {
|
||||
OrderEnumerationHandler handler = handlerFactory.createHandler(module);
|
||||
List<String> outputUrls = new SmartList<>();
|
||||
handler.addCustomModuleRoots(OrderRootType.CLASSES, moduleRootManager, outputUrls, true, true);
|
||||
for (String outputUrl : outputUrls) {
|
||||
outputPaths.add(VirtualFileManager.extractPath(outputUrl).replace('/', File.separatorChar));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ArrayUtil.toStringArray(outputPaths);
|
||||
}
|
||||
}
|
||||
/** @deprecated use {@link CompilerPaths} */
|
||||
@Deprecated
|
||||
public class CompilerPathsEx extends CompilerPaths { }
|
||||
@@ -67,37 +67,4 @@ public abstract class DeploymentUtil {
|
||||
|
||||
@Nullable
|
||||
public abstract String getConfigFileErrorMessage(ConfigFile configFile);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link com.intellij.openapi.util.io.FileUtil#getRelativePath}
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public static String getRelativePath(@NotNull String basePath, @NotNull final String filePath) {
|
||||
if (basePath.equals(filePath)) return "";
|
||||
if (!basePath.endsWith(File.separator)) basePath += File.separatorChar;
|
||||
|
||||
int len = 0;
|
||||
int lastSeparatorIndex = 0; // need this for cases like this: base="/temp/abcde/baseDir" and file="/temp/ab"
|
||||
while (len < filePath.length() && len < basePath.length() && filePath.charAt(len) == basePath.charAt(len)) {
|
||||
if (basePath.charAt(len) == File.separatorChar) {
|
||||
lastSeparatorIndex = len;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
return null;
|
||||
}
|
||||
final StringBuilder relativePath = new StringBuilder();
|
||||
for (int i=len; i < basePath.length(); i++) {
|
||||
if (basePath.charAt(i) == File.separatorChar) {
|
||||
relativePath.append("..");
|
||||
relativePath.append(File.separatorChar);
|
||||
}
|
||||
}
|
||||
relativePath.append(filePath.substring(lastSeparatorIndex + 1));
|
||||
|
||||
return relativePath.toString();
|
||||
}
|
||||
}
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.packaging.elements;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* @deprecated this interface was used in the old build infrastructure, it doesn't make sense anymore
|
||||
*/
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "192.0")
|
||||
@Deprecated
|
||||
public interface ArtifactIncrementalCompilerContext {
|
||||
}
|
||||
@@ -106,7 +106,7 @@ LIne read: #[wrote C:\temp\rmiTest\classes\mycompany\TTT.class]#
|
||||
|
||||
@Override
|
||||
protected void doExecute(final String line, final String dta, final OutputParser.Callback callback) {
|
||||
assertTrue("Expected: #" + myExpected + "#, but was: #" + dta + "#", myExpected.equals(dta));
|
||||
assertEquals("Expected: #" + myExpected + "#, but was: #" + dta + "#", myExpected, dta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ModuleCompileScopeTest extends BaseCompilerTestCase {
|
||||
|
||||
public void testForceCompileUpToDateFileAndDoNotCompileResources() {
|
||||
VirtualFile a = createFile("src/A.java", "class A{}");
|
||||
VirtualFile res = createFile("src/res.properties", "aaa=bbb");
|
||||
createFile("src/res.properties", "aaa=bbb");
|
||||
Module module = addModule("a", a.getParent());
|
||||
make(module);
|
||||
assertOutput(module, fs().file("A.class").file("res.properties"));
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.intellij.compiler;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class RecompileOnConfigurationChangeTest extends BaseCompilerTestCase {
|
||||
|
||||
File oldOutput = getOutputDir(m);
|
||||
File newOutput = createTempDir("new-output");
|
||||
PsiTestUtil.setCompilerOutputPath(m, VfsUtil.pathToUrl(FileUtil.toSystemIndependentName(newOutput.getAbsolutePath())), false);
|
||||
PsiTestUtil.setCompilerOutputPath(m, VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(newOutput.getAbsolutePath())), false);
|
||||
make(m);
|
||||
assertOutput(m, fs().file("A.class"));
|
||||
File[] files = oldOutput.listFiles();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger;
|
||||
|
||||
import com.intellij.debugger.engine.DebugProcess;
|
||||
@@ -34,9 +34,18 @@ public abstract class DebuggerManagerEx extends DebuggerManager {
|
||||
@NotNull
|
||||
public abstract DebuggerStateManager getContextManager();
|
||||
|
||||
public abstract void addDebuggerManagerListener(DebuggerManagerListener debuggerManagerListener);
|
||||
/**
|
||||
* @deprecated Use {@link DebuggerManagerListener#TOPIC}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void addDebuggerManagerListener(@NotNull DebuggerManagerListener debuggerManagerListener);
|
||||
|
||||
public abstract void removeDebuggerManagerListener(DebuggerManagerListener debuggerManagerListener);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link DebuggerManagerListener#TOPIC}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void removeDebuggerManagerListener(@NotNull DebuggerManagerListener debuggerManagerListener);
|
||||
|
||||
@Nullable
|
||||
public abstract DebuggerSession attachVirtualMachine(@NotNull DebugEnvironment environment) throws ExecutionException;
|
||||
|
||||
@@ -47,10 +47,7 @@ public class StepOutOfBlockAction extends DebuggerAction implements DumbAware {
|
||||
PsiElement block = PsiTreeUtil.getParentOfType(element, PsiCodeBlock.class, PsiLambdaExpression.class);
|
||||
if (block instanceof PsiCodeBlock) {
|
||||
PsiElement parent = block.getParent();
|
||||
if (parent instanceof PsiMethod || parent instanceof PsiLambdaExpression) {
|
||||
xSession.stepOut();
|
||||
}
|
||||
else {
|
||||
if (!(parent instanceof PsiMethod) && !(parent instanceof PsiLambdaExpression)) {
|
||||
TextRange textRange = block.getTextRange();
|
||||
Document document = FileDocumentManager.getInstance().getDocument(position.getFile().getVirtualFile());
|
||||
if (document != null) {
|
||||
@@ -58,14 +55,13 @@ public class StepOutOfBlockAction extends DebuggerAction implements DumbAware {
|
||||
int endLine = document.getLineNumber(textRange.getEndOffset());
|
||||
session.sessionResumed();
|
||||
session.stepOver(false, new BlockFilter(startLine, endLine), StepRequest.STEP_LINE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
xSession.stepOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
xSession.stepOut();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.unscramble.ThreadDumpParser;
|
||||
import com.intellij.unscramble.ThreadState;
|
||||
@@ -29,7 +30,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ThreadDumpAction extends AnAction implements AnAction.TransparentUpdate {
|
||||
public class ThreadDumpAction extends DumbAwareAction implements AnAction.TransparentUpdate {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class AlternativeJreClassFinder extends NonClasspathClassFinder {
|
||||
public AlternativeJreClassFinder(Project project) {
|
||||
super(project);
|
||||
|
||||
DebuggerManagerEx.getInstanceEx(project).addDebuggerManagerListener(new DebuggerManagerListener() {
|
||||
project.getMessageBus().connect().subscribe(DebuggerManagerListener.TOPIC, new DebuggerManagerListener() {
|
||||
@Override
|
||||
public void sessionCreated(DebuggerSession session) {
|
||||
clearCache();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.debugger.*;
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.Function;
|
||||
@@ -47,7 +46,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
public static final String LOCALHOST_ADDRESS_FALLBACK = "127.0.0.1";
|
||||
|
||||
private final Project myProject;
|
||||
private final HashMap<ProcessHandler, DebuggerSession> mySessions = new HashMap<>();
|
||||
private final Map<ProcessHandler, DebuggerSession> mySessions = new HashMap<>();
|
||||
private final BreakpointManager myBreakpointManager;
|
||||
private final List<NameMapper> myNameMappers = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private final List<Function<DebugProcess, PositionManager>> myCustomPositionManagerFactories = new SmartList<>();
|
||||
@@ -58,7 +57,6 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
private final DebuggerContextListener mySessionListener = new DebuggerContextListener() {
|
||||
@Override
|
||||
public void changeEvent(@NotNull DebuggerContextImpl newContext, DebuggerSession.Event event) {
|
||||
|
||||
final DebuggerSession session = newContext.getDebuggerSession();
|
||||
if (event == DebuggerSession.Event.PAUSE && myDebuggerStateManager.myDebuggerSession != session) {
|
||||
// if paused in non-active session; switch current session
|
||||
@@ -70,10 +68,10 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
myDebuggerStateManager.fireStateChanged(newContext, event);
|
||||
}
|
||||
if (event == DebuggerSession.Event.ATTACHED) {
|
||||
myDispatcher.getMulticaster().sessionAttached(session);
|
||||
getEventPublisher().sessionAttached(session);
|
||||
}
|
||||
else if (event == DebuggerSession.Event.DETACHED) {
|
||||
myDispatcher.getMulticaster().sessionDetached(session);
|
||||
getEventPublisher().sessionDetached(session);
|
||||
}
|
||||
else if (event == DebuggerSession.Event.DISPOSE) {
|
||||
dispose(session);
|
||||
@@ -85,6 +83,11 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
private DebuggerManagerListener getEventPublisher() {
|
||||
return myProject.getMessageBus().syncPublisher(DebuggerManagerListener.TOPIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassNameMapper(final NameMapper mapper) {
|
||||
myNameMappers.add(mapper);
|
||||
@@ -107,12 +110,12 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDebuggerManagerListener(DebuggerManagerListener listener) {
|
||||
public void addDebuggerManagerListener(@NotNull DebuggerManagerListener listener) {
|
||||
myDispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDebuggerManagerListener(DebuggerManagerListener listener) {
|
||||
public void removeDebuggerManagerListener(@NotNull DebuggerManagerListener listener) {
|
||||
myDispatcher.removeListener(listener);
|
||||
}
|
||||
|
||||
@@ -127,6 +130,8 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
getBreakpointManager().updateBreakpointsUI();
|
||||
}
|
||||
});
|
||||
|
||||
busConnection.subscribe(DebuggerManagerListener.TOPIC, myDispatcher.getMulticaster());
|
||||
}
|
||||
myBreakpointManager.addListeners(busConnection);
|
||||
}
|
||||
@@ -226,7 +231,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
}
|
||||
});
|
||||
}
|
||||
myDispatcher.getMulticaster().sessionCreated(session);
|
||||
getEventPublisher().sessionCreated(session);
|
||||
|
||||
if (debugProcess.isDetached() || debugProcess.isDetaching()) {
|
||||
session.dispose();
|
||||
@@ -387,7 +392,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
synchronized (mySessions) {
|
||||
DebuggerSession removed = mySessions.remove(processHandler);
|
||||
LOG.assertTrue(removed != null);
|
||||
myDispatcher.getMulticaster().sessionRemoved(session);
|
||||
getEventPublisher().sessionRemoved(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,13 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.util.messages.Topic;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface DebuggerManagerListener extends EventListener{
|
||||
public interface DebuggerManagerListener extends EventListener {
|
||||
Topic<DebuggerManagerListener> TOPIC = new Topic<>("DebuggerManagerListener", DebuggerManagerListener.class);
|
||||
|
||||
default void sessionCreated(DebuggerSession session) {
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.engine.*;
|
||||
import com.intellij.debugger.engine.evaluation.*;
|
||||
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilder;
|
||||
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
|
||||
import com.intellij.debugger.engine.evaluation.expression.UnBoxingEvaluator;
|
||||
import com.intellij.debugger.engine.requests.RequestManagerImpl;
|
||||
@@ -19,7 +18,6 @@ import com.intellij.debugger.jdi.JvmtiError;
|
||||
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
|
||||
import com.intellij.debugger.requests.Requestor;
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.tree.DebuggerTreeNode;
|
||||
import com.intellij.execution.filters.ExceptionFilters;
|
||||
import com.intellij.execution.filters.LineNumbersMapping;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
@@ -27,13 +25,11 @@ import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.RunnerLayoutUi;
|
||||
import com.intellij.execution.ui.layout.impl.RunnerContentUi;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -175,40 +171,6 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
return val1.equals(val2);
|
||||
}
|
||||
|
||||
public static String getValueOrErrorAsString(final EvaluationContext evaluationContext, Value value) {
|
||||
try {
|
||||
return getValueAsString(evaluationContext, value);
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCharOrInteger(Value value) {
|
||||
return value instanceof CharValue || isInteger(value);
|
||||
}
|
||||
|
||||
private static Set<String> myCharOrIntegers;
|
||||
|
||||
public static boolean isCharOrIntegerArray(Value value) {
|
||||
if (value == null) return false;
|
||||
if (myCharOrIntegers == null) {
|
||||
myCharOrIntegers = new HashSet<>();
|
||||
myCharOrIntegers.add("C");
|
||||
myCharOrIntegers.add("B");
|
||||
myCharOrIntegers.add("S");
|
||||
myCharOrIntegers.add("I");
|
||||
myCharOrIntegers.add("J");
|
||||
}
|
||||
|
||||
String signature = value.type().signature();
|
||||
int i;
|
||||
for (i = 0; signature.charAt(i) == '['; i++) ;
|
||||
if (i == 0) return false;
|
||||
signature = signature.substring(i);
|
||||
return myCharOrIntegers.contains(signature);
|
||||
}
|
||||
|
||||
public static ClassFilter create(Element element) throws InvalidDataException {
|
||||
ClassFilter filter = new ClassFilter();
|
||||
DefaultJDOMExternalizer.readExternal(filter, element);
|
||||
@@ -263,7 +225,7 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public static void writeFilters(Element parentNode, @NonNls String tagName, ClassFilter[] filters) throws WriteExternalException {
|
||||
public static void writeFilters(@NotNull Element parentNode, @NonNls String tagName, ClassFilter[] filters) throws WriteExternalException {
|
||||
for (ClassFilter filter : filters) {
|
||||
Element element = new Element(tagName);
|
||||
parentNode.addContent(element);
|
||||
@@ -370,34 +332,6 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static TextWithImports getEditorText(final Editor editor) {
|
||||
if (editor == null) {
|
||||
return null;
|
||||
}
|
||||
final Project project = editor.getProject();
|
||||
if (project == null) return null;
|
||||
|
||||
String defaultExpression = editor.getSelectionModel().getSelectedText();
|
||||
if (defaultExpression == null) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||
if (psiFile != null) {
|
||||
PsiElement elementAtCursor = psiFile.findElementAt(offset);
|
||||
if (elementAtCursor != null) {
|
||||
final EditorTextProvider textProvider = EditorTextProvider.EP.forLanguage(elementAtCursor.getLanguage());
|
||||
if (textProvider != null) {
|
||||
final TextWithImports editorText = textProvider.getEditorText(elementAtCursor);
|
||||
if (editorText != null) return editorText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, defaultExpression);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int myThreadDumpsCount = 0;
|
||||
|
||||
public static void addThreadDump(Project project, List<ThreadState> threads, RunnerLayoutUi ui, GlobalSearchScope searchScope) {
|
||||
@@ -441,10 +375,6 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
return context.computeAndKeep(() -> context.getDebugProcess().newInstance(arrayType, dimension));
|
||||
}
|
||||
|
||||
public abstract DebuggerTreeNode getSelectedNode(DataContext context);
|
||||
|
||||
public abstract EvaluatorBuilder getEvaluatorBuilder();
|
||||
|
||||
@NotNull
|
||||
public static CodeFragmentFactory getCodeFragmentFactory(@Nullable PsiElement context, @Nullable FileType fileType) {
|
||||
DefaultCodeFragmentFactory defaultFactory = DefaultCodeFragmentFactory.getInstance();
|
||||
@@ -1058,19 +988,6 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
return Comparing.equal(getContainingMethod(elem), method);
|
||||
}
|
||||
|
||||
public static boolean inTheSameMethod(@NotNull SourcePosition pos1, @NotNull SourcePosition pos2) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
PsiElement elem1 = pos1.getElementAt();
|
||||
PsiElement elem2 = pos2.getElementAt();
|
||||
if (elem1 == null) return elem2 == null;
|
||||
if (elem2 != null) {
|
||||
PsiElement expectedMethod = getContainingMethod(elem1);
|
||||
PsiElement currentMethod = getContainingMethod(elem2);
|
||||
return Comparing.equal(expectedMethod, currentMethod);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean methodMatches(@NotNull PsiMethod psiMethod,
|
||||
String className,
|
||||
String name,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.configurationStore.XmlSerializer;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.actions.DebuggerAction;
|
||||
import com.intellij.debugger.engine.DebugProcess;
|
||||
@@ -10,11 +11,8 @@ import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
|
||||
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilder;
|
||||
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl;
|
||||
import com.intellij.debugger.impl.attach.PidRemoteConnection;
|
||||
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeExpression;
|
||||
import com.intellij.debugger.ui.tree.DebuggerTreeNode;
|
||||
import com.intellij.debugger.ui.tree.render.BatchEvaluator;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
@@ -32,8 +30,6 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiJavaParserFacadeImpl;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.intellij.xdebugger.XExpression;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XExpressionState;
|
||||
import com.sun.jdi.*;
|
||||
@@ -60,16 +56,6 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
return DebuggerTreeNodeExpression.substituteThis(expressionWithThis, howToEvaluateThis, howToEvaluateThisValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EvaluatorBuilder getEvaluatorBuilder() {
|
||||
return EvaluatorBuilderImpl.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DebuggerTreeNode getSelectedNode(DataContext context) {
|
||||
return DebuggerAction.getSelectedNode(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DebuggerContextImpl getDebuggerContext(DataContext context) {
|
||||
return DebuggerAction.getDebuggerContext(context);
|
||||
@@ -107,7 +93,7 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
Element element = JDOMExternalizerUtil.writeOption(root, name);
|
||||
XExpression expression = TextWithImportsImpl.toXExpression(value);
|
||||
if (expression != null) {
|
||||
XmlSerializer.serializeInto(new XExpressionState(expression), element, new SkipDefaultValuesSerializationFilters());
|
||||
XmlSerializer.serializeObjectInto(new XExpressionState(expression), element);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +108,7 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
Element option = JDOMExternalizerUtil.readOption(root, name);
|
||||
if (option != null) {
|
||||
XExpressionState state = new XExpressionState();
|
||||
XmlSerializer.deserializeInto(state, option);
|
||||
XmlSerializer.deserializeInto(option, state);
|
||||
return TextWithImportsImpl.fromXExpression(state.toXExpression());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
|
||||
import com.intellij.ide.actions.ActionsCollector;
|
||||
@@ -14,6 +13,8 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@@ -23,9 +24,9 @@ public class HotSwapManager {
|
||||
private static final String CLASS_EXTENSION = ".class";
|
||||
private final Project myProject;
|
||||
|
||||
public HotSwapManager(Project project, DebuggerManagerEx manager) {
|
||||
public HotSwapManager(@NotNull Project project) {
|
||||
myProject = project;
|
||||
manager.addDebuggerManagerListener(new DebuggerManagerListener() {
|
||||
project.getMessageBus().connect().subscribe(DebuggerManagerListener.TOPIC, new DebuggerManagerListener() {
|
||||
@Override
|
||||
public void sessionCreated(DebuggerSession session) {
|
||||
myTimeStamps.put(session, Long.valueOf(System.currentTimeMillis()));
|
||||
@@ -131,28 +132,27 @@ public class HotSwapManager {
|
||||
}
|
||||
|
||||
|
||||
public static Map<DebuggerSession, Map<String, HotSwapFile>> scanForModifiedClasses(final List<? extends DebuggerSession> sessions,
|
||||
final HotSwapProgress swapProgress) {
|
||||
final Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses = new HashMap<>();
|
||||
|
||||
@NotNull
|
||||
public static Map<DebuggerSession, Map<String, HotSwapFile>> scanForModifiedClasses(@NotNull List<? extends DebuggerSession> sessions,
|
||||
@NotNull HotSwapProgress swapProgress) {
|
||||
final Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses = new THashMap<>();
|
||||
final MultiProcessCommand scanClassesCommand = new MultiProcessCommand();
|
||||
|
||||
swapProgress.setCancelWorker(() -> scanClassesCommand.cancel());
|
||||
|
||||
for (final DebuggerSession debuggerSession : sessions) {
|
||||
if (debuggerSession.isAttached()) {
|
||||
scanClassesCommand.addCommand(debuggerSession.getProcess(), new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() {
|
||||
swapProgress.setDebuggerSession(debuggerSession);
|
||||
final Map<String, HotSwapFile> sessionClasses =
|
||||
getInstance(swapProgress.getProject()).scanForModifiedClasses(debuggerSession, swapProgress);
|
||||
if (!sessionClasses.isEmpty()) {
|
||||
modifiedClasses.put(debuggerSession, sessionClasses);
|
||||
}
|
||||
}
|
||||
});
|
||||
for (DebuggerSession debuggerSession : sessions) {
|
||||
if (!debuggerSession.isAttached()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
scanClassesCommand.addCommand(debuggerSession.getProcess(), new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() {
|
||||
swapProgress.setDebuggerSession(debuggerSession);
|
||||
Map<String, HotSwapFile> sessionClasses = getInstance(swapProgress.getProject()).scanForModifiedClasses(debuggerSession, swapProgress);
|
||||
if (!sessionClasses.isEmpty()) {
|
||||
modifiedClasses.put(debuggerSession, sessionClasses);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
swapProgress.setTitle(DebuggerBundle.message("progress.hotswap.scanning.classes"));
|
||||
@@ -162,17 +162,17 @@ public class HotSwapManager {
|
||||
for (DebuggerSession session : sessions) {
|
||||
session.setModifiedClassesScanRequired(true);
|
||||
}
|
||||
return new HashMap<>();
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
else {
|
||||
return modifiedClasses;
|
||||
}
|
||||
return modifiedClasses;
|
||||
}
|
||||
|
||||
public static void reloadModifiedClasses(final Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses, final HotSwapProgress reloadClassesProgress) {
|
||||
final MultiProcessCommand reloadClassesCommand = new MultiProcessCommand();
|
||||
|
||||
public static void reloadModifiedClasses(@NotNull Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses, @NotNull HotSwapProgress reloadClassesProgress) {
|
||||
MultiProcessCommand reloadClassesCommand = new MultiProcessCommand();
|
||||
reloadClassesProgress.setCancelWorker(() -> reloadClassesCommand.cancel());
|
||||
|
||||
for (final DebuggerSession debuggerSession : modifiedClasses.keySet()) {
|
||||
for (DebuggerSession debuggerSession : modifiedClasses.keySet()) {
|
||||
reloadClassesCommand.addCommand(debuggerSession.getProcess(), new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.settings;
|
||||
|
||||
import com.intellij.configurationStore.XmlSerializer;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -14,8 +15,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.classFilter.ClassFilter;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.containers.hash.LinkedHashMap;
|
||||
import com.intellij.util.xmlb.SkipDefaultsSerializationFilter;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.intellij.util.xmlb.annotations.OptionTag;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import com.intellij.util.xmlb.annotations.XCollection;
|
||||
@@ -122,7 +121,11 @@ public class DebuggerSettings implements Cloneable, PersistentStateComponent<Ele
|
||||
@Nullable
|
||||
@Override
|
||||
public Element getState() {
|
||||
Element state = XmlSerializer.serialize(this, new SkipDefaultsSerializationFilter());
|
||||
Element state = XmlSerializer.serialize(this);
|
||||
if (state == null) {
|
||||
state = new Element("state");
|
||||
}
|
||||
|
||||
if (!Arrays.equals(DEFAULT_STEPPING_FILTERS, mySteppingFilters)) {
|
||||
DebuggerUtilsEx.writeFilters(state, "filter", mySteppingFilters);
|
||||
}
|
||||
@@ -138,7 +141,7 @@ public class DebuggerSettings implements Cloneable, PersistentStateComponent<Ele
|
||||
|
||||
@Override
|
||||
public void loadState(@NotNull Element state) {
|
||||
XmlSerializer.deserializeInto(this, state);
|
||||
XmlSerializer.deserializeInto(state, this);
|
||||
|
||||
List<Element> steppingFiltersElement = state.getChildren("filter");
|
||||
if (steppingFiltersElement.isEmpty()) {
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.settings;
|
||||
|
||||
import com.intellij.internal.statistic.beans.UsageDescriptor;
|
||||
import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.internal.statistic.utils.StatisticsUtilKt.addIfDiffers;
|
||||
|
||||
public class DebuggerSettingsStatisticsCollector extends ApplicationUsagesCollector {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "debugger.settings.ide";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<UsageDescriptor> getUsages() {
|
||||
Set<UsageDescriptor> set = new HashSet<>();
|
||||
|
||||
DebuggerSettings settings = DebuggerSettings.getInstance();
|
||||
DebuggerSettings sDefault = new DebuggerSettings();
|
||||
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.FORCE_CLASSIC_VM, "forceClassicVm");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.DISABLE_JIT, "disableJit");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.SHOW_ALTERNATIVE_SOURCE, "showAlternativeSource");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.HOTSWAP_IN_BACKGROUND, "hotswapInBackround");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.ENABLE_MEMORY_AGENT, "enableMemoryAgent");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.ALWAYS_SMART_STEP_INTO, "alwaysSmartStepInto");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.SKIP_CONSTRUCTORS, "skipConstructors");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.SKIP_GETTERS, "skipGetters");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.SKIP_CLASSLOADERS, "skipClassloaders");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.COMPILE_BEFORE_HOTSWAP, "compileBeforeHotswap");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.HOTSWAP_HANG_WARNING_ENABLED, "hotswapHangWarningEnabled");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.WATCH_RETURN_VALUES, "watchReturnValues");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.AUTO_VARIABLES_MODE, "autoVariablesMode");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.KILL_PROCESS_IMMEDIATELY, "killProcessImmediately");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.RESUME_ONLY_CURRENT_THREAD, "resumeOnlyCurrentThread");
|
||||
addBoolIfDiffers(set, settings, sDefault, s -> s.INSTRUMENTING_AGENT, "instrumentingAgent");
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
private static <T> void addBoolIfDiffers(Set<UsageDescriptor> set, T settingsBean, T defaultSettingsBean,
|
||||
Function1<T, Boolean> valueFunction, String featureId) {
|
||||
addIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction, (it) -> it ? featureId : "no" + StringUtil.capitalize(featureId));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.ui;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerManager;
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.impl.DebuggerManagerListener;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
@@ -16,7 +13,7 @@ import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
|
||||
import com.intellij.openapi.compiler.CompilerPaths;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -24,13 +21,11 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.task.*;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.MessageCategory;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -50,16 +45,15 @@ public class HotSwapUIImpl extends HotSwapUI {
|
||||
private final Project myProject;
|
||||
private boolean myPerformHotswapAfterThisCompilation = true;
|
||||
|
||||
public HotSwapUIImpl(final Project project, final MessageBus bus, DebuggerManager debugManager) {
|
||||
public HotSwapUIImpl(@NotNull Project project) {
|
||||
myProject = project;
|
||||
|
||||
((DebuggerManagerEx)debugManager).addDebuggerManagerListener(new DebuggerManagerListener() {
|
||||
project.getMessageBus().connect().subscribe(DebuggerManagerListener.TOPIC, new DebuggerManagerListener() {
|
||||
private MessageBusConnection myConn = null;
|
||||
|
||||
@Override
|
||||
public void sessionAttached(DebuggerSession session) {
|
||||
if (myConn == null) {
|
||||
myConn = bus.connect();
|
||||
myConn = project.getMessageBus().connect();
|
||||
myConn.subscribe(ProjectTaskListener.TOPIC, new MyCompilationStatusListener());
|
||||
}
|
||||
}
|
||||
@@ -76,7 +70,7 @@ public class HotSwapUIImpl extends HotSwapUI {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addListener(HotSwapVetoableListener listener) {
|
||||
myListeners.add(listener);
|
||||
@@ -168,7 +162,7 @@ public class HotSwapUIImpl extends HotSwapUI {
|
||||
modifiedClasses.putAll(HotSwapManager.findModifiedClasses(toUseGenerated, generatedPaths));
|
||||
}
|
||||
if (!toScan.isEmpty()) {
|
||||
modifiedClasses.putAll(scanForModifiedClassesWithProgress(toScan, findClassesProgress));
|
||||
modifiedClasses.putAll(scanForModifiedClassesWithProgress(toScan, Objects.requireNonNull(findClassesProgress)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +218,6 @@ public class HotSwapUIImpl extends HotSwapUI {
|
||||
if (!modifiedClasses.isEmpty()) {
|
||||
final HotSwapProgressImpl progress = new HotSwapProgressImpl(myProject);
|
||||
if (modifiedClasses.keySet().size() == 1) {
|
||||
//noinspection ConstantConditions
|
||||
progress.setSessionForActions(ContainerUtil.getFirstItem(modifiedClasses.keySet()));
|
||||
}
|
||||
progress.addProgressListener(new HotSwapProgressImpl.HotSwapProgressListener() {
|
||||
@@ -249,18 +242,17 @@ public class HotSwapUIImpl extends HotSwapUI {
|
||||
});
|
||||
}
|
||||
|
||||
private static Map<DebuggerSession, Map<String, HotSwapFile>> scanForModifiedClassesWithProgress(final List<DebuggerSession> sessions,
|
||||
final HotSwapProgressImpl progress) {
|
||||
final Ref<Map<DebuggerSession, Map<String, HotSwapFile>>> result = Ref.create(null);
|
||||
ProgressManager.getInstance().runProcess(() -> {
|
||||
@NotNull
|
||||
private static Map<DebuggerSession, Map<String, HotSwapFile>> scanForModifiedClassesWithProgress(@NotNull List<DebuggerSession> sessions,
|
||||
@NotNull HotSwapProgressImpl progress) {
|
||||
return ProgressManager.getInstance().runProcess(() -> {
|
||||
try {
|
||||
result.set(HotSwapManager.scanForModifiedClasses(sessions, progress));
|
||||
return HotSwapManager.scanForModifiedClasses(sessions, progress);
|
||||
}
|
||||
finally {
|
||||
progress.finished();
|
||||
}
|
||||
}, progress.getProgressIndicator());
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private static void reloadModifiedClasses(final Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses,
|
||||
@@ -317,7 +309,7 @@ public class HotSwapUIImpl extends HotSwapUI {
|
||||
|
||||
private MyCompilationStatusListener() {
|
||||
myOutputRoots = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
for (final String path : CompilerPathsEx.getOutputPaths(ModuleManager.getInstance(myProject).getModules())) {
|
||||
for (final String path : CompilerPaths.getOutputPaths(ModuleManager.getInstance(myProject).getModules())) {
|
||||
myOutputRoots.add(new File(path));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,6 +7,8 @@ import com.intellij.debugger.ui.tree.ValueDescriptor;
|
||||
import com.sun.jdi.ArrayReference;
|
||||
import com.sun.jdi.Value;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author egor
|
||||
*/
|
||||
@@ -24,7 +26,7 @@ final class ByteArrayAsStringRenderer extends CompoundReferenceRenderer {
|
||||
// TODO: read charset from the target vm
|
||||
byte[] bytes = DebuggerUtilsImpl.readBytesArray(value);
|
||||
if (bytes != null) {
|
||||
return new String(bytes);
|
||||
return new String(bytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+19
-34
@@ -1,25 +1,10 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
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;
|
||||
@@ -31,8 +16,8 @@ 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() {
|
||||
public UnboxableTypeRenderer(String className) {
|
||||
super(StringUtil.getShortName(className), new LabelRenderer() {
|
||||
@Override
|
||||
public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener)
|
||||
throws EvaluateException {
|
||||
@@ -55,50 +40,50 @@ public abstract class UnboxableTypeRenderer extends CompoundReferenceRenderer {
|
||||
}
|
||||
|
||||
public static class BooleanRenderer extends UnboxableTypeRenderer {
|
||||
public BooleanRenderer(NodeRendererSettings rendererSettings) {
|
||||
super(CommonClassNames.JAVA_LANG_BOOLEAN, rendererSettings);
|
||||
public BooleanRenderer() {
|
||||
super(CommonClassNames.JAVA_LANG_BOOLEAN);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ByteRenderer extends UnboxableTypeRenderer {
|
||||
public ByteRenderer(NodeRendererSettings rendererSettings) {
|
||||
super(CommonClassNames.JAVA_LANG_BYTE, rendererSettings);
|
||||
public ByteRenderer() {
|
||||
super(CommonClassNames.JAVA_LANG_BYTE);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CharacterRenderer extends UnboxableTypeRenderer {
|
||||
public CharacterRenderer(NodeRendererSettings rendererSettings) {
|
||||
super(CommonClassNames.JAVA_LANG_CHARACTER, rendererSettings);
|
||||
public CharacterRenderer() {
|
||||
super(CommonClassNames.JAVA_LANG_CHARACTER);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShortRenderer extends UnboxableTypeRenderer {
|
||||
public ShortRenderer(NodeRendererSettings rendererSettings) {
|
||||
super(CommonClassNames.JAVA_LANG_SHORT, rendererSettings);
|
||||
public ShortRenderer() {
|
||||
super(CommonClassNames.JAVA_LANG_SHORT);
|
||||
}
|
||||
}
|
||||
|
||||
public static class IntegerRenderer extends UnboxableTypeRenderer {
|
||||
public IntegerRenderer(NodeRendererSettings rendererSettings) {
|
||||
super(CommonClassNames.JAVA_LANG_INTEGER, rendererSettings);
|
||||
public IntegerRenderer() {
|
||||
super(CommonClassNames.JAVA_LANG_INTEGER);
|
||||
}
|
||||
}
|
||||
|
||||
public static class LongRenderer extends UnboxableTypeRenderer {
|
||||
public LongRenderer(NodeRendererSettings rendererSettings) {
|
||||
super(CommonClassNames.JAVA_LANG_LONG, rendererSettings);
|
||||
public LongRenderer() {
|
||||
super(CommonClassNames.JAVA_LANG_LONG);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FloatRenderer extends UnboxableTypeRenderer {
|
||||
public FloatRenderer(NodeRendererSettings rendererSettings) {
|
||||
super(CommonClassNames.JAVA_LANG_FLOAT, rendererSettings);
|
||||
public FloatRenderer() {
|
||||
super(CommonClassNames.JAVA_LANG_FLOAT);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DoubleRenderer extends UnboxableTypeRenderer {
|
||||
public DoubleRenderer(NodeRendererSettings rendererSettings) {
|
||||
super(CommonClassNames.JAVA_LANG_DOUBLE, rendererSettings);
|
||||
public DoubleRenderer() {
|
||||
super(CommonClassNames.JAVA_LANG_DOUBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.application;
|
||||
|
||||
import com.intellij.codeInsight.TestFrameworks;
|
||||
@@ -32,7 +32,9 @@ public abstract class AbstractApplicationConfigurationProducer<T extends Applica
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setupConfigurationFromContext(T configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
|
||||
protected boolean setupConfigurationFromContext(@NotNull T configuration,
|
||||
@NotNull ConfigurationContext context,
|
||||
@NotNull Ref<PsiElement> sourceElement) {
|
||||
final Location contextLocation = context.getLocation();
|
||||
if (contextLocation == null) {
|
||||
return false;
|
||||
@@ -82,7 +84,7 @@ public abstract class AbstractApplicationConfigurationProducer<T extends Applica
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurationFromContext(T appConfiguration, ConfigurationContext context) {
|
||||
public boolean isConfigurationFromContext(@NotNull T appConfiguration, @NotNull ConfigurationContext context) {
|
||||
final PsiElement location = context.getPsiLocation();
|
||||
final PsiClass aClass = ApplicationConfigurationType.getMainClass(location);
|
||||
if (aClass != null && Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass), appConfiguration.getMainClassName())) {
|
||||
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.application
|
||||
|
||||
import com.intellij.configurationStore.Property
|
||||
@@ -7,7 +7,6 @@ import com.intellij.execution.JvmConfigurationOptions
|
||||
import com.intellij.execution.ShortenCommandLine
|
||||
import com.intellij.util.xmlb.annotations.OptionTag
|
||||
import com.intellij.util.xmlb.annotations.XMap
|
||||
import java.util.*
|
||||
|
||||
open class JvmMainMethodRunConfigurationOptions : JvmConfigurationOptions() {
|
||||
@get:OptionTag("PROGRAM_PARAMETERS")
|
||||
@@ -27,7 +26,7 @@ open class JvmMainMethodRunConfigurationOptions : JvmConfigurationOptions() {
|
||||
|
||||
@Property(description = "Environment variables")
|
||||
@get:XMap(propertyElementName = "envs", entryTagName = "env", keyAttributeName = "name")
|
||||
var env: MutableMap<String, String> by property(LinkedHashMap())
|
||||
var env by linkedMap<String, String>()
|
||||
|
||||
// see ConfigurationWithCommandLineShortener - "null if option was not selected explicitly, legacy user-local options to be used"
|
||||
// so, we cannot use NONE as default value
|
||||
|
||||
+6
-10
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.jar;
|
||||
|
||||
import com.intellij.configurationStore.XmlSerializer;
|
||||
import com.intellij.diagnostic.logging.LogConfigurationPanel;
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configuration.EnvironmentVariablesComponent;
|
||||
@@ -12,14 +13,10 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.options.SettingsEditorGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopes;
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -34,7 +31,6 @@ import java.util.Map;
|
||||
* @author nik
|
||||
*/
|
||||
public class JarApplicationConfiguration extends LocatableConfigurationBase implements CommonJavaRunConfigurationParameters, SearchScopeProvidingRunProfile, InputRedirectAware {
|
||||
private static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
|
||||
private JarApplicationConfigurationBean myBean = new JarApplicationConfigurationBean();
|
||||
private Map<String, String> myEnvs = new LinkedHashMap<>();
|
||||
private JavaRunConfigurationModule myConfigurationModule;
|
||||
@@ -62,10 +58,10 @@ public class JarApplicationConfiguration extends LocatableConfigurationBase impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(@NotNull Element element) throws InvalidDataException {
|
||||
public void readExternal(@NotNull Element element) {
|
||||
super.readExternal(element);
|
||||
JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element);
|
||||
XmlSerializer.deserializeInto(myBean, element);
|
||||
XmlSerializer.deserializeInto(element, myBean);
|
||||
EnvironmentVariablesComponent.readExternal(element, getEnvs());
|
||||
myConfigurationModule.readExternal(element);
|
||||
myInputRedirectOptions.readExternal(element);
|
||||
@@ -91,10 +87,10 @@ public class JarApplicationConfiguration extends LocatableConfigurationBase impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(@NotNull Element element) throws WriteExternalException {
|
||||
public void writeExternal(@NotNull Element element) {
|
||||
super.writeExternal(element);
|
||||
JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
|
||||
XmlSerializer.serializeInto(myBean, element, SERIALIZATION_FILTERS);
|
||||
XmlSerializer.serializeObjectInto(myBean, element);
|
||||
EnvironmentVariablesComponent.writeExternal(element, getEnvs());
|
||||
if (myConfigurationModule.getModule() != null) {
|
||||
myConfigurationModule.writeExternal(element);
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.jar;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
@@ -24,9 +24,9 @@ public final class JarApplicationConfigurationProducer extends LazyRunConfigurat
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setupConfigurationFromContext(JarApplicationConfiguration configuration,
|
||||
ConfigurationContext context,
|
||||
Ref<PsiElement> sourceElement) {
|
||||
protected boolean setupConfigurationFromContext(@NotNull JarApplicationConfiguration configuration,
|
||||
@NotNull ConfigurationContext context,
|
||||
@NotNull Ref<PsiElement> sourceElement) {
|
||||
VirtualFile file = getJarFileFromContext(context);
|
||||
if (file != null) {
|
||||
configuration.setName(file.getName());
|
||||
@@ -46,7 +46,7 @@ public final class JarApplicationConfigurationProducer extends LazyRunConfigurat
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurationFromContext(JarApplicationConfiguration configuration, ConfigurationContext context) {
|
||||
public boolean isConfigurationFromContext(@NotNull JarApplicationConfiguration configuration, @NotNull ConfigurationContext context) {
|
||||
VirtualFile file = getJarFileFromContext(context);
|
||||
return file != null && FileUtil.pathsEqual(file.getPath(), configuration.getJarPath());
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ import com.intellij.execution.process.*;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.actions.CloseAction;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -81,7 +84,7 @@ public class JShellHandler {
|
||||
myProcess = handler;
|
||||
|
||||
final PipedInputStream is = new PipedInputStream();
|
||||
final OutputStreamWriter readerSink = new OutputStreamWriter(new PipedOutputStream(is));
|
||||
final OutputStreamWriter readerSink = new OutputStreamWriter(new PipedOutputStream(is), StandardCharsets.UTF_8);
|
||||
myMessageReader = new MessageReader<>(is, Response.class);
|
||||
myMessageWriter = new MessageWriter<>(handler.getProcessInput());
|
||||
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.junit;
|
||||
|
||||
import com.intellij.execution.JavaRunConfigurationExtensionManager;
|
||||
@@ -77,7 +77,7 @@ public abstract class JavaRunConfigurationProducerBase<T extends ModuleBasedConf
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ConfigurationFromContext createConfigurationFromContext(ConfigurationContext context) {
|
||||
public ConfigurationFromContext createConfigurationFromContext(@NotNull ConfigurationContext context) {
|
||||
ConfigurationFromContext fromContext = super.createConfigurationFromContext(context);
|
||||
if (fromContext != null) {
|
||||
JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration((RunConfigurationBase)fromContext.getConfiguration(),
|
||||
|
||||
+5
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.scratch;
|
||||
|
||||
import com.intellij.execution.JavaExecutionUtil;
|
||||
@@ -29,7 +29,9 @@ public class JavaScratchConfigurationProducer extends AbstractApplicationConfigu
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setupConfigurationFromContext(JavaScratchConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
|
||||
protected boolean setupConfigurationFromContext(@NotNull JavaScratchConfiguration configuration,
|
||||
@NotNull ConfigurationContext context,
|
||||
@NotNull Ref<PsiElement> sourceElement) {
|
||||
final Location location = context.getLocation();
|
||||
if (location != null) {
|
||||
final VirtualFile vFile = location.getVirtualFile();
|
||||
@@ -50,7 +52,7 @@ public class JavaScratchConfigurationProducer extends AbstractApplicationConfigu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurationFromContext(JavaScratchConfiguration configuration, ConfigurationContext context) {
|
||||
public boolean isConfigurationFromContext(@NotNull JavaScratchConfiguration configuration, @NotNull ConfigurationContext context) {
|
||||
final PsiElement location = context.getPsiLocation();
|
||||
final PsiClass aClass = ApplicationConfigurationType.getMainClass(location);
|
||||
if (aClass != null && Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass), configuration.getMainClassName())) {
|
||||
|
||||
+6
-5
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.testDiscovery;
|
||||
|
||||
import com.intellij.codeInsight.TestFrameworks;
|
||||
@@ -43,9 +43,9 @@ public abstract class TestDiscoveryConfigurationProducer extends JavaRunConfigur
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean setupConfigurationFromContext(final JavaTestConfigurationWithDiscoverySupport configuration,
|
||||
ConfigurationContext configurationContext,
|
||||
Ref<PsiElement> ref) {
|
||||
protected boolean setupConfigurationFromContext(@NotNull final JavaTestConfigurationWithDiscoverySupport configuration,
|
||||
@NotNull ConfigurationContext configurationContext,
|
||||
@NotNull Ref<PsiElement> ref) {
|
||||
if (!Registry.is(TestDiscoveryExtension.TEST_DISCOVERY_REGISTRY_KEY)) {
|
||||
return false;
|
||||
}
|
||||
@@ -181,7 +181,8 @@ public abstract class TestDiscoveryConfigurationProducer extends JavaRunConfigur
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurationFromContext(JavaTestConfigurationWithDiscoverySupport configuration, ConfigurationContext configurationContext) {
|
||||
public boolean isConfigurationFromContext(@NotNull JavaTestConfigurationWithDiscoverySupport configuration,
|
||||
@NotNull ConfigurationContext configurationContext) {
|
||||
final Pair<String, String> position = getPosition(getSourceMethod(configurationContext.getLocation()));
|
||||
return position != null && position.equals(getPosition(configuration));
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class TestFilesIndex extends MapReduceIndex<Integer, Void, UsedSources> {
|
||||
@Nullable
|
||||
Collection<Integer> getTestDataFor(int testId) throws IOException {
|
||||
ForwardIndex forwardIndex = getForwardIndexMap();
|
||||
KeyCollectionForwardIndexAccessor<Integer, Void, UsedSources> forwardIndexAccessor = (KeyCollectionForwardIndexAccessor<Integer, Void, UsedSources>)getForwardIndexAccessor();
|
||||
KeyCollectionForwardIndexAccessor<Integer, Void> forwardIndexAccessor = (KeyCollectionForwardIndexAccessor<Integer, Void>)getForwardIndexAccessor();
|
||||
return forwardIndexAccessor.deserializeData(forwardIndex.get(testId));
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.JavaTestConfigurationBase;
|
||||
@@ -87,9 +87,9 @@ public abstract class AbstractInClassConfigurationProducer<T extends JavaTestCon
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setupConfigurationFromContext(T configuration,
|
||||
ConfigurationContext context,
|
||||
Ref<PsiElement> sourceElement) {
|
||||
protected boolean setupConfigurationFromContext(@NotNull T configuration,
|
||||
@NotNull ConfigurationContext context,
|
||||
@NotNull Ref<PsiElement> sourceElement) {
|
||||
if (isMultipleElementsSelected(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.codeInsight.TestFrameworks;
|
||||
@@ -29,6 +29,7 @@ import com.intellij.testIntegration.JavaTestFramework;
|
||||
import com.intellij.testIntegration.TestFramework;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -75,7 +76,7 @@ public abstract class AbstractJavaTestConfigurationProducer<T extends JavaTestCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurationFromContext(T configuration, ConfigurationContext context) {
|
||||
public boolean isConfigurationFromContext(@NotNull T configuration, @NotNull ConfigurationContext context) {
|
||||
if (isMultipleElementsSelected(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.jshell.protocol;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class MessageReader<T> extends Endpoint {
|
||||
private final Class<T> myMsgType;
|
||||
|
||||
public MessageReader(InputStream input, Class<T> msgType) {
|
||||
myIn = new BufferedReader(new InputStreamReader(input));
|
||||
myIn = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
|
||||
myMsgType = msgType;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.jshell.protocol;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ public class MessageWriter<T extends Message> extends Endpoint {
|
||||
private final BufferedWriter myOut;
|
||||
|
||||
public MessageWriter(OutputStream output) {
|
||||
myOut = new BufferedWriter(new OutputStreamWriter(output));
|
||||
myOut = new BufferedWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public void send(T message) throws IOException {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
/*
|
||||
* @author max
|
||||
@@ -204,7 +204,8 @@ public class NewProjectUtil {
|
||||
if (openProjects.length > 0) {
|
||||
int exitCode = ProjectUtil.confirmOpenNewProject(true);
|
||||
if (exitCode == GeneralSettings.OPEN_PROJECT_SAME_WINDOW) {
|
||||
ProjectUtil.closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1]);
|
||||
Project project = projectToClose != null ? projectToClose : openProjects[openProjects.length - 1];
|
||||
ProjectManagerEx.getInstanceEx().closeAndDispose(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -56,7 +57,7 @@ public class NewProjectWizard extends AbstractProjectWizard {
|
||||
for (ModuleWizardStep step : mySequence.getAllSteps()) {
|
||||
addStep(step);
|
||||
}
|
||||
if (myWizardContext.isCreatingNewProject()) {
|
||||
if (myWizardContext.isCreatingNewProject() && Registry.is("new.project.load.remote.templates")) {
|
||||
projectTypeStep.loadRemoteTemplates(chooseTemplateStep);
|
||||
}
|
||||
super.init();
|
||||
|
||||
@@ -9,6 +9,9 @@ import com.intellij.ide.util.newProjectWizard.*;
|
||||
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
|
||||
import com.intellij.ide.util.projectWizard.*;
|
||||
import com.intellij.ide.wizard.CommitStepException;
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
|
||||
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger;
|
||||
import com.intellij.internal.statistic.utils.PluginInfoDetectorKt;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -247,6 +250,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
Icon icon = factory.getGroupIcon(group);
|
||||
String parentGroup = factory.getParentGroup(group);
|
||||
TemplatesGroup templatesGroup = new TemplatesGroup(group, null, icon, factory.getGroupWeight(group), parentGroup, group, null);
|
||||
templatesGroup.setSafeToReport(PluginInfoDetectorKt.getPluginInfo(factory.getClass()).isSafeToReport());
|
||||
groups.putValues(templatesGroup, values);
|
||||
}
|
||||
}
|
||||
@@ -496,6 +500,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
throw new CommitStepException(null);
|
||||
}
|
||||
}
|
||||
reportStatistics("new.project.wizard.finish");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -718,4 +723,21 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
}
|
||||
return myContext.isCreatingNewProject() ? "Project_Category_and_Options" : "Module_Category_and_Options";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStepLeaving() {
|
||||
reportStatistics("new.project.wizard.attempt");
|
||||
}
|
||||
|
||||
private void reportStatistics(String groupId) {
|
||||
TemplatesGroup group = myProjectTypeList.getSelectedValue();
|
||||
FeatureUsageData data = new FeatureUsageData();
|
||||
myFrameworksPanel.reportFeatureUsageData(data);
|
||||
ModuleWizardStep step = getCustomStep();
|
||||
if (step instanceof StatisticsAwareModuleWizardStep) {
|
||||
((StatisticsAwareModuleWizardStep) step).reportFeatureUsageData(data);
|
||||
}
|
||||
|
||||
FUCounterUsageLogger.getInstance().logEvent(groupId, group.isSafeToReport() ? group.getId() : "third-party");
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -15,6 +15,8 @@ import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider;
|
||||
import com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil;
|
||||
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator;
|
||||
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
|
||||
import com.intellij.internal.statistic.utils.PluginInfoDetectorKt;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -457,4 +459,14 @@ public class AddSupportForFrameworksPanel implements Disposable {
|
||||
final Comparator<FrameworkSupportInModuleProvider> comparator = FrameworkSupportUtil.getFrameworkSupportProvidersComparator(myProviders);
|
||||
Collections.sort(nodes, (o1, o2) -> comparator.compare(o1.getUserObject(), o2.getUserObject()));
|
||||
}
|
||||
|
||||
public void reportFeatureUsageData(FeatureUsageData data) {
|
||||
List<FrameworkSupportNode> nodes = getSelectedNodes();
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
FrameworkSupportNode node = nodes.get(i);
|
||||
FrameworkSupportInModuleProvider provider = node.getUserObject();
|
||||
String id = PluginInfoDetectorKt.getPluginInfo(provider.getClass()).isSafeToReport() ? provider.getId() : "third-party";
|
||||
data.addData("framework" + i, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.ide.util.newProjectWizard;
|
||||
|
||||
import com.intellij.ide.projectWizard.ProjectCategory;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.internal.statistic.utils.PluginInfoDetectorKt;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -37,6 +38,7 @@ public class TemplatesGroup implements Comparable<TemplatesGroup> {
|
||||
private final String myId;
|
||||
private final ModuleBuilder myModuleBuilder;
|
||||
private ProjectCategory myProjectCategory;
|
||||
private boolean mySafeToReport = false;
|
||||
|
||||
public TemplatesGroup(String name, String description, Icon icon, int weight, String parentGroup, String id, ModuleBuilder moduleBuilder) {
|
||||
myName = name;
|
||||
@@ -122,4 +124,15 @@ public class TemplatesGroup implements Comparable<TemplatesGroup> {
|
||||
public String getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
public boolean isSafeToReport() {
|
||||
if (myModuleBuilder != null) {
|
||||
return PluginInfoDetectorKt.getPluginInfo(myModuleBuilder.getClass()).isSafeToReport();
|
||||
}
|
||||
return mySafeToReport;
|
||||
}
|
||||
|
||||
public void setSafeToReport(boolean report) {
|
||||
mySafeToReport = report;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-16
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.util.projectWizard.importSources.util;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -26,6 +12,7 @@ import com.intellij.util.text.StringFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public abstract class CommonSourceRootDetectionUtil<F> {
|
||||
|
||||
@@ -109,7 +96,7 @@ public abstract class CommonSourceRootDetectionUtil<F> {
|
||||
|
||||
private static char[] loadFileTextSkippingBom(File file) throws IOException {
|
||||
try (InputStream stream = CharsetToolkit.inputStreamSkippingBOM(new BufferedInputStream(new FileInputStream(file)));
|
||||
Reader reader = new InputStreamReader(stream)) {
|
||||
Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
|
||||
return FileUtilRt.loadText(reader, (int)file.length());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,41 +91,32 @@ public class JarRepositoryManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String coord = dialog.getCoordinateText();
|
||||
final boolean attachSources = dialog.getAttachSources();
|
||||
final boolean attachJavaDoc = dialog.getAttachJavaDoc();
|
||||
final boolean attachAnnotations = dialog.getAttachExternalAnnotations();
|
||||
boolean includeTransitiveDependencies = dialog.getIncludeTransitiveDependencies();
|
||||
final String copyTo = dialog.getDirectoryPath();
|
||||
JpsMavenRepositoryLibraryDescriptor libraryDescriptor = dialog.getSelectedLibraryDescriptor();
|
||||
|
||||
final EnumSet<ArtifactKind> artifactKinds = kindsOf(attachSources, attachJavaDoc, dialog.getPackaging());
|
||||
final EnumSet<ArtifactKind> artifactKinds = ArtifactKind.kindsOf(attachSources, attachJavaDoc, libraryDescriptor.getPackaging());
|
||||
if (attachAnnotations) {
|
||||
artifactKinds.add(ArtifactKind.ANNOTATIONS);
|
||||
}
|
||||
|
||||
final NewLibraryConfiguration config = resolveAndDownload(
|
||||
project, coord, artifactKinds, includeTransitiveDependencies, copyTo, RemoteRepositoriesConfiguration.getInstance(project).getRepositories()
|
||||
project, artifactKinds, copyTo, RemoteRepositoriesConfiguration.getInstance(project).getRepositories(), libraryDescriptor
|
||||
);
|
||||
if (config == null) {
|
||||
Messages.showErrorDialog(parentComponent, "No files were downloaded for " + coord, CommonBundle.getErrorTitle());
|
||||
Messages.showErrorDialog(parentComponent, "No files were downloaded for " + libraryDescriptor.getMavenId(), CommonBundle.getErrorTitle());
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
private static NewLibraryConfiguration resolveAndDownload(Project project,
|
||||
String coord,
|
||||
EnumSet<ArtifactKind> kinds,
|
||||
boolean includeTransitiveDependencies,
|
||||
String copyTo,
|
||||
Collection<RemoteRepositoryDescription> repositories) {
|
||||
String packaging = JpsMavenRepositoryLibraryDescriptor.DEFAULT_PACKAGING;
|
||||
for (ArtifactKind kind : kinds) {
|
||||
if (kind.getClassifier().isEmpty()) {
|
||||
packaging = kind.getExtension(); // correct packaging according to the requested artifact kind
|
||||
break;
|
||||
}
|
||||
}
|
||||
RepositoryLibraryProperties props = new RepositoryLibraryProperties(coord, packaging, includeTransitiveDependencies);
|
||||
Collection<RemoteRepositoryDescription> repositories,
|
||||
JpsMavenRepositoryLibraryDescriptor libraryDescriptor) {
|
||||
RepositoryLibraryProperties props = new RepositoryLibraryProperties(libraryDescriptor);
|
||||
final JpsMavenRepositoryLibraryDescriptor libDescriptor = props.getRepositoryLibraryDescriptor();
|
||||
final Collection<OrderRoot> roots = ContainerUtil.newArrayList();
|
||||
if (libDescriptor.getMavenId() != null) {
|
||||
@@ -141,26 +132,15 @@ public class JarRepositoryManager {
|
||||
|
||||
@Nullable
|
||||
public static NewLibraryConfiguration resolveAndDownload(@NotNull Project project,
|
||||
String coord,
|
||||
boolean attachSources,
|
||||
boolean attachJavaDoc,
|
||||
boolean includeTransitiveDependencies,
|
||||
String copyTo,
|
||||
Collection<RemoteRepositoryDescription> repositories) {
|
||||
return resolveAndDownload(project, coord, attachSources, attachJavaDoc, JpsMavenRepositoryLibraryDescriptor.DEFAULT_PACKAGING,
|
||||
includeTransitiveDependencies, copyTo, repositories);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewLibraryConfiguration resolveAndDownload(@NotNull Project project,
|
||||
String coord,
|
||||
boolean attachSources,
|
||||
boolean attachJavaDoc,
|
||||
String packaging,
|
||||
boolean includeTransitiveDependencies,
|
||||
String copyTo,
|
||||
Collection<RemoteRepositoryDescription> repositories) {
|
||||
return resolveAndDownload(project, coord, kindsOf(attachSources, attachJavaDoc, packaging), includeTransitiveDependencies, copyTo, repositories);
|
||||
String coord,
|
||||
boolean attachSources,
|
||||
boolean attachJavaDoc,
|
||||
boolean includeTransitiveDependencies,
|
||||
String copyTo,
|
||||
Collection<RemoteRepositoryDescription> repositories) {
|
||||
JpsMavenRepositoryLibraryDescriptor libraryDescriptor = new JpsMavenRepositoryLibraryDescriptor(coord, includeTransitiveDependencies, Collections.emptyList());
|
||||
return resolveAndDownload(project, ArtifactKind.kindsOf(attachSources, attachJavaDoc, libraryDescriptor.getPackaging()),
|
||||
copyTo, repositories, libraryDescriptor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -216,7 +196,7 @@ public class JarRepositoryManager {
|
||||
@Nullable Collection<RemoteRepositoryDescription> repositories) {
|
||||
final JpsMavenRepositoryLibraryDescriptor libDescriptor = libraryProps.getRepositoryLibraryDescriptor();
|
||||
if (libDescriptor.getMavenId() != null) {
|
||||
EnumSet<ArtifactKind> kinds = kindsOf(loadSources, loadJavadoc, libraryProps.getPackaging());
|
||||
EnumSet<ArtifactKind> kinds = ArtifactKind.kindsOf(loadSources, loadJavadoc, libraryProps.getPackaging());
|
||||
return loadDependenciesModal(project, libDescriptor, kinds, repositories, copyTo);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
@@ -240,7 +220,7 @@ public class JarRepositoryManager {
|
||||
boolean loadJavadoc,
|
||||
@Nullable List<RemoteRepositoryDescription> repos,
|
||||
@Nullable String copyTo) {
|
||||
EnumSet<ArtifactKind> kinds = kindsOf(loadSources, loadJavadoc, libraryProps.getPackaging());
|
||||
EnumSet<ArtifactKind> kinds = ArtifactKind.kindsOf(loadSources, loadJavadoc, libraryProps.getPackaging());
|
||||
return loadDependenciesAsync(
|
||||
project,
|
||||
libraryProps.getRepositoryLibraryDescriptor(),
|
||||
@@ -276,22 +256,6 @@ public class JarRepositoryManager {
|
||||
return repositories;
|
||||
}
|
||||
|
||||
public static EnumSet<ArtifactKind> kindsOf(boolean loadSources, boolean loadJavadoc, String... artifactPackaging) {
|
||||
final EnumSet<ArtifactKind> kinds = ArtifactKind.kindsOf(loadSources, loadJavadoc);
|
||||
if (artifactPackaging.length == 0 || artifactPackaging.length == 1 && artifactPackaging[0] == null) {
|
||||
kinds.add(ArtifactKind.ARTIFACT);
|
||||
}
|
||||
else {
|
||||
for (String packaging : artifactPackaging) {
|
||||
final ArtifactKind artifact = ArtifactKind.find(ArtifactKind.ARTIFACT.getClassifier(), packaging);
|
||||
if (artifact != null) {
|
||||
kinds.add(artifact);
|
||||
}
|
||||
}
|
||||
}
|
||||
return kinds;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Promise<Collection<String>> getAvailableVersions(@NotNull Project project, @NotNull RepositoryLibraryDescription libraryDescription) {
|
||||
List<RemoteRepositoryDescription> repos = RemoteRepositoriesConfiguration.getInstance(project).getRepositories();
|
||||
|
||||
@@ -392,22 +392,28 @@ public class RepositoryAttachDialog extends DialogWrapper {
|
||||
return text.split(":").length == 3;
|
||||
}
|
||||
|
||||
public String getCoordinateText() {
|
||||
private String getCoordinateText() {
|
||||
String text = getFullCoordinateText();
|
||||
List<String> parts = StringUtil.split(text, ":");
|
||||
return parts.size() == 4 ? parts.get(0) + ":" + parts.get(1) + ":" + parts.get(3) : text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPackaging() {
|
||||
@NotNull
|
||||
private String getPackaging() {
|
||||
List<String> parts = StringUtil.split(getFullCoordinateText(), ":");
|
||||
return parts.size() == 4 ? parts.get(2) : null;
|
||||
return parts.size() == 4 ? parts.get(2) : JpsMavenRepositoryLibraryDescriptor.DEFAULT_PACKAGING;
|
||||
}
|
||||
|
||||
private String getFullCoordinateText() {
|
||||
return ((JTextField)myCombobox.getEditor().getEditorComponent()).getText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JpsMavenRepositoryLibraryDescriptor getSelectedLibraryDescriptor() {
|
||||
return new JpsMavenRepositoryLibraryDescriptor(getCoordinateText(), getPackaging(),
|
||||
getIncludeTransitiveDependencies(), Collections.emptyList());
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
myProgressIcon = new AsyncProcessIcon("Progress");
|
||||
}
|
||||
|
||||
+3
-3
@@ -50,9 +50,9 @@ public class RepositoryLibraryWithDescriptionEditor
|
||||
//String oldVersion = properties.getVersion();
|
||||
boolean wasGeneratedName =
|
||||
RepositoryLibraryType.getInstance().getDescription(properties).equals(myEditorComponent.getLibraryEditor().getName());
|
||||
final EnumSet<ArtifactKind> artifactKinds = JarRepositoryManager.kindsOf(libraryHasSources(myEditorComponent.getLibraryEditor()),
|
||||
libraryHasJavaDocs(myEditorComponent.getLibraryEditor()),
|
||||
properties.getPackaging());
|
||||
final EnumSet<ArtifactKind> artifactKinds = ArtifactKind.kindsOf(libraryHasSources(myEditorComponent.getLibraryEditor()),
|
||||
libraryHasJavaDocs(myEditorComponent.getLibraryEditor()),
|
||||
properties.getPackaging());
|
||||
if (libraryHasExternalAnnotations(myEditorComponent.getLibraryEditor())) {
|
||||
artifactKinds.add(ArtifactKind.ANNOTATIONS);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class IdeaProjectModelModifier extends JavaProjectModelModifier {
|
||||
return Promises.rejectedPromise();
|
||||
}
|
||||
|
||||
RepositoryLibraryProperties libraryProperties = new RepositoryLibraryProperties(dialog.getCoordinateText(), true);
|
||||
RepositoryLibraryProperties libraryProperties = new RepositoryLibraryProperties(dialog.getSelectedLibraryDescriptor());
|
||||
Collection<OrderRoot> roots =
|
||||
JarRepositoryManager.loadDependenciesModal(myProject, libraryProperties, dialog.getAttachSources(), dialog.getAttachJavaDoc(), dialog.getDirectoryPath(), null);
|
||||
if (roots.isEmpty()) {
|
||||
|
||||
+1
-2
@@ -139,8 +139,7 @@ abstract class ConvertToRepositoryLibraryActionBase(protected val context: Struc
|
||||
return null
|
||||
}
|
||||
|
||||
return JpsMavenRepositoryLibraryDescriptor(dialog.coordinateText, dialog.includeTransitiveDependencies,
|
||||
emptyList<String>())
|
||||
return dialog.selectedLibraryDescriptor
|
||||
}
|
||||
|
||||
private fun replaceByLibrary(library: Library, configuration: NewLibraryConfiguration) {
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.idea.maven.utils.library.propertiesEditor;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.intellij.jarRepository.JarRepositoryManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.idea.maven.aether.ArtifactKind;
|
||||
|
||||
@@ -37,7 +36,7 @@ public class RepositoryLibraryPropertiesModel {
|
||||
|
||||
public RepositoryLibraryPropertiesModel(String version, boolean downloadSources, boolean downloadJavaDocs,
|
||||
boolean includeTransitiveDependencies, List<String> excludedDependencies) {
|
||||
this(version, JarRepositoryManager.kindsOf(downloadSources, downloadJavaDocs), includeTransitiveDependencies, excludedDependencies);
|
||||
this(version, ArtifactKind.kindsOf(downloadSources, downloadJavaDocs), includeTransitiveDependencies, excludedDependencies);
|
||||
}
|
||||
|
||||
public RepositoryLibraryPropertiesModel(String version, EnumSet<ArtifactKind> artifactKinds,
|
||||
|
||||
+2
-10
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.lang.jvm.actions
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
@@ -16,17 +16,10 @@ import com.intellij.lang.jvm.JvmModifiersOwner
|
||||
*/
|
||||
abstract class JvmElementActionsFactory {
|
||||
|
||||
open fun createChangeModifierActions(target: JvmModifiersOwner, request: ChangeModifierRequest): List<IntentionAction> =
|
||||
createChangeModifierActions(target, MemberRequest.Modifier(request.modifier, request.shouldBePresent()))
|
||||
|
||||
@Deprecated(message = "use createChangeModifierActions(JvmModifiersOwner, ChangeModifierRequest)")
|
||||
open fun createChangeModifierActions(target: JvmModifiersOwner, request: MemberRequest.Modifier): List<IntentionAction> = emptyList()
|
||||
open fun createChangeModifierActions(target: JvmModifiersOwner, request: ChangeModifierRequest): List<IntentionAction> = emptyList()
|
||||
|
||||
open fun createAddAnnotationActions(target: JvmModifiersOwner, request: AnnotationRequest): List<IntentionAction> = emptyList()
|
||||
|
||||
@Deprecated(message = "use createAddMethodActions with proper request")
|
||||
open fun createAddPropertyActions(targetClass: JvmClass, request: MemberRequest.Property): List<IntentionAction> = emptyList()
|
||||
|
||||
open fun createAddFieldActions(targetClass: JvmClass, request: CreateFieldRequest): List<IntentionAction> = emptyList()
|
||||
|
||||
open fun createAddMethodActions(targetClass: JvmClass, request: CreateMethodRequest): List<IntentionAction> = emptyList()
|
||||
@@ -34,5 +27,4 @@ abstract class JvmElementActionsFactory {
|
||||
open fun createAddConstructorActions(targetClass: JvmClass, request: CreateConstructorRequest): List<IntentionAction> = emptyList()
|
||||
|
||||
open fun createChangeParametersActions(target: JvmMethod, request: ChangeParametersRequest): List<IntentionAction> = emptyList()
|
||||
|
||||
}
|
||||
|
||||
@@ -42,13 +42,6 @@ fun createAddAnnotationActions(target: JvmModifiersOwner, request: AnnotationReq
|
||||
fun createModifierActions(target: JvmModifiersOwner, request: ChangeModifierRequest): List<IntentionAction> =
|
||||
createActions { it.createChangeModifierActions(target, request) }
|
||||
|
||||
@Deprecated("use createModifierActions(JvmModifiersOwner, ChangeModifierRequest)")
|
||||
fun createModifierActions(target: JvmModifiersOwner, request: MemberRequest.Modifier): List<IntentionAction> {
|
||||
return createActions {
|
||||
it.createChangeModifierActions(target, request)
|
||||
}
|
||||
}
|
||||
|
||||
fun createAddFieldActions(target: JvmClass, request: CreateFieldRequest): List<IntentionAction> =
|
||||
createActions { it.createAddFieldActions(target, request) }
|
||||
|
||||
|
||||
@@ -14,12 +14,6 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<idea-plugin>
|
||||
<project-components>
|
||||
<component>
|
||||
<implementation-class>com.intellij.codeInsight.daemon.impl.JavaSoftKeywordHighlightingPassFactory</implementation-class>
|
||||
</component>
|
||||
</project-components>
|
||||
|
||||
<extensionPoints>
|
||||
<extensionPoint qualifiedName="com.intellij.deadCode"
|
||||
interface="com.intellij.codeInspection.reference.EntryPoint"/>
|
||||
@@ -48,6 +42,7 @@
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<highlightingPassFactory implementation="com.intellij.codeInsight.daemon.impl.JavaSoftKeywordHighlightingPassFactory"/>
|
||||
<deadCode implementation="com.intellij.codeInspection.java19modules.Java9ModuleEntryPoint"/>
|
||||
<smartPointer.anchorProvider implementation="com.intellij.uast.UastElementAnchorProvider"/>
|
||||
<metaLanguage implementation="com.intellij.uast.UastMetaLanguage"/>
|
||||
@@ -239,9 +234,9 @@
|
||||
<lang.syntaxHighlighterFactory language="JAVA" implementationClass="com.intellij.lang.java.JavaSyntaxHighlighterFactory"/>
|
||||
<moduleExtension implementation="com.intellij.openapi.roots.impl.JavaModuleExternalPathsImpl"/>
|
||||
<localInspection groupPath="Java" language="JAVA" cleanupTool="true"
|
||||
enabledByDefault="true" level="WARNING" groupBundle="messages.InspectionsBundle"
|
||||
enabledByDefault="true" level="WARNING" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.language.level.specific.issues.and.migration.aids" bundle="messages.InspectionsBundle" shortName="RedundantBackticksAroundRawStringLiteral"
|
||||
implementationClass="com.intellij.codeInspection.RedundantBackticksAroundRawStringLiteralInspection" key="redundant.backticks.around.raw.string.literal.display.name"
|
||||
implementationClass="com.intellij.codeInspection.RedundantBackticksAroundRawStringLiteralInspection" key="redundant.backticks.around.raw.string.literal.display.name"
|
||||
isInternal="true"/>
|
||||
<localInspection groupPath="Java" language="JAVA" shortName="ClassGetClass"
|
||||
groupBundle="messages.InspectionsBundle" groupKey="group.names.probable.bugs"
|
||||
|
||||
+5
-3
@@ -1,18 +1,20 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight.daemon.impl
|
||||
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPass
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPassFactory
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPassFactoryRegistrar
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar
|
||||
import com.intellij.lang.java.lexer.JavaLexer
|
||||
import com.intellij.openapi.editor.Document
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
import com.intellij.psi.*
|
||||
|
||||
class JavaSoftKeywordHighlightingPassFactory(registrar: TextEditorHighlightingPassRegistrar) : TextEditorHighlightingPassFactory {
|
||||
init {
|
||||
internal class JavaSoftKeywordHighlightingPassFactory : TextEditorHighlightingPassFactory, TextEditorHighlightingPassFactoryRegistrar {
|
||||
override fun registerHighlightingPassFactory(registrar: TextEditorHighlightingPassRegistrar, project: Project) {
|
||||
registrar.registerTextEditorHighlightingPass(this, null, null, false, -1)
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -29,7 +29,6 @@ import com.intellij.psi.search.searches.SuperMethodsSearch;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.siyeh.ig.psiutils.ExpressionUtils;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -839,7 +838,7 @@ public class GenericsHighlightUtil {
|
||||
@Nullable
|
||||
static HighlightInfo checkEnumInstantiation(@NotNull PsiElement expression, @Nullable PsiClass aClass) {
|
||||
if (aClass != null && aClass.isEnum() &&
|
||||
!(expression instanceof PsiNewExpression && ExpressionUtils.isArrayCreationExpression((PsiNewExpression)expression))) {
|
||||
!(expression instanceof PsiNewExpression && ((PsiNewExpression)expression).isArrayCreation())) {
|
||||
String description = JavaErrorMessages.message("enum.types.cannot.be.instantiated");
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
|
||||
}
|
||||
|
||||
+1
-2
@@ -217,8 +217,7 @@ class ApiUsageUastVisitor(private val apiUsageProcessor: ApiUsageProcessor) : Ab
|
||||
return false
|
||||
}
|
||||
|
||||
private fun isInsideImportStatement(node: UElement) =
|
||||
node.skipParentOfType(true, UQualifiedReferenceExpression::class.java) is UImportStatement
|
||||
private fun isInsideImportStatement(node: UElement) = node.sourcePsi.findContaining(UImportStatement::class.java) != null
|
||||
|
||||
private fun maybeProcessImplicitConstructorInvocationAtSubclassDeclaration(sourceNode: UElement, subclassDeclaration: UClass) {
|
||||
val hasExplicitConstructor = subclassDeclaration.methods.any { it.isConstructor }
|
||||
|
||||
+5
-2
@@ -682,14 +682,17 @@ public class DataFlowInspectionBase extends AbstractBaseJavaLocalInspectionTool
|
||||
reporter.registerProblem(toHighlight, message, fixes.toArray(LocalQuickFix.EMPTY_ARRAY));
|
||||
}
|
||||
|
||||
private static void reportFailingCasts(ProblemReporter reporter, DataFlowInstructionVisitor visitor) {
|
||||
private void reportFailingCasts(ProblemReporter reporter, DataFlowInstructionVisitor visitor) {
|
||||
for (TypeCastInstruction instruction : visitor.getClassCastExceptionInstructions()) {
|
||||
PsiTypeCastExpression typeCast = instruction.getExpression();
|
||||
PsiExpression operand = typeCast.getOperand();
|
||||
PsiTypeElement castType = typeCast.getCastType();
|
||||
assert castType != null;
|
||||
assert operand != null;
|
||||
reporter.registerProblem(castType, InspectionsBundle.message("dataflow.message.cce", operand.getText()));
|
||||
if (reporter.isOnTheFly()) {
|
||||
reporter.registerProblem(castType, InspectionsBundle.message("dataflow.message.cce", operand.getText()),
|
||||
createExplainFix(typeCast, new TrackingRunner.CastDfaProblemType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -241,14 +241,14 @@ public class TrackingDfaMemoryState extends DfaMemoryStateImpl {
|
||||
@Nullable
|
||||
MemoryStateChange findExpressionPush(@Nullable PsiExpression expression) {
|
||||
if (expression == null) return null;
|
||||
return findChange(change -> change.getExpression() == expression);
|
||||
return findChange(change -> change.getExpression() == expression, false);
|
||||
}
|
||||
|
||||
MemoryStateChange findRelation(DfaVariableValue value, @NotNull Predicate<Relation> relationPredicate) {
|
||||
MemoryStateChange findRelation(DfaVariableValue value, @NotNull Predicate<Relation> relationPredicate, boolean startFromSelf) {
|
||||
return findChange(change -> {
|
||||
Change varChange = change.myChanges.get(value);
|
||||
return varChange != null && varChange.myAddedRelations.stream().anyMatch(relationPredicate);
|
||||
});
|
||||
}, startFromSelf);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -272,8 +272,8 @@ public class TrackingDfaMemoryState extends DfaMemoryStateImpl {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MemoryStateChange findChange(@NotNull Predicate<MemoryStateChange> predicate) {
|
||||
for (MemoryStateChange change = myPrevious; change != null; change = change.myPrevious) {
|
||||
private MemoryStateChange findChange(@NotNull Predicate<MemoryStateChange> predicate, boolean startFromSelf) {
|
||||
for (MemoryStateChange change = startFromSelf ? this : myPrevious; change != null; change = change.myPrevious) {
|
||||
if (predicate.test(change)) {
|
||||
return change;
|
||||
}
|
||||
|
||||
+313
-63
@@ -7,17 +7,17 @@ import com.intellij.codeInspection.dataFlow.TrackingDfaMemoryState.MemoryStateCh
|
||||
import com.intellij.codeInspection.dataFlow.TrackingDfaMemoryState.Relation;
|
||||
import com.intellij.codeInspection.dataFlow.instructions.*;
|
||||
import com.intellij.codeInspection.dataFlow.rangeSet.LongRangeSet;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaConstValue;
|
||||
import com.intellij.codeInspection.dataFlow.value.*;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaRelationValue.RelationType;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaValue;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaVariableValue;
|
||||
import com.intellij.codeInspection.dataFlow.value.VariableDescriptor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Segment;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -76,18 +76,25 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
StandardInstructionVisitor visitor = new StandardInstructionVisitor();
|
||||
RunnerResult result = runner.analyzeMethodRecursively(body, visitor, ignoreAssertions);
|
||||
if (result != RunnerResult.OK) return Collections.emptyList();
|
||||
List<CauseItem> results = new ArrayList<>();
|
||||
CauseItem cause = null;
|
||||
for (MemoryStateChange history : runner.myHistoryForContext) {
|
||||
CauseItem root = findCauseChain(expression, history, type);
|
||||
if (!results.contains(root)) {
|
||||
results.add(root);
|
||||
if (cause == null) {
|
||||
cause = root;
|
||||
} else {
|
||||
cause = cause.merge(root);
|
||||
if (cause == null) return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
return results;
|
||||
return Collections.singletonList(cause);
|
||||
}
|
||||
|
||||
public abstract static class DfaProblemType {
|
||||
public abstract String toString();
|
||||
|
||||
CauseItem[] findCauses(PsiExpression expression, MemoryStateChange history) {
|
||||
return new CauseItem[0];
|
||||
}
|
||||
}
|
||||
|
||||
public static class CauseItem {
|
||||
@@ -128,20 +135,24 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CauseItem item = (CauseItem)o;
|
||||
return myChildren.equals(item.myChildren) &&
|
||||
myProblem.toString().equals(item.myProblem.toString()) &&
|
||||
getProblemName().equals(item.getProblemName()) &&
|
||||
Objects.equals(myTarget, item.myTarget);
|
||||
}
|
||||
|
||||
private String getProblemName() {
|
||||
return myProblem.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(myChildren, myProblem, myTarget);
|
||||
return Objects.hash(myChildren, getProblemName(), myTarget);
|
||||
}
|
||||
|
||||
public String dump(Document doc) {
|
||||
return dump(doc, 0);
|
||||
return dump(doc, 0, null);
|
||||
}
|
||||
|
||||
private String dump(Document doc, int indent) {
|
||||
private String dump(Document doc, int indent, CauseItem parent) {
|
||||
String text = null;
|
||||
if (myTarget != null) {
|
||||
Segment range = myTarget.getRange();
|
||||
@@ -149,8 +160,8 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
text = doc.getText(TextRange.create(range));
|
||||
}
|
||||
}
|
||||
return StringUtil.repeat(" ", indent) + render(doc) + (text == null ? "" : " (" + text + ")") + "\n" +
|
||||
StreamEx.of(myChildren).map(child -> child.dump(doc, indent + 1)).joining();
|
||||
return StringUtil.repeat(" ", indent) + render(doc, parent) + (text == null ? "" : " (" + text + ")") + "\n" +
|
||||
StreamEx.of(myChildren).map(child -> child.dump(doc, indent + 1, this)).joining();
|
||||
}
|
||||
|
||||
public Stream<CauseItem> children() {
|
||||
@@ -166,24 +177,117 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
return myTarget == null ? null : myTarget.getRange();
|
||||
}
|
||||
|
||||
public String render(Document doc) {
|
||||
public String render(Document doc, CauseItem parent) {
|
||||
String title = null;
|
||||
Segment range = getTargetSegment();
|
||||
if (range != null) {
|
||||
String cause = myProblem.toString();
|
||||
String cause = getProblemName();
|
||||
if (cause.endsWith("#ref")) {
|
||||
int offset = range.getStartOffset();
|
||||
int number = doc.getLineNumber(offset);
|
||||
return cause.replaceFirst("#ref$", "line #" + (number + 1));
|
||||
title = cause.replaceFirst("#ref$", "line #" + (number + 1));
|
||||
}
|
||||
}
|
||||
return toString();
|
||||
if (title == null) {
|
||||
title = toString();
|
||||
}
|
||||
int childIndex = parent == null ? 0 : parent.myChildren.indexOf(this);
|
||||
if (childIndex > 0) {
|
||||
title = (parent.myProblem instanceof PossibleExecutionDfaProblemType ? "or " : "and ") + title;
|
||||
} else {
|
||||
title = StringUtil.capitalize(title);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myProblem.toString().replaceFirst("#ref$", "here");
|
||||
return getProblemName().replaceFirst("#ref$", "here");
|
||||
}
|
||||
|
||||
public CauseItem merge(CauseItem other) {
|
||||
if (this.equals(other)) return this;
|
||||
if (Objects.equals(this.myTarget, other.myTarget) && getProblemName().equals(other.getProblemName())) {
|
||||
if(tryMergeChildren(other.myChildren)) return this;
|
||||
if(other.tryMergeChildren(this.myChildren)) return other;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean tryMergeChildren(List<CauseItem> children) {
|
||||
if (myChildren.isEmpty()) return false;
|
||||
if (myChildren.size() != 1 || !(myChildren.get(0).myProblem instanceof PossibleExecutionDfaProblemType)) {
|
||||
if (children.size() == myChildren.size()) {
|
||||
List<CauseItem> merged = StreamEx.zip(myChildren, children, CauseItem::merge).toList();
|
||||
if (!merged.contains(null)) {
|
||||
myChildren.clear();
|
||||
myChildren.addAll(merged);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
insertIntoHierarchy(new CauseItem(new PossibleExecutionDfaProblemType(), (PsiElement)null));
|
||||
}
|
||||
CauseItem mergePoint = myChildren.get(0);
|
||||
if (children.isEmpty()) {
|
||||
((PossibleExecutionDfaProblemType)mergePoint.myProblem).myComplete = false;
|
||||
}
|
||||
for (CauseItem child : children) {
|
||||
if (!mergePoint.myChildren.contains(child)) {
|
||||
mergePoint.myChildren.add(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void insertIntoHierarchy(CauseItem intermediate) {
|
||||
intermediate.myChildren.addAll(myChildren);
|
||||
myChildren.clear();
|
||||
myChildren.add(intermediate);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CastDfaProblemType extends DfaProblemType {
|
||||
@Override
|
||||
public CauseItem[] findCauses(PsiExpression expression, MemoryStateChange history) {
|
||||
if (expression instanceof PsiTypeCastExpression) {
|
||||
PsiType expressionType = expression.getType();
|
||||
MemoryStateChange operandPush = history.findExpressionPush(((PsiTypeCastExpression)expression).getOperand());
|
||||
if (operandPush != null) {
|
||||
return new CauseItem[]{findTypeCause(operandPush, expressionType, false)};
|
||||
}
|
||||
}
|
||||
return new CauseItem[0];
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "cast may fail";
|
||||
}
|
||||
}
|
||||
|
||||
public static class NullableDfaProblemType extends DfaProblemType {
|
||||
@Override
|
||||
public CauseItem[] findCauses(PsiExpression expression, MemoryStateChange history) {
|
||||
Pair<MemoryStateChange, DfaNullability> nullability = history.findFact(history.myTopOfStack, DfaFactType.NULLABILITY);
|
||||
if (nullability.second == DfaNullability.NULLABLE || nullability.second == DfaNullability.NULL) {
|
||||
return new CauseItem[]{findNullabilityCause(history, nullability.first, nullability.second)};
|
||||
}
|
||||
return new CauseItem[0];
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "may be null";
|
||||
}
|
||||
}
|
||||
|
||||
static class PossibleExecutionDfaProblemType extends DfaProblemType {
|
||||
boolean myComplete = true;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myComplete ? "one of the following happens:" : "an execution might exist where:";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ValueDfaProblemType extends DfaProblemType {
|
||||
final Object myValue;
|
||||
@@ -192,9 +296,14 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CauseItem[] findCauses(PsiExpression expression, MemoryStateChange history) {
|
||||
return findConstantValueCause(expression, history, myValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Value is always " + myValue;
|
||||
return "value is always " + myValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,16 +322,17 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
|
||||
/*
|
||||
TODO: 1. Find causes of other warnings:
|
||||
Cause for possible NPE
|
||||
Cause for AIOOBE
|
||||
Cause for "Contract always fails"
|
||||
Cause for possible CCE
|
||||
Cause for "modifying an immutable collection"
|
||||
Cause for "Collection is always empty" (separate inspection now)
|
||||
TODO: 2. Describe causes in more cases:
|
||||
Warning caused by contract
|
||||
Warning caused by CustomMethodHandler
|
||||
Warning caused by mismatched type constraints
|
||||
Warning caused by polyadic math
|
||||
Warning caused by narrowing conversion
|
||||
Warning caused by unary minus
|
||||
Warning caused by final field initializer
|
||||
TODO: 3. Check how it works with
|
||||
Inliners (notably: Stream API)
|
||||
Ternary operators
|
||||
@@ -233,20 +343,17 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
private static CauseItem findCauseChain(PsiExpression expression, MemoryStateChange history, DfaProblemType type) {
|
||||
CauseItem root = new CauseItem(type, expression);
|
||||
if (history.getExpression() != expression) return root;
|
||||
if (type instanceof ValueDfaProblemType) {
|
||||
Object expectedValue = ((ValueDfaProblemType)type).myValue;
|
||||
CauseItem[] causes = findConstantValueCause(expression, history, expectedValue);
|
||||
root.addChildren(causes);
|
||||
}
|
||||
root.addChildren(type.findCauses(expression, history));
|
||||
return root;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CauseItem[] findConstantValueCause(PsiExpression expression, MemoryStateChange history, Object expectedValue) {
|
||||
if (expression instanceof PsiLiteralExpression) return new CauseItem[0];
|
||||
Object constantExpressionValue = ExpressionUtils.computeConstantExpression(expression);
|
||||
DfaValue value = history.myTopOfStack;
|
||||
if (constantExpressionValue != null && constantExpressionValue.equals(expectedValue)) {
|
||||
return new CauseItem[]{new CauseItem("It's compile-time constant which evaluates to '" + value + "'", expression)};
|
||||
return new CauseItem[]{new CauseItem("it's compile-time constant which evaluates to '" + value + "'", expression)};
|
||||
}
|
||||
if (value instanceof DfaConstValue) {
|
||||
Object constValue = ((DfaConstValue)value).getValue();
|
||||
@@ -257,7 +364,7 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
if (value instanceof DfaVariableValue) {
|
||||
MemoryStateChange change = history.findRelation(
|
||||
(DfaVariableValue)value, rel -> rel.myRelationType == RelationType.EQ && rel.myCounterpart instanceof DfaConstValue &&
|
||||
Objects.equals(expectedValue, ((DfaConstValue)rel.myCounterpart).getValue()));
|
||||
Objects.equals(expectedValue, ((DfaConstValue)rel.myCounterpart).getValue()), false);
|
||||
if (change != null) {
|
||||
PsiExpression varSourceExpression = change.getExpression();
|
||||
Instruction instruction = change.myInstruction;
|
||||
@@ -270,7 +377,7 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
}
|
||||
return new CauseItem[]{item};
|
||||
}
|
||||
else if (expectedValue instanceof Boolean && varSourceExpression != null) {
|
||||
else if (varSourceExpression != null) {
|
||||
return new CauseItem[]{new CauseItem("'" + value + " == "+expectedValue+"' was established from condition", varSourceExpression)};
|
||||
}
|
||||
}
|
||||
@@ -286,12 +393,33 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
if (negated != null) {
|
||||
MemoryStateChange negatedPush = history.findExpressionPush(negated);
|
||||
if (negatedPush != null) {
|
||||
CauseItem cause = new CauseItem("Value '" + negated.getText() + "' is always '" + !value + "'", negated);
|
||||
CauseItem cause = new CauseItem("value '" + negated.getText() + "' is always '" + !value + "'", negated);
|
||||
cause.addChildren(findConstantValueCause(negated, negatedPush, !value));
|
||||
return new CauseItem[]{cause};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expression instanceof PsiPolyadicExpression) {
|
||||
IElementType tokenType = ((PsiPolyadicExpression)expression).getOperationTokenType();
|
||||
boolean and = tokenType.equals(JavaTokenType.ANDAND);
|
||||
if ((and || tokenType.equals(JavaTokenType.OROR)) && value != and) {
|
||||
PsiExpression[] operands = ((PsiPolyadicExpression)expression).getOperands();
|
||||
for (int i = 0; i < operands.length; i++) {
|
||||
PsiExpression operand = operands[i];
|
||||
operand = PsiUtil.skipParenthesizedExprDown(operand);
|
||||
MemoryStateChange push = history.findExpressionPush(operand);
|
||||
if (push != null &&
|
||||
((push.myInstruction instanceof ConditionalGotoInstruction &&
|
||||
((ConditionalGotoInstruction)push.myInstruction).isTarget(value, history.myInstruction)) ||
|
||||
(push.myTopOfStack instanceof DfaConstValue &&
|
||||
Boolean.valueOf(value).equals(((DfaConstValue)push.myTopOfStack).getValue())))) {
|
||||
CauseItem cause = new CauseItem("operand #" + (i + 1) + " of " + (and ? "&&" : "||") + "-chain is " + value, operand);
|
||||
cause.addChildren(findBooleanResultCauses(operand, push, value));
|
||||
return new CauseItem[]{cause};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expression instanceof PsiBinaryExpression) {
|
||||
PsiBinaryExpression binOp = (PsiBinaryExpression)expression;
|
||||
RelationType relationType =
|
||||
@@ -300,33 +428,85 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
if (!value) {
|
||||
relationType = relationType.getNegated();
|
||||
}
|
||||
PsiExpression leftOperand = binOp.getLOperand();
|
||||
PsiExpression rightOperand = binOp.getROperand();
|
||||
PsiExpression leftOperand = PsiUtil.skipParenthesizedExprDown(binOp.getLOperand());
|
||||
PsiExpression rightOperand = PsiUtil.skipParenthesizedExprDown(binOp.getROperand());
|
||||
MemoryStateChange leftChange = history.findExpressionPush(leftOperand);
|
||||
MemoryStateChange rightChange = history.findExpressionPush(rightOperand);
|
||||
if (leftChange != null && rightChange != null) {
|
||||
DfaValue leftValue = leftChange.myTopOfStack;
|
||||
DfaValue rightValue = rightChange.myTopOfStack;
|
||||
CauseItem[] causes = findRelationCause(relationType, leftChange, rightChange);
|
||||
if (causes.length > 0) {
|
||||
return causes;
|
||||
}
|
||||
if (leftValue == rightValue &&
|
||||
(leftValue instanceof DfaVariableValue || leftValue instanceof DfaConstValue)) {
|
||||
return new CauseItem[]{new CauseItem("Comparison arguments are the same", binOp.getOperationSign())};
|
||||
return new CauseItem[]{new CauseItem("comparison arguments are the same", binOp.getOperationSign())};
|
||||
}
|
||||
if (leftValue != rightValue && relationType.isInequality() &&
|
||||
leftValue instanceof DfaConstValue && rightValue instanceof DfaConstValue) {
|
||||
return new CauseItem[]{
|
||||
new CauseItem("Comparison arguments are different constants", binOp.getOperationSign())};
|
||||
new CauseItem("comparison arguments are different constants", binOp.getOperationSign())};
|
||||
}
|
||||
return findRelationCause(relationType, leftChange, rightChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expression instanceof PsiInstanceOfExpression) {
|
||||
PsiInstanceOfExpression instanceOfExpression = (PsiInstanceOfExpression)expression;
|
||||
PsiExpression operand = instanceOfExpression.getOperand();
|
||||
MemoryStateChange operandHistory = history.findExpressionPush(operand);
|
||||
if (operandHistory != null) {
|
||||
DfaValue operandValue = operandHistory.myTopOfStack;
|
||||
if (!value) {
|
||||
Pair<MemoryStateChange, DfaNullability> nullability = operandHistory.findFact(operandValue, DfaFactType.NULLABILITY);
|
||||
if (nullability.second == DfaNullability.NULL) {
|
||||
CauseItem causeItem = new CauseItem("value '" + operand.getText() + "' is always 'null'", operand);
|
||||
causeItem.addChildren(findConstantValueCause(operand, operandHistory, null));
|
||||
return new CauseItem[]{causeItem};
|
||||
}
|
||||
}
|
||||
PsiTypeElement typeElement = instanceOfExpression.getCheckType();
|
||||
if (typeElement != null) {
|
||||
PsiType type = typeElement.getType();
|
||||
CauseItem causeItem = findTypeCause(operandHistory, type, value);
|
||||
if (causeItem != null) return new CauseItem[]{causeItem};
|
||||
}
|
||||
}
|
||||
}
|
||||
return new CauseItem[0];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static CauseItem findTypeCause(MemoryStateChange operandHistory, PsiType type, boolean isInstance) {
|
||||
PsiExpression operand = Objects.requireNonNull(operandHistory.getExpression());
|
||||
DfaValue operandValue = operandHistory.myTopOfStack;
|
||||
DfaPsiType wanted = operandValue.getFactory().createDfaType(type);
|
||||
|
||||
Pair<MemoryStateChange, TypeConstraint> fact = operandHistory.findFact(operandValue, DfaFactType.TYPE_CONSTRAINT);
|
||||
String explanation = fact.second == null ? null : fact.second.getAssignabilityExplanation(wanted, isInstance);
|
||||
while (explanation != null) {
|
||||
MemoryStateChange causeLocation = fact.first;
|
||||
if (causeLocation == null) break;
|
||||
MemoryStateChange prevHistory = causeLocation.myPrevious;
|
||||
if (prevHistory == null) break;
|
||||
fact = prevHistory.findFact(operandValue, DfaFactType.TYPE_CONSTRAINT);
|
||||
TypeConstraint prevConstraint = fact.second == null ? TypeConstraint.empty() : fact.second;
|
||||
String prevExplanation = prevConstraint.getAssignabilityExplanation(wanted, isInstance);
|
||||
if (prevExplanation == null) {
|
||||
CauseItem causeItem = new CauseItem(explanation, operand);
|
||||
causeItem.addChildren(new CauseItem("type of '" + operand.getText() + "' is known from #ref", causeLocation));
|
||||
return causeItem;
|
||||
}
|
||||
explanation = prevExplanation;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CauseItem[] findRelationCause(RelationType relationType,
|
||||
MemoryStateChange leftChange,
|
||||
MemoryStateChange rightChange) {
|
||||
ProgressManager.checkCanceled();
|
||||
DfaValue leftValue = leftChange.myTopOfStack;
|
||||
DfaValue rightValue = rightChange.myTopOfStack;
|
||||
if (leftValue instanceof DfaVariableValue) {
|
||||
@@ -372,8 +552,8 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
LongRangeSet fromRelation = rightRange.second.fromRelation(relationType.getNegated());
|
||||
if (fromRelation != null && !fromRelation.intersects(leftRange.second)) {
|
||||
return new CauseItem[]{
|
||||
findRangeCause(leftChange, leftRange.first, leftRange.second, "Left operand is %s"),
|
||||
findRangeCause(rightChange, rightRange.first, rightRange.second, "Right operand is %s")};
|
||||
findRangeCause(leftChange, leftRange.first, leftRange.second, "left operand is %s"),
|
||||
findRangeCause(rightChange, rightRange.first, rightRange.second, "right operand is %s")};
|
||||
}
|
||||
}
|
||||
return new CauseItem[0];
|
||||
@@ -393,12 +573,12 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
}
|
||||
if (instruction instanceof InstanceofInstruction) {
|
||||
PsiExpression expression = ((InstanceofInstruction)instruction).getExpression();
|
||||
return new CauseItem("The 'instanceof' check implies non-nullity", expression);
|
||||
return new CauseItem("the 'instanceof' check implies non-nullity", expression);
|
||||
}
|
||||
}
|
||||
if (instruction instanceof AssignInstruction) {
|
||||
DfaValue target = change.myTopOfStack;
|
||||
PsiExpression rValue = ((AssignInstruction)instruction).getRExpression();
|
||||
PsiExpression rValue = PsiUtil.skipParenthesizedExprDown(((AssignInstruction)instruction).getRExpression());
|
||||
if (target == value) {
|
||||
CauseItem item = new CauseItem("'" + target + "' was assigned", rValue);
|
||||
MemoryStateChange rValuePush = change.findExpressionPush(rValue);
|
||||
@@ -423,11 +603,11 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
DfaValue rightValue = rightPos.myTopOfStack;
|
||||
if (leftValue == value && rightValue == relation.myCounterpart ||
|
||||
rightValue == value && leftValue == relation.myCounterpart) {
|
||||
return new CauseItem(new CustomDfaProblemType(condition + " was checked before"), expression);
|
||||
return new CauseItem(new CustomDfaProblemType("condition '" + condition + "' was checked before"), expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new CauseItem(new CustomDfaProblemType(condition + " is known from #ref"), expression);
|
||||
return new CauseItem(new CustomDfaProblemType("result of '" + condition + "' is known from #ref"), expression);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -435,28 +615,48 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
private static CauseItem findNullabilityCause(MemoryStateChange factUse, MemoryStateChange factDef, DfaNullability nullability) {
|
||||
PsiExpression expression = factUse.getExpression();
|
||||
if (factDef != null && expression != null) {
|
||||
DfaValue value = factUse.myTopOfStack;
|
||||
if (factDef.myInstruction instanceof AssignInstruction && factDef.myTopOfStack == value) {
|
||||
PsiExpression rExpression = PsiUtil.skipParenthesizedExprDown(((AssignInstruction)factDef.myInstruction).getRExpression());
|
||||
while (rExpression instanceof PsiTypeCastExpression) {
|
||||
rExpression = PsiUtil.skipParenthesizedExprDown(((PsiTypeCastExpression)rExpression).getOperand());
|
||||
}
|
||||
if (rExpression != null) {
|
||||
MemoryStateChange rValuePush = factDef.findExpressionPush(rExpression);
|
||||
if (rValuePush != null) {
|
||||
CauseItem assignmentItem = new CauseItem("'" + value + "' was assigned", rExpression);
|
||||
Pair<MemoryStateChange, DfaNullability> rValueFact = rValuePush.findFact(rValuePush.myTopOfStack, DfaFactType.NULLABILITY);
|
||||
assignmentItem.addChildren(findNullabilityCause(rValuePush, rValueFact.first, nullability));
|
||||
return assignmentItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
PsiExpression defExpression = factDef.getExpression();
|
||||
if (defExpression != null) {
|
||||
return new CauseItem(
|
||||
new CustomDfaProblemType(expression.getText() + " is known to be '" + nullability.getPresentationName() + "' from #ref"),
|
||||
defExpression);
|
||||
return new CauseItem("'" + expression.getText() + "' is known to be '" + nullability.getPresentationName() + "' from #ref", defExpression);
|
||||
}
|
||||
}
|
||||
if (expression instanceof PsiMethodCallExpression) {
|
||||
PsiMethodCallExpression call = (PsiMethodCallExpression)expression;
|
||||
PsiMethod method = call.resolveMethod();
|
||||
return fromMemberNullability(nullability, method, "Method", call.getMethodExpression().getReferenceNameElement());
|
||||
return fromMemberNullability(nullability, method, "method", call.getMethodExpression().getReferenceNameElement());
|
||||
}
|
||||
if (expression instanceof PsiReferenceExpression) {
|
||||
PsiVariable variable = ObjectUtils.tryCast(((PsiReferenceExpression)expression).resolve(), PsiVariable.class);
|
||||
if (variable instanceof PsiField) {
|
||||
return fromMemberNullability(nullability, variable, "Field", ((PsiReferenceExpression)expression).getReferenceNameElement());
|
||||
return fromMemberNullability(nullability, variable, "field", ((PsiReferenceExpression)expression).getReferenceNameElement());
|
||||
}
|
||||
if (variable instanceof PsiParameter) {
|
||||
return fromMemberNullability(nullability, variable, "Parameter", ((PsiReferenceExpression)expression).getReferenceNameElement());
|
||||
return fromMemberNullability(nullability, variable, "parameter", ((PsiReferenceExpression)expression).getReferenceNameElement());
|
||||
}
|
||||
if (variable != null) {
|
||||
return fromMemberNullability(nullability, variable, "Variable", ((PsiReferenceExpression)expression).getReferenceNameElement());
|
||||
return fromMemberNullability(nullability, variable, "variable", ((PsiReferenceExpression)expression).getReferenceNameElement());
|
||||
}
|
||||
}
|
||||
if (nullability == DfaNullability.NOT_NULL) {
|
||||
String explanation = getObviouslyNonNullExplanation(expression);
|
||||
if (explanation != null) {
|
||||
return new CauseItem("expression cannot be null as it's " + explanation, expression);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -477,13 +677,37 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
message = memberName + " '" + name + "' is externally annotated as '" + nullability.getPresentationName() + "'";
|
||||
}
|
||||
else if (info.isContainer()) {
|
||||
message = memberName + " '" + name + "' inherits container annotation, thus '" + nullability.getPresentationName() + "'";
|
||||
PsiAnnotationOwner annoOwner = info.getAnnotation().getOwner();
|
||||
String details = "container annotation";
|
||||
if (annoOwner instanceof PsiModifierList) {
|
||||
PsiElement parent = ((PsiModifierList)annoOwner).getParent();
|
||||
if (parent instanceof PsiClass) {
|
||||
PsiClass aClass = (PsiClass)parent;
|
||||
details = "annotation from class " + aClass.getName();
|
||||
if ("package-info".equals(aClass.getName())) {
|
||||
PsiFile file = aClass.getContainingFile();
|
||||
if (file instanceof PsiJavaFile) {
|
||||
details = "annotation from package " + ((PsiJavaFile)file).getPackageName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (annoOwner instanceof PsiNamedElement) {
|
||||
details = " from " + ((PsiNamedElement)annoOwner).getName();
|
||||
}
|
||||
message =
|
||||
memberName + " '" + name + "' inherits " + details + ", thus '" + nullability.getPresentationName() + "'";
|
||||
}
|
||||
else {
|
||||
message = memberName + " '" + name + "' is annotated as '" + nullability.getPresentationName() + "'";
|
||||
}
|
||||
if (owner.getContainingFile() == anchor.getContainingFile()) {
|
||||
if (info.getAnnotation().getContainingFile() == anchor.getContainingFile()) {
|
||||
anchor = info.getAnnotation();
|
||||
} else if (owner.getContainingFile() == anchor.getContainingFile()) {
|
||||
anchor = owner.getNavigationElement();
|
||||
if (anchor instanceof PsiNameIdentifierOwner) {
|
||||
anchor = ((PsiNameIdentifierOwner)anchor).getNameIdentifier();
|
||||
}
|
||||
}
|
||||
return new CauseItem(message, anchor);
|
||||
}
|
||||
@@ -501,11 +725,11 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
if (descriptor instanceof SpecialField && range.equals(LongRangeSet.indexRange())) {
|
||||
switch (((SpecialField)descriptor)) {
|
||||
case ARRAY_LENGTH:
|
||||
return new CauseItem("Array length is always non-negative", factUse);
|
||||
return new CauseItem("array length is always non-negative", factUse);
|
||||
case STRING_LENGTH:
|
||||
return new CauseItem("String length is always non-negative", factUse);
|
||||
return new CauseItem("string length is always non-negative", factUse);
|
||||
case COLLECTION_SIZE:
|
||||
return new CauseItem("Collection size is always non-negative", factUse);
|
||||
return new CauseItem("collection size is always non-negative", factUse);
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -521,7 +745,7 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
if (method != null) {
|
||||
LongRangeSet fromAnnotation = LongRangeSet.fromPsiElement(method);
|
||||
if (fromAnnotation.equals(range)) {
|
||||
return new CauseItem("The range of '" + method.getName() + "' is specified by annotation as " + range,
|
||||
return new CauseItem("the range of '" + method.getName() + "' is specified by annotation as " + range,
|
||||
call.getMethodExpression().getReferenceNameElement());
|
||||
}
|
||||
}
|
||||
@@ -530,8 +754,8 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
(PsiType.LONG.equals(expression.getType()) || PsiType.INT.equals(expression.getType()))) {
|
||||
boolean isLong = PsiType.LONG.equals(expression.getType());
|
||||
PsiBinaryExpression binOp = (PsiBinaryExpression)expression;
|
||||
PsiExpression left = binOp.getLOperand();
|
||||
PsiExpression right = binOp.getROperand();
|
||||
PsiExpression left = PsiUtil.skipParenthesizedExprDown(binOp.getLOperand());
|
||||
PsiExpression right = PsiUtil.skipParenthesizedExprDown(binOp.getROperand());
|
||||
MemoryStateChange leftPush = factUse.findExpressionPush(left);
|
||||
MemoryStateChange rightPush = factUse.findExpressionPush(right);
|
||||
if (leftPush != null && rightPush != null) {
|
||||
@@ -548,14 +772,14 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
}
|
||||
LongRangeSet result = leftSet.second.binOpFromToken(binOp.getOperationTokenType(), rightSet.second, isLong);
|
||||
if (range.equals(result)) {
|
||||
CauseItem cause = new CauseItem("Result of '" + binOp.getOperationSign().getText() +
|
||||
CauseItem cause = new CauseItem("result of '" + binOp.getOperationSign().getText() +
|
||||
"' is " + range.getPresentationText(expression.getType()), factUse);
|
||||
CauseItem leftCause = null, rightCause = null;
|
||||
if (!leftSet.second.equals(fromType)) {
|
||||
leftCause = findRangeCause(leftPush, leftSet.first, leftSet.second, "Left operand is %s");
|
||||
leftCause = findRangeCause(leftPush, leftSet.first, leftSet.second, "left operand is %s");
|
||||
}
|
||||
if (!rightSet.second.equals(fromType)) {
|
||||
rightCause = findRangeCause(rightPush, rightSet.first, rightSet.second, "Right operand is %s");
|
||||
rightCause = findRangeCause(rightPush, rightSet.first, rightSet.second, "right operand is %s");
|
||||
}
|
||||
cause.addChildren(leftCause, rightCause);
|
||||
return cause;
|
||||
@@ -566,14 +790,40 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
String rangeText = range.getPresentationText(expression != null ? expression.getType() : null);
|
||||
CauseItem item = new CauseItem(String.format(template, rangeText), factUse);
|
||||
if (factDef != null) {
|
||||
if (factDef.myInstruction instanceof AssignInstruction && factDef.myTopOfStack == value) {
|
||||
PsiExpression rExpression = PsiUtil.skipParenthesizedExprDown(((AssignInstruction)factDef.myInstruction).getRExpression());
|
||||
if (rExpression != null) {
|
||||
MemoryStateChange rValuePush = factDef.findExpressionPush(rExpression);
|
||||
if (rValuePush != null) {
|
||||
CauseItem assignmentItem = new CauseItem("'" + value + "' was assigned", rExpression);
|
||||
Pair<MemoryStateChange, LongRangeSet> rValueFact = rValuePush.findFact(rValuePush.myTopOfStack, DfaFactType.RANGE);
|
||||
assignmentItem.addChildren(findRangeCause(rValuePush, rValueFact.first, range, "Value is %s"));
|
||||
item.addChildren(assignmentItem);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
PsiExpression defExpression = factDef.getExpression();
|
||||
if (defExpression != null) {
|
||||
item.addChildren(new CauseItem("Range is known from #ref", defExpression));
|
||||
item.addChildren(new CauseItem("range is known from #ref", defExpression));
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getObviouslyNonNullExplanation(PsiExpression arg) {
|
||||
if (arg == null || ExpressionUtils.isNullLiteral(arg)) return null;
|
||||
if (arg instanceof PsiNewExpression) return "newly created object";
|
||||
if (arg instanceof PsiLiteralExpression) return "literal";
|
||||
if (arg.getType() instanceof PsiPrimitiveType) return "a value of primitive type '" + arg.getType().getCanonicalText() + "'";
|
||||
if (arg instanceof PsiPolyadicExpression && ((PsiPolyadicExpression)arg).getOperationTokenType() == JavaTokenType.PLUS) {
|
||||
return "concatenation";
|
||||
}
|
||||
if (arg instanceof PsiThisExpression) return "'this' object";
|
||||
return null;
|
||||
}
|
||||
|
||||
private static MemoryStateChange findRelationAddedChange(MemoryStateChange history, DfaVariableValue var, Relation relation) {
|
||||
List<Relation> subRelations;
|
||||
switch (relation.myRelationType) {
|
||||
@@ -592,6 +842,6 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
default:
|
||||
subRelations = Collections.singletonList(relation);
|
||||
}
|
||||
return history.findRelation(var, subRelations::contains);
|
||||
return history.findRelation(var, subRelations::contains, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public abstract class TypeConstraint {
|
||||
|
||||
public abstract boolean isExact(String typeName);
|
||||
|
||||
public abstract String getAssignabilityExplanation(DfaPsiType otherType, boolean expectedAssignable);
|
||||
|
||||
static final class Exact extends TypeConstraint {
|
||||
final @NotNull DfaPsiType myType;
|
||||
@@ -95,6 +96,21 @@ public abstract class TypeConstraint {
|
||||
return type.isAssignableFrom(myType) ? null : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssignabilityExplanation(DfaPsiType otherType, boolean expectedAssignable) {
|
||||
boolean actual = otherType.isAssignableFrom(myType);
|
||||
if (actual != expectedAssignable) return null;
|
||||
if (expectedAssignable) {
|
||||
if (myType == otherType) {
|
||||
return "an object is already known to be " + myType;
|
||||
}
|
||||
return "an object type is exactly " + myType + " which is a subtype of " + otherType;
|
||||
}
|
||||
else {
|
||||
return "an object type is exactly " + myType + " which is not a subtype of " + otherType;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
TypeConstraint withoutType(@NotNull DfaPsiType type) {
|
||||
@@ -411,6 +427,31 @@ public abstract class TypeConstraint {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssignabilityExplanation(DfaPsiType otherType, boolean expectedAssignable) {
|
||||
if (expectedAssignable) {
|
||||
for (DfaPsiType dfaTypeValue : myInstanceofValues) {
|
||||
if (otherType.isAssignableFrom(dfaTypeValue)) {
|
||||
return "an object is already known to be " + dfaTypeValue +
|
||||
(otherType == dfaTypeValue ? "" : " which is a subtype of " + otherType);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (DfaPsiType dfaTypeValue : myNotInstanceofValues) {
|
||||
if (dfaTypeValue.isAssignableFrom(otherType)) {
|
||||
return "an object is known to be not " + dfaTypeValue +
|
||||
(otherType == dfaTypeValue ? "" : " which is a supertype of " + otherType);
|
||||
}
|
||||
}
|
||||
for (DfaPsiType dfaTypeValue : myInstanceofValues) {
|
||||
if (!otherType.isConvertibleFrom(dfaTypeValue)) {
|
||||
return "an object is known to be " + dfaTypeValue + " which is definitely incompatible with " + otherType;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
+4
@@ -43,6 +43,10 @@ public class ConditionalGotoInstruction extends BranchingInstruction implements
|
||||
return "IF_" + (isNegated() ? "NE" : "EQ") + " " + getOffset();
|
||||
}
|
||||
|
||||
public boolean isTarget(boolean whenTrueOnStack, Instruction target) {
|
||||
return target.getIndex() == (whenTrueOnStack == myIsNegated ? getIndex() + 1 : getOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
return myOffset.getInstructionOffset();
|
||||
|
||||
+2
-7
@@ -19,6 +19,7 @@ import com.intellij.codeInspection.dataFlow.TypeConstraint;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -95,13 +96,7 @@ public class DfaPsiType {
|
||||
@NotNull
|
||||
public static PsiType normalizeType(@NotNull PsiType psiType) {
|
||||
if (psiType instanceof PsiArrayType) {
|
||||
int dimensions = psiType.getArrayDimensions();
|
||||
psiType = psiType.getDeepComponentType();
|
||||
psiType = normalizeType(psiType);
|
||||
while (dimensions-- > 0) {
|
||||
psiType = psiType.createArrayType();
|
||||
}
|
||||
return psiType;
|
||||
return PsiTypesUtil.createArrayType(normalizeType(psiType.getDeepComponentType()), psiType.getArrayDimensions());
|
||||
}
|
||||
if (psiType instanceof PsiWildcardType) {
|
||||
return normalizeType(((PsiWildcardType)psiType).getExtendsBound());
|
||||
|
||||
+3
-5
@@ -7,6 +7,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.reference.*;
|
||||
import com.intellij.configurationStore.XmlSerializer;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
@@ -24,8 +25,6 @@ import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.xmlb.SkipDefaultsSerializationFilter;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import org.jdom.Element;
|
||||
@@ -133,7 +132,7 @@ public abstract class EntryPointsManagerBase extends EntryPointsManager implemen
|
||||
getPatterns().clear();
|
||||
for (Element pattern : element.getChildren("pattern")) {
|
||||
final ClassPattern classPattern = new ClassPattern();
|
||||
XmlSerializer.deserializeInto(classPattern, pattern);
|
||||
XmlSerializer.deserializeInto(pattern, classPattern);
|
||||
getPatterns().add(classPattern);
|
||||
}
|
||||
|
||||
@@ -154,9 +153,8 @@ public abstract class EntryPointsManagerBase extends EntryPointsManager implemen
|
||||
Element element = new Element("state");
|
||||
writeExternal(element, myPersistentEntryPoints, ADDITIONAL_ANNOTATIONS);
|
||||
if (!getPatterns().isEmpty()) {
|
||||
SkipDefaultsSerializationFilter filter = new SkipDefaultsSerializationFilter();
|
||||
for (ClassPattern pattern : getPatterns()) {
|
||||
element.addContent(XmlSerializer.serialize(pattern, filter));
|
||||
element.addContent(XmlSerializer.serialize(pattern));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class Java9RedundantRequiresStatementInspection extends GlobalJavaBatchIn
|
||||
isDependencyUnused(requiredModule.packagesExportedByModule, moduleImportedPackages, refJavaModule.getName())) {
|
||||
PsiRequiresStatement requiresStatement = ContainerUtil.find(
|
||||
psiJavaModule.getRequires(), statement -> requiredModuleName.equals(statement.getModuleName()));
|
||||
if (requiresStatement != null) {
|
||||
if (requiresStatement != null && !isSuppressedFor(requiresStatement)) {
|
||||
CommonProblemDescriptor descriptor = manager.createProblemDescriptor(
|
||||
requiresStatement,
|
||||
InspectionsBundle.message("inspection.redundant.requires.statement.description", requiredModuleName),
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ import java.util.stream.Stream;
|
||||
public class RefJavaManagerImpl extends RefJavaManager {
|
||||
private static final Condition<PsiElement> PROBLEM_ELEMENT_CONDITION =
|
||||
Conditions.or(Conditions.instanceOf(PsiFile.class, PsiJavaModule.class),
|
||||
Conditions.and(Conditions.notInstanceOf(PsiTypeParameter.class), psi -> {
|
||||
Conditions.and(Conditions.and(Conditions.notInstanceOf(PsiTypeParameter.class), Conditions.instanceOf(PsiNamedElement.class)), psi -> {
|
||||
UDeclaration decl = UastContextKt.toUElement(psi, UDeclaration.class);
|
||||
return decl != null && (decl instanceof UField || !(decl instanceof UVariable)) && (!(decl instanceof UClassInitializer));
|
||||
}));
|
||||
|
||||
+13
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.util;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
@@ -16,6 +16,7 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ig.psiutils.ExpectedTypeUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -696,6 +697,14 @@ public class RedundantCastUtil {
|
||||
addToResults(typeCast);
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiBinaryExpression) {
|
||||
PsiExpression lOperand = ((PsiBinaryExpression)parent).getLOperand();
|
||||
PsiExpression rOperand = ((PsiBinaryExpression)parent).getROperand();
|
||||
PsiType oppositeType = lOperand == typeCast ? rOperand != null ? rOperand.getType() : null : lOperand.getType();
|
||||
if (oppositeType != null && TypeConversionUtil.areTypesConvertible(opType, oppositeType)) {
|
||||
addToResults(typeCast);
|
||||
}
|
||||
}
|
||||
else if (TypeConversionUtil.isAssignable(castTo, opType, false) &&
|
||||
(expectedTypeByParent == null || TypeConversionUtil.isAssignable(expectedTypeByParent, opType, false))) {
|
||||
addToResults(typeCast);
|
||||
@@ -767,8 +776,9 @@ public class RedundantCastUtil {
|
||||
if (castType instanceof PsiPrimitiveType) {
|
||||
if (opType instanceof PsiPrimitiveType) {
|
||||
PsiElement parent = PsiUtil.skipParenthesizedExprUp(typeCast.getParent());
|
||||
if (parent instanceof PsiReturnStatement || parent instanceof PsiExpressionList || parent instanceof PsiVariable ||
|
||||
parent instanceof PsiAssignmentExpression) {
|
||||
if ((parent instanceof PsiReturnStatement || parent instanceof PsiExpressionList || parent instanceof PsiVariable ||
|
||||
parent instanceof PsiAssignmentExpression) &&
|
||||
castType.equals(ExpectedTypeUtils.findExpectedType(typeCast, false))) {
|
||||
return !TypeConversionUtil.isSafeConversion(castType, opType); // let's suppose that casts losing precision are important
|
||||
} else {
|
||||
return !castType.equals(opType); // cast might be necessary (e.g. ((double)1)/5)
|
||||
@@ -39,10 +39,6 @@
|
||||
</xi:include>
|
||||
|
||||
<application-components>
|
||||
<component>
|
||||
<interface-class>com.intellij.openapi.vfs.jrt.JrtFileSystem</interface-class>
|
||||
<implementation-class>com.intellij.openapi.vfs.impl.jrt.JrtFileSystemImpl</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<interface-class>com.intellij.openapi.projectRoots.JavaSdk</interface-class>
|
||||
<implementation-class>com.intellij.openapi.projectRoots.impl.JavaSdkImpl</implementation-class>
|
||||
@@ -61,12 +57,6 @@
|
||||
<interface-class>com.intellij.psi.RefResolveService</interface-class>
|
||||
<implementation-class>com.intellij.psi.refResolve.RefResolveServiceImpl</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.codeInsight.hints.AnnotationHintsPassFactory</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.codeInsight.hints.MethodChainHintsPassFactory</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.lang.java.JavaModuleRenameListener</implementation-class>
|
||||
</component>
|
||||
@@ -308,6 +298,11 @@
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<highlightingPassFactory implementation="com.intellij.codeInsight.hints.AnnotationHintsPassFactory"/>
|
||||
<highlightingPassFactory implementation="com.intellij.codeInsight.hints.MethodChainHintsPassFactory"/>
|
||||
<highlightingPassFactory implementation="com.intellij.framework.detection.impl.FrameworkDetectionManager$FrameworkDetectionHighlightingPassFactory"/>
|
||||
|
||||
<virtualFileSystem implementationClass="com.intellij.openapi.vfs.impl.jrt.JrtFileSystemImpl" key="jrt" physical="true"/>
|
||||
<applicationService serviceImplementation="com.intellij.codeInsight.generation.SetterTemplatesManager"/>
|
||||
<applicationService serviceImplementation="com.intellij.codeInsight.generation.GetterTemplatesManager"/>
|
||||
<applicationService serviceImplementation="com.intellij.codeInsight.generation.EqualsHashCodeTemplatesManager"/>
|
||||
@@ -423,6 +418,8 @@
|
||||
<applicationService serviceImplementation="com.intellij.debugger.settings.ThreadsViewSettings"/>
|
||||
<applicationService serviceImplementation="com.intellij.debugger.settings.TraceSettings"/>
|
||||
|
||||
<statistics.applicationUsagesCollector implementation="com.intellij.debugger.settings.DebuggerSettingsStatisticsCollector"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.packaging.elements.PackagingElementFactory"
|
||||
serviceImplementation="com.intellij.packaging.impl.elements.PackagingElementFactoryImpl"/>
|
||||
|
||||
@@ -1907,6 +1904,9 @@
|
||||
<applicationInitializedListener implementation="com.intellij.util.xml.impl.JavaDomApplicationComponent$Initializer"/>
|
||||
<java.externalAnnotation.locationProvider
|
||||
implementation="com.intellij.codeInsight.externalAnnotation.location.JBBundledAnnotationsProvider"/>
|
||||
|
||||
<statistics.counterUsagesCollector groupId="new.project.wizard.attempt" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="new.project.wizard.finish" version="1"/>
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains">
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.intellij.util.BitUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.siyeh.ig.psiutils.ExpressionUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -203,7 +202,7 @@ public class JavaTargetElementEvaluator extends TargetElementEvaluatorEx2 implem
|
||||
public Collection<PsiElement> getTargetCandidates(@NotNull PsiReference reference) {
|
||||
PsiElement parent = reference.getElement().getParent();
|
||||
if (parent instanceof PsiMethodCallExpression ||
|
||||
parent instanceof PsiNewExpression && !ExpressionUtils.isArrayCreationExpression((PsiNewExpression)parent)) {
|
||||
parent instanceof PsiNewExpression && !((PsiNewExpression)parent).isArrayCreation()) {
|
||||
PsiCallExpression callExpr = (PsiCallExpression)parent;
|
||||
boolean allowStatics = false;
|
||||
PsiExpression qualifier = callExpr instanceof PsiMethodCallExpression ? ((PsiMethodCallExpression)callExpr).getMethodExpression().getQualifierExpression()
|
||||
|
||||
@@ -5,8 +5,11 @@ import com.intellij.codeInspection.dataFlow.HardcodedContracts;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.index.JavaAnnotationIndex;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -205,7 +208,7 @@ public class NullableNotNullManagerImpl extends NullableNotNullManager implement
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected NullabilityAnnotationInfo isJsr305Default(@NotNull PsiAnnotation annotation, @NotNull PsiAnnotation.TargetType[] placeTargetTypes) {
|
||||
PsiClass declaration = resolveAnnotationType(annotation);
|
||||
PsiModifierList modList = declaration == null ? null : declaration.getModifierList();
|
||||
@@ -226,6 +229,37 @@ public class NullableNotNullManagerImpl extends NullableNotNullManager implement
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
NullabilityAnnotationInfo getNullityDefault(@NotNull PsiModifierListOwner container,
|
||||
@NotNull PsiAnnotation.TargetType[] placeTargetTypes,
|
||||
PsiModifierListOwner owner, boolean superPackage) {
|
||||
PsiModifierList modifierList = container.getModifierList();
|
||||
if (modifierList == null) return null;
|
||||
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
|
||||
if (container instanceof PsiPackage) {
|
||||
PsiFile file = annotation.getContainingFile();
|
||||
ProjectFileIndex index = ProjectRootManager.getInstance(file.getProject()).getFileIndex();
|
||||
VirtualFile annotationRoot = index.getClassRootForFile(file.getVirtualFile());
|
||||
VirtualFile ownerRoot = index.getClassRootForFile(owner.getContainingFile().getVirtualFile());
|
||||
if (ownerRoot != null && !ownerRoot.equals(annotationRoot)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
NullabilityAnnotationInfo result = checkNullityDefault(annotation, placeTargetTypes, superPackage);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private NullabilityAnnotationInfo checkNullityDefault(@NotNull PsiAnnotation annotation, @NotNull PsiAnnotation.TargetType[] placeTargetTypes, boolean superPackage) {
|
||||
NullabilityAnnotationInfo jsr = superPackage ? null : isJsr305Default(annotation, placeTargetTypes);
|
||||
return jsr != null ? jsr : CheckerFrameworkNullityUtil.isCheckerDefault(annotation, placeTargetTypes);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiClass resolveAnnotationType(@NotNull PsiAnnotation annotation) {
|
||||
PsiJavaCodeReferenceElement element = annotation.getNameReferenceElement();
|
||||
|
||||
@@ -277,7 +277,8 @@ public class JavaCompletionUtil {
|
||||
|
||||
List<PsiType> runtimeQualifiers = getQualifierCastTypes(javaReference, parameters);
|
||||
if (!runtimeQualifiers.isEmpty()) {
|
||||
PsiType composite = PsiIntersectionType.createIntersection(JBIterable.of(plainQualifier).append(runtimeQualifiers).toList());
|
||||
PsiType[] conjuncts = JBIterable.of(plainQualifier).append(runtimeQualifiers).toArray(PsiType.EMPTY_ARRAY);
|
||||
PsiType composite = PsiIntersectionType.createIntersection(false, conjuncts);
|
||||
PsiElement ctx = createContextWithXxxVariable(element, composite);
|
||||
javaReference = createReference("xxx.xxx", ctx);
|
||||
processor.setQualifierType(composite);
|
||||
@@ -835,7 +836,7 @@ public class JavaCompletionUtil {
|
||||
if (afterTailOffset > tailOffset &&
|
||||
tailOffset > caretOffset &&
|
||||
TabOutScopesTracker.getInstance().removeScopeEndingAt(editor, caretOffset) > 0) {
|
||||
TabOutScopesTracker.getInstance().registerEmptyScope(editor, caretOffset, afterTailOffset - caretOffset);
|
||||
TabOutScopesTracker.getInstance().registerEmptyScope(editor, caretOffset, afterTailOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+20
-15
@@ -24,6 +24,7 @@ import com.intellij.util.containers.hash.LinkedHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -41,9 +42,8 @@ public class JavaCompletionProcessor implements PsiScopeProcessor, ElementClassH
|
||||
private final PsiElement myScope;
|
||||
private final ElementFilter myFilter;
|
||||
private boolean myMembersFlag;
|
||||
private boolean myQualified;
|
||||
private final boolean myQualified;
|
||||
private PsiType myQualifierType;
|
||||
private PsiClass myQualifierClass;
|
||||
private final Condition<? super String> myMatcher;
|
||||
private final Options myOptions;
|
||||
private final boolean myAllowStaticWithInstanceQualifier;
|
||||
@@ -61,33 +61,34 @@ public class JavaCompletionProcessor implements PsiScopeProcessor, ElementClassH
|
||||
}
|
||||
myScope = scope;
|
||||
|
||||
PsiClass qualifierClass = null;
|
||||
PsiElement elementParent = element.getContext();
|
||||
myQualified = elementParent instanceof PsiReferenceExpression && ((PsiReferenceExpression)elementParent).isQualified();
|
||||
if (elementParent instanceof PsiReferenceExpression) {
|
||||
PsiExpression qualifier = ((PsiReferenceExpression)elementParent).getQualifierExpression();
|
||||
if (qualifier instanceof PsiSuperExpression) {
|
||||
final PsiJavaCodeReferenceElement qSuper = ((PsiSuperExpression)qualifier).getQualifier();
|
||||
if (qSuper == null) {
|
||||
myQualifierClass = JavaResolveUtil.getContextClass(myElement);
|
||||
qualifierClass = JavaResolveUtil.getContextClass(myElement);
|
||||
} else {
|
||||
final PsiElement target = qSuper.resolve();
|
||||
myQualifierClass = target instanceof PsiClass ? (PsiClass)target : null;
|
||||
qualifierClass = target instanceof PsiClass ? (PsiClass)target : null;
|
||||
}
|
||||
}
|
||||
else if (qualifier != null) {
|
||||
myQualified = true;
|
||||
setQualifierType(qualifier.getType());
|
||||
myQualifierType = qualifier.getType();
|
||||
if (myQualifierType == null && qualifier instanceof PsiJavaCodeReferenceElement) {
|
||||
final PsiElement target = ((PsiJavaCodeReferenceElement)qualifier).resolve();
|
||||
if (target instanceof PsiClass) {
|
||||
myQualifierClass = (PsiClass)target;
|
||||
qualifierClass = (PsiClass)target;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
myQualifierClass = JavaResolveUtil.getContextClass(myElement);
|
||||
qualifierClass = JavaResolveUtil.getContextClass(myElement);
|
||||
}
|
||||
}
|
||||
if (myQualifierClass != null && myQualifierType == null) {
|
||||
myQualifierType = JavaPsiFacade.getElementFactory(element.getProject()).createType(myQualifierClass);
|
||||
if (qualifierClass != null) {
|
||||
myQualifierType = JavaPsiFacade.getElementFactory(element.getProject()).createType(qualifierClass);
|
||||
}
|
||||
|
||||
myAllowStaticWithInstanceQualifier = !options.filterStaticAfterInstance ||
|
||||
@@ -220,9 +221,6 @@ public class JavaCompletionProcessor implements PsiScopeProcessor, ElementClassH
|
||||
|
||||
public void setQualifierType(@Nullable PsiType qualifierType) {
|
||||
myQualifierType = qualifierType;
|
||||
myQualifierClass = PsiUtil.resolveClassInClassTypeOnly(qualifierType instanceof PsiIntersectionType
|
||||
? ((PsiIntersectionType)qualifierType).getRepresentative()
|
||||
: qualifierType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -243,9 +241,16 @@ public class JavaCompletionProcessor implements PsiScopeProcessor, ElementClassH
|
||||
|
||||
private boolean isAccessibleForResolve(@Nullable PsiElement element) {
|
||||
if (element instanceof PsiMember) {
|
||||
PsiClass accessObjectClass = myQualified ? myQualifierClass : null;
|
||||
Set<PsiClass> accessObjectClasses =
|
||||
!myQualified ? Collections.singleton(null) :
|
||||
myQualifierType instanceof PsiIntersectionType ? ContainerUtil.map2Set(((PsiIntersectionType)myQualifierType).getConjuncts(),
|
||||
PsiUtil::resolveClassInClassTypeOnly) :
|
||||
Collections.singleton(PsiUtil.resolveClassInClassTypeOnly(myQualifierType));
|
||||
PsiMember member = (PsiMember)element;
|
||||
return getResolveHelper().isAccessible(member, member.getModifierList(), myElement, accessObjectClass, myDeclarationHolder);
|
||||
PsiResolveHelper helper = getResolveHelper();
|
||||
PsiModifierList modifierList = member.getModifierList();
|
||||
return ContainerUtil.exists(accessObjectClasses, aoc ->
|
||||
helper.isAccessible(member, modifierList, myElement, aoc, myDeclarationHolder));
|
||||
}
|
||||
if (element instanceof PsiPackage) {
|
||||
return getResolveHelper().isAccessible((PsiPackage)element, myElement);
|
||||
|
||||
@@ -42,7 +42,13 @@ import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
|
||||
public class JavaLineMarkerProvider extends LineMarkerProviderDescriptor {
|
||||
private final Option myLambdaOption = new Option("java.lambda", "Lambda", AllIcons.Gutter.ImplementingFunctionalInterface);
|
||||
public static final Option LAMBDA_OPTION = new Option("java.lambda", "Lambda", AllIcons.Gutter.ImplementingFunctionalInterface) {
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private final Option myOverriddenOption = new Option("java.overridden", "Overridden method", AllIcons.Gutter.OverridenMethod);
|
||||
private final Option myImplementedOption = new Option("java.implemented", "Implemented method", AllIcons.Gutter.ImplementedMethod);
|
||||
private final Option myOverridingOption = new Option("java.overriding", "Overriding method", AllIcons.Gutter.OverridingMethod);
|
||||
@@ -87,7 +93,7 @@ public class JavaLineMarkerProvider extends LineMarkerProviderDescriptor {
|
||||
// in case of ()->{}, anchor to "->"
|
||||
// in case of (xxx)->{}, anchor to "->"
|
||||
// in case of Type::method, anchor to "method"
|
||||
if (myLambdaOption.isEnabled() &&
|
||||
if (LAMBDA_OPTION.isEnabled() &&
|
||||
parent instanceof PsiFunctionalExpression &&
|
||||
(element instanceof PsiJavaToken && ((PsiJavaToken)element).getTokenType() == JavaTokenType.ARROW && parent instanceof PsiLambdaExpression ||
|
||||
element instanceof PsiIdentifier && parent instanceof PsiMethodReferenceExpression && ((PsiMethodReferenceExpression)parent).getReferenceNameElement() == element)
|
||||
@@ -330,7 +336,7 @@ public class JavaLineMarkerProvider extends LineMarkerProviderDescriptor {
|
||||
@NotNull
|
||||
@Override
|
||||
public Option[] getOptions() {
|
||||
return new Option[]{myLambdaOption, myOverriddenOption, myImplementedOption, myOverridingOption, myImplementingOption, mySiblingsOption, myServiceOption};
|
||||
return new Option[]{LAMBDA_OPTION, myOverriddenOption, myImplementedOption, myOverridingOption, myImplementingOption, mySiblingsOption, myServiceOption};
|
||||
}
|
||||
|
||||
private static boolean isServiceProviderMethod(@NotNull PsiMethod method) {
|
||||
|
||||
+4
-4
@@ -167,9 +167,10 @@ public class ConvertSwitchToIfIntention implements IntentionAction {
|
||||
parent = (PsiCodeBlock)(switchStatement.getParent());
|
||||
}
|
||||
}
|
||||
JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project);
|
||||
if (hadSideEffects) {
|
||||
final PsiStatement declarationStatement = factory.createStatementFromText(declarationString, switchStatement);
|
||||
parent.addBefore(declarationStatement, switchStatement);
|
||||
javaCodeStyleManager.shortenClassReferences(parent.addBefore(declarationStatement, switchStatement));
|
||||
}
|
||||
final PsiStatement ifStatement = factory.createStatementFromText(ifStatementText, switchStatement);
|
||||
if (unwrapDefault) {
|
||||
@@ -189,12 +190,11 @@ public class ConvertSwitchToIfIntention implements IntentionAction {
|
||||
addedIf.delete();
|
||||
}
|
||||
else {
|
||||
JavaCodeStyleManager.getInstance(project).shortenClassReferences(addedIf);
|
||||
javaCodeStyleManager.shortenClassReferences(addedIf);
|
||||
}
|
||||
}
|
||||
else {
|
||||
JavaCodeStyleManager.getInstance(project)
|
||||
.shortenClassReferences(commentTracker.replaceAndRestoreComments(switchStatement, ifStatement));
|
||||
javaCodeStyleManager.shortenClassReferences(commentTracker.replaceAndRestoreComments(switchStatement, ifStatement));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -476,6 +476,11 @@ public class CreateLocalVarFromInstanceofAction extends BaseIntentionAction {
|
||||
public Result calculateQuickResult(ExpressionContext context) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommittedPSI() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
template.addVariable("", expr, expr, true);
|
||||
|
||||
|
||||
+31
-18
@@ -54,7 +54,13 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
myReturnTypePointer = SmartTypePointerManager.getInstance(method.getProject()).createSmartTypePointer(returnType);
|
||||
myFixWholeHierarchy = fixWholeHierarchy;
|
||||
myName = method.getName();
|
||||
myCanonicalText = returnType.getCanonicalText();
|
||||
if (fixWholeHierarchy) {
|
||||
PsiType type = getHierarchyAdjustedReturnType(method, returnType);
|
||||
myCanonicalText = (type != null ? type : returnType).getCanonicalText();
|
||||
}
|
||||
else {
|
||||
myCanonicalText = returnType.getCanonicalText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -192,27 +198,34 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
return editor;
|
||||
}
|
||||
|
||||
private static PsiType getHierarchyAdjustedReturnType(final PsiMethod method, @NotNull PsiType returnType) {
|
||||
for (PsiMethod superMethod : method.findDeepestSuperMethods()) {
|
||||
PsiType superMethodReturnType = superMethod.getReturnType();
|
||||
if (superMethodReturnType != null && superMethodReturnType.isAssignableFrom(returnType)) {
|
||||
if (superMethodReturnType instanceof PsiClassType && returnType instanceof PsiPrimitiveType) {
|
||||
return ((PsiPrimitiveType)returnType).getBoxedType(method);
|
||||
}
|
||||
return returnType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PsiMethod[] getChangeRoots(final PsiMethod method, @NotNull PsiType returnType) {
|
||||
if (!myFixWholeHierarchy) return new PsiMethod[]{method};
|
||||
|
||||
final PsiMethod[] methods = method.findDeepestSuperMethods();
|
||||
|
||||
if (methods.length > 0) {
|
||||
for (PsiMethod psiMethod : methods) {
|
||||
if (returnType.equals(psiMethod.getReturnType())) {
|
||||
return new PsiMethod[] {method};
|
||||
private List<PsiMethod> changeReturnType(final PsiMethod method, @NotNull PsiType returnType) {
|
||||
PsiMethod[] methods = new PsiMethod[] {method};
|
||||
if (myFixWholeHierarchy) {
|
||||
PsiType type = getHierarchyAdjustedReturnType(method, returnType);
|
||||
if (type != null) {
|
||||
returnType = type;
|
||||
}
|
||||
else {
|
||||
final PsiMethod[] superMethods = method.findDeepestSuperMethods();
|
||||
if (superMethods.length > 0) {
|
||||
methods = superMethods;
|
||||
}
|
||||
}
|
||||
return methods;
|
||||
}
|
||||
// no - only base
|
||||
return new PsiMethod[] {method};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<PsiMethod> changeReturnType(final PsiMethod method, @NotNull final PsiType returnType) {
|
||||
final PsiMethod[] methods = getChangeRoots(method, returnType);
|
||||
|
||||
final MethodSignatureChangeVisitor methodSignatureChangeVisitor = new MethodSignatureChangeVisitor();
|
||||
for (PsiMethod targetMethod : methods) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user