mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
CPP-16098 - Lags during inplace rename typing
- changed behaviour in safe way by introducing new method to check that particular expression does not depend on committed PSI GitOrigin-RevId: f5ec732613cdafdcef8a1d48eb8d04135c634047
This commit is contained in:
committed by
intellij-monorepo-bot
parent
338ad6db56
commit
2d9369d983
6
.idea/libraries/completion_ranking_java.xml
generated
6
.idea/libraries/completion_ranking_java.xml
generated
@@ -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
.idea/libraries/completion_ranking_python.xml
generated
Normal file
12
.idea/libraries/completion_ranking_python.xml
generated
Normal file
@@ -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>
|
||||
6
.idea/libraries/jediterm_pty.xml
generated
6
.idea/libraries/jediterm_pty.xml
generated
@@ -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>
|
||||
10
.idea/libraries/jna.xml
generated
10
.idea/libraries/jna.xml
generated
@@ -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.0" />
|
||||
<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.0/jna-platform-5.3.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna/5.3.0/jna-5.3.0.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.0/jna-platform-5.3.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/java/dev/jna/jna/5.3.0/jna-5.3.0-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);
|
||||
|
||||
@@ -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.
@@ -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...");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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())) {
|
||||
|
||||
@@ -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,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -682,14 +682,15 @@ 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()));
|
||||
reporter.registerProblem(castType, InspectionsBundle.message("dataflow.message.cce", operand.getText()),
|
||||
createExplainFix(typeCast, new TrackingRunner.CastDfaProblemType()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,14 +76,17 @@ 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 {
|
||||
@@ -128,20 +131,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 +156,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 +173,90 @@ 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 {
|
||||
public String toString() {
|
||||
return "cast may fail";
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -194,7 +267,7 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Value is always " + myValue;
|
||||
return "value is always " + myValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,13 +289,14 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
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
|
||||
TODO: 3. Check how it works with
|
||||
Inliners (notably: Stream API)
|
||||
Ternary operators
|
||||
@@ -238,15 +312,23 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
CauseItem[] causes = findConstantValueCause(expression, history, expectedValue);
|
||||
root.addChildren(causes);
|
||||
}
|
||||
if (type instanceof CastDfaProblemType && expression instanceof PsiTypeCastExpression) {
|
||||
PsiType expressionType = expression.getType();
|
||||
MemoryStateChange operandPush = history.findExpressionPush(((PsiTypeCastExpression)expression).getOperand());
|
||||
if (operandPush != null) {
|
||||
root.addChildren(findTypeCause(operandPush, expressionType, false));
|
||||
}
|
||||
}
|
||||
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 +339,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 +352,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 +368,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 +403,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 +527,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 +548,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 +578,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;
|
||||
}
|
||||
@@ -437,26 +592,30 @@ public class TrackingRunner extends StandardDataFlowRunner {
|
||||
if (factDef != null && expression != null) {
|
||||
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,7 +636,26 @@ 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() + "'";
|
||||
@@ -501,11 +679,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 +699,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 +708,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 +726,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 +744,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 +796,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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -767,8 +768,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>
|
||||
@@ -308,6 +304,7 @@
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<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 +420,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"/>
|
||||
|
||||
|
||||
@@ -835,7 +835,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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -93,6 +93,11 @@ public class JavaWithCastSurrounder extends JavaExpressionSurrounder {
|
||||
public Result calculateQuickResult(ExpressionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommittedPSI() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
template.addTextSegment("((");
|
||||
template.addVariable(TYPE_TEMPLATE_VARIABLE, expr, expr, true);
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
@@ -27,7 +13,6 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.xml.XmlEntityDecl;
|
||||
@@ -45,18 +30,10 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.intellij.openapi.util.Pair.pair;
|
||||
|
||||
public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.ConvertToBasicLatinAction");
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) {
|
||||
if (!element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) return false;
|
||||
final Pair<PsiElement, Handler> pair = findHandler(element);
|
||||
if (pair == null) return false;
|
||||
|
||||
String text = pair.first.getText();
|
||||
return !IOUtil.isAscii(text);
|
||||
}
|
||||
private static final Logger LOG = Logger.getInstance(ConvertToBasicLatinAction.class);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -71,99 +48,108 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
|
||||
final Pair<PsiElement, Handler> pair = findHandler(element);
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
|
||||
if (element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
|
||||
Pair<PsiElement, Handler> pair = findHandler(element);
|
||||
if (pair != null) {
|
||||
return !IOUtil.isAscii(pair.first.getText());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
Pair<PsiElement, Handler> pair = findHandler(element);
|
||||
if (pair == null) return;
|
||||
final PsiElement workElement = pair.first;
|
||||
final Handler handler = pair.second;
|
||||
final String newText = handler.processText(workElement);
|
||||
final PsiElement newElement = handler.createReplacement(workElement, newText);
|
||||
workElement.replace(newElement);
|
||||
PsiElement toReplace = pair.first;
|
||||
PsiElement newElement = pair.second.getSubstitution(toReplace);
|
||||
toReplace.replace(newElement);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Pair<PsiElement, Handler> findHandler(final PsiElement element) {
|
||||
for (final Handler handler : ourHandlers) {
|
||||
final PsiElement applicable = handler.findApplicable(element);
|
||||
private static Pair<PsiElement, Handler> findHandler(PsiElement element) {
|
||||
for (Handler handler : ourHandlers) {
|
||||
PsiElement applicable = handler.findApplicable(element);
|
||||
if (applicable != null) {
|
||||
return Pair.create(applicable, handler);
|
||||
return pair(applicable, handler);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean shouldConvert(final char ch) {
|
||||
return Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.BASIC_LATIN;
|
||||
}
|
||||
|
||||
private abstract static class Handler {
|
||||
@Nullable
|
||||
public abstract PsiElement findApplicable(final PsiElement element);
|
||||
abstract @Nullable PsiElement findApplicable(PsiElement element);
|
||||
|
||||
public String processText(final PsiElement element) {
|
||||
final String text = element.getText();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
PsiElement getSubstitution(PsiElement element) {
|
||||
String text = element.getText();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
final char ch = text.charAt(i);
|
||||
if (!shouldConvert(ch)) {
|
||||
char ch = text.charAt(i);
|
||||
if (isBasicLatin(ch)) {
|
||||
sb.append(ch);
|
||||
}
|
||||
else {
|
||||
convert(sb, ch);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(element.getProject());
|
||||
return getSubstitution(factory, element, sb.toString());
|
||||
}
|
||||
|
||||
protected static boolean isBasicLatin(char ch) {
|
||||
return Character.UnicodeBlock.of(ch) == Character.UnicodeBlock.BASIC_LATIN;
|
||||
}
|
||||
|
||||
protected abstract void convert(StringBuilder sb, char ch);
|
||||
|
||||
public abstract PsiElement createReplacement(final PsiElement element, final String newText);
|
||||
protected abstract PsiElement getSubstitution(PsiElementFactory factory, PsiElement element, String newText);
|
||||
}
|
||||
|
||||
private static final Handler[] ourHandlers = { new MyLiteralHandler(), new MyDocCommentHandler(), new MyCommentHandler() };
|
||||
private static final Handler[] ourHandlers = {new LiteralHandler(), new DocCommentHandler(), new CommentHandler()};
|
||||
|
||||
private static class MyLiteralHandler extends Handler {
|
||||
private static class LiteralHandler extends Handler {
|
||||
private static final TokenSet LITERALS = TokenSet.create(JavaTokenType.CHARACTER_LITERAL, JavaTokenType.STRING_LITERAL);
|
||||
|
||||
@Override
|
||||
public PsiElement findApplicable(final PsiElement element) {
|
||||
final PsiElement parent = element.getParent();
|
||||
return element instanceof PsiJavaToken &&
|
||||
LITERALS.contains(((PsiJavaToken)element).getTokenType()) &&
|
||||
parent instanceof PsiLiteralExpression
|
||||
? parent : null;
|
||||
PsiElement findApplicable(PsiElement element) {
|
||||
if (element instanceof PsiJavaToken && LITERALS.contains(((PsiJavaToken)element).getTokenType())) {
|
||||
PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiLiteralExpression) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement createReplacement(final PsiElement element, final String newText) {
|
||||
return JavaPsiFacade.getElementFactory(element.getProject()).createExpressionFromText(newText, element.getParent());
|
||||
protected PsiElement getSubstitution(PsiElementFactory factory, PsiElement element, String newText) {
|
||||
return factory.createExpressionFromText(newText, element.getParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(final StringBuilder sb, final char ch) {
|
||||
protected void convert(StringBuilder sb, char ch) {
|
||||
sb.append(String.format("\\u%04x", (int)ch));
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyDocCommentHandler extends Handler {
|
||||
private static class DocCommentHandler extends Handler {
|
||||
private static Map<Character, String> ourEntities;
|
||||
|
||||
@Override
|
||||
public PsiElement findApplicable(final PsiElement element) {
|
||||
PsiElement findApplicable(PsiElement element) {
|
||||
return PsiTreeUtil.getParentOfType(element, PsiDocComment.class, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String processText(final PsiElement element) {
|
||||
PsiElement getSubstitution(PsiElement element) {
|
||||
loadEntities(element.getProject());
|
||||
return super.processText(element);
|
||||
return ourEntities != null ? super.getSubstitution(element) : element;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(final StringBuilder sb, final char ch) {
|
||||
assert ourEntities != null;
|
||||
final String entity = ourEntities.get(ch);
|
||||
protected void convert(StringBuilder sb, char ch) {
|
||||
String entity = ourEntities.get(ch);
|
||||
if (entity != null) {
|
||||
sb.append('&').append(entity).append(';');
|
||||
}
|
||||
@@ -173,20 +159,20 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement createReplacement(final PsiElement element, final String newText) {
|
||||
return JavaPsiFacade.getElementFactory(element.getProject()).createDocCommentFromText(newText);
|
||||
protected PsiElement getSubstitution(PsiElementFactory factory, PsiElement element, String newText) {
|
||||
return factory.createCommentFromText(newText, element.getParent());
|
||||
}
|
||||
|
||||
private static void loadEntities(final Project project) {
|
||||
private static void loadEntities(Project project) {
|
||||
if (ourEntities != null) return;
|
||||
|
||||
final XmlFile file;
|
||||
XmlFile file;
|
||||
try {
|
||||
final String url = ExternalResourceManager.getInstance().getResourceLocation(XmlUtil.HTML4_LOOSE_URI, project);
|
||||
String url = ExternalResourceManager.getInstance().getResourceLocation(XmlUtil.HTML4_LOOSE_URI, project);
|
||||
if (url == null) { LOG.error("Namespace not found: " + XmlUtil.HTML4_LOOSE_URI); return; }
|
||||
final VirtualFile vFile = VfsUtil.findFileByURL(new URL(url));
|
||||
VirtualFile vFile = VfsUtil.findFileByURL(new URL(url));
|
||||
if (vFile == null) { LOG.error("Resource not found: " + url); return; }
|
||||
final PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
|
||||
if (!(psiFile instanceof XmlFile)) { LOG.error("Unexpected resource: " + psiFile); return; }
|
||||
file = (XmlFile)psiFile;
|
||||
}
|
||||
@@ -194,36 +180,30 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
LOG.error(e); return;
|
||||
}
|
||||
|
||||
ourEntities = new HashMap<>();
|
||||
final Pattern pattern = Pattern.compile("&#(\\d+);");
|
||||
XmlUtil.processXmlElements(file, new PsiElementProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element) {
|
||||
if (element instanceof XmlEntityDecl) {
|
||||
final XmlEntityDecl entity = (XmlEntityDecl)element;
|
||||
final Matcher m = pattern.matcher(entity.getValueElement().getValue());
|
||||
if (m.matches()) {
|
||||
final char i = (char)Integer.parseInt(m.group(1));
|
||||
if (shouldConvert(i)) {
|
||||
ourEntities.put(i, entity.getName());
|
||||
}
|
||||
Map<Character, String> entities = new HashMap<>();
|
||||
Pattern pattern = Pattern.compile("&#(\\d+);");
|
||||
XmlUtil.processXmlElements(file, element -> {
|
||||
if (element instanceof XmlEntityDecl) {
|
||||
XmlEntityDecl entity = (XmlEntityDecl)element;
|
||||
Matcher m = pattern.matcher(entity.getValueElement().getValue());
|
||||
if (m.matches()) {
|
||||
char i = (char)Integer.parseInt(m.group(1));
|
||||
if (!isBasicLatin(i)) {
|
||||
entities.put(i, entity.getName());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}, true);
|
||||
|
||||
ourEntities = entities;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyCommentHandler extends MyDocCommentHandler {
|
||||
private static class CommentHandler extends DocCommentHandler {
|
||||
@Override
|
||||
public PsiElement findApplicable(final PsiElement element) {
|
||||
PsiElement findApplicable(PsiElement element) {
|
||||
return element instanceof PsiComment ? element : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement createReplacement(final PsiElement element, final String newText) {
|
||||
return JavaPsiFacade.getElementFactory(element.getProject()).createCommentFromText(newText, element.getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,6 +278,11 @@ public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
|
||||
return new TextResult(myNames[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommittedPSI() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LookupElement[] calculateLookupItems(ExpressionContext context) {
|
||||
return Stream.of(myNames).map(LookupElementBuilder::create).toArray(LookupElement[]::new);
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.tryCast;
|
||||
|
||||
@@ -59,7 +60,12 @@ public class ConvertToSingleReturnAction extends PsiElementBaseIntentionAction {
|
||||
PsiCodeBlock copy = (PsiCodeBlock)block.copy();
|
||||
indicator.checkCanceled();
|
||||
indicator.setFraction(0.3);
|
||||
convertReturns(project, copy, returnType, marker, returns.size(), indicator);
|
||||
PsiLocalVariable variable = convertReturns(project, copy, returnType, marker, returns.size(), indicator);
|
||||
if (variable != null) {
|
||||
PsiJavaToken end = Objects.requireNonNull(copy.getRBrace());
|
||||
copy.addBefore(JavaPsiFacade.getElementFactory(project).createStatementFromText("return " + variable.getName() + ";", copy), end);
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,8 +122,6 @@ class ExitContext {
|
||||
// Keep final when possible to respect code style setting "generate local variables as 'final'"
|
||||
requireNonNull(var.getModifierList()).setModifierProperty(PsiModifier.FINAL, false);
|
||||
}
|
||||
PsiJavaToken end = requireNonNull(myBlock.getRBrace());
|
||||
myBlock.addBefore(myFactory.createStatementFromText("return " + myReturnVariable + ";", myBlock), end);
|
||||
return var;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.template.PsiElementResult;
|
||||
import com.intellij.codeInsight.template.PsiTypeResult;
|
||||
import com.intellij.codeInsight.template.Result;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.scope.util.PsiScopesUtil;
|
||||
@@ -73,7 +74,11 @@ public class MacroUtil {
|
||||
String text = result.toString();
|
||||
if (text == null) return null;
|
||||
PsiManager manager = PsiManager.getInstance(project);
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
|
||||
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
|
||||
Editor editor = context.getEditor();
|
||||
if(editor == null) return null;
|
||||
psiDocumentManager.commitDocument(editor.getDocument());
|
||||
PsiFile file = psiDocumentManager.getPsiFile(editor.getDocument());
|
||||
//-1: Hack to deal with resolve algorithm
|
||||
PsiElement place = file != null ? file.findElementAt(context.getStartOffset()) : null;
|
||||
if (place != null) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -75,11 +76,16 @@ public class SuggestVariableNameMacro extends Macro {
|
||||
private static String[] getNames (final ExpressionContext context) {
|
||||
String[] names = ExpressionUtil.getNames(context);
|
||||
if (names == null || names.length == 0) return names;
|
||||
PsiFile file = PsiDocumentManager.getInstance(context.getProject()).getPsiFile(context.getEditor().getDocument());
|
||||
PsiElement e = file.findElementAt(context.getStartOffset());
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(context.getProject());
|
||||
Editor editor = context.getEditor();
|
||||
if(editor == null) return null;
|
||||
documentManager.commitDocument(editor.getDocument());
|
||||
PsiFile file = documentManager.getPsiFile(editor.getDocument());
|
||||
PsiElement e = file != null ? file.findElementAt(context.getStartOffset()) : null;
|
||||
PsiVariable[] vars = MacroUtil.getVariablesVisibleAt(e, "");
|
||||
LinkedList<String> namesList = new LinkedList<>(Arrays.asList(names));
|
||||
for (PsiVariable var : vars) {
|
||||
//noinspection ConstantConditions
|
||||
if (e.equals(var.getNameIdentifier())) continue;
|
||||
namesList.remove(var.getName());
|
||||
}
|
||||
@@ -90,6 +96,7 @@ public class SuggestVariableNameMacro extends Macro {
|
||||
for (int j = 1; ; j++) {
|
||||
String name1 = name + j;
|
||||
for (PsiVariable var : vars) {
|
||||
//noinspection ConstantConditions
|
||||
if (name1.equals(var.getName()) && !var.getNameIdentifier().equals(e)) continue index;
|
||||
}
|
||||
return new String[]{name1};
|
||||
|
||||
@@ -76,6 +76,11 @@ public class CastVarPostfixTemplate extends StringBasedPostfixTemplate {
|
||||
public Result calculateQuickResult(ExpressionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommittedPSI() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template.addVariable(TYPE_VAR, expr, expr, true);
|
||||
|
||||
@@ -110,6 +110,11 @@ public class InstanceofExpressionPostfixTemplate extends PostfixTemplate {
|
||||
public Result calculateQuickResult(ExpressionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommittedPSI() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template.addTextSegment(exprText);
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.BlockUtils;
|
||||
import com.intellij.codeInspection.dataFlow.ContractReturnValue;
|
||||
import com.intellij.codeInspection.dataFlow.*;
|
||||
import com.intellij.codeInspection.dataFlow.ContractReturnValue.ParameterReturnValue;
|
||||
import com.intellij.codeInspection.dataFlow.ContractValue;
|
||||
import com.intellij.codeInspection.dataFlow.JavaMethodContractUtil;
|
||||
import com.intellij.codeInspection.dataFlow.MethodContract;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -34,13 +31,13 @@ public class ObviousNullCheckInspection extends AbstractBaseJavaLocalInspectionT
|
||||
PsiExpression[] args = call.getArgumentList().getExpressions();
|
||||
// Avoid method resolve if no argument is a candidate for obvious non-null warning
|
||||
// (checking this is easier than resolving and calls without arguments are excluded at all)
|
||||
if (!ContainerUtil.exists(args, arg -> getObviouslyNonNullExplanation(PsiUtil.skipParenthesizedExprDown(arg)) != null)) return;
|
||||
if (!ContainerUtil.exists(args, arg -> TrackingRunner.getObviouslyNonNullExplanation(PsiUtil.skipParenthesizedExprDown(arg)) != null)) return;
|
||||
NullCheckParameter nullCheckParameter = NullCheckParameter.fromCall(call);
|
||||
if (nullCheckParameter == null) return;
|
||||
if (!ExpressionUtils.isVoidContext(call) && !nullCheckParameter.myReturnsParameter) return;
|
||||
if (args.length <= nullCheckParameter.myIndex) return;
|
||||
PsiExpression nullArg = PsiUtil.skipParenthesizedExprDown(args[nullCheckParameter.myIndex]);
|
||||
String explanation = getObviouslyNonNullExplanation(nullArg);
|
||||
String explanation = TrackingRunner.getObviouslyNonNullExplanation(nullArg);
|
||||
if (explanation == null) return;
|
||||
if(nullCheckParameter.myNull) {
|
||||
holder.registerProblem(nullArg, InspectionsBundle.message("inspection.redundant.null.check.always.fail.message", explanation));
|
||||
@@ -53,19 +50,6 @@ public class ObviousNullCheckInspection extends AbstractBaseJavaLocalInspectionT
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private 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;
|
||||
}
|
||||
|
||||
static class NullCheckParameter {
|
||||
int myIndex;
|
||||
boolean myNull;
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.dataFlow.TrackingRunner;
|
||||
import com.intellij.ide.util.PsiNavigationSupport;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -24,13 +23,14 @@ import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Segment;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import one.util.streamex.EntryStream;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -69,22 +69,20 @@ public class FindDfaProblemCauseFix implements LocalQuickFix, LowPriorityAction
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
ProgressManager.getInstance().runProcessWithProgressSynchronously(
|
||||
() -> ReadAction.run(this::findCause), "Finding Cause", true, project);
|
||||
}
|
||||
|
||||
private void findCause() {
|
||||
PsiExpression element = myAnchor.getElement();
|
||||
if (element == null) return;
|
||||
PsiFile file = element.getContainingFile();
|
||||
List<TrackingRunner.CauseItem> items =
|
||||
TrackingRunner.findProblemCause(myUnknownMembersAsNullable, myIgnoreAssertStatements, element, myProblemType);
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(() -> ReadAction.run(() -> displayProblemCause(file, items)));
|
||||
ThrowableComputable<List<TrackingRunner.CauseItem>, RuntimeException> causeFinder = () -> {
|
||||
PsiExpression element = myAnchor.getElement();
|
||||
if (element == null) return Collections.emptyList();
|
||||
return TrackingRunner.findProblemCause(myUnknownMembersAsNullable, myIgnoreAssertStatements, element, myProblemType);
|
||||
};
|
||||
List<TrackingRunner.CauseItem> items = ProgressManager.getInstance().runProcessWithProgressSynchronously(
|
||||
() -> ReadAction.compute(causeFinder), "Finding Cause", true, project);
|
||||
PsiFile file = myAnchor.getContainingFile();
|
||||
if (!items.isEmpty() && file != null) {
|
||||
displayProblemCause(file, items);
|
||||
}
|
||||
}
|
||||
|
||||
private static void displayProblemCause(PsiFile file, List<TrackingRunner.CauseItem> items) {
|
||||
if (!file.isValid()) return;
|
||||
Project project = file.getProject();
|
||||
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
|
||||
if (editor == null) return;
|
||||
@@ -95,22 +93,25 @@ public class FindDfaProblemCauseFix implements LocalQuickFix, LowPriorityAction
|
||||
class CauseWithDepth {
|
||||
final int myDepth;
|
||||
final TrackingRunner.CauseItem myCauseItem;
|
||||
final CauseWithDepth myParent;
|
||||
|
||||
CauseWithDepth(int depth, TrackingRunner.CauseItem item) {
|
||||
myDepth = depth;
|
||||
CauseWithDepth(CauseWithDepth parent, TrackingRunner.CauseItem item) {
|
||||
myParent = parent;
|
||||
myDepth = parent == null ? 0 : parent.myDepth + 1;
|
||||
myCauseItem = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.repeat(" ", myDepth - 1) + myCauseItem.render(document);
|
||||
return StringUtil.repeat(" ", myDepth - 1) + myCauseItem.render(document, myParent == null ? null : myParent.myCauseItem);
|
||||
}
|
||||
}
|
||||
List<CauseWithDepth> causes;
|
||||
if (root == null) {
|
||||
causes = Collections.emptyList();
|
||||
} else {
|
||||
causes = EntryStream.ofTree(root, (depth, c) -> c.children()).skip(1).mapKeyValue((d, i) -> new CauseWithDepth(d, i)).toList();
|
||||
causes = StreamEx.ofTree(new CauseWithDepth(null, root), cwd -> cwd.myCauseItem.children()
|
||||
.map(child -> new CauseWithDepth(cwd, child))).skip(1).toList();
|
||||
}
|
||||
if (causes.isEmpty()) {
|
||||
HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance();
|
||||
@@ -146,7 +147,7 @@ public class FindDfaProblemCauseFix implements LocalQuickFix, LowPriorityAction
|
||||
highlighter.getAndSet(null).dropHighlight();
|
||||
}
|
||||
})
|
||||
.setItemChosenCallback(cause -> navigate(editor, file, cause.myCauseItem))
|
||||
.setItemChosenCallback(cause -> ReadAction.run(() -> navigate(editor, file, cause.myCauseItem)))
|
||||
.createPopup();
|
||||
popup.showInBestPositionFor(editor);
|
||||
}
|
||||
@@ -159,6 +160,6 @@ public class FindDfaProblemCauseFix implements LocalQuickFix, LowPriorityAction
|
||||
PsiNavigationSupport.getInstance().createNavigatable(file.getProject(), targetFile.getVirtualFile(), range.getStartOffset())
|
||||
.navigate(true);
|
||||
HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance();
|
||||
hintManager.showInformationHint(editor, StringUtil.escapeXmlEntities(item.toString()));
|
||||
hintManager.showInformationHint(editor, StringUtil.escapeXmlEntities(StringUtil.capitalize(item.toString())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,11 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// 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.codeInspection.deadCode;
|
||||
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.reference.RefElement;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.configurationStore.XmlSerializer;
|
||||
import com.intellij.psi.PsiDocCommentOwner;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -30,13 +13,13 @@ public class DeprecatedEntryPoint extends EntryPoint {
|
||||
public boolean DEPRECATED_ENTRY_POINT = true;
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
XmlSerializer.deserializeInto(this, element);
|
||||
public void readExternal(Element element) {
|
||||
XmlSerializer.deserializeInto(element, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
XmlSerializer.serializeInto(this, element, new SkipDefaultValuesSerializationFilters());
|
||||
public void writeExternal(Element element) {
|
||||
XmlSerializer.serializeObjectInto(this, element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -83,9 +83,11 @@ abstract class SourceOperation extends Operation {
|
||||
return fn == null ? null : new IterateSource(args[0], fn);
|
||||
}
|
||||
if (name.equals("stream") && args.length == 0 &&
|
||||
InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_UTIL_COLLECTION) &&
|
||||
ExpressionUtils.getEffectiveQualifier(call.getMethodExpression()) != null) {
|
||||
return new ForEachSource(call.getMethodExpression().getQualifierExpression());
|
||||
InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_UTIL_COLLECTION)) {
|
||||
PsiExpression qualifier = ExpressionUtils.getEffectiveQualifier(call.getMethodExpression());
|
||||
if (qualifier != null) {
|
||||
return new ForEachSource(qualifier);
|
||||
}
|
||||
}
|
||||
if (name.equals("stream") && args.length == 1 &&
|
||||
CommonClassNames.JAVA_UTIL_ARRAYS.equals(className)) {
|
||||
@@ -110,22 +112,20 @@ abstract class SourceOperation extends Operation {
|
||||
|
||||
static class ForEachSource extends SourceOperation {
|
||||
private final boolean myEntrySet;
|
||||
private @Nullable PsiExpression myQualifier;
|
||||
private @NotNull PsiExpression myQualifier;
|
||||
|
||||
ForEachSource(@Nullable PsiExpression qualifier) {
|
||||
ForEachSource(@NotNull PsiExpression qualifier) {
|
||||
this(qualifier, false);
|
||||
}
|
||||
|
||||
ForEachSource(@Nullable PsiExpression qualifier, boolean entrySet) {
|
||||
ForEachSource(@NotNull PsiExpression qualifier, boolean entrySet) {
|
||||
myQualifier = qualifier;
|
||||
myEntrySet = entrySet;
|
||||
}
|
||||
|
||||
@Override
|
||||
void rename(String oldName, String newName, StreamToLoopReplacementContext context) {
|
||||
if(myQualifier != null) {
|
||||
myQualifier = replaceVarReference(myQualifier, oldName, newName, context);
|
||||
}
|
||||
myQualifier = replaceVarReference(myQualifier, oldName, newName, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,10 +148,7 @@ abstract class SourceOperation extends Operation {
|
||||
|
||||
@Override
|
||||
public String wrap(StreamVariable outVar, String code, StreamToLoopReplacementContext context) {
|
||||
PsiExpression iterationParameter = myQualifier == null ? ExpressionUtils
|
||||
.getEffectiveQualifier(((PsiMethodCallExpression)context.createExpression("stream()")).getMethodExpression()) : myQualifier;
|
||||
assert iterationParameter != null; // Checked at construction site that effective qualifier is available
|
||||
String iterationParameterText = iterationParameter.getText() + (myEntrySet ? ".entrySet()" : "");
|
||||
String iterationParameterText = myQualifier.getText() + (myEntrySet ? ".entrySet()" : "");
|
||||
return context.getLoopLabel() + "for(" + outVar.getDeclaration() + ": " + iterationParameterText + ") {" + code + "}\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class StreamToLoopInspection extends AbstractBaseJavaLocalInspectionTool
|
||||
@Nullable
|
||||
static List<OperationRecord> extractIterableForEach(PsiMethodCallExpression terminalCall) {
|
||||
if (!ITERABLE_FOREACH.test(terminalCall) || !ExpressionUtils.isVoidContext(terminalCall)) return null;
|
||||
PsiExpression qualifier = terminalCall.getMethodExpression().getQualifierExpression();
|
||||
PsiExpression qualifier = ExpressionUtils.getEffectiveQualifier(terminalCall.getMethodExpression());
|
||||
if (qualifier == null) return null;
|
||||
// Do not visit this path if some class implements both Iterable and Stream
|
||||
PsiType type = qualifier.getType();
|
||||
@@ -167,7 +167,7 @@ public class StreamToLoopInspection extends AbstractBaseJavaLocalInspectionTool
|
||||
@Nullable
|
||||
static List<OperationRecord> extractMapForEach(PsiMethodCallExpression terminalCall) {
|
||||
if (!MAP_FOREACH.test(terminalCall) || !ExpressionUtils.isVoidContext(terminalCall)) return null;
|
||||
PsiExpression qualifier = terminalCall.getMethodExpression().getQualifierExpression();
|
||||
PsiExpression qualifier = ExpressionUtils.getEffectiveQualifier(terminalCall.getMethodExpression());
|
||||
if (qualifier == null) return null;
|
||||
// Do not visit this path if some class implements both Map and Stream
|
||||
PsiType type = qualifier.getType();
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SuperMethodWarningUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiMethod[] getTargetMethodCandidates(@NotNull PsiMethod method, @NotNull Collection<PsiElement> ignore) {
|
||||
public static PsiMethod[] getTargetMethodCandidates(@NotNull PsiMethod method, @NotNull Collection<? extends PsiElement> ignore) {
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
if (aClass == null) return new PsiMethod[]{method};
|
||||
|
||||
@@ -68,7 +68,7 @@ public class SuperMethodWarningUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiMethod[] checkSuperMethods(@NotNull PsiMethod method, @NotNull String actionString, @NotNull Collection<PsiElement> ignore) {
|
||||
public static PsiMethod[] checkSuperMethods(@NotNull PsiMethod method, @NotNull String actionString, @NotNull Collection<? extends PsiElement> ignore) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
PsiMethod[] methodTargetCandidates = getTargetMethodCandidates(method, ignore);
|
||||
if (methodTargetCandidates.length == 1 && methodTargetCandidates[0] == method) return methodTargetCandidates;
|
||||
@@ -100,7 +100,7 @@ public class SuperMethodWarningUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static Collection<PsiMethod> getSuperMethods(@NotNull PsiMethod method, PsiClass aClass, @NotNull Collection<PsiElement> ignore) {
|
||||
static Collection<PsiMethod> getSuperMethods(@NotNull PsiMethod method, PsiClass aClass, @NotNull Collection<? extends PsiElement> ignore) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
assert !ApplicationManager.getApplication().isWriteAccessAllowed();
|
||||
final Collection<PsiMethod> superMethods = DeepestSuperMethodsSearch.search(method).findAll();
|
||||
@@ -112,11 +112,12 @@ public class SuperMethodWarningUtil {
|
||||
PsiMethod[] siblingSuperMethod = new PsiMethod[1];
|
||||
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(()->{
|
||||
siblingSuperMethod[0] = ReadAction.compute(()->FindSuperElementsHelper.getSiblingInheritedViaSubClass(method));
|
||||
}, "Searching for sub-classes", true, aClass.getProject())) {
|
||||
}, "Searching for Sub-Classes", true, aClass.getProject())) {
|
||||
throw new ProcessCanceledException();
|
||||
}
|
||||
if (siblingSuperMethod[0] != null) {
|
||||
superMethods.add(siblingSuperMethod[0]);
|
||||
superMethods.add(method); // add original method too because sometimes FindUsages can't find usages of this method by sibling super method
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +192,7 @@ public class SuperMethodWarningUtil {
|
||||
.setMovable(false)
|
||||
.setResizable(false)
|
||||
.setRequestFocus(true)
|
||||
.setItemChosenCallback((value) -> {
|
||||
.setItemChosenCallback(value -> {
|
||||
if (value.equals(renameBase)) {
|
||||
try {
|
||||
methods[0].putUserData(SIBLINGS, superMethods);
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// 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.jarRepository.services.artifactory;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -27,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -48,7 +35,7 @@ public class ArtifactoryRepositoryService extends MavenRepositoryService {
|
||||
try {
|
||||
final Gson gson = new Gson();
|
||||
final InputStreamReader stream =
|
||||
new InputStreamReader(new Endpoint.Repositories(url).getRepositoryDetailsListJson(null).getInputStream());
|
||||
new InputStreamReader(new Endpoint.Repositories(url).getRepositoryDetailsListJson(null).getInputStream(), StandardCharsets.UTF_8);
|
||||
final ArtifactoryModel.RepositoryType[] repos = gson.fromJson(stream, ArtifactoryModel.RepositoryType[].class);
|
||||
final List<RemoteRepositoryDescription> result = new ArrayList<>(repos.length);
|
||||
for (ArtifactoryModel.RepositoryType repo : repos) {
|
||||
@@ -80,7 +67,8 @@ public class ArtifactoryRepositoryService extends MavenRepositoryService {
|
||||
final String name = StringUtil.join(Arrays.asList(template.getGroupId(), template.getArtifactId(), template.getVersion()), ":");
|
||||
final InputStream stream = new Endpoint.Search.Artifact(url).getArtifactSearchResultJson(name, null).getInputStream();
|
||||
|
||||
final ArtifactoryModel.GavcResults results = stream == null? null : gson.fromJson(new InputStreamReader(stream), ArtifactoryModel.GavcResults.class);
|
||||
final ArtifactoryModel.GavcResults results = stream == null? null : gson.fromJson(new InputStreamReader(stream,
|
||||
StandardCharsets.UTF_8), ArtifactoryModel.GavcResults.class);
|
||||
if (results != null && results.results != null) {
|
||||
for (ArtifactoryModel.GavcResult result : results.results) {
|
||||
if (!result.uri.endsWith(packaging)) continue;
|
||||
@@ -93,7 +81,8 @@ public class ArtifactoryRepositoryService extends MavenRepositoryService {
|
||||
final String searchString = className.endsWith("*") || className.endsWith("?") ? className : className + ".class";
|
||||
final InputStream stream = new Endpoint.Search.Archive(url).getArchiveSearchResultJson(searchString, null).getInputStream();
|
||||
|
||||
final ArtifactoryModel.ArchiveResults results = stream == null? null : gson.fromJson(new InputStreamReader(stream), ArtifactoryModel.ArchiveResults.class);
|
||||
final ArtifactoryModel.ArchiveResults results = stream == null? null : gson.fromJson(new InputStreamReader(stream,
|
||||
StandardCharsets.UTF_8), ArtifactoryModel.ArchiveResults.class);
|
||||
if (results != null && results.results != null) {
|
||||
for (ArtifactoryModel.ArchiveResult result : results.results) {
|
||||
for (String uri : result.archiveUris) {
|
||||
|
||||
@@ -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.jarRepository.services.bintray;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -16,6 +16,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -225,7 +226,7 @@ public class BintrayEndpoint {
|
||||
private <Data> void handleRequest(HttpRequests.Request request, Class<Data> responseDataClass,
|
||||
ThrowableConsumer<Data, IOException> responseHandler) throws IOException {
|
||||
try (InputStream in = request.getInputStream();
|
||||
Reader reader = new InputStreamReader(in)) {
|
||||
Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
|
||||
Data data = gson.fromJson(reader, responseDataClass);
|
||||
responseHandler.consume(data);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ internal class FieldExpression(
|
||||
|
||||
override fun calculateQuickResult(context: ExpressionContext): Result? = calculateResult(context)
|
||||
|
||||
override fun requiresCommittedPSI(): Boolean = false
|
||||
|
||||
override fun calculateLookupItems(context: ExpressionContext): Array<LookupElement> {
|
||||
val psiClass = myClassPointer.element ?: return LookupElement.EMPTY_ARRAY
|
||||
|
||||
|
||||
@@ -29,5 +29,7 @@ internal class RangeExpression(
|
||||
|
||||
override fun calculateQuickResult(context: ExpressionContext): Result? = calculateResult(context)
|
||||
|
||||
override fun requiresCommittedPSI(): Boolean = false
|
||||
|
||||
override fun calculateLookupItems(context: ExpressionContext): Array<out LookupElement> = LookupElement.EMPTY_ARRAY
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user