diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 3b81f0900665..9ed72b4f6bdd 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -12,4 +12,7 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/jackson.xml b/.idea/libraries/jackson.xml
new file mode 100644
index 000000000000..fef6850f1700
--- /dev/null
+++ b/.idea/libraries/jackson.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/dependencies/gradle.properties b/build/dependencies/gradle.properties
index eae2587cbec6..4dc0c7cf84f1 100644
--- a/build/dependencies/gradle.properties
+++ b/build/dependencies/gradle.properties
@@ -1,5 +1,5 @@
# The file might be automatically updated. Comments and empty lines will be removed.
kotlinPluginBuild=1.2.30-eap-16-IJ2018.1-1:ideadev
jetSignBuild=42.30
-jdkBuild=u152b1136.12
+jdkBuild=u152b1153.1
gradleApiVersion=4.4
diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/CommandLineProjectTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/CommandLineProjectTest.kt
index 61704f33dca6..16990e831b41 100644
--- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/CommandLineProjectTest.kt
+++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/CommandLineProjectTest.kt
@@ -21,6 +21,7 @@ import com.intellij.openapi.ui.MultiLineLabelUI
import com.intellij.openapi.util.text.StringUtil
import com.intellij.testGuiFramework.framework.RunWithIde
import com.intellij.testGuiFramework.impl.GuiTestCase
+import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.testGuiFramework.launcher.ide.CommunityIde
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -46,6 +47,7 @@ public class Main {
actionLink("Create New Project").click()
dialog("New Project") {
jList("Java").clickItem("Java")
+ GuiTestUtilKt.waitProgressDialogUntilGone(robot(), "Loading Templates")
button("Next").click()
checkbox("Create project from template").click()
jList("Command Line App").clickItem("Command Line App")
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java
index ce10b0d03c1d..178089f3268e 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java
@@ -51,7 +51,7 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
-public class HotSwapProgressImpl extends HotSwapProgress{
+public class HotSwapProgressImpl extends HotSwapProgress {
static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup("HotSwap", ToolWindowId.DEBUG);
private final TIntObjectHashMap> myMessages = new TIntObjectHashMap<>();
@@ -59,6 +59,7 @@ public class HotSwapProgressImpl extends HotSwapProgress{
private String myTitle = DebuggerBundle.message("progress.hot.swap.title");
private final MergingUpdateQueue myUpdateQueue;
private WeakReference mySessionRef = null;
+ private List myListeners = ContainerUtil.newSmartList();
public HotSwapProgressImpl(Project project) {
super(project);
@@ -78,10 +79,22 @@ public class HotSwapProgressImpl extends HotSwapProgress{
myUpdateQueue = new MergingUpdateQueue("HotSwapProgress update queue", 100, true, null, myProgressWindow);
}
+ @Override
+ public void cancel() {
+ super.cancel();
+ for (HotSwapProgressListener listener : myListeners) {
+ listener.onCancel();
+ }
+ }
+
@Override
public void finished() {
super.finished();
+ for (HotSwapProgressListener listener : myListeners) {
+ listener.onFinish();
+ }
+
List errors = getMessages(MessageCategory.ERROR);
List warnings = getMessages(MessageCategory.WARNING);
@@ -143,7 +156,7 @@ public class HotSwapProgressImpl extends HotSwapProgress{
mySessionRef = new WeakReference<>(session.getXDebugSession());
}
- private List getMessages(int category) {
+ List getMessages(int category) {
return ContainerUtil.notNullize(myMessages.get(category));
}
@@ -215,4 +228,16 @@ public class HotSwapProgressImpl extends HotSwapProgress{
myTitle = DebuggerBundle.message("progress.hot.swap.title") + " : " + session.getSessionName();
myProgressWindow.setTitle(myTitle);
}
+
+ void addProgressListener(@NotNull HotSwapProgressListener listener) {
+ myListeners.add(listener);
+ }
+
+ interface HotSwapProgressListener {
+ default void onCancel() {
+ }
+
+ default void onFinish() {
+ }
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapStatusListener.java b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapStatusListener.java
new file mode 100644
index 000000000000..568ad11849a1
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapStatusListener.java
@@ -0,0 +1,10 @@
+// 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.
+package com.intellij.debugger.ui;
+
+import com.intellij.debugger.impl.DebuggerSession;
+
+import java.util.List;
+
+public interface HotSwapStatusListener {
+ void hotSwapFinished(boolean aborted, int errors, int warnings, List sessions);
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUI.java b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUI.java
index 5cae3a873c8c..fa6e5799da54 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUI.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUI.java
@@ -18,6 +18,8 @@ package com.intellij.debugger.ui;
import com.intellij.openapi.project.Project;
import com.intellij.debugger.impl.DebuggerSession;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @author nik
@@ -27,11 +29,12 @@ public abstract class HotSwapUI {
return project.getComponent(HotSwapUI.class);
}
- public abstract void reloadChangedClasses(DebuggerSession session, boolean compileBeforeHotswap);
+ public abstract void reloadChangedClasses(@NotNull DebuggerSession session, boolean compileBeforeHotswap);
+
+ public abstract void reloadChangedClasses(@NotNull DebuggerSession session, @Nullable HotSwapStatusListener callback);
public abstract void dontPerformHotswapAfterThisCompilation();
-
public abstract void addListener(HotSwapVetoableListener listener);
public abstract void removeListener(HotSwapVetoableListener listener);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java
index c8bd9bceec6b..752c2c77ec96 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java
@@ -35,6 +35,7 @@ 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;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -96,7 +97,8 @@ public class HotSwapUIImpl extends HotSwapUI {
return sessions.stream().anyMatch(DebuggerSession::isPaused);
}
- private void hotSwapSessions(final List sessions, @Nullable final Map> generatedPaths) {
+ private void hotSwapSessions(final List sessions, @Nullable final Map> generatedPaths,
+ @Nullable final HotSwapStatusListener callback) {
final boolean shouldAskBeforeHotswap = myAskBeforeHotswap;
myAskBeforeHotswap = true;
@@ -104,7 +106,14 @@ public class HotSwapUIImpl extends HotSwapUI {
final String runHotswap = settings.RUN_HOTSWAP_AFTER_COMPILE;
final boolean shouldDisplayHangWarning = shouldDisplayHangWarning(settings, sessions);
+ HotSwapStatusListener callbackWrapper = (aborted, errors, warnings, hotSwappedSessions) -> {
+ if (callback != null) {
+ callback.hotSwapFinished(aborted, errors, warnings, hotSwappedSessions);
+ }
+ };
+
if (shouldAskBeforeHotswap && DebuggerSettings.RUN_HOTSWAP_NEVER.equals(runHotswap)) {
+ callbackWrapper.hotSwapFinished(true, 0, 0, sessions);
return;
}
@@ -118,6 +127,14 @@ public class HotSwapUIImpl extends HotSwapUI {
boolean createProgress = sessions.stream().anyMatch(DebuggerSession::isModifiedClassesScanRequired);
findClassesProgress = createProgress ? new HotSwapProgressImpl(myProject) : null;
}
+ if (findClassesProgress != null) {
+ findClassesProgress.addProgressListener(new HotSwapProgressImpl.HotSwapProgressListener() {
+ @Override
+ public void onCancel() {
+ callbackWrapper.hotSwapFinished(true, 0, 0, sessions);
+ }
+ });
+ }
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final Map> modifiedClasses;
@@ -144,6 +161,7 @@ public class HotSwapUIImpl extends HotSwapUI {
if (modifiedClasses.isEmpty()) {
final String message = DebuggerBundle.message("status.hotswap.uptodate");
HotSwapProgressImpl.NOTIFICATION_GROUP.createNotification(message, NotificationType.INFORMATION).notify(myProject);
+ callbackWrapper.hotSwapFinished(false, 0, 0, sessions);
return;
}
@@ -154,6 +172,7 @@ public class HotSwapUIImpl extends HotSwapUI {
for (DebuggerSession session : modifiedClasses.keySet()) {
session.setModifiedClassesScanRequired(true);
}
+ callbackWrapper.hotSwapFinished(true, 0, 0, sessions);
return;
}
final Set toReload = new HashSet<>(dialog.getSessionsToReload());
@@ -181,6 +200,7 @@ public class HotSwapUIImpl extends HotSwapUI {
for (DebuggerSession session : modifiedClasses.keySet()) {
session.setModifiedClassesScanRequired(true);
}
+ callbackWrapper.hotSwapFinished(true, 0, 0, sessions);
return;
}
}
@@ -192,6 +212,17 @@ public class HotSwapUIImpl extends HotSwapUI {
//noinspection ConstantConditions
progress.setSessionForActions(ContainerUtil.getFirstItem(modifiedClasses.keySet()));
}
+ progress.addProgressListener(new HotSwapProgressImpl.HotSwapProgressListener() {
+ @Override
+ public void onCancel() {
+ notifyStatusListener(callbackWrapper, progress, sessions, true);
+ }
+
+ @Override
+ public void onFinish() {
+ notifyStatusListener(callbackWrapper, progress, sessions, false);
+ }
+ });
application.executeOnPooledThread(() -> reloadModifiedClasses(modifiedClasses, progress));
}
}, ModalityState.NON_MODAL);
@@ -212,7 +243,8 @@ public class HotSwapUIImpl extends HotSwapUI {
return result.get();
}
- private static void reloadModifiedClasses(final Map> modifiedClasses, final HotSwapProgressImpl progress) {
+ private static void reloadModifiedClasses(final Map> modifiedClasses,
+ final HotSwapProgressImpl progress) {
UsageTrigger.trigger("debugger.reload.classes");
ProgressManager.getInstance().runProcess(() -> {
HotSwapManager.reloadModifiedClasses(modifiedClasses, progress);
@@ -221,14 +253,25 @@ public class HotSwapUIImpl extends HotSwapUI {
}
@Override
- public void reloadChangedClasses(final DebuggerSession session, boolean compileBeforeHotswap) {
+ public void reloadChangedClasses(@NotNull DebuggerSession session, boolean compileBeforeHotswap) {
+ reloadChangedClasses(session, null, compileBeforeHotswap);
+ }
+
+ @Override
+ public void reloadChangedClasses(@NotNull DebuggerSession session, @Nullable HotSwapStatusListener callback) {
+ reloadChangedClasses(session, callback, false);
+ }
+
+ private void reloadChangedClasses(@NotNull DebuggerSession session,
+ @Nullable HotSwapStatusListener callback,
+ boolean compileBeforeHotswap) {
dontAskHotswapAfterThisCompilation();
if (compileBeforeHotswap) {
CompilerManager.getInstance(session.getProject()).make(null);
}
else {
if (session.isAttached()) {
- hotSwapSessions(Collections.singletonList(session), null);
+ hotSwapSessions(Collections.singletonList(session), null, callback);
}
}
}
@@ -278,7 +321,7 @@ public class HotSwapUIImpl extends HotSwapUI {
List sessions = getHotSwappableDebugSessions();
if (!sessions.isEmpty()) {
- hotSwapSessions(sessions, generated);
+ hotSwapSessions(sessions, generated, null);
}
}
myPerformHotswapAfterThisCompilation = true;
@@ -295,4 +338,14 @@ public class HotSwapUIImpl extends HotSwapUI {
.filter(HotSwapUIImpl::canHotSwap)
.collect(Collectors.toCollection(SmartList::new));
}
+
+ private static void notifyStatusListener(HotSwapStatusListener listener,
+ HotSwapProgressImpl progress,
+ List sessions,
+ boolean aborted) {
+ listener.hotSwapFinished(aborted,
+ progress.getMessages(MessageCategory.ERROR).size(),
+ progress.getMessages(MessageCategory.WARNING).size(),
+ sessions);
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/ThreadsPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/ThreadsPanel.java
index 921123727c4f..fd8a41d595e9 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/ThreadsPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/ThreadsPanel.java
@@ -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-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.
package com.intellij.debugger.ui.impl;
import com.intellij.debugger.actions.DebuggerAction;
@@ -40,6 +26,8 @@ import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
public class ThreadsPanel extends DebuggerTreePanel{
@NonNls private static final String HELP_ID = "debugging.debugThreads";
@@ -138,11 +126,15 @@ public class ThreadsPanel extends DebuggerTreePanel{
}
private static void updateNodeLabels(DebuggerTreeNodeImpl from) {
- final int childCount = from.getChildCount();
- for (int idx = 0; idx < childCount; idx++) {
- final DebuggerTreeNodeImpl child = (DebuggerTreeNodeImpl)from.getChildAt(idx);
- child.getDescriptor().updateRepresentation(null, child::labelChanged);
- updateNodeLabels(child);
+ Enumeration children = from.children();
+ try {
+ while (children.hasMoreElements()) {
+ DebuggerTreeNodeImpl child = (DebuggerTreeNodeImpl)children.nextElement();
+ child.getDescriptor().updateRepresentation(null, child::labelChanged);
+ updateNodeLabels(child);
+ }
+ }
+ catch (NoSuchElementException ignored) { // children have changed - just skip
}
}
diff --git a/java/java-analysis-impl/src/META-INF/JavaAnalysisPlugin.xml b/java/java-analysis-impl/src/META-INF/JavaAnalysisPlugin.xml
index a1c0333612a2..d8d6685b75c9 100644
--- a/java/java-analysis-impl/src/META-INF/JavaAnalysisPlugin.xml
+++ b/java/java-analysis-impl/src/META-INF/JavaAnalysisPlugin.xml
@@ -17,7 +17,6 @@
com.intellij.codeInsight.daemon.impl.JavaSoftKeywordHighlightingPassFactory
-
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java
index 675d9d994059..fd7450047d5c 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java
@@ -17,6 +17,7 @@ package com.intellij.codeInspection.miscGenerics;
import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil;
import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.openapi.util.NullableLazyValue;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
import com.intellij.psi.search.GlobalSearchScope;
@@ -167,7 +168,7 @@ public class SuspiciousMethodCallUtil {
PsiElement element = resolveResult.getElement();
if (!(element instanceof PsiMethod)) return null;
PsiMethod calleeMethod = (PsiMethod)element;
- PsiMethod contextMethod = PsiTreeUtil.getParentOfType(methodExpression, PsiMethod.class);
+ NullableLazyValue lazyContextMethod = NullableLazyValue.createValue(() -> PsiTreeUtil.getParentOfType(methodExpression, PsiMethod.class));
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (patternMethods) {
@@ -182,6 +183,7 @@ public class SuspiciousMethodCallUtil {
int index = indices.get(i);
//we are in collections method implementation
+ PsiMethod contextMethod = lazyContextMethod.getValue();
if (contextMethod != null && isInheritorOrSelf(contextMethod, patternMethod)) return null;
final PsiClass calleeClass = calleeMethod.getContainingClass();
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallElement.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallElement.java
index 942005696a8f..5da3c84ded3e 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallElement.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallElement.java
@@ -332,6 +332,13 @@ public class JavaMethodCallElement extends LookupItem implements Type
}
}
+ public static void setCompletionModeIfNotSet(@NotNull PsiCall expression, @NotNull Disposable disposable) {
+ if (!isCompletionMode(expression)) {
+ setCompletionMode(expression, true);
+ Disposer.register(disposable, () -> setCompletionMode(expression, false));
+ }
+ }
+
public static void setCompletionMode(@NotNull PsiCall expression, boolean value) {
expression.putUserData(COMPLETION_HINTS, value ? Boolean.TRUE : null);
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaMethodOverloadSwitchHandler.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaMethodOverloadSwitchHandler.java
index 9004380c7813..94fb628dc7d8 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaMethodOverloadSwitchHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaMethodOverloadSwitchHandler.java
@@ -15,12 +15,10 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorModificationUtil;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.infos.CandidateInfo;
-import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -94,7 +92,7 @@ class JavaMethodOverloadSwitchHandler extends EditorActionHandler {
currentIndex = mySwitchUp ? objects.length : -1;
}
else {
- currentIndex = ContainerUtil.indexOf(Arrays.asList(objects), highlighted);
+ currentIndex = Arrays.asList(objects).indexOf(highlighted);
if (currentIndex < 0) return;
PsiMethod currentMethod = (PsiMethod)((CandidateInfo)objects[currentIndex]).getElement();
@@ -141,10 +139,7 @@ class JavaMethodOverloadSwitchHandler extends EditorActionHandler {
});
caret.moveToLogicalPosition(editor.offsetToLogicalPosition(targetCaretPosition.get()).leanForward(true));
PsiCall methodCall = (PsiCall)call;
- if (!JavaMethodCallElement.isCompletionMode(methodCall)) {
- JavaMethodCallElement.setCompletionMode(methodCall, true);
- Disposer.register(controller, () -> JavaMethodCallElement.setCompletionMode(methodCall, false));
- }
+ JavaMethodCallElement.setCompletionModeIfNotSet(methodCall, controller);
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
CompletionMemory.registerChosenMethod(targetMethod, methodCall);
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaVarArgNextParameterHandler.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaVarArgNextParameterHandler.java
index 6ebe6027a5db..d8d56aabed7d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaVarArgNextParameterHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaVarArgNextParameterHandler.java
@@ -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-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.
package com.intellij.codeInsight.editorActions;
import com.intellij.codeInsight.hint.ParameterInfoController;
@@ -26,7 +12,6 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.infos.CandidateInfo;
-import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -70,7 +55,7 @@ public class JavaVarArgNextParameterHandler extends EditorActionHandler {
Object[] objects = controller.getObjects();
Object highlighted = controller.getHighlighted();
if (objects != null && objects.length > 0 && (highlighted != null || objects.length == 1)) {
- int currentIndex = highlighted == null ? 0 : ContainerUtil.indexOf(Arrays.asList(objects), highlighted);
+ int currentIndex = highlighted == null ? 0 : Arrays.asList(objects).indexOf(highlighted);
if (currentIndex >= 0) {
PsiMethod currentMethod = (PsiMethod)((CandidateInfo)objects[currentIndex]).getElement();
if (currentMethod.isVarArgs()) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaVarArgPrevParameterHandler.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaVarArgPrevParameterHandler.java
index 50281fa48520..ea1924145b4f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaVarArgPrevParameterHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaVarArgPrevParameterHandler.java
@@ -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-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.
package com.intellij.codeInsight.editorActions;
import com.intellij.codeInsight.hint.ParameterInfoController;
@@ -26,7 +12,6 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.infos.CandidateInfo;
-import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -65,7 +50,7 @@ public class JavaVarArgPrevParameterHandler extends EditorActionHandler {
Object[] objects = controller.getObjects();
Object highlighted = controller.getHighlighted();
if (objects != null && objects.length > 0 && (highlighted != null || objects.length == 1)) {
- int currentIndex = highlighted == null ? 0 : ContainerUtil.indexOf(Arrays.asList(objects), highlighted);
+ int currentIndex = highlighted == null ? 0 : Arrays.asList(objects).indexOf(highlighted);
if (currentIndex >= 0) {
PsiMethod currentMethod = (PsiMethod)((CandidateInfo)objects[currentIndex]).getElement();
if (currentMethod.isVarArgs()) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java b/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java
index 6e3ac8d766bc..4b8d86404975 100644
--- a/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java
@@ -10,6 +10,7 @@ import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.codeInsight.completion.JavaMethodCallElement;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInsight.daemon.impl.ParameterHintsPresentationManager;
+import com.intellij.codeInsight.hint.ParameterInfoController;
import com.intellij.codeInsight.hints.ParameterHintsPass;
import com.intellij.codeInsight.javadoc.JavaDocInfoGenerator;
import com.intellij.codeInsight.lookup.LookupElement;
@@ -55,7 +56,7 @@ import java.util.List;
public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabActionSupport, DumbAware {
private static final Set ourArgumentListAllowedParentClassesSet = ContainerUtil.newHashSet(
PsiMethodCallExpression.class, PsiNewExpression.class, PsiAnonymousClass.class, PsiEnumConstant.class);
- private static final Set extends Class> ourStopSearch = Collections.singleton(PsiMethod.class);
+ private static final Set ourStopSearch = Collections.singleton(PsiMethod.class);
private static final String WHITESPACE = " \t";
private static final Key CURRENT_HINT = Key.create("current.hint");
private static final Key> HIGHLIGHTED_HINTS = Key.create("highlighted.hints");
@@ -110,7 +111,24 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
@Override
public void showParameterInfo(@NotNull final PsiExpressionList element, @NotNull final CreateParameterInfoContext context) {
- context.showHint(element, element.getTextRange().getStartOffset(), this);
+ int offset = element.getTextRange().getStartOffset();
+ if (CodeInsightSettings.getInstance().SHOW_PARAMETER_NAME_HINTS_ON_COMPLETION) {
+ ParameterInfoController controller = ParameterInfoController.findControllerAtOffset(context.getEditor(), offset);
+ PsiElement parent = element.getParent();
+ if (parent instanceof PsiCall && controller != null && controller.isHintShown(false)) {
+ Object highlighted = controller.getHighlighted();
+ Object[] objects = controller.getObjects();
+ if (objects != null && objects.length > 0 && (highlighted != null || objects.length == 1)) {
+ PsiCall methodCall = (PsiCall)parent;
+ JavaMethodCallElement.setCompletionModeIfNotSet(methodCall, controller);
+ PsiMethod targetMethod = (PsiMethod)((CandidateInfo)(highlighted == null ? objects[0] : highlighted)).getElement();
+ CompletionMemory.registerChosenMethod(targetMethod, methodCall);
+ controller.setPreservedOnHintHidden(true);
+ ParameterHintsPass.syncUpdate(methodCall, context.getEditor());
+ }
+ }
+ }
+ context.showHint(element, offset, this);
}
@Override
@@ -499,7 +517,7 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
@NotNull
@Override
- public Set extends Class> getArgListStopSearchClasses() {
+ public Set getArgListStopSearchClasses() {
return ourStopSearch;
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/DefaultAnnotationParamInspection.java b/java/java-impl/src/com/intellij/codeInspection/DefaultAnnotationParamInspection.java
index 14a2e5967e7f..b313fbd4d847 100644
--- a/java/java-impl/src/com/intellij/codeInspection/DefaultAnnotationParamInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/DefaultAnnotationParamInspection.java
@@ -26,22 +26,28 @@ public class DefaultAnnotationParamInspection extends AbstractBaseJavaLocalInspe
PsiAnnotationMemberValue defaultValue = ((PsiAnnotationMethod)element).getDefaultValue();
if (defaultValue == null) return;
if (AnnotationUtil.equal(value, defaultValue)) {
- holder.registerProblem(value, "Redundant default parameter value assignment", ProblemHighlightType.LIKE_UNUSED_SYMBOL, new LocalQuickFix() {
- @Nls
- @NotNull
- @Override
- public String getFamilyName() {
- return "Remove redundant parameter";
- }
-
- @Override
- public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
- PsiElement parent = descriptor.getPsiElement().getParent();
- parent.delete();
- }
- });
+ holder.registerProblem(value, "Redundant default parameter value assignment", ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+ createRemoveParameterFix());
}
}
};
}
+
+ @NotNull
+ private static LocalQuickFix createRemoveParameterFix() {
+ return new LocalQuickFix() {
+ @Nls
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return "Remove redundant parameter";
+ }
+
+ @Override
+ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+ PsiElement parent = descriptor.getPsiElement().getParent();
+ parent.delete();
+ }
+ };
+ }
}
diff --git a/java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticVariableRenamer.java b/java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticVariableRenamer.java
index c6831b089a4c..407ccfc89b9a 100644
--- a/java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticVariableRenamer.java
+++ b/java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticVariableRenamer.java
@@ -52,17 +52,17 @@ public class AutomaticVariableRenamer extends AutomaticRenamer {
if (statement != null) {
for(PsiElement declaredElement: statement.getDeclaredElements()) {
if (declaredElement instanceof PsiVariable) {
- checkRenameVariable(element, (PsiVariable) declaredElement, oldClassName);
+ checkRenameVariable(element, (PsiVariable) declaredElement, oldClassName, newClassName);
}
}
}
else {
PsiVariable variable = PsiTreeUtil.getParentOfType(element, PsiVariable.class);
if (variable != null) {
- checkRenameVariable(element, variable, oldClassName);
+ checkRenameVariable(element, variable, oldClassName, newClassName);
if (variable instanceof PsiField) {
for(PsiField field: getFieldsInSameDeclaration((PsiField) variable)) {
- checkRenameVariable(element, field, oldClassName);
+ checkRenameVariable(element, field, oldClassName, newClassName);
}
}
}
@@ -104,13 +104,18 @@ public class AutomaticVariableRenamer extends AutomaticRenamer {
return result;
}
- private void checkRenameVariable(final PsiElement element, final PsiVariable variable, final String oldClassName) {
+ private void checkRenameVariable(final PsiElement element,
+ final PsiVariable variable,
+ final String oldClassName,
+ String newClassName) {
final PsiTypeElement typeElement = variable.getTypeElement();
if (typeElement == null) return;
final PsiJavaCodeReferenceElement ref = typeElement.getInnermostComponentReferenceElement();
if (ref == null) return;
final String variableName = variable.getName();
- if (variableName != null && !StringUtil.containsIgnoreCase(variableName, oldClassName)) return;
+ if (variableName == null) return;
+ if (variableName.equalsIgnoreCase(newClassName)) return;
+ if (!StringUtil.containsIgnoreCase(variableName, oldClassName)) return;
if (ref.equals(element)) {
myElements.add(variable);
if (variable.getType() instanceof PsiArrayType) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/LambdaExpressionElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/LambdaExpressionElementType.java
index a812d92d28a7..3d21dc2c6c25 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/LambdaExpressionElementType.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/LambdaExpressionElementType.java
@@ -62,7 +62,7 @@ public class LambdaExpressionElementType extends FunctionalExpressionElementType
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
final IElementType elType = child.getElementType();
if (elType == JavaTokenType.ARROW) {
return ChildRole.ARROW;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/MethodReferenceElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/MethodReferenceElementType.java
index 0dd61074af68..37fe449a4c35 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/MethodReferenceElementType.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/MethodReferenceElementType.java
@@ -70,7 +70,7 @@ public class MethodReferenceElementType extends FunctionalExpressionElementType<
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
final IElementType elType = child.getElementType();
if (elType == JavaTokenType.DOUBLE_COLON) {
return ChildRole.DOUBLE_COLON;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java
index affc24678325..e406a386b6c2 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java
@@ -82,7 +82,7 @@ public class PsiImportStaticReferenceElementImpl extends CompositePsiElement imp
}
@Override
- public final int getChildRole(ASTNode child) {
+ public final int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaElementType.JAVA_CODE_REFERENCE) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java
index cf6965607e5d..69ac6ded8da5 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java
@@ -247,7 +247,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
}
@Override
- public final int getChildRole(final ASTNode child) {
+ public final int getChildRole(@NotNull final ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
final IElementType i = child.getElementType();
if (i == JavaElementType.REFERENCE_PARAMETER_LIST) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java
index c27861b3710c..c871de394ba2 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java
@@ -199,7 +199,7 @@ public class PsiModifierListImpl extends JavaStubPsiElement
final CompositeElement tree = (CompositeElement)getNode();
final IElementType type = NAME_TO_KEYWORD_TYPE_MAP.get(name);
- return tree.findChildByType(type) != null;
+ return type != null && tree.findChildByType(type) != null;
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java
index d79afae2c1cc..a6f2d0bce0b7 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java
@@ -44,7 +44,7 @@ public class CorePsiDocTagValueImpl extends CompositePsiElement implements PsiDo
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) {
return ChildRole.COMMA;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocCommentImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocCommentImpl.java
index 1ac3ed2734c5..8e20cb864191 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocCommentImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocCommentImpl.java
@@ -321,7 +321,7 @@ public class PsiDocCommentImpl extends LazyParseablePsiElement implements PsiDoc
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == DOC_TAG) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagImpl.java
index 22e318e29e25..5cc589a1eef8 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagImpl.java
@@ -77,7 +77,7 @@ public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Con
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
assert child.getTreeParent() == this : child.getTreeParent();
IElementType i = child.getElementType();
if (i == DOC_TAG_NAME) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiInlineDocTagImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiInlineDocTagImpl.java
index bc02ff3c5f86..2610209eed6b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiInlineDocTagImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiInlineDocTagImpl.java
@@ -83,7 +83,7 @@ public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlin
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
assert child.getTreeParent() == this : child.getTreeParent();
IElementType i = child.getElementType();
if (i == DOC_TAG_NAME) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationElement.java
index 8576334e52aa..46c86b3ebec4 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationElement.java
@@ -23,6 +23,7 @@ import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.psi.impl.source.tree.CompositeElement;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -35,7 +36,7 @@ public class AnnotationElement extends CompositeElement implements Constants {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationMethodElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationMethodElement.java
index 972b89e5068e..5c9f0bde4fb6 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationMethodElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationMethodElement.java
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.source.tree.java;
import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.lang.ASTNode;
+import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -36,7 +37,7 @@ public class AnnotationMethodElement extends MethodElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
if (ANNOTATION_MEMBER_VALUE_BIT_SET.contains(child.getElementType())) {
return ChildRole.ANNOTATION_DEFAULT_VALUE;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationParamListElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationParamListElement.java
index e1ffc8b91766..82ac368550a6 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationParamListElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnnotationParamListElement.java
@@ -38,7 +38,7 @@ public class AnnotationParamListElement extends CompositeElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
IElementType i = child.getElementType();
if (i == JavaTokenType.COMMA) {
return ChildRole.COMMA;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnonymousClassElementBase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnonymousClassElementBase.java
index ec2be5cd8071..789ad5217e8b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnonymousClassElementBase.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/AnonymousClassElementBase.java
@@ -22,6 +22,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.lang.ASTNode;
+import org.jetbrains.annotations.NotNull;
public abstract class AnonymousClassElementBase extends ClassElement {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.AnonymousClassElement");
@@ -52,7 +53,7 @@ public abstract class AnonymousClassElementBase extends ClassElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaElementType.JAVA_CODE_REFERENCE) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ClassElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ClassElement.java
index 94a1a3787aca..1a0e50fd6539 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ClassElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ClassElement.java
@@ -323,7 +323,7 @@ public class ClassElement extends CompositeElement implements Constants {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
assert child.getTreeParent() == this;
IElementType i = child.getElementType();
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ClassInitializerElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ClassInitializerElement.java
index 0026b5d3d6d3..8ab274fbbe10 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ClassInitializerElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ClassInitializerElement.java
@@ -22,6 +22,7 @@ import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.psi.impl.source.tree.CompositeElement;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
public class ClassInitializerElement extends CompositeElement implements Constants {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.ClassInitializerElement");
@@ -46,7 +47,7 @@ public class ClassInitializerElement extends CompositeElement implements Constan
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == C_STYLE_COMMENT || i == END_OF_LINE_COMMENT) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/EnumConstantElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/EnumConstantElement.java
index b18dd77d0bdf..4ff82b254e3c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/EnumConstantElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/EnumConstantElement.java
@@ -23,6 +23,7 @@ import com.intellij.psi.impl.source.Constants;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
/**
* @author dsl
@@ -63,7 +64,7 @@ public class EnumConstantElement extends CompositeElement implements Constants {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaDocElementType.DOC_COMMENT) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/FieldElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/FieldElement.java
index bba320dee8b0..dc80ccd5ca3e 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/FieldElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/FieldElement.java
@@ -20,7 +20,6 @@ import com.intellij.psi.JavaTokenType;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiField;
import com.intellij.psi.impl.PsiImplUtil;
-import com.intellij.psi.impl.source.Constants;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.tree.IElementType;
@@ -83,7 +82,7 @@ public class FieldElement extends CompositeElement{
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
assert (child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaDocElementType.DOC_COMMENT) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStatementBaseElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStatementBaseElement.java
index 853e45178ee6..0b6face169f9 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStatementBaseElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStatementBaseElement.java
@@ -24,6 +24,7 @@ import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.impl.source.tree.TreeUtil;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
/**
* @author dsl
@@ -57,7 +58,7 @@ public class ImportStatementBaseElement extends CompositeElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaTokenType.IMPORT_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStaticStatementElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStaticStatementElement.java
index 4e331956c7c9..fb20edf5c950 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStaticStatementElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStaticStatementElement.java
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTNode;
import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.tree.ChildRoleBase;
+import org.jetbrains.annotations.NotNull;
public class ImportStaticStatementElement extends ImportStatementBaseElement {
@@ -46,7 +47,7 @@ public class ImportStaticStatementElement extends ImportStatementBaseElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
final int role = super.getChildRole(child);
if (role != ChildRoleBase.NONE) return role;
if (child.getElementType() == JavaElementType.IMPORT_STATIC_REFERENCE) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/JavaFileElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/JavaFileElement.java
index 2239f0b35d39..dc2800087289 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/JavaFileElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/JavaFileElement.java
@@ -66,7 +66,7 @@ public class JavaFileElement extends FileElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaElementType.PACKAGE_STATEMENT) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodElement.java
index 5398f47a39d8..209fc869baac 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodElement.java
@@ -123,7 +123,7 @@ public class MethodElement extends CompositeElement implements Constants {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaDocElementType.DOC_COMMENT) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ModifierListElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ModifierListElement.java
index 9aa2e4ef28c3..9b9da7248f64 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ModifierListElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ModifierListElement.java
@@ -24,6 +24,8 @@ import com.intellij.psi.impl.source.SourceTreeToPsiMap;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.psi.tree.ChildRoleBase;
import java.util.HashMap;
+
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ModifierListElement extends CompositeElement {
@@ -46,7 +48,7 @@ public class ModifierListElement extends CompositeElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child.getElementType() == JavaElementType.ANNOTATION) return ChildRole.ANNOTATION;
return ChildRoleBase.NONE;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/NameValuePairElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/NameValuePairElement.java
index 3f3788f98930..721bd065463d 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/NameValuePairElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/NameValuePairElement.java
@@ -34,7 +34,7 @@ public class NameValuePairElement extends CompositeElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
if (ElementType.ANNOTATION_MEMBER_VALUE_BIT_SET.contains(child.getElementType())) {
return ChildRole.ANNOTATION_VALUE;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterElement.java
index ae2b5b16df7a..0ceefe4f5d9c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterElement.java
@@ -57,7 +57,7 @@ public class ParameterElement extends CompositeElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterListElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterListElement.java
index 359ef51e804e..f948d7fb4f64 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterListElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterListElement.java
@@ -127,7 +127,7 @@ public class ParameterListElement extends CompositeElement implements Constants
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (PARAMETER_SET.contains((i))) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayAccessExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayAccessExpressionImpl.java
index c2162f8c0485..1b985af082f4 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayAccessExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayAccessExpressionImpl.java
@@ -83,7 +83,7 @@ public class PsiArrayAccessExpressionImpl extends ExpressionPsiElement implement
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == LBRACKET) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayInitializerExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayInitializerExpressionImpl.java
index 80b7e94f972b..d947111430e1 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayInitializerExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayInitializerExpressionImpl.java
@@ -76,7 +76,7 @@ public class PsiArrayInitializerExpressionImpl extends ExpressionPsiElement impl
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaTokenType.COMMA) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayInitializerMemberValueImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayInitializerMemberValueImpl.java
index b03766f54d55..f3d00d211881 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayInitializerMemberValueImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiArrayInitializerMemberValueImpl.java
@@ -58,7 +58,7 @@ public class PsiArrayInitializerMemberValueImpl extends CompositePsiElement impl
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAssertStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAssertStatementImpl.java
index 90c7d301a335..a9367c7fc2bf 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAssertStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAssertStatementImpl.java
@@ -78,7 +78,7 @@ public class PsiAssertStatementImpl extends CompositePsiElement implements PsiAs
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == ASSERT_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAssignmentExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAssignmentExpressionImpl.java
index a450c8a8ac42..fe24df32eab2 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAssignmentExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiAssignmentExpressionImpl.java
@@ -80,7 +80,7 @@ public class PsiAssignmentExpressionImpl extends ExpressionPsiElement implements
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) {
if (child == getFirstChildNode()) return ChildRole.LOPERAND;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBinaryExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBinaryExpressionImpl.java
index 74eefc7a5f4c..860a5e689fb1 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBinaryExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBinaryExpressionImpl.java
@@ -109,7 +109,7 @@ public class PsiBinaryExpressionImpl extends ExpressionPsiElement implements Psi
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) {
if (child == getFirstChildNode()) return ChildRole.LOPERAND;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBlockStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBlockStatementImpl.java
index dbea6fd60fd8..0b74f963fd96 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBlockStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBlockStatementImpl.java
@@ -54,7 +54,7 @@ public class PsiBlockStatementImpl extends CompositePsiElement implements PsiBlo
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child.getElementType() == JavaElementType.CODE_BLOCK) {
return ChildRole.BLOCK;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBreakStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBreakStatementImpl.java
index 9697349b76b5..9532544e805b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBreakStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBreakStatementImpl.java
@@ -90,7 +90,7 @@ public class PsiBreakStatementImpl extends CompositePsiElement implements PsiBre
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == BREAK_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCatchSectionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCatchSectionImpl.java
index dfe8ae9dbd25..21a3e3c30b83 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCatchSectionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCatchSectionImpl.java
@@ -232,7 +232,7 @@ public class PsiCatchSectionImpl extends CompositePsiElement implements PsiCatch
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == PARAMETER) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiClassObjectAccessExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiClassObjectAccessExpressionImpl.java
index 6e81bfcb114a..202bc1c97c42 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiClassObjectAccessExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiClassObjectAccessExpressionImpl.java
@@ -68,7 +68,7 @@ public class PsiClassObjectAccessExpressionImpl extends ExpressionPsiElement imp
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == TYPE) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCodeBlockImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCodeBlockImpl.java
index db477db1a9b8..9ba504085ab8 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCodeBlockImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCodeBlockImpl.java
@@ -194,7 +194,7 @@ public class PsiCodeBlockImpl extends LazyParseablePsiElement implements PsiCode
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaTokenType.LBRACE) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java
index 21ba57d2d703..41949ef222ee 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiConditionalExpressionImpl.java
@@ -156,7 +156,7 @@ public class PsiConditionalExpressionImpl extends ExpressionPsiElement implement
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())){
int role = getChildRole(child, ChildRole.CONDITION);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiContinueStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiContinueStatementImpl.java
index 8460fa1ed4cf..8d35fdce5c42 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiContinueStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiContinueStatementImpl.java
@@ -86,7 +86,7 @@ public class PsiContinueStatementImpl extends CompositePsiElement implements Psi
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == CONTINUE_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiDeclarationStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiDeclarationStatementImpl.java
index a36ef9193fe1..9d207cf74fe5 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiDeclarationStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiDeclarationStatementImpl.java
@@ -39,7 +39,7 @@ public class PsiDeclarationStatementImpl extends CompositePsiElement implements
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
if (child.getElementType() == JavaTokenType.COMMA) return ChildRole.COMMA;
return super.getChildRole(child);
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiDoWhileStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiDoWhileStatementImpl.java
index c2f1d0ba4de7..2b8c49c4467f 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiDoWhileStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiDoWhileStatementImpl.java
@@ -90,7 +90,7 @@ public class PsiDoWhileStatementImpl extends CompositePsiElement implements PsiD
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == DO_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionListImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionListImpl.java
index 4e6871ef896c..eb4c0bf4db66 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionListImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionListImpl.java
@@ -81,7 +81,7 @@ public class PsiExpressionListImpl extends CompositePsiElement implements PsiExp
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaTokenType.COMMA) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionListStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionListStatementImpl.java
index 5670d47ec30d..56b7cbf57be7 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionListStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionListStatementImpl.java
@@ -57,7 +57,7 @@ public class PsiExpressionListStatementImpl extends CompositePsiElement implemen
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == EXPRESSION_LIST) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionStatementImpl.java
index 585813333d1c..9befa25de382 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiExpressionStatementImpl.java
@@ -57,7 +57,7 @@ public class PsiExpressionStatementImpl extends CompositePsiElement implements P
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaTokenType.SEMICOLON) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiForStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiForStatementImpl.java
index a83605b3814b..3845f9919a10 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiForStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiForStatementImpl.java
@@ -126,7 +126,7 @@ public class PsiForStatementImpl extends CompositePsiElement implements PsiForSt
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == FOR_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiForeachStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiForeachStatementImpl.java
index 26f3545e22fa..cddbc4e3413e 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiForeachStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiForeachStatementImpl.java
@@ -95,7 +95,7 @@ public class PsiForeachStatementImpl extends CompositePsiElement implements PsiF
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiIfStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiIfStatementImpl.java
index fe2b2bb95b44..07d090f255a7 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiIfStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiIfStatementImpl.java
@@ -149,7 +149,7 @@ public class PsiIfStatementImpl extends CompositePsiElement implements PsiIfStat
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == IF_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiInstanceOfExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiInstanceOfExpressionImpl.java
index 4275acfd05ff..e129f03888ba 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiInstanceOfExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiInstanceOfExpressionImpl.java
@@ -66,7 +66,7 @@ public class PsiInstanceOfExpressionImpl extends ExpressionPsiElement implements
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == TYPE) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLabeledStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLabeledStatementImpl.java
index b7c69c63db34..0f14a82e4518 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLabeledStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLabeledStatementImpl.java
@@ -68,7 +68,7 @@ public class PsiLabeledStatementImpl extends CompositePsiElement implements PsiL
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == IDENTIFIER) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLocalVariableImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLocalVariableImpl.java
index 37fc475c05be..47044c9504d2 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLocalVariableImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLocalVariableImpl.java
@@ -262,7 +262,7 @@ public class PsiLocalVariableImpl extends CompositePsiElement implements PsiLoca
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == MODIFIER_LIST) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java
index f92a6715d72c..bff7fc1212b2 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java
@@ -107,7 +107,7 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaElementType.EXPRESSION_LIST) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java
index cf3763be03a1..46a0f01a9564 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java
@@ -327,7 +327,7 @@ public class PsiNewExpressionImpl extends ExpressionPsiElement implements PsiNew
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaElementType.REFERENCE_PARAMETER_LIST) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPackageStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPackageStatementImpl.java
index 29d072970560..8f6d1b213cd7 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPackageStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPackageStatementImpl.java
@@ -68,7 +68,7 @@ public class PsiPackageStatementImpl extends CompositePsiElement implements PsiP
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaTokenType.PACKAGE_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiParenthesizedExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiParenthesizedExpressionImpl.java
index cce0eea32bac..20ca855f67ed 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiParenthesizedExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiParenthesizedExpressionImpl.java
@@ -65,7 +65,7 @@ public class PsiParenthesizedExpressionImpl extends ExpressionPsiElement impleme
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == LPARENTH) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java
index d0ea45221443..c50b1de7324b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java
@@ -92,7 +92,7 @@ public class PsiPolyadicExpressionImpl extends ExpressionPsiElement implements P
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (OUR_OPERATIONS_BIT_SET.contains(child.getElementType())) {
return ChildRole.OPERATION_SIGN;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPostfixExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPostfixExpressionImpl.java
index 059d8bc57acd..92722f438537 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPostfixExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPostfixExpressionImpl.java
@@ -71,7 +71,7 @@ public class PsiPostfixExpressionImpl extends ExpressionPsiElement implements Ps
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child == getFirstChildNode()) return ChildRole.OPERAND;
if (child == getLastChildNode()) return ChildRole.OPERATION_SIGN;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPrefixExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPrefixExpressionImpl.java
index 2590a75a9167..585e1e04762c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPrefixExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPrefixExpressionImpl.java
@@ -88,7 +88,7 @@ public class PsiPrefixExpressionImpl extends ExpressionPsiElement implements Psi
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child == getFirstChildNode()) return ChildRole.OPERATION_SIGN;
if (child == getLastChildNode() && ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) return ChildRole.OPERAND;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
index 5a61c70a1203..3e2e27434711 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
@@ -774,7 +774,7 @@ public class PsiReferenceExpressionImpl extends ExpressionPsiElement implements
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JavaTokenType.DOT) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceParameterListImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceParameterListImpl.java
index 743bd36abf5f..e679cf8d0d8a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceParameterListImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceParameterListImpl.java
@@ -50,7 +50,7 @@ public class PsiReferenceParameterListImpl extends CompositePsiElement implement
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
IElementType i = child.getElementType();
if (i == JavaElementType.TYPE) {
return ChildRole.TYPE_IN_REFERENCE_PARAMETER_LIST;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReturnStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReturnStatementImpl.java
index 166bea5f67ec..b3cddc5492e4 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReturnStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReturnStatementImpl.java
@@ -60,7 +60,7 @@ public class PsiReturnStatementImpl extends CompositePsiElement implements PsiRe
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == RETURN_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSuperExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSuperExpressionImpl.java
index d50bfcb1a21d..b438f4a2e8f7 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSuperExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSuperExpressionImpl.java
@@ -122,7 +122,7 @@ public class PsiSuperExpressionImpl extends ExpressionPsiElement implements PsiS
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JAVA_CODE_REFERENCE) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSwitchLabelStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSwitchLabelStatementImpl.java
index 18ac9584010a..25d3ea03923b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSwitchLabelStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSwitchLabelStatementImpl.java
@@ -77,7 +77,7 @@ public class PsiSwitchLabelStatementImpl extends CompositePsiElement implements
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == CASE_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSwitchStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSwitchStatementImpl.java
index aac24948dbf5..390f03504366 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSwitchStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSwitchStatementImpl.java
@@ -77,7 +77,7 @@ public class PsiSwitchStatementImpl extends CompositePsiElement implements PsiSw
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == SWITCH_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSynchronizedStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSynchronizedStatementImpl.java
index 104178a381d3..820d6ee66504 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSynchronizedStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiSynchronizedStatementImpl.java
@@ -67,7 +67,7 @@ public class PsiSynchronizedStatementImpl extends CompositePsiElement implements
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == SYNCHRONIZED_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiThisExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiThisExpressionImpl.java
index 2a8a62027cc1..f5e76277591c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiThisExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiThisExpressionImpl.java
@@ -86,7 +86,7 @@ public class PsiThisExpressionImpl extends ExpressionPsiElement implements PsiTh
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == JAVA_CODE_REFERENCE) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiThrowStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiThrowStatementImpl.java
index 75c2b4602eff..e8298304f873 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiThrowStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiThrowStatementImpl.java
@@ -60,7 +60,7 @@ public class PsiThrowStatementImpl extends CompositePsiElement implements PsiThr
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == THROW_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTryStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTryStatementImpl.java
index d44ed54665d4..a7a8282cc062 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTryStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTryStatementImpl.java
@@ -135,7 +135,7 @@ public class PsiTryStatementImpl extends CompositePsiElement implements PsiTrySt
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == TRY_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTypeCastExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTypeCastExpressionImpl.java
index a7bc5cb8f276..4dd6ec80965b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTypeCastExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTypeCastExpressionImpl.java
@@ -72,7 +72,7 @@ public class PsiTypeCastExpressionImpl extends ExpressionPsiElement implements P
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
assert child.getTreeParent() == this: "child:"+child+"; child.getTreeParent():"+child.getTreeParent();
IElementType i = child.getElementType();
if (i == LPARENTH) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiWhileStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiWhileStatementImpl.java
index 0afe99f77b1a..ab6b054ec433 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiWhileStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiWhileStatementImpl.java
@@ -78,7 +78,7 @@ public class PsiWhileStatementImpl extends CompositePsiElement implements PsiWhi
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == WHILE_KEYWORD) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ReferenceListElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ReferenceListElement.java
index 98e3f5caa1de..8cfc6dedd86c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ReferenceListElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ReferenceListElement.java
@@ -101,7 +101,7 @@ public class ReferenceListElement extends CompositeElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
assert child.getTreeParent() == this : child;
IElementType childType = child.getElementType();
if (childType == JavaTokenType.COMMA) return ChildRole.COMMA;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterElement.java
index 4eb53de83de6..b1b2fbc75f18 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterElement.java
@@ -21,6 +21,7 @@ import com.intellij.psi.JavaTokenType;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
/**
* @author max
@@ -33,7 +34,7 @@ public class TypeParameterElement extends CompositeElement {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
final IElementType i = child.getElementType();
if (i == JavaTokenType.IDENTIFIER) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterExtendsBoundsListElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterExtendsBoundsListElement.java
index db7c05569b78..dd1d135c9e97 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterExtendsBoundsListElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterExtendsBoundsListElement.java
@@ -22,6 +22,7 @@ import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
public class TypeParameterExtendsBoundsListElement extends ReferenceListElement {
public TypeParameterExtendsBoundsListElement() {
@@ -29,7 +30,7 @@ public class TypeParameterExtendsBoundsListElement extends ReferenceListElement
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
assert child.getTreeParent() == this : child;
IElementType childType = child.getElementType();
if (childType == JavaTokenType.AND) return ChildRole.AMPERSAND_IN_BOUNDS_LIST;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterListElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterListElement.java
index 2a3bdbaa2f4e..17561d582fe0 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterListElement.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/TypeParameterListElement.java
@@ -38,7 +38,7 @@ public class TypeParameterListElement extends CompositeElement {
}
@Override
- public int getChildRole(final ASTNode child) {
+ public int getChildRole(@NotNull final ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
final IElementType elType = child.getElementType();
if (elType == JavaElementType.TYPE_PARAMETER) {
diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/CompletionHintsTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/CompletionHintsTest.java
index 30ea8ea2af0b..c29f73cc12c1 100644
--- a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/CompletionHintsTest.java
+++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/CompletionHintsTest.java
@@ -901,6 +901,13 @@ public class CompletionHintsTest extends AbstractParameterInfoTestCase {
checkHintContents("long a The long to be printed. ");
}
+ public void testSecondCtrlPShowsHints() {
+ configureJava("class C { void m() { System.setProperty(\"a\", \"b\"); } }");
+ showParameterInfo();
+ showParameterInfo();
+ checkResultWithInlays("class C { void m() { System.setProperty(\"a\", \"b\"); } }");
+ }
+
private void checkResultWithInlays(String text) {
myFixture.checkResultWithInlays(text);
}
diff --git a/java/java-tests/testSrc/com/intellij/java/execution/ConfigurationsTest.java b/java/java-tests/testSrc/com/intellij/java/execution/ConfigurationsTest.java
index 09a95dcb0c35..7ee1a6581b86 100644
--- a/java/java-tests/testSrc/com/intellij/java/execution/ConfigurationsTest.java
+++ b/java/java-tests/testSrc/com/intellij/java/execution/ConfigurationsTest.java
@@ -193,7 +193,7 @@ public class ConfigurationsTest extends BaseConfigurationTestCase {
JUnitConfiguration configuration =
new JUnitConfiguration("", myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
configuration.getPersistentData().TEST_OBJECT = JUnitConfiguration.TEST_DIRECTORY;
- configuration.getPersistentData().setDirName(psiClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath());
+ configuration.getPersistentData().setDirName(psiClass.getContainingFile().getContainingDirectory().getVirtualFile().getParent().getPath());
configuration.setModule(module1);
JavaParameters parameters = checkCanRun(configuration);
String filePath = ContainerUtil.find(parameters.getProgramParametersList().getArray(),
@@ -206,7 +206,8 @@ public class ConfigurationsTest extends BaseConfigurationTestCase {
"test1.DerivedTest", RT_INNER_TEST_NAME,
"test1.nested.TestA",
"test1.nested.TestWithJunit4",
- "test1.ThirdPartyTest"},
+ "test1.ThirdPartyTest",
+ "TestA"},
lines);
}
diff --git a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java
index 12a39f8841bf..5db6d74c96b9 100644
--- a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java
+++ b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java
@@ -245,34 +245,34 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
if (context == PatternTreeContext.Block) {
final PsiCodeBlock codeBlock = elementFactory.createCodeBlockFromText("{\n" + text + "\n}", null);
- final PsiElement[] children = codeBlock.getChildren();
- final int extraChildCount = 4;
+ PsiElement element = codeBlock.getFirstBodyElement();
+ if (element == null) return PsiElement.EMPTY_ARRAY;
+ final List result = new SmartList<>();
+ final PsiElement lastBodyElement = codeBlock.getLastBodyElement();
+ while (element != null) {
+ if (!(element instanceof PsiWhiteSpace)) result.add(element);
+ if (element == lastBodyElement) break;
+ element = element.getNextSibling();
+ }
+ if (result.isEmpty()) return PsiElement.EMPTY_ARRAY;
- if (children.length > extraChildCount) {
- PsiElement[] result = new PsiElement[children.length - extraChildCount];
- System.arraycopy(children, 2, result, 0, children.length - extraChildCount);
-
- if (shouldTryExpressionPattern(result)) {
- try {
- final PsiElement[] expressionPattern =
- createPatternTree(text, PatternTreeContext.Expression, fileType, language, contextName, extension, project, false);
- if (expressionPattern.length == 1) {
- result = expressionPattern;
- }
- } catch (IncorrectOperationException ignore) {}
- }
- else if (shouldTryClassPattern(result)) {
- final PsiElement[] classPattern =
- createPatternTree(text, PatternTreeContext.Class, fileType, language, contextName, extension, project, false);
- if (classPattern.length == 1) {
- result = classPattern;
+ if (shouldTryExpressionPattern(result)) {
+ try {
+ final PsiElement[] expressionPattern =
+ createPatternTree(text, PatternTreeContext.Expression, fileType, language, contextName, extension, project, false);
+ if (expressionPattern.length == 1) {
+ return expressionPattern;
}
+ } catch (IncorrectOperationException ignore) {}
+ }
+ else if (shouldTryClassPattern(result)) {
+ final PsiElement[] classPattern =
+ createPatternTree(text, PatternTreeContext.Class, fileType, language, contextName, extension, project, false);
+ if (classPattern.length == 1) {
+ return classPattern;
}
- return result;
- }
- else {
- return PsiElement.EMPTY_ARRAY;
}
+ return result.toArray(PsiElement.EMPTY_ARRAY);
}
else if (context == PatternTreeContext.Class) {
final PsiClass clazz = elementFactory.createClassFromText(text, null);
@@ -300,9 +300,9 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
}
}
- private static boolean shouldTryExpressionPattern(PsiElement[] elements) {
- if (elements.length >= 1 && elements.length <= 3) {
- final PsiElement firstElement = elements[0];
+ private static boolean shouldTryExpressionPattern(List elements) {
+ if (elements.size() >= 1 && elements.size() <= 3) {
+ final PsiElement firstElement = elements.get(0);
if (firstElement instanceof PsiDeclarationStatement) {
final PsiElement lastChild = firstElement.getLastChild();
if (lastChild instanceof PsiErrorElement && PsiTreeUtil.prevLeaf(lastChild) instanceof PsiErrorElement) {
@@ -316,13 +316,13 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
return false;
}
- private static boolean shouldTryClassPattern(PsiElement[] elements) {
- if (elements.length < 2) {
+ private static boolean shouldTryClassPattern(List elements) {
+ if (elements.size() < 2) {
return false;
}
- final PsiElement firstElement = elements[0];
- final PsiElement secondElement = elements[1];
- final PsiElement lastElement = elements[elements.length - 1];
+ final PsiElement firstElement = elements.get(0);
+ final PsiElement secondElement = elements.get(1);
+ final PsiElement lastElement = elements.get(elements.size() - 1);
if (firstElement instanceof PsiDocComment) {
// might be method with javadoc
@@ -437,7 +437,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
boolean targetFound = false;
for (final String name : matchOptions.getVariableConstraintNames()) {
final MatchVariableConstraint constraint = matchOptions.getVariableConstraint(name);
- if (constraint.isPartOfSearchResults()) {
+ if (constraint.isPartOfSearchResults() && !Configuration.CONTEXT_VAR_NAME.equals(constraint.getName())) {
targetFound = true;
break;
}
diff --git a/jetCheck/src/org/jetbrains/jetCheck/Generator.java b/jetCheck/src/org/jetbrains/jetCheck/Generator.java
index e76579cd327c..6d6e1eefd6c9 100644
--- a/jetCheck/src/org/jetbrains/jetCheck/Generator.java
+++ b/jetCheck/src/org/jetbrains/jetCheck/Generator.java
@@ -73,7 +73,9 @@ public class Generator {
/**
* Turns off automatic minimization for the data produced by this generator (and its components, if any).
- * This can be useful to speed up minimization by not wasting time on shrinking objects where it makes no sense.
+ * This can be useful to speed up minimization by not wasting time on shrinking objects where it makes no sense.
+ * It's especially useful when using stateful generators (e.g. {@link ImperativeCommand}), because
+ * shrinkable values there can lead to doubling of the shrinking time.
*/
public Generator noShrink() {
return from(data -> data.generateNonShrinkable(this));
@@ -176,7 +178,7 @@ public class Generator {
/** Generates characters in the given range (both ends inclusive) */
public static Generator charsInRange(char min, char max) {
- return integers(min, max).map(i -> (char)i.intValue()).noShrink();
+ return integers(min, max).map(i -> (char)i.intValue());
}
/** Generates ASCII characters excluding the system ones (lower than 32) */
diff --git a/jetCheck/src/org/jetbrains/jetCheck/ImperativeCommand.java b/jetCheck/src/org/jetbrains/jetCheck/ImperativeCommand.java
index 07a7472a0c86..25073df67947 100644
--- a/jetCheck/src/org/jetbrains/jetCheck/ImperativeCommand.java
+++ b/jetCheck/src/org/jetbrains/jetCheck/ImperativeCommand.java
@@ -82,7 +82,10 @@ public interface ImperativeCommand {
* The message is a Java format string, so you can use it to include the generated value, e.g.
* {@code String s = generateValue(stringsOf(asciiLetters(), "Generated %s")}.
* If you don't want to generate message, or would like to show the generated value in a custom way, pass {@code null}.
- * You can use {@link #logMessage} later to still leave a trace of this value generation in the log.
+ * You can use {@link #logMessage} later to still leave a trace of this value generation in the log.
+ *
+ * Consider making generators non-shrinkable (by invoking {@link Generator#noShrink()}) where possible
+ * because it can speed up overall failing scenario minimization significantly.
*/
T generateValue(@NotNull Generator generator, @Nullable String logMessage);
diff --git a/jetCheck/src/org/jetbrains/jetCheck/Iteration.java b/jetCheck/src/org/jetbrains/jetCheck/Iteration.java
index 5f025524abfe..fb03491b1d13 100644
--- a/jetCheck/src/org/jetbrains/jetCheck/Iteration.java
+++ b/jetCheck/src/org/jetbrains/jetCheck/Iteration.java
@@ -71,7 +71,9 @@ class Iteration {
String rechecking = failureReason != null && StatusNotifier.printStackTrace(failureReason).contains("ImperativeCommand.checkScenario") ?
"ImperativeCommand.checkScenario(" + iterationSeed + "L, " + sizeHint + ", ...))\n" :
"PropertyChecker.forAll(...).rechecking(" + iterationSeed + "L, " + sizeHint + ").shouldHold(...)\n";
- return "To reproduce the last iteration, run " + rechecking + "Global seed: " + session.globalSeed + "L";
+ return "To reproduce the last iteration, run " + rechecking +
+ "To debug the minimal failing example, catch this exception and invoke 'replayMinimalExample' on it.\n" +
+ "Global seed: " + session.globalSeed + "L";
}
String printSeeds() {
diff --git a/jetCheck/src/org/jetbrains/jetCheck/PropertyFalsified.java b/jetCheck/src/org/jetbrains/jetCheck/PropertyFalsified.java
index b76fa019050c..a1789a4ebfda 100644
--- a/jetCheck/src/org/jetbrains/jetCheck/PropertyFalsified.java
+++ b/jetCheck/src/org/jetbrains/jetCheck/PropertyFalsified.java
@@ -125,4 +125,13 @@ public class PropertyFalsified extends RuntimeException {
public DataStructure getData() {
return failure.getMinimalCounterexample().createReplayData();
}
+
+ /**
+ * Re-invoke the generator and the property check on the minimal counter-example found after testing and shrinking. Useful for debugging.
+ *
+ * The same as {@code getFailure().getMinimalCounterexample().replay()}.
+ */
+ public PropertyFailure.CounterExample> replayMinimalExample() {
+ return failure.getMinimalCounterexample().replay();
+ }
}
diff --git a/jetCheck/src/org/jetbrains/jetCheck/RemoveListRange.java b/jetCheck/src/org/jetbrains/jetCheck/RemoveListRange.java
index 6af694f74546..662a82a63b92 100644
--- a/jetCheck/src/org/jetbrains/jetCheck/RemoveListRange.java
+++ b/jetCheck/src/org/jetbrains/jetCheck/RemoveListRange.java
@@ -56,7 +56,7 @@ class RemoveListRange extends ShrinkStep {
}
int newEnd = start == 1 ? node.children.size() : start;
- if (newEnd == lastSuccessfulRemove) return node.shrinkChild(1);
+ if (newEnd == lastSuccessfulRemove) return node.shrinkChild(node.children.size() - 1);
return new RemoveListRange(node, lastSuccessfulRemove, newEnd - 1, 1);
}
diff --git a/jetCheck/src/org/jetbrains/jetCheck/StructureNode.java b/jetCheck/src/org/jetbrains/jetCheck/StructureNode.java
index 0bac624a566a..3bd6f26e2101 100644
--- a/jetCheck/src/org/jetbrains/jetCheck/StructureNode.java
+++ b/jetCheck/src/org/jetbrains/jetCheck/StructureNode.java
@@ -69,12 +69,13 @@ class StructureNode extends StructureElement {
ShrinkStep shrink() {
if (shrinkProhibited) return null;
- return isList() ? new RemoveListRange(this) : shrinkChild(0);
+ return isList() ? new RemoveListRange(this) : shrinkChild(children.size() - 1);
}
@Nullable
ShrinkStep shrinkChild(int index) {
- for (; index < children.size(); index++) {
+ int minIndex = isList() ? 1 : 0;
+ for (; index >= minIndex; index--) {
ShrinkStep childShrink = children.get(index).shrink();
if (childShrink != null) return wrapChildShrink(index, childShrink);
}
@@ -84,7 +85,7 @@ class StructureNode extends StructureElement {
@Nullable
private ShrinkStep wrapChildShrink(int index, @Nullable ShrinkStep step) {
- if (step == null) return shrinkChild(index + 1);
+ if (step == null) return shrinkChild(index - 1);
NodeId oldChild = children.get(index).id;
@@ -229,7 +230,13 @@ class IntData extends StructureElement {
@Nullable
@Override
ShrinkStep shrink() {
- return value == 0 ? null : tryInt(0, () -> null, this::tryNegation);
+ if (value == 0) return null;
+
+ int minValue = 0;
+ if (distribution instanceof BoundedIntDistribution) {
+ minValue = Math.max(minValue, ((BoundedIntDistribution)distribution).getMin());
+ }
+ return tryInt(minValue, () -> null, this::tryNegation);
}
private ShrinkStep tryNegation() {
@@ -242,7 +249,7 @@ class IntData extends StructureElement {
private ShrinkStep divisionLoop(int value) {
if (value == 0) return null;
int divided = value / 2;
- return tryInt(divided, () -> divisionLoop(divided / 2), null);
+ return tryInt(divided, () -> divisionLoop(divided), null);
}
private ShrinkStep tryInt(int value, @NotNull Supplier success, @Nullable Supplier fail) {
diff --git a/jetCheck/test/org/jetbrains/jetCheck/ExceptionTest.java b/jetCheck/test/org/jetbrains/jetCheck/ExceptionTest.java
index c4e53bada88e..fdbb4f90279f 100644
--- a/jetCheck/test/org/jetbrains/jetCheck/ExceptionTest.java
+++ b/jetCheck/test/org/jetbrains/jetCheck/ExceptionTest.java
@@ -68,4 +68,13 @@ public class ExceptionTest extends PropertyCheckerTestCase {
}
}
+ public void testRecommendReplay() {
+ PropertyFalsified e = checkFails(forAllStable(integers()), i -> {
+ throw new AssertionError("fail");
+ });
+
+ assertTrue(e.getMessage().contains("replayMinimalExample"));
+ assertNotNull(e.replayMinimalExample());
+ }
+
}
diff --git a/jetCheck/test/org/jetbrains/jetCheck/GeneratorTest.java b/jetCheck/test/org/jetbrains/jetCheck/GeneratorTest.java
index 4ee859583a8f..00b8469a7469 100644
--- a/jetCheck/test/org/jetbrains/jetCheck/GeneratorTest.java
+++ b/jetCheck/test/org/jetbrains/jetCheck/GeneratorTest.java
@@ -23,7 +23,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
public void testListSumMod() {
checkFalsified(nonEmptyLists(integers()),
l -> l.stream().mapToInt(Integer::intValue).sum() % 10 != 0,
- 390);
+ 223);
}
public void testListContainsDivisible() {
@@ -35,7 +35,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
public void testStringContains() {
assertEquals("a", checkGeneratesExample(stringsOf(asciiPrintableChars()),
s -> s.contains("a"),
- 8));
+ 10));
}
public void testLetterStringContains() {
@@ -47,7 +47,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
public void testIsSorted() {
PropertyFailure> failure = checkFalsified(nonEmptyLists(integers()),
l -> l.stream().sorted().collect(Collectors.toList()).equals(l),
- 22);
+ 36);
List value = failure.getMinimalCounterexample().getExampleValue();
assertEquals(2, value.size());
assertTrue(value.toString(), value.stream().allMatch(i -> Math.abs(i) < 2));
@@ -60,7 +60,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
public void testSortedDoublesNonDescending() {
PropertyFailure> failure = checkFalsified(listsOf(doubles()),
l -> isSorted(l.stream().sorted().collect(Collectors.toList())),
- 23);
+ 21);
assertEquals(2, failure.getMinimalCounterexample().getExampleValue().size());
}
@@ -173,4 +173,9 @@ public class GeneratorTest extends PropertyCheckerTestCase {
assertEquals(log, Collections.singletonList(goldMin));
}
+ public void testShrinkToRangeStart() {
+ PropertyFailure failure = checkFalsified(stringsOf(asciiUppercaseChars()), s -> s.length() < 5, 11);
+ assertEquals("AAAAA", failure.getMinimalCounterexample().getExampleValue());
+ }
+
}
diff --git a/jetCheck/test/org/jetbrains/jetCheck/ShrinkTest.java b/jetCheck/test/org/jetbrains/jetCheck/ShrinkTest.java
index 7153086b1d84..445036d8b971 100644
--- a/jetCheck/test/org/jetbrains/jetCheck/ShrinkTest.java
+++ b/jetCheck/test/org/jetbrains/jetCheck/ShrinkTest.java
@@ -21,7 +21,7 @@ public class ShrinkTest extends PropertyCheckerTestCase {
String s = l.toString();
return !"abcdefghijklmnopqrstuvwxyz()[]#!".chars().allMatch(c -> s.indexOf((char)c) >= 0);
},
- 254);
+ 298);
}
public void testShrinkingNonEmptyList() {
diff --git a/jetCheck/test/org/jetbrains/jetCheck/StatefulGeneratorTest.java b/jetCheck/test/org/jetbrains/jetCheck/StatefulGeneratorTest.java
index c43dbfcf0f83..49909f326709 100644
--- a/jetCheck/test/org/jetbrains/jetCheck/StatefulGeneratorTest.java
+++ b/jetCheck/test/org/jetbrains/jetCheck/StatefulGeneratorTest.java
@@ -56,7 +56,7 @@ public class StatefulGeneratorTest extends PropertyCheckerTestCase {
};
env.executeCommands(withRecursion(insertStringCmd(sb), replace, deleteStringCmd(sb), checkDoesNotContain(sb, "A")));
- }), Scenario::ensureSuccessful, 56).getMinimalCounterexample().getExampleValue();
+ }), Scenario::ensureSuccessful, 55).getMinimalCounterexample().getExampleValue();
assertEquals("commands:\n" +
" insert A at 0\n" +
diff --git a/plugins/settings-repository/lib/com/fasterxml/jackson/core/util/annotations.xml b/lib/annotations/jackson/com/fasterxml/jackson/core/util/annotations.xml
similarity index 100%
rename from plugins/settings-repository/lib/com/fasterxml/jackson/core/util/annotations.xml
rename to lib/annotations/jackson/com/fasterxml/jackson/core/util/annotations.xml
diff --git a/plugins/settings-repository/lib/com/fasterxml/jackson/databind/annotations.xml b/lib/annotations/jackson/com/fasterxml/jackson/databind/annotations.xml
similarity index 100%
rename from plugins/settings-repository/lib/com/fasterxml/jackson/databind/annotations.xml
rename to lib/annotations/jackson/com/fasterxml/jackson/databind/annotations.xml
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
index 728f73ce9ebd..cec588bfdf55 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
@@ -85,6 +85,7 @@ public class HighlightInfo implements Segment {
volatile RangeHighlighterEx highlighter;// modified in EDT only
+ @Nullable
public List> quickFixActionRanges;
public List> quickFixActionMarkers;
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightingSessionImpl.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightingSessionImpl.java
index 512ba021ba89..3f14981693c5 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightingSessionImpl.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightingSessionImpl.java
@@ -156,4 +156,8 @@ public class HighlightingSessionImpl implements HighlightingSession {
ApplicationManager.getApplication().assertIsDispatchThread();
myEDTQueue.drain();
}
+
+ static void clearProgressIndicator(@NotNull DaemonProgressIndicator indicator) {
+ indicator.putUserData(HIGHLIGHTING_SESSION, null);
+ }
}
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy
index 88426f60f0b1..5d5b6be795c2 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy
@@ -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-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.
package org.jetbrains.intellij.build
import groovy.transform.CompileStatic
@@ -179,8 +179,8 @@ class CommunityLibraryLicenses {
url: "https://github.com/JetBrains/jediterm", licenseUrl: "https://github.com/JetBrains/jediterm/blob/master/COPYING"),
new LibraryLicense(name: "JEuclid", libraryName: "jeuclid-core-3.1.9.jar", version: "3.1.9", license: "Apache 2.0",
url: "http://jeuclid.sourceforge.net", licenseUrl: "http://sourceforge.net/p/jeuclid/code/ci/default/tree/LICENSE.txt"),
- new LibraryLicense(name: "Jackson", libraryName: "jackson", version: "2.5.1", license: "Apache 2.0",
- licenseUrl: "http://www.eclipse.org/org/documents/edl-v10.php", url: "https://github.com/FasterXML/jackson"),
+ new LibraryLicense(name: "Jackson", libraryName: "jackson-databind", version: "2.9.4", license: "Apache 2.0",
+ licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0", url: "https://github.com/FasterXML/jackson"),
new LibraryLicense(name: "javax inject", libraryName: "javax.inject:javax.inject:1", version: "1", license: "Apache 2.0",
licenseUrl: "http://apache.org/licenses/LICENSE-2.0", url: "http://code.google.com/p/atinject/"),
new LibraryLicense(name: "JGit", libraryName: "jgit", version: "4.0", license: "Eclipse Distribution License 1.0",
diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerCollectionTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerCollectionTest.kt
index 3d6be5bfdc85..de0c90fc368a 100644
--- a/platform/configuration-store-impl/testSrc/xml/XmlSerializerCollectionTest.kt
+++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerCollectionTest.kt
@@ -1,3 +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.
@file:Suppress("DEPRECATION")
package com.intellij.configurationStore.xml
@@ -18,10 +19,16 @@ import com.intellij.util.xmlb.annotations.Tag
import com.intellij.util.xmlb.annotations.XCollection
import org.jdom.Element
import org.junit.Test
-import java.util.*
+@Suppress("PropertyName")
internal class XmlSerializerCollectionTest {
@Test fun jdomExternalizableStringList() {
+ @Tag("b")
+ class Bean3 {
+ @Suppress("DEPRECATED_SYMBOL_WITH_MESSAGE")
+ var list = JDOMExternalizableStringList()
+ }
+
val bean = Bean3()
bean.list.add("\u0001one")
bean.list.add("two")
@@ -57,7 +64,14 @@ internal class XmlSerializerCollectionTest {
bean.list.add("one")
bean.list.add("two")
bean.list.add("three")
- testSerializer("\n" + " \n" + " \n" + " \n" + " \n" + "
\n" + " ", bean, SkipDefaultsSerializationFilter())
+ testSerializer("""
+
+
+
+
+
+
+ """, bean, SkipDefaultsSerializationFilter())
}
@Test fun collectionBeanReadJDOMExternalizableStringList() {
@@ -76,7 +90,7 @@ internal class XmlSerializerCollectionTest {
@Test fun polymorphicArray() {
@Tag("bean")
class BeanWithPolymorphicArray {
- @AbstractCollection(elementTypes = arrayOf(BeanWithPublicFields::class, BeanWithPublicFieldsDescendant::class))
+ @AbstractCollection(elementTypes = [(BeanWithPublicFields::class), (BeanWithPublicFieldsDescendant::class)])
var v = arrayOf()
}
@@ -120,7 +134,7 @@ internal class XmlSerializerCollectionTest {
@Test fun arrayAnnotationWithElementTag() {
@Tag("bean") class Bean {
- @AbstractCollection(elementTag = "vvalue", elementValueAttribute = "v")
+ @AbstractCollection(elementTag = "vValue", elementValueAttribute = "v")
var v = arrayOf("a", "b")
}
@@ -130,24 +144,32 @@ internal class XmlSerializerCollectionTest {
-
-
+
+
""", bean)
bean.v = arrayOf("1", "2", "3")
- testSerializer(
- "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " ",
- bean)
+ testSerializer("""
+
+
+
+
+
+
+
+
+ """, bean)
}
@Test fun arrayWithoutTag() {
@Tag("bean")
class Bean {
- @XCollection(elementName = "vvalue", valueAttributeName = "v")
+ @XCollection(elementName = "vValue", valueAttributeName = "v")
var v = arrayOf("a", "b")
+ @Suppress("PropertyName", "unused")
var INT_V = 1
}
@@ -157,8 +179,8 @@ internal class XmlSerializerCollectionTest {
-
-
+
+
""", bean)
@@ -168,14 +190,14 @@ internal class XmlSerializerCollectionTest {
-
-
-
+
+
+
""", bean)
}
- private data class BeanWithArray(var ARRAY_V: Array = arrayOf("a", "b"))
+ private data class BeanWithArray(@Suppress("ArrayInDataClass") var ARRAY_V: Array = arrayOf("a", "b"))
@Test fun array() {
val bean = BeanWithArray()
@@ -189,40 +211,6 @@ internal class XmlSerializerCollectionTest {
bean)
}
- private class BeanWithList {
- var VALUES: List = ArrayList(Arrays.asList("a", "b", "c"))
- }
-
- @Test fun ListSerialization() {
- val bean = BeanWithList()
-
- testSerializer(
- "\n \n \n \n \n \n
\n \n ",
- bean)
-
- bean.VALUES = ArrayList(Arrays.asList("1", "2", "3"))
-
- testSerializer(
- "\n \n \n \n \n \n
\n \n ",
- bean)
- }
-
- internal class BeanWithSet {
- var VALUES: Set = LinkedHashSet(Arrays.asList("a", "b", "w"))
- }
-
- @Test fun setSerialization() {
- val bean = BeanWithSet()
- testSerializer(
- "\n \n \n \n \n \n \n \n ",
- bean)
- bean.VALUES = LinkedHashSet(Arrays.asList("1", "2", "3"))
-
- testSerializer(
- "\n \n \n \n \n \n \n \n ",
- bean)
- }
-
@Test fun testPropertyAndNoSurround() {
val bean = XmlSerializer.deserialize(loadElement("""
com.intellij.database.ide
@@ -253,8 +241,6 @@ internal class XmlSerializerCollectionTest {
-
-
@@ -267,7 +253,7 @@ internal class XmlSerializerCollectionTest {
- com.intellij.database.autoconfig.DatabaseConfigFileWatcher
+ com.intellij.database.autoConfig.DatabaseConfigFileWatcher
@@ -319,12 +305,6 @@ internal class XmlSerializerCollectionTest {
}
}
-@Tag("b")
-private class Bean3 {
- @Suppress("DEPRECATED_SYMBOL_WITH_MESSAGE")
- var list = JDOMExternalizableStringList()
-}
-
@Tag("b")
private class Bean4 {
@CollectionBean
diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerListTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerListTest.kt
new file mode 100644
index 000000000000..53be6768f43d
--- /dev/null
+++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerListTest.kt
@@ -0,0 +1,122 @@
+// 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.
+package com.intellij.configurationStore.xml
+
+import com.intellij.util.xmlb.annotations.OptionTag
+import com.intellij.util.xmlb.annotations.Tag
+import com.intellij.util.xmlb.annotations.XCollection
+import org.junit.Test
+
+class XmlSerializerListTest {
+ @Test
+ fun notFinalField() {
+ @Tag("bean")
+ class Bean {
+ @JvmField
+ var values = arrayListOf("a", "b", "w")
+ }
+
+ val bean = Bean()
+ check(bean) {
+ bean.values = it
+ }
+ }
+
+ @Test
+ fun notFinalProperty() {
+ @Tag("bean")
+ class Bean {
+ var values = arrayListOf("a", "b", "w")
+ }
+
+ val bean = Bean()
+ check(bean) {
+ bean.values = it
+ }
+ }
+
+ @Test
+ fun finalField() {
+ @Tag("bean")
+ class Bean {
+ @JvmField
+ val values = arrayListOf("a", "b", "w")
+ }
+
+ val bean = Bean()
+ check(bean) {
+ bean.values.clear()
+ bean.values.addAll(it)
+ }
+ }
+
+ @Test
+ fun finalProperty() {
+ @Tag("bean")
+ class Bean {
+ @OptionTag
+ val values = arrayListOf("a", "b", "w")
+ }
+
+ val bean = Bean()
+ check(bean) {
+ bean.values.clear()
+ bean.values.addAll(it)
+ }
+ }
+
+ @Test
+ fun finalPropertyWithoutWrapping() {
+ @Tag("bean")
+ class Bean {
+ @XCollection
+ val values = arrayListOf("a", "b", "w")
+ }
+
+ val bean = Bean()
+ testSerializer("""
+
+
+
+
+
+
+ """, bean)
+
+ bean.values.clear()
+ bean.values.addAll(arrayListOf("1", "2", "3"))
+
+ testSerializer("""
+
+
+
+
+
+
+ """, bean)
+ }
+
+ private fun check(bean: T, setter: (values: ArrayList) -> Unit) {
+ testSerializer("""
+
+
+
+
+
+
+
+
+ """, bean)
+ setter(arrayListOf("1", "2", "3"))
+
+ testSerializer("""
+
+
+
+
+
+
+
+
+ """, bean)
+ }
+}
\ No newline at end of file
diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerOldMapAnnotationTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerOldMapAnnotationTest.kt
index 2011a07daeff..35094b85a8bf 100644
--- a/platform/configuration-store-impl/testSrc/xml/XmlSerializerOldMapAnnotationTest.kt
+++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerOldMapAnnotationTest.kt
@@ -96,17 +96,17 @@ internal class XmlSerializerOldMapAnnotationTest {
@Tag("bean")
class BeanWithMapWithSetValue {
@MapAnnotation(entryTagName = "entry-tag", keyAttributeName = "key-attr", surroundWithTag = false)
- var myValues = LinkedHashMap>()
+ var values = LinkedHashMap>()
}
val bean = BeanWithMapWithSetValue()
- bean.myValues.put("a", LinkedHashSet(Arrays.asList("first1", "second1")))
- bean.myValues.put("b", LinkedHashSet(Arrays.asList("first2", "second2")))
+ bean.values.put("a", linkedSetOf("first1", "second1"))
+ bean.values.put("b", linkedSetOf("first2", "second2"))
testSerializer("""
-
+
diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerSetTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerSetTest.kt
new file mode 100644
index 000000000000..c551fecf93bb
--- /dev/null
+++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerSetTest.kt
@@ -0,0 +1,123 @@
+// 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.
+package com.intellij.configurationStore.xml
+
+import com.intellij.util.xmlb.annotations.OptionTag
+import com.intellij.util.xmlb.annotations.Tag
+import com.intellij.util.xmlb.annotations.XCollection
+import org.junit.Test
+import java.util.*
+
+class XmlSerializerSetTest {
+ @Test
+ fun notFinalField() {
+ @Tag("bean")
+ class BeanWithSet {
+ @JvmField
+ var values = linkedSetOf("a", "b", "w")
+ }
+
+ val bean = BeanWithSet()
+ assertSet(bean) {
+ bean.values = it
+ }
+ }
+
+ @Test
+ fun notFinalProperty() {
+ @Tag("bean")
+ class BeanWithSet {
+ var values = linkedSetOf("a", "b", "w")
+ }
+
+ val bean = BeanWithSet()
+ assertSet(bean) {
+ bean.values = it
+ }
+ }
+
+ @Test
+ fun finalField() {
+ @Tag("bean")
+ class BeanWithSet {
+ @JvmField
+ val values = linkedSetOf("a", "b", "w")
+ }
+
+ val bean = BeanWithSet()
+ assertSet(bean) {
+ bean.values.clear()
+ bean.values.addAll(it)
+ }
+ }
+
+ @Test
+ fun finalProperty() {
+ @Tag("bean")
+ class BeanWithSet {
+ @OptionTag
+ val values = linkedSetOf("a", "b", "w")
+ }
+
+ val bean = BeanWithSet()
+ assertSet(bean) {
+ bean.values.clear()
+ bean.values.addAll(it)
+ }
+ }
+
+ @Test
+ fun finalPropertyWithoutWrapping() {
+ @Tag("bean")
+ class Bean {
+ @XCollection
+ val values = linkedSetOf("a", "b", "w")
+ }
+
+ val bean = Bean()
+ testSerializer("""
+
+
+
+
+
+
+ """, bean)
+
+ bean.values.clear()
+ bean.values.addAll(linkedSetOf("1", "2", "3"))
+
+ testSerializer("""
+
+
+
+
+
+
+ """, bean)
+ }
+
+ private fun assertSet(bean: T, setter: (values: LinkedHashSet) -> Unit) {
+ testSerializer("""
+
+
+
+
+
+
+
+
+ """, bean)
+ setter(linkedSetOf("1", "2", "3"))
+
+ testSerializer("""
+
+
+
+
+
+
+
+
+ """, bean)
+ }
+}
\ No newline at end of file
diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt
index 0ebe35d6a800..64a9d7c6b4b5 100644
--- a/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt
+++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt
@@ -1,18 +1,6 @@
-/*
- * 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-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.
+@file:Suppress("PropertyName")
+
package com.intellij.configurationStore.xml
import com.intellij.configurationStore.StoredPropertyStateTest
@@ -40,10 +28,13 @@ import java.util.*
XmlSerializerCollectionTest::class,
StoredPropertyStateTest::class,
KotlinXmlSerializerTest::class,
- XmlSerializerConversionTest::class
+ XmlSerializerConversionTest::class,
+ XmlSerializerListTest::class,
+ XmlSerializerSetTest::class
)
class XmlSerializerTestSuite
+@Suppress("PropertyName")
internal class XmlSerializerTest {
@Test fun annotatedInternalVar() {
class Bean {
@@ -120,7 +111,7 @@ internal class XmlSerializerTest {
testSerializer("\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " ", bean)
}
- @Test fun SubBeanSerializationAndSkipDefaults() {
+ @Test fun subBeanSerializationAndSkipDefaults() {
val bean = BeanWithSubBean()
testSerializer(" ", bean, SkipDefaultsSerializationFilter())
}
@@ -131,22 +122,25 @@ internal class XmlSerializerTest {
override fun equals(other: Any?): Boolean {
// any instance of this class is equal
+ @Suppress("SuspiciousEqualsCombination")
return this === other || (other != null && javaClass == other.javaClass)
}
}
- private class BeanWithSubBeanWithEquals {
- var BEAN1: EmptyBeanWithCustomName = EmptyBeanWithCustomName()
- var BEAN2: BeanWithEquals = BeanWithEquals()
- }
-
@Test fun subBeanWithEqualsSerializationAndSkipDefaults() {
+ @Tag("bean")
+ class BeanWithSubBeanWithEquals {
+ @Suppress("unused")
+ var bean1: EmptyBeanWithCustomName = EmptyBeanWithCustomName()
+ var bean2: BeanWithEquals = BeanWithEquals()
+ }
+
val bean = BeanWithSubBeanWithEquals()
val filter = SkipDefaultsSerializationFilter()
- testSerializer(" ", bean, filter)
+ testSerializer(" ", bean, filter)
- bean.BEAN2.STRING_V = "new"
- testSerializer(" ", bean, filter)
+ bean.bean2.STRING_V = "new"
+ testSerializer(" ", bean, filter)
}
@Test fun nullFieldValue() {
@@ -247,7 +241,7 @@ internal class XmlSerializerTest {
element.removeContent(node)
element.addContent(node)
- bean = element.deserialize()
+ bean = element.deserialize()
assertThat(bean.INT_V).isEqualTo(987)
assertThat(bean.STRING_V).isEqualTo("1234")
}
@@ -259,18 +253,22 @@ internal class XmlSerializerTest {
@Test fun transient() {
class Bean {
+ @Suppress("unused")
var INT_V: Int = 1
@Transient
get
- @Transient fun getValue(): String = "foo"
+ @Suppress("unused")
+ @Transient
+ fun getValue(): String = "foo"
}
testSerializer(" ", Bean())
}
- @Test fun PropertyWithoutTagWithPrimitiveType() {
+ @Test fun propertyWithoutTagWithPrimitiveType() {
class BeanWithPropertyWithoutTagOnPrimitiveValue {
+ @Suppress("unused")
@Property(surroundWithTag = false)
var INT_V = 1
}
@@ -319,7 +317,7 @@ internal class XmlSerializerTest {
@Tag("bean")
private class BeanWithArrayWithoutAllTag {
@Property(surroundWithTag = false)
- @XCollection(elementName = "vvalue", valueAttributeName = "v")
+ @XCollection(elementName = "vValue", valueAttributeName = "v")
var v = arrayOf("a", "b")
var intV = 1
@@ -330,8 +328,8 @@ internal class XmlSerializerTest {
testSerializer("""
-
-
+
+
""", bean)
bean.intV = 2
@@ -339,9 +337,9 @@ internal class XmlSerializerTest {
testSerializer("""
-
-
-
+
+
+
""", bean)
}
@@ -349,7 +347,7 @@ internal class XmlSerializerTest {
@Tag("bean")
class BeanWithArrayWithoutAllTag2 {
@Property(surroundWithTag = false)
- @XCollection(elementName = "vvalue", valueAttributeName = "")
+ @XCollection(elementName = "vValue", valueAttributeName = "")
var v = arrayOf("a", "b")
var intV = 1
}
@@ -358,8 +356,8 @@ internal class XmlSerializerTest {
testSerializer("""
- a
- b
+ a
+ b
""", bean)
bean.intV = 2
@@ -367,14 +365,20 @@ internal class XmlSerializerTest {
testSerializer("""
- 1
- 2
- 3
+ 1
+ 2
+ 3
""", bean)
}
@Test fun deserializeFromFormattedXML() {
- val bean = loadElement("\n" + " \n" + " \n" + " \n" + " \n" + " ").deserialize()
+ val bean = loadElement("""
+
+
+
+
+
+ """).deserialize()
assertThat(bean.intV).isEqualTo(2)
assertThat("[1, 2, 3]").isEqualTo(Arrays.asList(*bean.v).toString())
}
@@ -384,11 +388,12 @@ internal class XmlSerializerTest {
var COUNT = 3
@Attribute("name")
var name = "James"
+ @Suppress("unused")
@Attribute("occupation")
var occupation: String? = null
}
- @Test fun BeanWithPrimitivePropertyBoundToAttribute() {
+ @Test fun beanWithPrimitivePropertyBoundToAttribute() {
val bean = BeanWithPropertiesBoundToAttribute()
testSerializer(" ", bean)
@@ -443,7 +448,7 @@ internal class XmlSerializerTest {
val bean = loadElement(" ").deserialize()
assertThat(bean.STRING_V).isEqualTo("bye")
- assertThat(bean.actions).isNotNull()
+ assertThat(bean.actions).isNotNull
assertThat(bean.actions!!.getChildren("action")).hasSize(2)
}
@@ -555,8 +560,10 @@ internal class XmlSerializerTest {
@Test fun defaultAttributeName() {
class BeanWithDefaultAttributeName {
+ @Suppress("unused")
@Attribute fun getFoo() = "foo"
+ @Suppress("unused")
fun setFoo(@Suppress("UNUSED_PARAMETER") value: String) {
}
}
@@ -571,6 +578,7 @@ internal class XmlSerializerTest {
@Attribute
var module: String? = null
+ @Suppress("unused")
@Attribute
var ac: String? = null
}
@@ -652,8 +660,7 @@ internal class BeanWithTextAnnotation {
this.STRING_V = STRING_V
}
- constructor() {
- }
+ constructor()
}
internal class BeanWithProperty {
diff --git a/platform/core-api/src/com/intellij/lang/ASTNode.java b/platform/core-api/src/com/intellij/lang/ASTNode.java
index 7bc14d750099..a3ffee8dbed9 100644
--- a/platform/core-api/src/com/intellij/lang/ASTNode.java
+++ b/platform/core-api/src/com/intellij/lang/ASTNode.java
@@ -188,7 +188,7 @@ public interface ASTNode extends UserDataHolder {
*
* @param anotherParent the parent node whose children are used for replacement.
*/
- void replaceAllChildrenToChildrenOf(ASTNode anotherParent);
+ void replaceAllChildrenToChildrenOf(@NotNull ASTNode anotherParent);
/**
* Adds a range of nodes belonging to the same parent to the list of children of this node,
@@ -198,7 +198,7 @@ public interface ASTNode extends UserDataHolder {
* @param firstChildToNotAdd the first child node following firstChild which will not be added to the tree.
* @param anchorBefore the node before which the child nodes are inserted.
*/
- void addChildren(ASTNode firstChild, ASTNode firstChildToNotAdd, ASTNode anchorBefore);
+ void addChildren(@NotNull ASTNode firstChild, ASTNode firstChildToNotAdd, ASTNode anchorBefore);
/**
* Creates and returns a deep copy of the AST tree part starting at this node.
@@ -230,7 +230,7 @@ public interface ASTNode extends UserDataHolder {
*
* @param key the key for accessing the user data object.
* @return the user data object, or null if no such object is found in the current node.
- * @see #putCopyableUserData(com.intellij.openapi.util.Key, Object)
+ * @see #putCopyableUserData(Key, Object)
*/
@Nullable
T getCopyableUserData(@NotNull Key key);
@@ -241,7 +241,7 @@ public interface ASTNode extends UserDataHolder {
*
* @param key the key for accessing the user data object.
* @param value the user data object to attach.
- * @see #getCopyableUserData(com.intellij.openapi.util.Key)
+ * @see #getCopyableUserData(Key)
*/
void putCopyableUserData(@NotNull Key key, T value);
@@ -252,7 +252,7 @@ public interface ASTNode extends UserDataHolder {
* @return the found node, or null if none was found.
*/
@Nullable
- ASTNode findChildByType(IElementType type);
+ ASTNode findChildByType(@NotNull IElementType type);
/**
* Returns the first child after anchor of the specified node which has the specified type.
@@ -262,7 +262,7 @@ public interface ASTNode extends UserDataHolder {
* @return the found node, or null if none was found.
*/
@Nullable
- ASTNode findChildByType(IElementType type, @Nullable ASTNode anchor);
+ ASTNode findChildByType(@NotNull IElementType type, @Nullable ASTNode anchor);
/**
* Returns the first child of the specified node which has type from specified set.
diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
index d8157ec3fa1c..7b52cfe2cb0d 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
@@ -823,6 +823,11 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
}
List files = viewProvider.getAllFiles();
+ if (files.isEmpty()) {
+ handleCommitWithoutPsi(document);
+ return;
+ }
+
boolean commitNecessary = files.stream().noneMatch(file -> PsiToDocumentSynchronizer.isInsideAtomicChange(file) || !(file instanceof PsiFileImpl));
boolean forceCommit = ApplicationManager.getApplication().hasWriteAction(ExternalChangeAction.class) &&
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java b/platform/core-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java
index ca7c9fc288ba..e111654188d3 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java
@@ -41,15 +41,15 @@ public class CodeEditUtil {
private CodeEditUtil() { }
- public static void addChild(ASTNode parent, ASTNode child, ASTNode anchorBefore) {
+ public static void addChild(@NotNull ASTNode parent, @NotNull ASTNode child, @Nullable ASTNode anchorBefore) {
addChildren(parent, child, child, anchorBefore);
}
- public static void removeChild(ASTNode parent, @NotNull ASTNode child) {
+ public static void removeChild(@NotNull ASTNode parent, @NotNull ASTNode child) {
removeChildren(parent, child, child);
}
- public static ASTNode addChildren(ASTNode parent, @NotNull ASTNode first, @NotNull ASTNode last, ASTNode anchorBefore) {
+ public static ASTNode addChildren(@NotNull ASTNode parent, @NotNull ASTNode first, @NotNull ASTNode last, @Nullable ASTNode anchorBefore) {
ASTNode lastChild = last.getTreeNext();
ASTNode current = first;
while (current != lastChild) {
@@ -85,7 +85,7 @@ public class CodeEditUtil {
return result;
}
- private static boolean isComment(IElementType type) {
+ private static boolean isComment(@NotNull IElementType type) {
final ParserDefinition def = LanguageParserDefinitions.INSTANCE.forLanguage(type.getLanguage());
return def != null && def.getCommentTokens().contains(type);
}
@@ -128,7 +128,7 @@ public class CodeEditUtil {
return stored != null ? stored : -1;
}
- public static void removeChildren(ASTNode parent, @NotNull ASTNode first, @NotNull ASTNode last) {
+ public static void removeChildren(@NotNull ASTNode parent, @NotNull ASTNode first, @NotNull ASTNode last) {
final boolean tailingElement = last.getStartOffset() + last.getTextLength() == parent.getStartOffset() + parent.getTextLength();
final boolean forceReformat = needToForceReformat(parent, first, last);
saveWhitespacesInfo(first);
@@ -167,7 +167,7 @@ public class CodeEditUtil {
return buffer.toString().trim().length();
}
- public static void replaceChild(ASTNode parent, @NotNull ASTNode oldChild, @NotNull ASTNode newChild) {
+ public static void replaceChild(@NotNull ASTNode parent, @NotNull ASTNode oldChild, @NotNull ASTNode newChild) {
saveWhitespacesInfo(oldChild);
saveWhitespacesInfo(newChild);
@@ -307,11 +307,11 @@ public class CodeEditUtil {
}
}
- public static void markToReformatBefore(final ASTNode right, boolean value) {
+ public static void markToReformatBefore(@NotNull ASTNode right, boolean value) {
right.putCopyableUserData(REFORMAT_BEFORE_KEY, value ? true : null);
}
- private static int getBlankLines(final String text) {
+ private static int getBlankLines(@NotNull String text) {
int result = 0;
int currentIndex = -1;
while ((currentIndex = text.indexOf('\n', currentIndex + 1)) >= 0) result++;
@@ -340,12 +340,12 @@ public class CodeEditUtil {
treeElement.putCopyableUserData(INDENT_INFO, oldIndentation >= 0 ? oldIndentation : null);
}
- public static boolean isMarkedToReformatBefore(final TreeElement element) {
+ public static boolean isMarkedToReformatBefore(@NotNull TreeElement element) {
return element.getCopyableUserData(REFORMAT_BEFORE_KEY) != null;
}
@Nullable
- public static PsiElement createLineFeed(final PsiManager manager) {
+ public static PsiElement createLineFeed(@NotNull PsiManager manager) {
return Factory.createSingleLeafElement(TokenType.WHITE_SPACE, "\n", 0, 1, null, manager).getPsi();
}
@@ -355,7 +355,7 @@ public class CodeEditUtil {
* @param node node to check
* @return {@code true} if given node is configured to be reformatted; {@code false} otherwise
*/
- public static boolean isMarkedToReformat(final ASTNode node) {
+ public static boolean isMarkedToReformat(@NotNull ASTNode node) {
if (node.getCopyableUserData(REFORMAT_KEY) == null || !isSuspendedNodesReformattingAllowed()) {
return false;
}
@@ -369,7 +369,7 @@ public class CodeEditUtil {
* @param node target element which {@code 'reformat'} status should be changed
* @param value {@code true} if the element should be reformatted; {@code false} otherwise
*/
- public static void markToReformat(final ASTNode node, boolean value) {
+ public static void markToReformat(@NotNull ASTNode node, boolean value) {
if (ALLOW_TO_MARK_NODES_TO_REFORMAT.get()) {
node.putCopyableUserData(REFORMAT_KEY, value ? true : null);
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java
index ef59875fedb4..02f7131609d0 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java
@@ -24,7 +24,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.pom.tree.events.TreeChangeEvent;
import com.intellij.pom.tree.events.impl.TreeChangeEventImpl;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
@@ -127,7 +126,7 @@ public class CompositeElement extends TreeElement {
}
@Override
- public void acceptTree(TreeElementVisitor visitor) {
+ public void acceptTree(@NotNull TreeElementVisitor visitor) {
visitor.visitComposite(this);
}
@@ -167,19 +166,19 @@ public class CompositeElement extends TreeElement {
}
@Nullable
- public PsiElement findPsiChildByType(IElementType type) {
+ public PsiElement findPsiChildByType(@NotNull IElementType type) {
final ASTNode node = findChildByType(type);
return node == null ? null : node.getPsi();
}
@Nullable
- public PsiElement findPsiChildByType(TokenSet types) {
+ public PsiElement findPsiChildByType(@NotNull TokenSet types) {
final ASTNode node = findChildByType(types);
return node == null ? null : node.getPsi();
}
@Override
- public ASTNode findChildByType(IElementType type) {
+ public ASTNode findChildByType(@NotNull IElementType type) {
if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED){
ApplicationManager.getApplication().assertReadAccessAllowed();
}
@@ -191,7 +190,7 @@ public class CompositeElement extends TreeElement {
}
@Override
- public ASTNode findChildByType(IElementType type, ASTNode anchor) {
+ public ASTNode findChildByType(@NotNull IElementType type, ASTNode anchor) {
if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED){
ApplicationManager.getApplication().assertReadAccessAllowed();
}
@@ -332,6 +331,7 @@ public class CompositeElement extends TreeElement {
return false;
}
+ @Override
protected int textMatches(@NotNull final CharSequence buffer, final int start) {
final int[] curOffset = {start};
acceptTree(new RecursiveTreeElementWalkingVisitor() {
@@ -376,12 +376,12 @@ public class CompositeElement extends TreeElement {
return null;
}
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this, child);
return 0; //ChildRole.NONE;
}
- protected final int getChildRole(ASTNode child, int roleCandidate) {
+ protected final int getChildRole(@NotNull ASTNode child, int roleCandidate) {
if (findChildByRole(roleCandidate) == child) {
return roleCandidate;
}
@@ -406,7 +406,7 @@ public class CompositeElement extends TreeElement {
}
@NotNull
- public T[] getChildrenAsPsiElements(@Nullable TokenSet filter, ArrayFactory constructor) {
+ public T[] getChildrenAsPsiElements(@Nullable TokenSet filter, @NotNull ArrayFactory constructor) {
ApplicationManager.getApplication().assertReadAccessAllowed();
int count = countChildren(filter);
T[] result = constructor.create(count);
@@ -425,7 +425,7 @@ public class CompositeElement extends TreeElement {
}
@NotNull
- public T[] getChildrenAsPsiElements(@NotNull IElementType type, ArrayFactory constructor) {
+ public T[] getChildrenAsPsiElements(@NotNull IElementType type, @NotNull ArrayFactory constructor) {
ApplicationManager.getApplication().assertReadAccessAllowed();
int count = countChildren(type);
T[] result = constructor.create(count);
@@ -470,13 +470,13 @@ public class CompositeElement extends TreeElement {
/**
* @return First element that was appended (for example whitespaces could be skipped)
*/
- public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) {
+ public TreeElement addInternal(TreeElement first, ASTNode last, @Nullable ASTNode anchor, @Nullable Boolean before) {
ASTNode anchorBefore;
- if (anchor != null) {
- anchorBefore = before.booleanValue() ? anchor : anchor.getTreeNext();
+ if (anchor == null) {
+ anchorBefore = before == null || before.booleanValue() ? null : getFirstChildNode();
}
else {
- anchorBefore = before == null || before.booleanValue() ? null : getFirstChildNode();
+ anchorBefore = before.booleanValue() ? anchor : anchor.getTreeNext();
}
return (TreeElement)CodeEditUtil.addChildren(this, first, last, anchorBefore);
}
@@ -610,15 +610,12 @@ public class CompositeElement extends TreeElement {
removeChildrenInner(first, last);
- ChangeUtil.prepareAndRunChangeAction(new ChangeUtil.ChangeAction(){
- @Override
- public void makeChange(TreeChangeEvent destinationTreeChange) {
- if (anchorBefore != null) {
- insertBefore((TreeChangeEventImpl)destinationTreeChange, (TreeElement)anchorBefore, first);
- }
- else {
- add((TreeChangeEventImpl)destinationTreeChange, CompositeElement.this, first);
- }
+ ChangeUtil.prepareAndRunChangeAction(destinationTreeChange -> {
+ if (anchorBefore != null) {
+ insertBefore((TreeChangeEventImpl)destinationTreeChange, (TreeElement)anchorBefore, first);
+ }
+ else {
+ add((TreeChangeEventImpl)destinationTreeChange, this, first);
}
}, this);
}
@@ -659,17 +656,14 @@ public class CompositeElement extends TreeElement {
removeChildrenInner(newChild1, newChildNext);
- ChangeUtil.prepareAndRunChangeAction(new ChangeUtil.ChangeAction(){
- @Override
- public void makeChange(TreeChangeEvent destinationTreeChange) {
- replace((TreeChangeEventImpl)destinationTreeChange, oldChild1, newChild1);
- repairRemovedElement(CompositeElement.this, oldChild1);
- }
+ ChangeUtil.prepareAndRunChangeAction(destinationTreeChange -> {
+ replace((TreeChangeEventImpl)destinationTreeChange, oldChild1, newChild1);
+ repairRemovedElement(this, oldChild1);
}, this);
}
@Override
- public void replaceAllChildrenToChildrenOf(final ASTNode anotherParent) {
+ public void replaceAllChildrenToChildrenOf(@NotNull final ASTNode anotherParent) {
TreeUtil.ensureParsed(getFirstChildNode());
TreeUtil.ensureParsed(anotherParent.getFirstChildNode());
final ASTNode firstChild = anotherParent.getFirstChildNode();
@@ -706,11 +700,11 @@ public class CompositeElement extends TreeElement {
}
@Override
- public void addChildren(ASTNode firstChild, ASTNode lastChild, ASTNode anchorBefore) {
+ public void addChildren(@NotNull ASTNode firstChild, ASTNode lastChild, ASTNode anchorBefore) {
while (firstChild != lastChild) {
- final ASTNode next1 = firstChild.getTreeNext();
+ final ASTNode next = firstChild.getTreeNext();
addChild(firstChild, anchorBefore);
- firstChild = next1;
+ firstChild = next;
}
}
@@ -848,12 +842,9 @@ public class CompositeElement extends TreeElement {
private static void removeChildrenInner(final TreeElement first, final TreeElement last) {
final FileElement fileElement = TreeUtil.getFileElement(first);
if (fileElement != null) {
- ChangeUtil.prepareAndRunChangeAction(new ChangeUtil.ChangeAction() {
- @Override
- public void makeChange(TreeChangeEvent destinationTreeChange) {
- remove((TreeChangeEventImpl)destinationTreeChange, first, last);
- repairRemovedElement(fileElement, first);
- }
+ ChangeUtil.prepareAndRunChangeAction(destinationTreeChange -> {
+ remove((TreeChangeEventImpl)destinationTreeChange, first, last);
+ repairRemovedElement(fileElement, first);
}, first.getTreeParent());
}
else {
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/Factory.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/Factory.java
index fe8764e84dee..2cc3f8754005 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/Factory.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/Factory.java
@@ -31,21 +31,20 @@ public class Factory {
private Factory() {}
@NotNull
- public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, PsiFile originalFile) {
+ public static LeafElement createSingleLeafElement(@NotNull IElementType type, @NotNull CharSequence buffer, int startOffset, int endOffset, CharTable table, @NotNull PsiManager manager, PsiFile originalFile) {
DummyHolder dummyHolder = DummyHolderFactory.createHolder(manager, table, type.getLanguage());
dummyHolder.setOriginalFile(originalFile);
FileElement holderElement = dummyHolder.getTreeElement();
- LeafElement newElement = ASTFactory.leaf(type, holderElement.getCharTable().intern(
- buffer, startOffset, endOffset));
+ LeafElement newElement = ASTFactory.leaf(type, holderElement.getCharTable().intern(buffer, startOffset, endOffset));
holderElement.rawAddChildren(newElement);
CodeEditUtil.setNodeGenerated(newElement, true);
return newElement;
}
@NotNull
- public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, boolean generatedFlag) {
+ public static LeafElement createSingleLeafElement(@NotNull IElementType type, @NotNull CharSequence buffer, int startOffset, int endOffset, CharTable table, @NotNull PsiManager manager, boolean generatedFlag) {
final FileElement holderElement = DummyHolderFactory.createHolder(manager, table, type.getLanguage()).getTreeElement();
final LeafElement newElement = ASTFactory.leaf(type, holderElement.getCharTable().intern(
buffer, startOffset, endOffset));
@@ -55,12 +54,12 @@ public class Factory {
}
@NotNull
- public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, CharTable table, PsiManager manager) {
+ public static LeafElement createSingleLeafElement(@NotNull IElementType type, @NotNull CharSequence buffer, CharTable table, @NotNull PsiManager manager) {
return createSingleLeafElement(type, buffer, 0, buffer.length(), table, manager);
}
@NotNull
- public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, int startOffset, int endOffset, @Nullable CharTable table, PsiManager manager) {
+ public static LeafElement createSingleLeafElement(@NotNull IElementType type, @NotNull CharSequence buffer, int startOffset, int endOffset, @Nullable CharTable table, @NotNull PsiManager manager) {
return createSingleLeafElement(type, buffer, startOffset, endOffset, table, manager, true);
}
@@ -72,7 +71,7 @@ public class Factory {
@NotNull
public static CompositeElement createCompositeElement(@NotNull IElementType type,
final CharTable charTableByTree,
- final PsiManager manager) {
+ @NotNull PsiManager manager) {
final FileElement treeElement = DummyHolderFactory.createHolder(manager, null, charTableByTree).getTreeElement();
final CompositeElement composite = ASTFactory.composite(type);
treeElement.rawAddChildren(composite);
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LeafElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LeafElement.java
index bbddaa44c53d..7e08e9f7cb8c 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LeafElement.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LeafElement.java
@@ -182,17 +182,17 @@ public abstract class LeafElement extends TreeElement {
}
@Override
- public void acceptTree(TreeElementVisitor visitor) {
+ public void acceptTree(@NotNull TreeElementVisitor visitor) {
visitor.visitLeaf(this);
}
@Override
- public ASTNode findChildByType(IElementType type) {
+ public ASTNode findChildByType(@NotNull IElementType type) {
return null;
}
@Override
- public ASTNode findChildByType(IElementType type, @Nullable ASTNode anchor) {
+ public ASTNode findChildByType(@NotNull IElementType type, @Nullable ASTNode anchor) {
return null;
}
@@ -276,7 +276,7 @@ public abstract class LeafElement extends TreeElement {
}
@Override
- public void replaceAllChildrenToChildrenOf(ASTNode anotherParent) {
+ public void replaceAllChildrenToChildrenOf(@NotNull ASTNode anotherParent) {
throw new IncorrectOperationException("Leaf elements cannot have children.");
}
@@ -286,7 +286,7 @@ public abstract class LeafElement extends TreeElement {
}
@Override
- public void addChildren(ASTNode firstChild, ASTNode lastChild, ASTNode anchorBefore) {
+ public void addChildren(@NotNull ASTNode firstChild, ASTNode lastChild, ASTNode anchorBefore) {
throw new IncorrectOperationException("Leaf elements cannot have children.");
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/TreeElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/TreeElement.java
index feba3bdd180e..6d9232109af8 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/TreeElement.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/TreeElement.java
@@ -231,7 +231,7 @@ public abstract class TreeElement extends ElementBase implements ASTNode, Clonea
public abstract int hc(); // Used in tree diffing
- public abstract void acceptTree(TreeElementVisitor visitor);
+ public abstract void acceptTree(@NotNull TreeElementVisitor visitor);
protected void onInvalidated() {
DebugUtil.onInvalidated(this);
diff --git a/platform/lang-api/src/com/intellij/lang/parameterInfo/ParameterInfoHandlerWithTabActionSupport.java b/platform/lang-api/src/com/intellij/lang/parameterInfo/ParameterInfoHandlerWithTabActionSupport.java
index 6faffd2dea34..0d8242a62757 100644
--- a/platform/lang-api/src/com/intellij/lang/parameterInfo/ParameterInfoHandlerWithTabActionSupport.java
+++ b/platform/lang-api/src/com/intellij/lang/parameterInfo/ParameterInfoHandlerWithTabActionSupport.java
@@ -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-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.
package com.intellij.lang.parameterInfo;
@@ -35,6 +21,7 @@ public interface ParameterInfoHandlerWithTabActionSupport getArgumentListAllowedParentClasses();
+ @SuppressWarnings("TypeParameterExtendsFinalClass") // keep historical signature for compatibility
@NotNull
Set extends Class> getArgListStopSearchClasses();
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
index 5d4a6eab02d5..45f780d47e65 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
@@ -891,6 +891,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
public void stopIfRunning() {
super.stopIfRunning();
myProject.getMessageBus().syncPublisher(DAEMON_EVENT_TOPIC).daemonFinished();
+ HighlightingSessionImpl.clearProgressIndicator(this);
}
};
progress.setModalityProgress(null);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HintRenderer.kt b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HintRenderer.kt
index 77d489ac84db..3945e414e20c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HintRenderer.kt
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HintRenderer.kt
@@ -72,20 +72,13 @@ open class HintRenderer(var text: String?) : EditorCustomElementRenderer {
val xEnd = r.x + r.width
val y = r.y + ascent
val font = editor.getColorsScheme().getFont(EditorFontType.PLAIN)
- if (effectType == EffectType.LINE_UNDERSCORE) {
- EffectPainter.LINE_UNDERSCORE.paint(g2d, xStart, y, xEnd - xStart, descent, font)
- }
- else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
- EffectPainter.BOLD_LINE_UNDERSCORE.paint(g2d, xStart, y, xEnd - xStart, descent, font)
- }
- else if (effectType == EffectType.STRIKEOUT) {
- EffectPainter.STRIKE_THROUGH.paint(g2d, xStart, y, xEnd - xStart, editor.charHeight, font)
- }
- else if (effectType == EffectType.WAVE_UNDERSCORE) {
- EffectPainter.WAVE_UNDERSCORE.paint(g2d, xStart, y, xEnd - xStart, descent, font)
- }
- else if (effectType == EffectType.BOLD_DOTTED_LINE) {
- EffectPainter.BOLD_DOTTED_UNDERSCORE.paint(g2d, xStart, y, xEnd - xStart, descent, font)
+ @Suppress("NON_EXHAUSTIVE_WHEN")
+ when (effectType) {
+ EffectType.LINE_UNDERSCORE -> EffectPainter.LINE_UNDERSCORE.paint(g2d, xStart, y, xEnd - xStart, descent, font)
+ EffectType.BOLD_LINE_UNDERSCORE -> EffectPainter.BOLD_LINE_UNDERSCORE.paint(g2d, xStart, y, xEnd - xStart, descent, font)
+ EffectType.STRIKEOUT -> EffectPainter.STRIKE_THROUGH.paint(g2d, xStart, y, xEnd - xStart, editor.charHeight, font)
+ EffectType.WAVE_UNDERSCORE -> EffectPainter.WAVE_UNDERSCORE.paint(g2d, xStart, y, xEnd - xStart, descent, font)
+ EffectType.BOLD_DOTTED_LINE -> EffectPainter.BOLD_DOTTED_UNDERSCORE.paint(g2d, xStart, y, xEnd - xStart, descent, font)
}
}
}
@@ -147,6 +140,6 @@ open class HintRenderer(var text: String?) : EditorCustomElementRenderer {
companion object {
private val HINT_FONT_METRICS = Key.create("ParameterHintFontMetrics")
- private val BACKGROUND_ALPHA = 0.55f
+ private const val BACKGROUND_ALPHA = 0.55f
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java
index 65d13518869d..e9d594f40fcf 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java
@@ -463,10 +463,6 @@ public class ParameterInfoController extends UserDataHolderBase implements Visib
return myComponent.getHighlighted();
}
- public void resetHighlighted() {
- myComponent.setHighlightedParameter(null);
- }
-
public void setPreservedOnHintHidden(boolean value) {
myKeepOnHintHidden = value;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java
index 50368fd129b9..e61f2999b86f 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java
@@ -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-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.
package com.intellij.codeInsight.hint;
import com.intellij.lang.parameterInfo.CreateParameterInfoContext;
@@ -128,9 +114,6 @@ public class ShowParameterInfoContext implements CreateParameterInfoContext {
final ParameterInfoHandler handler,
final boolean requestFocus,
boolean singleParameterInfo) {
- ParameterInfoController pic = ParameterInfoController.findControllerAtOffset(editor, elementStart);
- if (pic != null && pic.isHintShown(singleParameterInfo)) return;
-
if (editor.isDisposed() || !editor.getComponent().isVisible()) return;
PsiDocumentManager.getInstance(project).performLaterWhenAllCommitted(() -> {
diff --git a/platform/lang-impl/src/com/intellij/execution/update/RunningApplicationUpdater.java b/platform/lang-impl/src/com/intellij/execution/update/RunningApplicationUpdater.java
new file mode 100644
index 000000000000..5b51162c1fb0
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/execution/update/RunningApplicationUpdater.java
@@ -0,0 +1,21 @@
+// 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.
+package com.intellij.execution.update;
+
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public interface RunningApplicationUpdater {
+ String getDescription();
+
+ String getShortName();
+
+ @Nullable
+ Icon getIcon();
+
+ default boolean isEnabled() {
+ return true;
+ }
+
+ void performUpdate();
+}
diff --git a/platform/lang-impl/src/com/intellij/execution/update/RunningApplicationUpdaterProvider.java b/platform/lang-impl/src/com/intellij/execution/update/RunningApplicationUpdaterProvider.java
new file mode 100644
index 000000000000..5bf1ece22ec3
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/execution/update/RunningApplicationUpdaterProvider.java
@@ -0,0 +1,16 @@
+// 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.
+package com.intellij.execution.update;
+
+import com.intellij.execution.process.ProcessHandler;
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public interface RunningApplicationUpdaterProvider {
+ ExtensionPointName EP_NAME =
+ ExtensionPointName.create("com.intellij.runningApplicationUpdaterProvider");
+
+ @Nullable
+ RunningApplicationUpdater createUpdater(@NotNull Project project, @NotNull ProcessHandler process);
+}
diff --git a/platform/lang-impl/src/com/intellij/execution/update/UpdateRunningApplicationAction.java b/platform/lang-impl/src/com/intellij/execution/update/UpdateRunningApplicationAction.java
new file mode 100644
index 000000000000..9e945c5625c8
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/execution/update/UpdateRunningApplicationAction.java
@@ -0,0 +1,130 @@
+// 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.
+package com.intellij.execution.update;
+
+import com.intellij.execution.ExecutionManager;
+import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.ui.RunContentDescriptor;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
+import com.intellij.openapi.ui.popup.ListPopup;
+import com.intellij.openapi.ui.popup.PopupStep;
+import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class UpdateRunningApplicationAction extends AnAction {
+ public UpdateRunningApplicationAction() {
+ super("Update Running Application", null, AllIcons.Javaee.UpdateRunningApplication);
+ }
+
+ @Override
+ public void update(AnActionEvent e) {
+ final Project project = e.getData(CommonDataKeys.PROJECT);
+ final RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
+ final Presentation presentation = e.getPresentation();
+ if (contentDescriptor != null && project != null) {
+ final ProcessHandler processHandler = contentDescriptor.getProcessHandler();
+ final RunningApplicationUpdater updater = findUpdater(project, processHandler);
+ if (updater != null) {
+ presentation.setEnabled(processHandler.isStartNotified() && !processHandler.isProcessTerminating()
+ && !processHandler.isProcessTerminated() && updater.isEnabled());
+ presentation.setText(updater.getDescription());
+ }
+ else {
+ presentation.setEnabled(false);
+ }
+ presentation.setVisible(true);
+ return;
+ }
+
+ final List updaters = getAvailableUpdaters(project);
+ final boolean enable = !updaters.isEmpty();
+ presentation.setEnabledAndVisible(enable);
+ if (updaters.size() == 1) {
+ presentation.setText(updaters.get(0).getDescription());
+ }
+ else {
+ presentation.setText("Update Running Application...");
+ }
+ }
+
+ @Nullable
+ private static RunningApplicationUpdater findUpdater(@NotNull Project project, @Nullable ProcessHandler processHandler) {
+ if (processHandler == null) return null;
+
+ for (RunningApplicationUpdaterProvider provider : RunningApplicationUpdaterProvider.EP_NAME.getExtensions()) {
+ final RunningApplicationUpdater updater = provider.createUpdater(project, processHandler);
+ if (updater != null) {
+ return updater;
+ }
+ }
+ return null;
+ }
+
+ private static List getAvailableUpdaters(@Nullable Project project) {
+ if (project == null) {
+ return Collections.emptyList();
+ }
+
+ List result = new ArrayList<>();
+ ProcessHandler[] processes = ExecutionManager.getInstance(project).getRunningProcesses();
+ for (ProcessHandler process : processes) {
+ if (!process.isProcessTerminated() && !process.isProcessTerminating() && process.isStartNotified()) {
+ ContainerUtil.addIfNotNull(result, findUpdater(project, process));
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ final Project project = e.getData(CommonDataKeys.PROJECT);
+ if (project == null) return;
+
+ final RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
+ if (contentDescriptor != null) {
+ final RunningApplicationUpdater updater = findUpdater(project, contentDescriptor.getProcessHandler());
+
+ if (updater != null && updater.isEnabled()) {
+ updater.performUpdate();
+ return;
+ }
+ }
+
+ final List updaters = getAvailableUpdaters(project);
+ if (updaters.isEmpty()) return;
+
+ if (updaters.size() > 1) {
+ final ListPopup popup =
+ JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep("Select Process to Update", updaters) {
+ @NotNull
+ @Override
+ public String getTextFor(RunningApplicationUpdater value) {
+ return value.getShortName();
+ }
+
+ @Override
+ public Icon getIconFor(RunningApplicationUpdater value) {
+ return value.getIcon();
+ }
+
+ @Override
+ public PopupStep onChosen(final RunningApplicationUpdater selectedValue, boolean finalChoice) {
+ return doFinalStep(() -> selectedValue.performUpdate());
+ }
+ });
+ popup.showCenteredInCurrentWindow(project);
+ }
+ else {
+ updaters.get(0).performUpdate();
+ }
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java
index 7db8b2b4787e..0178174a885d 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java
@@ -712,9 +712,10 @@ public class FindPopupPanel extends JBPanel implements FindUI {
bottomPanel.add(Box.createHorizontalGlue(), "growx, pushx");
myOKHintLabel = new JBLabel("");
myOKHintLabel.setEnabled(false);
- bottomPanel.add(myOKHintLabel, "gapright " + JBUI.scale(8));
- bottomPanel.add(myOKButton, "gapright " + JBUI.scale(12));
- bottomPanel.add(myReplaceAllButton, "gapright " + JBUI.scale(12));
+ Insets insets = myOKButton.getInsets();
+ bottomPanel.add(myOKHintLabel, "gapright " + Math.max(0, (JBUI.scale(8) - insets.left)));
+ bottomPanel.add(myOKButton, "gapright " + Math.max(0, (JBUI.scale(12) - insets.left - insets.right)));
+ bottomPanel.add(myReplaceAllButton, "gapright " + Math.max(0, (JBUI.scale(12) - insets.left - insets.right)));
bottomPanel.add(myReplaceSelectedButton);
myCodePreviewComponent = myUsagePreviewPanel.createComponent();
diff --git a/platform/lang-impl/src/com/intellij/ide/util/PsiElementModuleRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/PsiElementModuleRenderer.java
index 56983d2f4214..50831c297d2f 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/PsiElementModuleRenderer.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/PsiElementModuleRenderer.java
@@ -7,6 +7,8 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
+import com.intellij.openapi.projectRoots.ProjectJdkTable;
+import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
@@ -14,6 +16,7 @@ import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
+import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
@@ -108,6 +111,19 @@ public class PsiElementModuleRenderer extends DefaultListCellRenderer{
}
}
+ if (StringUtil.isEmpty(myText) && Registry.is("index.run.configuration.jre")) {
+ VirtualFile rootJar = JarFileSystem.getInstance().getRootByEntry(vFile);
+ if (rootJar != null) {
+ for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
+ if (ArrayUtil.contains(rootJar, sdk.getRootProvider().getFiles(OrderRootType.CLASSES)) ||
+ ArrayUtil.contains(rootJar, sdk.getRootProvider().getFiles(OrderRootType.SOURCES))) {
+ myText = "< " + sdk.getName() + " >";
+ break;
+ }
+ }
+ }
+ }
+
myText = myText.substring(myText.lastIndexOf(File.separatorChar) + 1);
VirtualFile jar = JarFileSystem.getInstance().getVirtualFileForJar(vFile);
if (jar != null && !myText.equals(jar.getName())) {
diff --git a/platform/lang-impl/src/com/intellij/lang/ReadOnlyASTNode.java b/platform/lang-impl/src/com/intellij/lang/ReadOnlyASTNode.java
index 97ebaab06537..9d50a6f9214e 100644
--- a/platform/lang-impl/src/com/intellij/lang/ReadOnlyASTNode.java
+++ b/platform/lang-impl/src/com/intellij/lang/ReadOnlyASTNode.java
@@ -147,12 +147,12 @@ public abstract class ReadOnlyASTNode extends UserDataHolderBase implements ASTN
}
@Override
- public void replaceAllChildrenToChildrenOf(ASTNode anotherParent) {
+ public void replaceAllChildrenToChildrenOf(@NotNull ASTNode anotherParent) {
throw new UnsupportedOperationException();
}
@Override
- public void addChildren(ASTNode firstChild, ASTNode firstChildToNotAdd, ASTNode anchorBefore) {
+ public void addChildren(@NotNull ASTNode firstChild, ASTNode firstChildToNotAdd, ASTNode anchorBefore) {
throw new UnsupportedOperationException();
}
@@ -173,13 +173,13 @@ public abstract class ReadOnlyASTNode extends UserDataHolderBase implements ASTN
@Nullable
@Override
- public ASTNode findChildByType(IElementType type) {
+ public ASTNode findChildByType(@NotNull IElementType type) {
return findChildByType(type, null);
}
@Nullable
@Override
- public ASTNode findChildByType(IElementType type, @Nullable ASTNode anchor) {
+ public ASTNode findChildByType(@NotNull IElementType type, @Nullable ASTNode anchor) {
boolean flag = anchor == null;
for (ASTNode node : getChildren(null)) {
if (!flag && node.equals(anchor)) flag = true;
diff --git a/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java b/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java
index 7fa580ce42bc..be51fa1a9efa 100644
--- a/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java
+++ b/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java
@@ -37,7 +37,7 @@ public class CopyPasteManagerEx extends CopyPasteManager implements ClipboardOwn
private final List myData = new ArrayList<>();
private final EventDispatcher myDispatcher = EventDispatcher.create(ContentChangedListener.class);
private final ClipboardSynchronizer myClipboardSynchronizer;
- private boolean myOwnContent = false;
+ private boolean myOwnContent;
public static CopyPasteManagerEx getInstanceEx() {
return (CopyPasteManagerEx)getInstance();
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/BackAction.java b/platform/platform-impl/src/com/intellij/ide/actions/BackAction.java
index 2c86e35a1ff4..75effc5ef79d 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/BackAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/BackAction.java
@@ -24,12 +24,14 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
public class BackAction extends AnAction implements DumbAware {
+ @Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
if (project == null) return;
IdeDocumentHistory.getInstance(project).back();
}
+ @Override
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
Project project = event.getProject();
diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/LogEvents.kt b/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/LogEvents.kt
index 45206904c44d..5bf69a3f3c11 100644
--- a/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/LogEvents.kt
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/LogEvents.kt
@@ -97,8 +97,6 @@ class LogEventAction(val id: String) {
}
override fun hashCode(): Int {
- var result = id.hashCode()
- result = 31 * result + (data?.hashCode() ?: 0)
- return result
+ return 31 * id.hashCode() + data.hashCode()
}
}
\ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java
index 17ce610e1df4..2e50141d360f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java
+++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java
@@ -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-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.
package com.intellij.openapi.command.impl;
import com.intellij.CommonBundle;
@@ -188,11 +188,6 @@ abstract class UndoRedo {
final boolean[] isOk = new boolean[1];
TransactionGuard.getInstance().submitTransactionAndWait(() -> {
String actionText = getActionName(myUndoableGroup.getCommandName());
-
- if (actionText.length() > 80) {
- actionText = actionText.substring(0, 80) + "... ";
- }
-
isOk[0] = Messages.showOkCancelDialog(myManager.getProject(), actionText + "?", getActionName(),
Messages.getQuestionIcon()) == Messages.OK;
});
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
index 1d9b7f73b653..ddb85b2a005d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
@@ -70,6 +70,7 @@ import com.intellij.ui.components.JBLayeredPane;
import com.intellij.ui.components.JBScrollBar;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.mac.MacGestureSupportForEditor;
+import com.intellij.ui.paint.PaintUtil;
import com.intellij.util.*;
import com.intellij.util.concurrency.EdtExecutorService;
import com.intellij.util.containers.ContainerUtil;
@@ -1170,6 +1171,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
Graphics graphics = GraphicsUtil.safelyGetGraphics(myEditorComponent);
if (graphics != null) { // editor component is not showing
+ PaintUtil.alignToInt((Graphics2D)graphics, true, false);
processKeyTypedImmediately(c, graphics, context);
graphics.dispose();
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java
index 007c486f3d74..ef67dc6e274a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java
@@ -4,7 +4,6 @@ package com.intellij.openapi.wm.impl.content;
import com.intellij.ide.ui.AntialiasingType;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.ui.EngravedTextGraphics;
-import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.ui.content.Content;
import com.intellij.util.ui.GraphicsUtil;
@@ -44,7 +43,7 @@ public class BaseLabel extends JLabel {
@Override
public void updateUI() {
setActiveFg(JBColor.foreground());
- setPassiveFg(new JBColor(Gray._75, UIUtil.getLabelDisabledForeground()));
+ setPassiveFg(JBColor.foreground());
super.updateUI();
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java
index c9d468e32ad9..99ded16384d4 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java
@@ -225,7 +225,7 @@ class ContentTabLabel extends BaseLabel {
@Override
protected Color getPassiveFg(boolean selected) {
if (contentManager().getContentCount() > 1) {
- return JBUI.CurrentTheme.Label.disabledForeground(selected);
+ return JBUI.CurrentTheme.Label.foreground(selected);
}
return super.getPassiveFg(selected);
diff --git a/platform/platform-impl/src/com/intellij/ui/tree/ProjectFileTreeModel.java b/platform/platform-impl/src/com/intellij/ui/tree/ProjectFileTreeModel.java
index fe6f28c594fc..67ca6f652331 100644
--- a/platform/platform-impl/src/com/intellij/ui/tree/ProjectFileTreeModel.java
+++ b/platform/platform-impl/src/com/intellij/ui/tree/ProjectFileTreeModel.java
@@ -8,11 +8,12 @@ import com.intellij.openapi.roots.ModuleRootEvent;
import com.intellij.openapi.roots.ModuleRootListener;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileFilter;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.*;
import com.intellij.util.SmartList;
+import com.intellij.util.ThreeState;
import com.intellij.util.concurrency.Invoker;
import com.intellij.util.concurrency.InvokerSupplier;
import com.intellij.util.messages.MessageBusConnection;
@@ -33,7 +34,6 @@ import static com.intellij.openapi.vfs.VfsUtilCore.isAncestor;
import static com.intellij.openapi.vfs.VirtualFileManager.VFS_CHANGES;
import static com.intellij.ui.tree.TreePathUtil.pathToCustomNode;
import static java.util.Collections.emptyList;
-import static java.util.Collections.unmodifiableList;
public final class ProjectFileTreeModel extends BaseTreeModel implements InvokerSupplier {
private final Invoker invoker = new Invoker.BackgroundThread(this);
@@ -47,7 +47,7 @@ public final class ProjectFileTreeModel extends BaseTreeModel implements
public void rootsChanged(ModuleRootEvent event) {
onValidThread(() -> {
root.valid = false; // need to reload content roots
- treeStructureChanged(null, null, null);
+ pathChanged(null);
});
}
});
@@ -122,19 +122,45 @@ public final class ProjectFileTreeModel extends BaseTreeModel implements
Node node = object instanceof Node && isValidThread() ? (Node)object : null;
if (node == null) return emptyList();
List> children = node.getChildren();
- return unmodifiableList(children);
+ if (children.isEmpty()) return emptyList();
+ List result = new SmartList<>();
+ VirtualFileFilter filter = root.filter;
+ for (Object child : children) {
+ if (filter == null || child instanceof FileNode && isVisible((FileNode)child, filter)) {
+ result.add(child);
+ }
+ }
+ return result;
+ }
+
+ private static boolean isVisible(@NotNull FileNode node, @NotNull VirtualFileFilter filter) {
+ ThreeState visibility = node.visibility;
+ if (visibility == ThreeState.NO) return false;
+ if (visibility == ThreeState.YES) return true;
+ boolean visible;
+ if (!node.file.isDirectory()) {
+ visible = filter.accept(node.file);
+ }
+ else {
+ List children = node.getChildren();
+ visible = !children.stream().allMatch(child -> child.visibility == ThreeState.NO) &&
+ (children.stream().anyMatch(child -> child.visibility == ThreeState.YES) ||
+ children.stream().anyMatch(child -> isVisible(child, filter)));
+ }
+ node.visibility = ThreeState.fromBoolean(visible);
+ return visible;
}
@Nullable
- public Object getContentRoot(@Nullable Object object) {
- FileNode node = object instanceof FileNode && isValidThread() ? (FileNode)object : null;
- return node == null ? null : node.findParent(RootNode.class);
- }
-
- @Nullable
- public Pair getContent(@Nullable Object object) {
+ public static Module getModule(@Nullable Object object) {
FileNode node = object instanceof FileNode ? (FileNode)object : null;
- return node == null ? null : Pair.create(node.file, node.module);
+ return node == null ? null : node.module;
+ }
+
+ @Nullable
+ public static VirtualFile getVirtualFile(@Nullable Object object) {
+ FileNode node = object instanceof FileNode ? (FileNode)object : null;
+ return node == null ? null : node.file;
}
public void invalidate(VirtualFile file) {
@@ -148,12 +174,25 @@ public final class ProjectFileTreeModel extends BaseTreeModel implements
for (RootNode node : root.children) {
if (node.module == module && node.invalidate(file) && node.valid && root.valid) {
- node.invalidateLater(invoker, path -> treeStructureChanged(path, null, null));
+ node.invalidateLater(invoker, this::pathChanged);
}
}
});
}
+ public void setFilter(@Nullable VirtualFileFilter filter) {
+ onValidThread(() -> {
+ if (root.filter == null && filter == null) return;
+ root.filter = filter;
+ root.resetVisibility();
+ pathChanged(null);
+ });
+ }
+
+ private void pathChanged(@Nullable TreePath path) {
+ onValidThread(() -> treeStructureChanged(path, null, null));
+ }
+
private static final class Mapper implements BiFunction {
private final HashMap map = new HashMap<>();
@@ -175,6 +214,7 @@ public final class ProjectFileTreeModel extends BaseTreeModel implements
private static abstract class Node {
volatile Node parent;
+ volatile ThreeState visibility;
volatile List children = emptyList();
volatile boolean valid;
@@ -192,6 +232,18 @@ public final class ProjectFileTreeModel extends BaseTreeModel implements
return newList;
}
+ final void resetVisibility() {
+ visibility = null;
+ children.forEach(Node::resetVisibility);
+ }
+
+ final void resetParentVisibility() {
+ for (Node node = parent; node != null; node = node.parent) {
+ node.visibility = null;
+ }
+ }
+
+ @SuppressWarnings("SameParameterValue")
final N findParent(Class type) {
for (Node node = this; node != null; node = node.parent) {
if (type.isInstance(node)) return type.cast(node);
@@ -202,6 +254,7 @@ public final class ProjectFileTreeModel extends BaseTreeModel implements
private static class ProjectNode extends Node {
+ volatile VirtualFileFilter filter;
final Project project;
ProjectNode(@NotNull Project project) {
@@ -255,9 +308,11 @@ public final class ProjectFileTreeModel extends BaseTreeModel implements
@NotNull
@Override
List getChildren(@NotNull List oldList) {
+ visibility = ThreeState.NO;
if (!file.isValid() || module.isDisposed()) return emptyList();
ModuleRootManager manager = ModuleRootManager.getInstance(module);
if (manager == null) return emptyList();
+ visibility = ThreeState.UNSURE;
List list = new SmartList<>();
Mapper mapper = new Mapper<>(oldList, FileNode::new);
@@ -326,10 +381,15 @@ public final class ProjectFileTreeModel extends BaseTreeModel implements
if (parent != null && !parent.project.isDisposed()) {
List list = new SmartList<>();
invalidateNow(node -> list.add(node));
- for (FileNode node : list) {
- //noinspection RedundantCast TODO:IDEA-186224
- TreePath path = pathToCustomNode((Node)node, child -> child.parent);
- if (path != null) invoker.invokeLaterIfNeeded(() -> consumer.accept(path));
+ if (parent.filter == null) {
+ for (FileNode node : list) {
+ TreePath path = pathToCustomNode((Node)node, child -> child.parent);
+ if (path != null) consumer.accept(path);
+ }
+ }
+ else if (!list.isEmpty()) {
+ list.forEach(Node::resetParentVisibility);
+ consumer.accept(null);
}
}
}
diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties
index c99e2d994900..0a47569e220f 100644
--- a/platform/platform-resources-en/src/messages/ActionsBundle.properties
+++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties
@@ -1171,9 +1171,9 @@ action.Vcs.ShowDiffAction.text=Show Changes
action.Vcs.ShowDiffAction.description=Show changes
action.Vcs.RollbackChanges.text=Rollback Changes
action.Vcs.RollbackChanges.description=Rollback changes
-action.Vcs.MoveChangedLinesToChangelist.text=Move to Another Changelist...
-action.Vcs.MoveChangedLinesToChangelist.description=Move selected changes to another changelist
-action.Vcs.RollbackChangedLines.text=Rollback
+action.Vcs.MoveChangedLinesToChangelist.text=Move Lines to Another Changelist...
+action.Vcs.MoveChangedLinesToChangelist.description=Move changes in selected lines to another changelist
+action.Vcs.RollbackChangedLines.text=Rollback Lines
action.Vcs.RollbackChangedLines.description=Rollback changes in selected lines
action.Vcs.EditSourceAction.text=Edit Source
action.Vcs.EditSourceAction.description=Edit source
diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
index 59f1c4588778..8e97875c4ec1 100644
--- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
@@ -925,6 +925,9 @@
beanClass="com.intellij.openapi.fileTypes.FileTypeExtensionPoint">
+
+
diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml
index 494d333392ef..e8b203c8d56a 100644
--- a/platform/platform-resources/src/META-INF/XmlPlugin.xml
+++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml
@@ -109,7 +109,6 @@
com.intellij.codeInsight.daemon.impl.tagTreeHighlighting.XmlTagTreeHighlightingPassFactory
-
diff --git a/platform/platform-resources/src/componentSets/Lang.xml b/platform/platform-resources/src/componentSets/Lang.xml
index cf9017f347e9..e91d72cb8d72 100644
--- a/platform/platform-resources/src/componentSets/Lang.xml
+++ b/platform/platform-resources/src/componentSets/Lang.xml
@@ -138,67 +138,51 @@
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPassFactory
-
com.intellij.codeInsight.daemon.impl.ChameleonSyntaxHighlightingPass$Factory
-
com.intellij.codeInsight.daemon.impl.InjectedGeneralHighlightingPassFactory
-
com.intellij.codeInsight.daemon.impl.LineMarkersPassFactory
-
com.intellij.codeInsight.daemon.impl.ShowIntentionsPassFactory
-
com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPassFactory
-
com.intellij.refactoring.changeSignature.inplace.ChangeSignaturePassFactory
-
com.intellij.codeInsight.daemon.impl.CodeFoldingPassFactory
-
com.intellij.codeInsight.hints.ParameterHintsPassFactory
-
com.intellij.codeInsight.daemon.impl.IndentsPassFactory
-
com.intellij.codeInsight.daemon.impl.InjectedCodeFoldingPassFactory
-
com.intellij.codeInsight.daemon.impl.LocalInspectionsPassFactory
-
com.intellij.codeInsight.daemon.impl.WholeFileLocalInspectionsPassFactory
-
com.intellij.codeInsight.daemon.impl.ExternalToolPassFactory
-
com.intellij.codeInsight.daemon.impl.WolfPassFactory
-
com.intellij.codeInsight.daemon.impl.ShowAutoImportPassFactory
-
com.intellij.util.indexing.FileBasedIndexProjectHandler
@@ -207,7 +191,6 @@
com.intellij.codeInsight.navigation.CtrlMouseHandler
com.intellij.codeInsight.navigation.CtrlMouseHandler
-
@@ -228,7 +211,6 @@
com.intellij.facet.impl.ui.FacetDependentToolWindowManager
-
diff --git a/platform/platform-resources/src/componentSets/Platform.xml b/platform/platform-resources/src/componentSets/Platform.xml
index b220a2f814e3..b9eda48226bd 100644
--- a/platform/platform-resources/src/componentSets/Platform.xml
+++ b/platform/platform-resources/src/componentSets/Platform.xml
@@ -153,12 +153,10 @@
com.intellij.notification.EventLog$ProjectTracker
-
com.intellij.notification.impl.MacEventReader$ProjectTracker
-
@@ -185,7 +183,6 @@
com.intellij.notification.impl.NotificationsManagerImpl$ProjectNotificationsComponent
-
diff --git a/platform/platform-resources/src/componentSets/ProjectView.xml b/platform/platform-resources/src/componentSets/ProjectView.xml
index e35a62c66bb8..c84baad00fbc 100644
--- a/platform/platform-resources/src/componentSets/ProjectView.xml
+++ b/platform/platform-resources/src/componentSets/ProjectView.xml
@@ -3,7 +3,6 @@
com.intellij.ide.favoritesTreeView.FavoritesManager
-
diff --git a/platform/platform-resources/src/componentSets/VCS.xml b/platform/platform-resources/src/componentSets/VCS.xml
index 74d9bafccd6d..7edaf115a96a 100644
--- a/platform/platform-resources/src/componentSets/VCS.xml
+++ b/platform/platform-resources/src/componentSets/VCS.xml
@@ -27,13 +27,11 @@
com.intellij.openapi.vcs.impl.VcsDirectoryMappingStorage
-
com.intellij.openapi.vcs.impl.LineStatusTrackerManagerI
com.intellij.openapi.vcs.impl.LineStatusTrackerManager
-
com.intellij.openapi.vcs.impl.PartialLineStatusTrackerManagerState
@@ -41,7 +39,6 @@
com.intellij.openapi.vcs.update.RestoreUpdateTree
-
com.intellij.openapi.vcs.changes.ChangeListManager
@@ -52,7 +49,6 @@
com.intellij.openapi.vcs.changes.ChangesViewManager
com.intellij.openapi.vcs.changes.DummyChangesView
-
com.intellij.openapi.vcs.changes.VcsDirtyScopeManager
@@ -71,32 +67,26 @@
com.intellij.openapi.vcs.changes.shelf.ShelvedChangesViewManager
-
com.intellij.openapi.vcs.changes.ui.ChangesViewContentI
com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager
com.intellij.openapi.vcs.changes.ui.DummyChangesViewContentManager
-
com.intellij.openapi.vcs.changes.committed.CommittedChangesCache
-
com.intellij.openapi.vcs.changes.committed.OutdatedVersionNotifier
-
com.intellij.openapi.vcs.changes.committed.IncomingChangesIndicator
-
com.intellij.openapi.vcs.impl.VcsFileStatusProvider
-
com.intellij.openapi.vcs.impl.VcsBaseContentProvider
com.intellij.openapi.vcs.impl.VcsFileStatusProvider
diff --git a/platform/platform-resources/src/componentSets/WindowManagement.xml b/platform/platform-resources/src/componentSets/WindowManagement.xml
index 1b3dd9f88b0e..dcef1abb4d82 100644
--- a/platform/platform-resources/src/componentSets/WindowManagement.xml
+++ b/platform/platform-resources/src/componentSets/WindowManagement.xml
@@ -20,7 +20,6 @@
com.intellij.openapi.wm.impl.WindowDressing
-
diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml
index ac3684040c63..039e4b0e82cf 100644
--- a/platform/platform-resources/src/idea/LangActions.xml
+++ b/platform/platform-resources/src/idea/LangActions.xml
@@ -1082,5 +1082,11 @@
+
+
+
+
+
diff --git a/platform/platform-resources/src/idea/VcsActions.xml b/platform/platform-resources/src/idea/VcsActions.xml
index 0e2e1e4af162..3dccc7e1de7b 100644
--- a/platform/platform-resources/src/idea/VcsActions.xml
+++ b/platform/platform-resources/src/idea/VcsActions.xml
@@ -312,8 +312,7 @@
-
+
@@ -370,6 +369,8 @@
+
+
@@ -413,7 +414,6 @@
-
diff --git a/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java
index fb7e72163535..476205da267a 100644
--- a/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java
@@ -928,4 +928,20 @@ public class PsiDocumentManagerImplTest extends PlatformTestCase {
PsiElement firstChild = psiFile.getFirstChild();
assertTrue(firstChild instanceof PsiComment);
}
+
+ public void testAutoCommitDoesNotGetStuckForDocumentsWithIgnoredFileName() throws IOException {
+ VirtualFile vFile = getVirtualFile(createTempFile("a.txt~", "text"));
+ assertNotNull(getPsiManager().findViewProvider(vFile));
+ assertNull(getPsiManager().findFile(vFile)); // because it's ignored
+
+ Document document = FileDocumentManager.getInstance().getDocument(vFile);
+ ApplicationManager.getApplication().runWriteAction(() -> document.setText("// things"));
+
+ boolean[] calledPerformWhenAllCommitted = new boolean[1];
+ getPsiDocumentManager().performWhenAllCommitted(() -> calledPerformWhenAllCommitted[0] = true);
+ waitForCommits();
+
+ assertTrue(getPsiDocumentManager().isCommitted(document));
+ assertTrue(calledPerformWhenAllCommitted[0]);
+ }
}
\ No newline at end of file
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java
index d903d2bb83e1..971546fe6992 100644
--- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java
+++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java
@@ -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-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.
package com.intellij.structuralsearch.plugin.ui;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
@@ -9,6 +9,8 @@ import com.intellij.ide.IdeBundle;
import com.intellij.ide.util.scopeChooser.ScopeChooserCombo;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageUtil;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.diagnostic.Logger;
@@ -115,7 +117,7 @@ public class SearchDialog extends DialogWrapper {
myConfiguration = createConfiguration(null);
init();
- myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, myDisposable);
+ myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, myDisposable);
}
public void setUseLastConfiguration(boolean useLastConfiguration) {
@@ -160,16 +162,20 @@ public class SearchDialog extends DialogWrapper {
void initiateValidation() {
myAlarm.cancelAllRequests();
myAlarm.addRequest(() -> {
- try {
- getOKAction().setEnabled(isValid());
- }
- catch (ProcessCanceledException e) {
- throw e;
- }
- catch (RuntimeException e) {
- Logger.getInstance(SearchDialog.class).error(e);
- }
- }, 500);
+ final boolean valid = ReadAction.compute(() -> {
+ try {
+ return Boolean.valueOf(isValid());
+ }
+ catch (ProcessCanceledException e) {
+ throw e;
+ }
+ catch (RuntimeException e) {
+ Logger.getInstance(SearchDialog.class).error(e);
+ }
+ return Boolean.FALSE;
+ }).booleanValue();
+ ApplicationManager.getApplication().invokeLater(() -> getOKAction().setEnabled(valid));
+ }, 250);
}
protected void buildOptions(JPanel searchOptions) {
@@ -704,6 +710,9 @@ public class SearchDialog extends DialogWrapper {
return myConfiguration;
}
+ /**
+ * Needs to be called on the event thread or while holding a read lock.
+ */
protected boolean isValid() {
try {
Matcher.validate(searchContext.getProject(), getConfiguration().getMatchOptions());
diff --git a/platform/structuralsearch/source/messages/SSRBundle.properties b/platform/structuralsearch/source/messages/SSRBundle.properties
index 4534540022af..51599ae91ef6 100644
--- a/platform/structuralsearch/source/messages/SSRBundle.properties
+++ b/platform/structuralsearch/source/messages/SSRBundle.properties
@@ -247,7 +247,7 @@ groovy.script.error=Groovy Script execution error: {0}
template.problem=Structural Search Inspection problem in template ''{0}''
problem=Structural Search problem: {0}
complete.match.variable.name=Complete Match
-predefined.configuration.sample.method.invokation.with.constant.argument=sample method invocation with constant parameter
+predefined.configuration.sample.method.invokation.with.constant.argument=sample method invocation with constant argument
predefined.configuration.interfaces.having.no.descendants=interface that is not implemented or extended
predefined.configuration.enums=enums
regular.expression.help.label=Regular Expressions Help
diff --git a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
index 279205ae0a53..b4e92db25c3a 100644
--- a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
+++ b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
@@ -2345,6 +2345,11 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
fail("malformed pattern warning expected");
} catch (MalformedPatternException ignored) {}
+ findMatchesCount(source, "'_ReturnType '_Method*('_ParameterType '_Parameter);");
+ }
+
+ public void testInvalidPatternWarnings() {
+ final String source = "{}";
try {
findMatchesCount(source, "import java.util.ArrayList;");
fail("malformed pattern warning expected");
@@ -2361,11 +2366,15 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
} catch (MalformedPatternException ignored) {}
try {
- findMatchesCount(s4, "0x100000000");
+ findMatchesCount(source, "0x100000000");
fail("malformed pattern warning expected");
} catch (MalformedPatternException ignored) {}
- findMatchesCount(source, "'_ReturnType '_Method*('_ParameterType '_Parameter);");
+ try {
+ findMatchesCount(source, "assert '_C;\n" +
+ "System.out.println(");
+ fail("malformed pattern warning expected");
+ } catch (MalformedPatternException ignored) {}
}
public void testFindInnerClass() {
diff --git a/platform/testFramework/extensions/src/com/intellij/keymap/KeymapsTestCase.java b/platform/testFramework/extensions/src/com/intellij/keymap/KeymapsTestCase.java
index 9db0356ed679..1acd4b5ec4f0 100644
--- a/platform/testFramework/extensions/src/com/intellij/keymap/KeymapsTestCase.java
+++ b/platform/testFramework/extensions/src/com/intellij/keymap/KeymapsTestCase.java
@@ -27,7 +27,7 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
{ "alt UP", "MethodUp", "Arrangement.Rule.Match.Condition.Move.Up"},
{ "alt F1", "SelectIn", "ProjectViewChangeView"},
{ "alt INSERT", "FileChooser.NewFolder", "Generate", "NewElement"},
- { "control F10", "Android.HotswapChanges", "javaee.UpdateRunningApplication", "liveedit.UpdateRunningApplication"},
+ { "control F10", "Android.HotswapChanges", "UpdateRunningApplication"},
{ "control 1", "FileChooser.GotoHome", "GotoBookmark1", "DuplicatesForm.SendToLeft"},
{ "control 2", "FileChooser.GotoProject", "GotoBookmark2", "DuplicatesForm.SendToRight"},
{ "control 3", "GotoBookmark3", "FileChooser.GotoModule"},
@@ -158,7 +158,7 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
{ "alt F8", "ReformatCode", "ForceStepInto", "EvaluateExpression"},
{ "control COMMA", "GotoClass", "GotoChangedFile"},
{ "control F1", "ExternalJavaDoc", "ShowErrorDescription"},
- { "control F10", "Android.HotswapChanges", "RunToCursor", "javaee.UpdateRunningApplication", "liveedit.UpdateRunningApplication"},
+ { "control F10", "Android.HotswapChanges", "RunToCursor", "UpdateRunningApplication"},
{ "control N", "FileChooser.NewFolder", "Generate", },
{ "control P", "FileChooser.TogglePathShowing", "Print"},
{ "control alt F", "ReformatCode", "IntroduceField"},
@@ -193,7 +193,7 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
{ "alt DOWN", "ShowContent", "MoveStatementDown", "Arrangement.Rule.Match.Condition.Move.Down"},
{ "alt UP", "MoveStatementUp", "Arrangement.Rule.Match.Condition.Move.Up"},
{ "alt HOME", "ViewNavigationBar", "ShowNavBar"},
- { "control F10", "Android.HotswapChanges", "ShowPopupMenu", "javaee.UpdateRunningApplication", "liveedit.UpdateRunningApplication"},
+ { "control F10", "Android.HotswapChanges", "ShowPopupMenu", "UpdateRunningApplication"},
{ "control D", "EditorDeleteLine", "Diff.ShowDiff", "CompareTwoFiles", "SendEOF", "FileChooser.GotoDesktop"},
{ "control L", "Vcs.Log.FocusTextFilter", "GotoLine"},
{ "control N", "ShowPopupMenu", "FileChooser.NewFolder"},
diff --git a/platform/testFramework/src/com/intellij/testFramework/PerformanceTestInfo.java b/platform/testFramework/src/com/intellij/testFramework/PerformanceTestInfo.java
index 4ed815ab2e31..31d8caafffaa 100644
--- a/platform/testFramework/src/com/intellij/testFramework/PerformanceTestInfo.java
+++ b/platform/testFramework/src/com/intellij/testFramework/PerformanceTestInfo.java
@@ -122,7 +122,7 @@ public class PerformanceTestInfo {
int expectedOnMyMachine = getExpectedTimeOnThisMachine();
// Allow 10% more in case of test machine is busy.
- double acceptableChangeFactor = attempts == 1 ? 1.1 : 1.0;
+ double acceptableChangeFactor = attempts == 0 ? 1.1 : 1.0;
int percentage = (int)(100.0 * (duration - expectedOnMyMachine) / expectedOnMyMachine);
String colorCode = duration < expectedOnMyMachine ? "32;1m" : // green
duration < expectedOnMyMachine * acceptableChangeFactor ? "33;1m" : // yellow
diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/ActionOnRange.java b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/ActionOnRange.java
index 6c5010d31e6c..69089eca3f3a 100644
--- a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/ActionOnRange.java
+++ b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/ActionOnRange.java
@@ -29,6 +29,7 @@ import com.intellij.psi.SmartPsiFileRange;
import com.intellij.psi.impl.DebugUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jetCheck.Generator;
/**
* @author peter
@@ -98,4 +99,14 @@ abstract class ActionOnRange implements MadTestingAction {
}
return myFinalRange;
}
+
+ @SuppressWarnings("SameParameterValue")
+ protected int generatePsiOffset(@NotNull Environment env, @Nullable String logMessage) {
+ return env.generateValue(Generator.integers(0, getFile().getTextLength()).noShrink(), logMessage);
+ }
+
+ protected int generateDocOffset(@NotNull Environment env, @Nullable String logMessage) {
+ return env.generateValue(Generator.integers(0, getDocument().getTextLength()).noShrink(), logMessage);
+ }
+
}
diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/DeleteRange.java b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/DeleteRange.java
index 5e3f9296958b..c1861e2ddb21 100644
--- a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/DeleteRange.java
+++ b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/DeleteRange.java
@@ -36,9 +36,8 @@ public class DeleteRange extends ActionOnRange {
public void performCommand(@NotNull Environment env) {
PsiFile psiFile = getFile();
- int fileLength = psiFile.getTextLength();
- int startOffset = env.generateValue(Generator.integers(0, fileLength), null);
- int endOffset = Math.min(fileLength, startOffset + env.generateValue(Generator.integers(IntDistribution.geometric(10)), null));
+ int startOffset = generatePsiOffset(env, null);
+ int endOffset = Math.min(psiFile.getTextLength(), startOffset + env.generateValue(Generator.integers(IntDistribution.geometric(10)).noShrink(), null));
PsiElement start = psiFile.findElementAt(startOffset);
PsiElement end = psiFile.findElementAt(endOffset);
if (start == null || end == null) return;
diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InsertLineComment.java b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InsertLineComment.java
index 8de374acc294..f534241bd2e9 100644
--- a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InsertLineComment.java
+++ b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InsertLineComment.java
@@ -25,7 +25,7 @@ public class InsertLineComment extends ActionOnRange {
public void performCommand(@NotNull Environment env) {
PsiDocumentManager.getInstance(getProject()).commitDocument(getDocument());
- int randomOffset = env.generateValue(Generator.integers(0, getFile().getTextLength()), null);
+ int randomOffset = generatePsiOffset(env, null);
PsiElement leaf = getFile().findElementAt(randomOffset);
TextRange leafRange = leaf != null ? leaf.getTextRange() : null;
int insertOffset = leafRange != null ? leafRange.getEndOffset() : 0;
diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InsertString.java b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InsertString.java
index 1b4d8f3a94b5..36e137cf1393 100644
--- a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InsertString.java
+++ b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InsertString.java
@@ -30,7 +30,7 @@ public class InsertString extends ActionOnRange {
@Override
public void performCommand(@NotNull Environment env) {
- int offset = env.generateValue(Generator.integers(0, getDocument().getTextLength()), null);
+ int offset = generateDocOffset(env, null);
String toInsert = env.generateValue(Generator.stringsOf(Generator.asciiPrintableChars()), "Insert '%s' at " + offset + " in " + getPath());
WriteCommandAction.runWriteCommandAction(getProject(), () -> getDocument().insertString(offset, toInsert));
}
diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeCompletion.java b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeCompletion.java
index b0bc49eff3d7..859e42f249f6 100644
--- a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeCompletion.java
+++ b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeCompletion.java
@@ -82,8 +82,7 @@ public class InvokeCompletion extends ActionOnRange {
@Override
public void performCommand(@NotNull Environment env) {
- int offset = env.generateValue(Generator.integers(0, getDocument().getTextLength()),
- "Invoke basic completion at offset %s (" + getPath() + ")");
+ int offset = generateDocOffset(env, "Invoke basic completion at offset %s (" + getPath() + ")");
String selectionCharacters = myPolicy.getPossibleSelectionCharacters();
char c = selectionCharacters.charAt(env.generateValue(Generator.integers(0, selectionCharacters.length() - 1), null));
performActionAt(offset, c, items -> env.generateValue(Generator.sampledFrom(items), null), env::logMessage);
diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeIntention.java b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeIntention.java
index b6574dfb13bc..4f52c0b541fe 100644
--- a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeIntention.java
+++ b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeIntention.java
@@ -74,8 +74,7 @@ public class InvokeIntention extends ActionOnRange {
@Override
public void performCommand(@NotNull Environment env) {
- int offset = env.generateValue(Generator.integers(0, getDocument().getTextLength()),
- "Go to offset %s and run daemon (" + getPath() + ")");
+ int offset = generateDocOffset(env, "Go to offset %s and run daemon (" + getPath() + ")");
doInvokeIntention(offset, actions -> {
if (actions.isEmpty()) {
@@ -83,7 +82,7 @@ public class InvokeIntention extends ActionOnRange {
return null;
}
- IntentionAction result = env.generateValue(Generator.sampledFrom(actions), null);
+ IntentionAction result = env.generateValue(Generator.sampledFrom(actions).noShrink(), null);
env.logMessage("Invoke intention '" + result.getText() + "'");
return result;
});
diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/MadTestingUtil.java b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/MadTestingUtil.java
index bdee0c122595..5ff29a54bfb0 100644
--- a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/MadTestingUtil.java
+++ b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/MadTestingUtil.java
@@ -41,7 +41,6 @@ import com.intellij.testFramework.RunAll;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
import com.intellij.util.ThrowableRunnable;
-import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.JBIterable;
import com.intellij.util.containers.TreeTraversal;
import com.intellij.util.ui.UIUtil;
@@ -236,7 +235,6 @@ public class MadTestingUtil {
return () -> env -> new RunAll()
.append(() -> {
File ioFile = env.generateValue(randomFiles, "Working with %s");
- System.out.println(ioFile);
VirtualFile vFile = copyFileToProject(ioFile, fixture, rootPath);
PsiFile psiFile = fixture.getPsiManager().findFile(vFile);
if (psiFile instanceof PsiBinaryFile || psiFile instanceof PsiPlainTextFile) {
diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestRunner.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestRunner.kt
index c040dadad0ae..4c44550fc2f7 100755
--- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestRunner.kt
+++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestRunner.kt
@@ -146,7 +146,7 @@ class GuiTestRunner internal constructor(val runner: GuiTestRunnerInterface) {
val runListener: RunListener = object : RunListener() {
override fun testFailure(failure: Failure?) {
- LOG.error("Test failed: '$testName'")
+ LOG.info("Test failed: '$testName'")
notifier.removeListener(this)
super.testFailure(failure)
}
diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt
index 78a2b4832853..07f02fde29e6 100644
--- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt
+++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt
@@ -40,6 +40,7 @@ import com.intellij.testGuiFramework.impl.GuiTestUtilKt.runOnEdt
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.waitUntil
import com.intellij.testGuiFramework.util.Key
import com.intellij.ui.Splash
+import com.intellij.util.concurrency.AppExecutorUtil
import org.fest.swing.core.Robot
import org.fest.swing.exception.ComponentLookupException
import org.fest.swing.exception.WaitTimedOutError
@@ -72,7 +73,6 @@ class GuiTestRule : TestRule {
private var myProjectPath: File? = null
set
private var myTestName: String = "undefined"
- private var currentTestErrors = 0
private var currentTestDateStart: Date = Date()
private val myRuleChain = RuleChain.emptyRuleChain()
@@ -112,7 +112,6 @@ class GuiTestRule : TestRule {
errors.addAll(tearDown()) // shouldn't throw, but called inside a try-finally for defense in depth
}
finally {
- currentTestErrors = errors.size
//noinspection ThrowFromFinallyBlock; assertEmpty is intended to throw here
MultipleFailureException.assertEmpty(errors)
}
@@ -230,11 +229,9 @@ class GuiTestRule : TestRule {
override fun after() {
try {
- if (currentTestErrors > 0) {
- GuiTestUtilKt.waitUntil("fatal errors in message log will sync") {
- MessagePool.getInstance().getFatalErrors(true, true).size >= currentTestErrors
- }
- }
+ val executorService = AppExecutorUtil.getAppExecutorService()
+ //wait 10 second for the termination of all
+ if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) executorService.shutdownNow()
MessagePool.getInstance().clearFatals()
}
catch (e: Exception) {
diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/remote/JUnitClientListener.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/remote/JUnitClientListener.kt
index c961f151a9c2..04e4cc6b976e 100644
--- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/remote/JUnitClientListener.kt
+++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/remote/JUnitClientListener.kt
@@ -44,7 +44,6 @@ class JUnitClientListener(val sendObjectFun: (JUnitInfo) -> Unit) : RunListener(
override fun testFailure(failure: Failure?) {
sendObjectFun(JUnitInfo(Type.FAILURE, failure!!.exception, JUnitInfo.getClassAndMethodName(failure.description)))
- LOG.error(failure.exception)
}
override fun testFinished(description: Description?) {
diff --git a/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java b/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java
index f640a121a372..90c20242bfc0 100644
--- a/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java
+++ b/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java
@@ -307,6 +307,7 @@ public class UsagePreviewPanel extends UsageContextPanelBase implements DataProv
settings.setAdditionalColumnsCount(0);
settings.setAdditionalLinesCount(0);
settings.setAnimatedScrolling(false);
+ settings.setAutoCodeFoldingEnabled(false);
}
@Override
diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties
index 35124907916b..a2acb1fd8871 100644
--- a/platform/util/resources/misc/registry.properties
+++ b/platform/util/resources/misc/registry.properties
@@ -277,7 +277,7 @@ editor.distraction.free.mode=false
editor.soft.wrap.force.limit=10000
editor.soft.wrap.force.limit.description=If document contains lines longer than this value, soft wraps will be forcibly enabled in editor due to performance reasons
-editor.navigation.history.stack.size=25
+editor.navigation.history.stack.size=150
editor.navigation.history.stack.size.description=Stack size limit for back/forward and last/next edit location navigation
editor.reformat.on.typing=false
@@ -392,6 +392,7 @@ debugger.enable.overhead.monitor=true
debugger.tree.states.depth=100
index.run.configuration.jre=false
+index.run.configuration.jre.restartRequired=true
index.run.configuration.jre.description=Index jre specified in run configuration for goto navigation etc.
analyze.exceptions.on.the.fly=false
diff --git a/platform/util/src/com/intellij/util/LazyInitializer.java b/platform/util/src/com/intellij/util/LazyInitializer.java
index 36a320e6a5c8..e27776e630ea 100644
--- a/platform/util/src/com/intellij/util/LazyInitializer.java
+++ b/platform/util/src/com/intellij/util/LazyInitializer.java
@@ -95,9 +95,4 @@ public class LazyInitializer {
public String toString() {
return value != null ? value.toString() : "null";
}
-
- @Override
- public int hashCode() {
- return value != null ? value.hashCode() : super.hashCode();
- }
}
diff --git a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java
index a4857df9115c..a79519987e9f 100644
--- a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java
+++ b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java
@@ -1,6 +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-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.
package com.intellij.util.xmlb;
import com.intellij.openapi.util.text.StringUtil;
@@ -18,12 +16,14 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
abstract class AbstractCollectionBinding extends NotNullDeserializeBinding implements MultiNodeBinding {
private List itemBindings;
protected final Class> itemType;
+ @SuppressWarnings("deprecation")
@Nullable
private final AbstractCollection annotation;
@Nullable
@@ -37,6 +37,7 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple
itemType = elementType;
newAnnotation = accessor == null ? null : accessor.getAnnotation(XCollection.class);
+ //noinspection deprecation
annotation = newAnnotation == null ? (accessor == null ? null : accessor.getAnnotation(AbstractCollection.class)) : null;
}
@@ -104,18 +105,15 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple
return null;
}
- @NotNull
- abstract Object processResult(@NotNull Collection result, @Nullable Object target);
-
@NotNull
abstract Collection getIterable(@NotNull Object o);
@Nullable
@Override
- public Object serialize(@NotNull Object o, @Nullable Object context, @Nullable SerializationFilter filter) {
- Collection collection = getIterable(o);
+ public Object serialize(@NotNull Object object, @Nullable Object context, @Nullable SerializationFilter filter) {
+ Collection collection = getIterable(object);
- String tagName = getTagName(o);
+ String tagName = isSurroundWithTag() ? getCollectionTagName(object) : null;
if (tagName == null) {
List result = new SmartList();
if (!ContainerUtil.isEmpty(collection)) {
@@ -139,34 +137,31 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple
}
}
+ @Override
+ @NotNull
+ public Object deserialize(@Nullable Object context, @NotNull Element element) {
+ if (!isSurroundWithTag()) {
+ return doDeserializeList(context, Collections.singletonList(element));
+ }
+
+ return doDeserializeList(context, element.getChildren());
+ }
+
@Nullable
@Override
public Object deserializeList(@Nullable Object context, @NotNull List elements) {
- Collection result;
- if (getTagName(context) == null) {
- if (context instanceof Collection) {
- result = (Collection)context;
- result.clear();
- }
- else {
- result = new SmartList();
- }
- for (Element node : elements) {
- //noinspection unchecked
- result.add(deserializeItem(node, context));
- }
+ if (!isSurroundWithTag()) {
+ return doDeserializeList(context, elements);
+ }
- if (result == context) {
- return result;
- }
- }
- else {
- assert elements.size() == 1;
- result = deserializeSingle(context, elements.get(0));
- }
- return processResult(result, context);
+ assert elements.size() == 1;
+ Element element = elements.get(0);
+ return doDeserializeList(context == null && element.getName().equals(Constants.SET) ? new HashSet() : context, element.getChildren());
}
+ @NotNull
+ protected abstract Object doDeserializeList(@Nullable Object context, @NotNull List elements);
+
@Nullable
private Object serializeItem(@Nullable Object value, Object context, @Nullable SerializationFilter filter) {
if (value == null) {
@@ -199,7 +194,7 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple
}
}
- private Object deserializeItem(@NotNull Element node, @Nullable Object context) {
+ protected final Object deserializeItem(@NotNull Element node, @Nullable Object context) {
Binding binding = getElementBinding(node);
if (binding == null) {
String attributeName = getValueAttributeName();
@@ -233,55 +228,12 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple
return annotation == null ? Constants.VALUE : annotation.elementValueAttribute();
}
- @Override
- @NotNull
- public Object deserialize(@Nullable Object context, @NotNull Element element) {
- Collection result;
- if (getTagName(context) == null) {
- if (context instanceof Collection) {
- result = (Collection)context;
- result.clear();
- }
- else {
- result = new SmartList();
- }
-
- //noinspection unchecked
- result.add(deserializeItem(element, context));
-
- if (result == context) {
- return result;
- }
- }
- else {
- result = deserializeSingle(context, element);
- }
- //noinspection unchecked
- return processResult(result, context);
- }
-
- @NotNull
- private Collection deserializeSingle(Object context, @NotNull Element node) {
- Collection result = createCollection(node.getName());
- for (Element child : node.getChildren()) {
- //noinspection unchecked
- result.add(deserializeItem(child, context));
- }
- return result;
- }
-
- protected Collection createCollection(@NotNull String tagName) {
- return new SmartList();
- }
-
@Override
public boolean isBoundTo(@NotNull Element element) {
- String tagName = getTagName(element);
- if (tagName != null) {
- return element.getName().equals(tagName);
+ if (isSurroundWithTag()) {
+ return element.getName().equals(getCollectionTagName(null));
}
-
- if (getElementBindings().isEmpty()) {
+ else if (getElementBindings().isEmpty()) {
return element.getName().equals(getElementName());
}
else {
@@ -289,10 +241,6 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple
}
}
- @Nullable
- private String getTagName(@Nullable Object target) {
- return isSurroundWithTag() ? getCollectionTagName(target) : null;
- }
-
+ @NotNull
protected abstract String getCollectionTagName(@Nullable Object target);
}
diff --git a/platform/util/src/com/intellij/util/xmlb/ArrayBinding.java b/platform/util/src/com/intellij/util/xmlb/ArrayBinding.java
index 04ec974de030..6a9a9a328d94 100644
--- a/platform/util/src/com/intellij/util/xmlb/ArrayBinding.java
+++ b/platform/util/src/com/intellij/util/xmlb/ArrayBinding.java
@@ -1,47 +1,41 @@
-/*
- * 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-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.
package com.intellij.util.xmlb;
+import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
class ArrayBinding extends AbstractCollectionBinding {
public ArrayBinding(@NotNull Class> valueClass, @Nullable MutableAccessor accessor) {
super(valueClass.getComponentType(), accessor);
}
+ @NotNull
@Override
protected String getCollectionTagName(@Nullable Object target) {
return "array";
}
@NotNull
- @Override
- @SuppressWarnings({"unchecked"})
- Object processResult(@NotNull Collection result, @Nullable Object target) {
- return result.toArray((Object[])Array.newInstance(itemType, result.size()));
+ protected Object doDeserializeList(@Nullable Object context, @NotNull List elements) {
+ int size = elements.size();
+ Object[] result = (Object[])Array.newInstance(itemType, size);
+ for (int i = 0; i < size; i++) {
+ result[i] = deserializeItem(elements.get(i), context);
+ }
+ return result;
}
@NotNull
@Override
Collection getIterable(@NotNull Object o) {
- return Arrays.asList((Object[])o);
+ Object[] list = (Object[])o;
+ return list.length == 0 ? Collections.emptyList() : Arrays.asList(list);
}
}
diff --git a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java
index 78c073aa9e76..8bafa44c9ab3 100644
--- a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java
+++ b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java
@@ -368,7 +368,7 @@ public class BeanBinding extends NotNullDeserializeBinding {
if (setter == null) {
// check hasStoreAnnotations to ensure that this addition will not lead to regression (since there is a chance that there is some existing not-annotated list getters without setter)
- return (List.class.isAssignableFrom(getter.getReturnType()) || Map.class.isAssignableFrom(getter.getReturnType())) && hasStoreAnnotations(getter);
+ return (Collection.class.isAssignableFrom(getter.getReturnType()) || Map.class.isAssignableFrom(getter.getReturnType())) && hasStoreAnnotations(getter);
}
if (setter.getAnnotation(Transient.class) != null || !getter.getReturnType().equals(setter.getParameterTypes()[0])) {
diff --git a/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java
index 8df123b586f9..39b697181d48 100644
--- a/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java
+++ b/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java
@@ -1,8 +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-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.
package com.intellij.util.xmlb;
+import com.intellij.util.SmartList;
+import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -13,21 +13,30 @@ class CollectionBinding extends AbstractCollectionBinding {
public CollectionBinding(@NotNull ParameterizedType type, @Nullable MutableAccessor accessor) {
super(XmlSerializerImpl.typeToClass(type.getActualTypeArguments()[0]), accessor);
}
-
- @Override
- @NotNull
- Object processResult(@NotNull Collection result, @Nullable Object target) {
- if (myAccessor == null || target == null) {
- return result;
- }
-
- assert target instanceof Collection : "Wrong target: " + target.getClass() + " in " + myAccessor;
- Collection c = (Collection)target;
- c.clear();
- //noinspection unchecked
- c.addAll(result);
- return target;
+ private static boolean isMutableCollection(@Nullable Object object) {
+ return object instanceof Collection && !object.getClass().getSimpleName().startsWith("Unmodifiable");
+ }
+
+ @NotNull
+ @Override
+ protected Object doDeserializeList(@Nullable Object context, @NotNull List elements) {
+ Collection result;
+ boolean isContextMutable = isMutableCollection(context);
+ if (isContextMutable) {
+ result = (Collection)context;
+ result.clear();
+ }
+ else {
+ result = context instanceof Set ? new HashSet() : new SmartList();
+ }
+
+ for (Element node : elements) {
+ //noinspection unchecked
+ result.add(deserializeItem(node, context));
+ }
+
+ return result;
}
@SuppressWarnings("unchecked")
@@ -40,6 +49,7 @@ class CollectionBinding extends AbstractCollectionBinding {
return o instanceof Set ? new TreeSet((Set)o) : (Collection)o;
}
+ @NotNull
@Override
protected String getCollectionTagName(@Nullable final Object target) {
if (target instanceof Set) {
@@ -52,9 +62,4 @@ class CollectionBinding extends AbstractCollectionBinding {
return "collection";
}
}
-
- @Override
- protected Collection createCollection(@NotNull String tagName) {
- return tagName.equals(Constants.SET) ? new HashSet() : super.createCollection(tagName);
- }
}
diff --git a/platform/util/src/com/intellij/util/xmlb/MapBinding.java b/platform/util/src/com/intellij/util/xmlb/MapBinding.java
index d42a274d04c8..ba80ab902ce3 100644
--- a/platform/util/src/com/intellij/util/xmlb/MapBinding.java
+++ b/platform/util/src/com/intellij/util/xmlb/MapBinding.java
@@ -245,7 +245,7 @@ class MapBinding extends Binding implements MultiNodeBinding {
}
else {
assert binding != null;
- return Binding.deserializeList(binding, context, children);
+ return Binding.deserializeList(binding, null, children);
}
}
return null;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java
index 701ac2d7dbe5..e5606df0a016 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java
@@ -12,6 +12,7 @@ import com.intellij.diff.util.Range;
import com.intellij.diff.util.Side;
import com.intellij.icons.AllIcons;
import com.intellij.idea.ActionsBundle;
+import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -36,7 +37,6 @@ import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
-import static com.intellij.util.ObjectUtils.assertNotNull;
import static com.intellij.util.ObjectUtils.notNull;
public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer {
@@ -53,7 +53,7 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer {
myTracker.addListener(new MyTrackerListener(), this);
- DiffUtil.registerAction(new MoveSelectedChangesToAnotherChangelistAction(), myPanel);
+ DiffUtil.registerAction(new MoveSelectedChangesToAnotherChangelistAction(true), myPanel);
}
@NotNull
@@ -68,7 +68,7 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer {
protected List createEditorPopupActions() {
List group = new ArrayList<>(super.createEditorPopupActions());
- group.add(new MoveSelectedChangesToAnotherChangelistAction());
+ group.add(new MoveSelectedChangesToAnotherChangelistAction(false));
return group;
}
@@ -185,8 +185,20 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer {
}
private class MoveSelectedChangesToAnotherChangelistAction extends DumbAwareAction {
+ private final boolean myShortcut;
+
+ public MoveSelectedChangesToAnotherChangelistAction(boolean shortcut) {
+ myShortcut = shortcut;
+ copyShortcutFrom(ActionManager.getInstance().getAction("Vcs.MoveChangedLinesToChangelist"));
+ }
+
@Override
public void update(@NotNull AnActionEvent e) {
+ if (myShortcut) {
+ e.getPresentation().setEnabledAndVisible(true);
+ return;
+ }
+
Editor editor = e.getData(CommonDataKeys.EDITOR);
Side side = Side.fromValue(getEditors(), editor);
if (side == null) {
@@ -215,7 +227,9 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Editor editor = e.getData(CommonDataKeys.EDITOR);
- Side side = assertNotNull(Side.fromValue(getEditors(), editor));
+ Side side = Side.fromValue(getEditors(), editor);
+ if (editor == null || side == null) return;
+
List selectedChanges = getSelectedChanges(side);
if (selectedChanges.isEmpty()) return;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.kt
index ab15ce16e170..d2af567d2ddb 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.kt
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.kt
@@ -16,7 +16,7 @@ import javax.swing.tree.DefaultTreeModel
private const val PROJECT_ROOT_TAG = ""
-class ChangesModuleGroupingPolicy(val myProject: Project, val myModel: DefaultTreeModel) : ChangesGroupingPolicy {
+open class ChangesModuleGroupingPolicy(val myProject: Project, val myModel: DefaultTreeModel) : ChangesGroupingPolicy {
private val myIndex = ProjectFileIndex.getInstance(myProject)
override fun getParentNodeFor(nodePath: StaticFilePath, subtreeRoot: ChangesBrowserNode<*>): ChangesBrowserNode<*>? {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/MoveChangesLineStatusAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/MoveChangesLineStatusAction.java
index e5643d574a6a..b4c18c6f123e 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/MoveChangesLineStatusAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/MoveChangesLineStatusAction.java
@@ -97,7 +97,7 @@ public class MoveChangesLineStatusAction extends LineStatusActionBase {
ChangeListChooser chooser = new ChangeListChooser(project,
suggestedLists,
defaultSelection,
- ActionsBundle.message("action.ChangesView.Move.text"),
+ ActionsBundle.message("action.Vcs.MoveChangedLinesToChangelist.text"),
null);
chooser.show();
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogData.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogData.java
index ec22ccfe7431..56deb18e4dc9 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogData.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogData.java
@@ -92,7 +92,7 @@ public class VcsLogData implements Disposable, VcsLogDataProvider {
@NotNull private final VcsLogIndex myIndex;
@NotNull private final Object myLock = new Object();
- private boolean myInitialized = false;
+ @NotNull private State myState = State.CREATED;
@Nullable private SingleTaskController.SingleTask myInitialization = null;
public VcsLogData(@NotNull Project project,
@@ -164,8 +164,8 @@ public class VcsLogData implements Disposable, VcsLogDataProvider {
public void initialize() {
synchronized (myLock) {
- if (!myInitialized) {
- myInitialized = true;
+ if (myState.equals(State.CREATED)) {
+ myState = State.INITIALIZED;
StopWatch stopWatch = StopWatch.start("initialize");
Task.Backgroundable backgroundable = new Task.Backgroundable(myProject, "Loading History...", false) {
@Override
@@ -179,9 +179,38 @@ public class VcsLogData implements Disposable, VcsLogDataProvider {
}
@Override
- public void onFinished() {
+ public void onCancel() {
synchronized (myLock) {
- myInitialization = null;
+ // Here be dragons:
+ // VcsLogProgressManager can cancel us when it's getting disposed,
+ // and we can also get cancelled by invalid git executable.
+ // Since we do not know what's up, we just restore the state
+ // and it is entirely possible to start another initialization after that.
+ // Eventually, everything gets cancelled for good in VcsLogData.dispose.
+ // But still.
+ if (myState.equals(State.INITIALIZED)) {
+ myState = State.CREATED;
+ myInitialization = null;
+ }
+ }
+ }
+
+ @Override
+ public void onThrowable(@NotNull Throwable error) {
+ synchronized (myLock) {
+ if (myState.equals(State.INITIALIZED)) {
+ myState = State.CREATED;
+ myInitialization = null;
+ }
+ }
+ }
+
+ @Override
+ public void onSuccess() {
+ synchronized (myLock) {
+ if (myState.equals(State.INITIALIZED)) {
+ myInitialization = null;
+ }
}
}
};
@@ -291,6 +320,7 @@ public class VcsLogData implements Disposable, VcsLogDataProvider {
* @param roots roots to refresh
*/
public void refreshSoftly(@NotNull Set roots) {
+ initialize();
myRefresher.refresh(roots);
}
@@ -299,6 +329,7 @@ public class VcsLogData implements Disposable, VcsLogDataProvider {
* This refresh can be optimized, i. e. it can query VCS just for the part of the log.
*/
public void refresh(@NotNull Collection roots) {
+ initialize();
myRefresher.refresh(roots);
}
@@ -318,7 +349,7 @@ public class VcsLogData implements Disposable, VcsLogDataProvider {
synchronized (myLock) {
initialization = myInitialization;
myInitialization = null;
- myInitialized = true;
+ myState = State.DISPOSED;
}
if (initialization != null) {
@@ -357,4 +388,8 @@ public class VcsLogData implements Disposable, VcsLogDataProvider {
public VcsLogIndex getIndex() {
return myIndex;
}
+
+ private enum State {
+ CREATED, INITIALIZED, DISPOSED
+ }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/PostponableLogRefresher.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/PostponableLogRefresher.java
index 957658282e45..eb63c46ed88b 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/PostponableLogRefresher.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/PostponableLogRefresher.java
@@ -48,7 +48,7 @@ public class PostponableLogRefresher implements VcsLogRefresher {
@NotNull
public Disposable addLogWindow(@NotNull VcsLogWindow window) {
myLogWindows.add(window);
- filtererActivated(window.getRefresher(), true);
+ refresherActivated(window.getRefresher(), true);
return () -> myLogWindows.remove(window);
}
@@ -73,7 +73,9 @@ public class PostponableLogRefresher implements VcsLogRefresher {
return false;
}
- public void filtererActivated(@NotNull VisiblePackRefresher refresher, boolean firstTime) {
+ public void refresherActivated(@NotNull VisiblePackRefresher refresher, boolean firstTime) {
+ myLogData.initialize();
+
if (!myRootsToRefresh.isEmpty()) {
refreshPostponedRoots();
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogTabsWatcher.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogTabsWatcher.java
index b233acf188bf..69bc923ecbdd 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogTabsWatcher.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogTabsWatcher.java
@@ -146,7 +146,7 @@ public class VcsLogTabsWatcher implements Disposable {
VcsLogWindow logWindow = ContainerUtil.find(myRefresher.getLogWindows(),
window -> window instanceof VcsLogTab && ((VcsLogTab)window).myTabName.equals(tabName));
if (logWindow != null) {
- myRefresher.filtererActivated(logWindow.getRefresher(), false);
+ myRefresher.refresherActivated(logWindow.getRefresher(), false);
}
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java
index 00495185a9fa..4166bac32441 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java
@@ -1,6 +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-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.
package com.intellij.xdebugger.impl;
import com.intellij.execution.ui.ConsoleView;
@@ -52,6 +50,7 @@ import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
import com.intellij.xdebugger.impl.breakpoints.ui.grouping.XBreakpointFileGroupingRule;
import com.intellij.xdebugger.impl.evaluate.quick.common.ValueLookupManager;
+import com.intellij.xdebugger.impl.frame.XStackFrameContainerEx;
import com.intellij.xdebugger.impl.settings.XDebuggerSettingManagerImpl;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
@@ -541,7 +540,7 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
public void logStack(@NotNull XSuspendContext suspendContext, @NotNull XDebugSession session) {
XExecutionStack activeExecutionStack = suspendContext.getActiveExecutionStack();
if (activeExecutionStack != null) {
- activeExecutionStack.computeStackFrames(0, new XExecutionStack.XStackFrameContainer() {
+ activeExecutionStack.computeStackFrames(0, new XStackFrameContainerEx() {
List myFrames = new ArrayList<>();
@Override
@@ -552,6 +551,11 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
}
}
+ @Override
+ public void addStackFrames(@NotNull List extends XStackFrame> stackFrames, @Nullable XStackFrame toSelect, boolean last) {
+ addStackFrames(stackFrames, last);
+ }
+
@Override
public void errorOccurred(@NotNull String errorMessage) {
print(errorMessage);
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ImplicitArrayToStringInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ImplicitArrayToStringInspection.java
index 7e0df264053e..dda54ad08cb1 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ImplicitArrayToStringInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ImplicitArrayToStringInspection.java
@@ -201,21 +201,13 @@ public class ImplicitArrayToStringInspection extends BaseInspection {
registerError(expression, expression, Boolean.FALSE);
}
- private static boolean isExplicitArrayToStringCall(
- PsiMethodCallExpression expression) {
- final PsiReferenceExpression methodExpression =
- expression.getMethodExpression();
+ private static boolean isExplicitArrayToStringCall(PsiMethodCallExpression expression) {
+ final PsiReferenceExpression methodExpression = expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
- if (!HardcodedMethodConstants.TO_STRING.equals(methodName)) {
+ if (!HardcodedMethodConstants.TO_STRING.equals(methodName) || !expression.getArgumentList().isEmpty()) {
return false;
}
- final PsiExpressionList argumentList = expression.getArgumentList();
- final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 0) {
- return false;
- }
- final PsiExpression qualifier =
- methodExpression.getQualifierExpression();
+ final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (qualifier == null) {
return false;
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/MismatchedArrayReadWriteInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/MismatchedArrayReadWriteInspection.java
index 396c5e5663ab..71b75d0f785e 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/MismatchedArrayReadWriteInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/MismatchedArrayReadWriteInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2017 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2018 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -174,6 +174,9 @@ public class MismatchedArrayReadWriteInspection extends BaseInspection {
}
return true;
}
+ else if (expression instanceof PsiLiteralExpression) {
+ return false;
+ }
return true;
}
@@ -235,7 +238,8 @@ public class MismatchedArrayReadWriteInspection extends BaseInspection {
if (parent instanceof PsiArrayAccessExpression) {
PsiArrayAccessExpression arrayAccessExpression = (PsiArrayAccessExpression)parent;
parent = getParent(parent);
- while (parent instanceof PsiArrayAccessExpression) {
+ while (parent instanceof PsiArrayAccessExpression &&
+ ((PsiArrayAccessExpression)parent).getArrayExpression() == arrayAccessExpression) {
arrayAccessExpression = (PsiArrayAccessExpression)parent;
parent = getParent(parent);
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ObjectToStringInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ObjectToStringInspection.java
index f740e24c27a5..1e7068a80aee 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ObjectToStringInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ObjectToStringInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2018 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,9 +103,7 @@ public class ObjectToStringInspection extends BaseInspection {
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
@NonNls final String name = methodExpression.getReferenceName();
if (HardcodedMethodConstants.TO_STRING.equals(name)) {
- final PsiExpressionList argumentList = expression.getArgumentList();
- final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 0) {
+ if (!expression.getArgumentList().isEmpty()) {
return;
}
final PsiExpression qualifier = methodExpression.getQualifierExpression();
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ParameterClassCheckVisitor.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ParameterClassCheckVisitor.java
index 986d6daee600..16ed75ade3da 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ParameterClassCheckVisitor.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ParameterClassCheckVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2018 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,12 +79,7 @@ class ParameterClassCheckVisitor extends JavaRecursiveElementWalkingVisitor {
private boolean isGetClassCall(PsiMethodCallExpression methodCallExpression) {
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
- if (!HardcodedMethodConstants.GET_CLASS.equals(methodName)) {
- return false;
- }
- final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
- final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 0) {
+ if (!HardcodedMethodConstants.GET_CLASS.equals(methodName) || !methodCallExpression.getArgumentList().isEmpty()) {
return false;
}
final PsiMethod method = methodCallExpression.resolveMethod();
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/UseOfCloneInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/UseOfCloneInspection.java
index 544975a4d099..ecc0c4c4fbaa 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/UseOfCloneInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/UseOfCloneInspection.java
@@ -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-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.
package com.siyeh.ig.cloneable;
import com.intellij.psi.*;
@@ -63,12 +49,7 @@ public class UseOfCloneInspection extends BaseInspection {
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
final String referenceName = methodExpression.getReferenceName();
- if (!HardcodedMethodConstants.CLONE.equals(referenceName)) {
- return;
- }
- final PsiExpressionList argumentList = expression.getArgumentList();
- final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 0) {
+ if (!HardcodedMethodConstants.CLONE.equals(referenceName) || !expression.getArgumentList().isEmpty()) {
return;
}
final PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java
index e48499935057..c7a998e339e3 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Bas Leijdekkers
+ * Copyright 2011-2018 Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,17 +47,13 @@ public class NewExceptionWithoutArgumentsInspection extends BaseInspection {
return new NewExceptionWithoutArgumentsVisitor();
}
- private class NewExceptionWithoutArgumentsVisitor extends BaseInspectionVisitor {
+ private static class NewExceptionWithoutArgumentsVisitor extends BaseInspectionVisitor {
@Override
public void visitNewExpression(PsiNewExpression expression) {
super.visitNewExpression(expression);
final PsiExpressionList argumentList = expression.getArgumentList();
- if (argumentList == null) {
- return;
- }
- final PsiExpression[] expressions = argumentList.getExpressions();
- if (expressions.length != 0) {
+ if (argumentList == null || !argumentList.isEmpty()) {
return;
}
final PsiJavaCodeReferenceElement classReference = expression.getClassReference();
@@ -77,7 +73,7 @@ public class NewExceptionWithoutArgumentsInspection extends BaseInspection {
}
}
- private boolean hasAccessibleConstructorWithParameters(PsiClass aClass, PsiElement context) {
+ private static boolean hasAccessibleConstructorWithParameters(PsiClass aClass, PsiElement context) {
final PsiMethod[] constructors = aClass.getConstructors();
for (PsiMethod constructor : constructors) {
final PsiParameterList parameterList = constructor.getParameterList();
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/MissingOverrideAnnotationInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/MissingOverrideAnnotationInspection.java
index 61d584af67d5..44fb180adc50 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/MissingOverrideAnnotationInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/MissingOverrideAnnotationInspection.java
@@ -32,11 +32,11 @@ import java.util.stream.Stream;
public class MissingOverrideAnnotationInspection extends AbstractBaseJavaLocalInspectionTool implements CleanupLocalInspectionTool{
private static final String OVERRIDE_SHORT_NAME = StringUtil.getShortName(CommonClassNames.JAVA_LANG_OVERRIDE);
- @SuppressWarnings({"PublicField"})
+ @SuppressWarnings("PublicField")
public boolean ignoreObjectMethods = true;
- @SuppressWarnings({"PublicField"})
- public boolean ignoreAnonymousClassMethods = false;
+ @SuppressWarnings("PublicField")
+ public boolean ignoreAnonymousClassMethods;
@Override
@NotNull
@@ -75,7 +75,7 @@ public class MissingOverrideAnnotationInspection extends AbstractBaseJavaLocalIn
}
/**
- * @deprecated. To be removed in 2019.1.
+ * @deprecated To be removed in 2019.1.
*/
@Deprecated
@SuppressWarnings("unused")
@@ -84,7 +84,7 @@ public class MissingOverrideAnnotationInspection extends AbstractBaseJavaLocalIn
}
/**
- * @deprecated. To be removed in 2019.1.
+ * @deprecated To be removed in 2019.1.
*/
@Deprecated
protected BaseInspectionVisitor buildVisitor() {
@@ -137,17 +137,7 @@ public class MissingOverrideAnnotationInspection extends AbstractBaseJavaLocalIn
InspectionGadgetsBundle.message(result.requireAnnotation
? "missing.override.annotation.problem.descriptor"
: "missing.override.annotation.in.overriding.problem.descriptor"),
- new AnnotateMethodFix(CommonClassNames.JAVA_LANG_OVERRIDE) {
- @Override
- protected boolean annotateSelf() {
- return result.requireAnnotation;
- }
-
- @Override
- protected boolean annotateOverriddenMethods() {
- return result.hierarchyAnnotated == ThreeState.NO;
- }
- });
+ createAnnotateFix(result.requireAnnotation, result.hierarchyAnnotated));
}
}
@@ -236,8 +226,23 @@ public class MissingOverrideAnnotationInspection extends AbstractBaseJavaLocalIn
};
}
+ @NotNull
+ private static AnnotateMethodFix createAnnotateFix(final boolean requireAnnotation, final ThreeState hierarchyAnnotated) {
+ return new AnnotateMethodFix(CommonClassNames.JAVA_LANG_OVERRIDE) {
+ @Override
+ protected boolean annotateSelf() {
+ return requireAnnotation;
+ }
+
+ @Override
+ protected boolean annotateOverriddenMethods() {
+ return hierarchyAnnotated == ThreeState.NO;
+ }
+ };
+ }
+
private static class InspectionResult {
- private boolean requireAnnotation = false;
+ private boolean requireAnnotation;
private ThreeState hierarchyAnnotated = ThreeState.UNSURE;
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javabeans/PropertyValueSetToItselfInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javabeans/PropertyValueSetToItselfInspection.java
index 2407842e954c..f8b499b94837 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javabeans/PropertyValueSetToItselfInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javabeans/PropertyValueSetToItselfInspection.java
@@ -1,18 +1,4 @@
-/*
- * 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.
- */
+// 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.
package com.siyeh.ig.javabeans;
import com.intellij.psi.*;
@@ -63,9 +49,7 @@ public class PropertyValueSetToItselfInspection extends BaseInspection {
return;
}
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)argument;
- final PsiExpressionList argumentList2 = methodCallExpression.getArgumentList();
- final PsiExpression[] arguments2 = argumentList2.getExpressions();
- if (arguments2.length != 0) {
+ if (!methodCallExpression.getArgumentList().isEmpty()) {
return;
}
final PsiReferenceExpression methodExpression1 = expression.getMethodExpression();
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/ForCanBeForeachInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/ForCanBeForeachInspectionBase.java
index 48c994ccd518..588e8e8a3dec 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/ForCanBeForeachInspectionBase.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/ForCanBeForeachInspectionBase.java
@@ -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-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.
package com.siyeh.ig.migration;
import com.intellij.psi.*;
@@ -213,9 +199,7 @@ public class ForCanBeForeachInspectionBase extends BaseInspection {
if (!HardcodedMethodConstants.ITERATOR.equals(initialCallName) && !"listIterator".equals(initialCallName)) {
return false;
}
- final PsiExpressionList argumentList = initialCall.getArgumentList();
- final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 0) {
+ if (!initialCall.getArgumentList().isEmpty()) {
return false;
}
final PsiExpression qualifier = ExpressionUtils.getQualifierOrThis(initialMethodExpression);
@@ -281,9 +265,7 @@ public class ForCanBeForeachInspectionBase extends BaseInspection {
return false;
}
final PsiMethodCallExpression call = (PsiMethodCallExpression)condition;
- final PsiExpressionList argumentList = call.getArgumentList();
- final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 0) {
+ if (!call.getArgumentList().isEmpty()) {
return false;
}
final PsiReferenceExpression methodExpression = call.getMethodExpression();
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/WhileCanBeForeachInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/WhileCanBeForeachInspectionBase.java
index 3a7da3fc6adb..e841d85d748f 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/WhileCanBeForeachInspectionBase.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/WhileCanBeForeachInspectionBase.java
@@ -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-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.
package com.siyeh.ig.migration;
import com.intellij.psi.*;
@@ -111,9 +97,7 @@ public class WhileCanBeForeachInspectionBase extends BaseInspection {
return false;
}
final PsiMethodCallExpression initialCall = (PsiMethodCallExpression)initialValue;
- final PsiExpressionList argumentList = initialCall.getArgumentList();
- final PsiExpression[] argument = argumentList.getExpressions();
- if (argument.length != 0) {
+ if (!initialCall.getArgumentList().isEmpty()) {
return false;
}
final PsiReferenceExpression initialMethodExpression = initialCall.getMethodExpression();
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspectionBase.java
index d8bc3908d56c..d44a8be2188d 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspectionBase.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspectionBase.java
@@ -18,6 +18,7 @@ package com.siyeh.ig.performance;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.OverridingMethodsSearch;
import com.intellij.psi.util.PropertyUtil;
+import com.intellij.psi.util.PropertyUtilBase;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.Query;
import com.siyeh.InspectionGadgetsBundle;
@@ -60,6 +61,13 @@ public class CallToSimpleGetterInClassInspectionBase extends BaseInspection {
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
super.visitMethodCallExpression(call);
+
+ String referenceName = call.getMethodExpression().getReferenceName();
+ if (referenceName == null ||
+ PropertyUtilBase.getMethodNameGetterFlavour(referenceName) == PropertyUtilBase.GetterFlavour.NOT_A_GETTER) {
+ return;
+ }
+
final PsiClass containingClass = ClassUtils.getContainingClass(call);
if (containingClass == null) {
return;
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InstantiatingObjectToGetClassObjectInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InstantiatingObjectToGetClassObjectInspection.java
index f7d034ecaa91..6f3ebe3e6212 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InstantiatingObjectToGetClassObjectInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InstantiatingObjectToGetClassObjectInspection.java
@@ -120,12 +120,7 @@ public class InstantiatingObjectToGetClassObjectInspection
expression.getMethodExpression();
@NonNls final String methodName =
methodExpression.getReferenceName();
- if (!"getClass".equals(methodName)) {
- return;
- }
- final PsiExpressionList argumentList = expression.getArgumentList();
- final PsiExpression[] args = argumentList.getExpressions();
- if (args.length != 0) {
+ if (!"getClass".equals(methodName) || !expression.getArgumentList().isEmpty()) {
return;
}
final PsiExpression qualifier =
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/StringBufferMustHaveInitialCapacityInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/StringBufferMustHaveInitialCapacityInspection.java
index ebc8c448f1fd..c30978d785f2 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/StringBufferMustHaveInitialCapacityInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/StringBufferMustHaveInitialCapacityInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2018 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,11 +65,7 @@ public class StringBufferMustHaveInitialCapacityInspection
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
- if (argumentList == null) {
- return;
- }
- final PsiExpression[] args = argumentList.getExpressions();
- if (args.length != 0) {
+ if (argumentList == null || !argumentList.isEmpty()) {
return;
}
registerNewExpressionError(expression);
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/ThreadingUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/ThreadingUtils.java
index e4df1f001605..681a38335d6d 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/ThreadingUtils.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/ThreadingUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2018 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,9 +80,7 @@ class ThreadingUtils {
if (!"signal".equals(methodName) && !"signalAll".equals(methodName)) {
return false;
}
- final PsiExpressionList argumentList = expression.getArgumentList();
- final PsiExpression[] args = argumentList.getExpressions();
- if (args.length != 0) {
+ if (!expression.getArgumentList().isEmpty()) {
return false;
}
final PsiMethod method = expression.resolveMethod();
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/migration/ForCanBeForeachInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/migration/ForCanBeForeachInspection.java
index f39ad14714ac..230007ba6718 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/migration/ForCanBeForeachInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/migration/ForCanBeForeachInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2017 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2018 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -749,12 +749,8 @@ public class ForCanBeForeachInspection extends ForCanBeForeachInspectionBase {
if (!(element instanceof PsiMethodCallExpression)) {
return false;
}
- final PsiMethodCallExpression callExpression =
- (PsiMethodCallExpression)element;
- final PsiExpressionList argumentList =
- callExpression.getArgumentList();
- final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 0) {
+ final PsiMethodCallExpression callExpression = (PsiMethodCallExpression)element;
+ if (!callExpression.getArgumentList().isEmpty()) {
return false;
}
final PsiReferenceExpression reference =
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/SizeReplaceableByIsEmptyInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/SizeReplaceableByIsEmptyInspection.java
index 49e6d49c508e..7d35fe68211d 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/style/SizeReplaceableByIsEmptyInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/SizeReplaceableByIsEmptyInspection.java
@@ -150,9 +150,7 @@ public class SizeReplaceableByIsEmptyInspection extends BaseInspection {
if (!HardcodedMethodConstants.SIZE.equals(referenceName) && !HardcodedMethodConstants.LENGTH.equals(referenceName)) {
return;
}
- final PsiExpressionList argumentList = callExpression.getArgumentList();
- final PsiExpression[] expressions = argumentList.getExpressions();
- if (expressions.length != 0) {
+ if (!callExpression.getArgumentList().isEmpty()) {
return;
}
final PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/implicit_array_to_string/ImplicitArrayToString.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/implicit_array_to_string/ImplicitArrayToString.java
index 7a6be2a9cb40..741ff3e8d28a 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/implicit_array_to_string/ImplicitArrayToString.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/implicit_array_to_string/ImplicitArrayToString.java
@@ -3,19 +3,16 @@ package com.siyeh.igtest.bugs.implicit_array_to_string;
import java.io.PrintWriter;
import java.util.Formatter;
-
-
-
public class ImplicitArrayToString {
void foo() {
String[] interfaces = {"java/util/Set", "java/util/List"};
- System.out.println("interfaces: " + interfaces); // triggered
+ System.out.println("interfaces: " + interfaces ); // triggered
System.out.printf("interfaces: %s\n", interfaces); // not triggered
- System.out.printf("interfaces: %s, count: %s", interfaces, "2");
+ System.out.printf("interfaces: %s, count: %s", interfaces , "2");
String.format("interfaces: %s\n", interfaces);
- String.format("interfaces: %s, count: %s", interfaces, "2");
- new Formatter().format("interfaces: %s\n", interfaces);
+ String.format("interfaces: %s, count: %s", interfaces , "2");
+ new Formatter().format("interfaces: %s\n", interfaces);
new PrintWriter(System.out).format("interfaces: %s\n", interfaces);
}
@@ -26,7 +23,7 @@ public class ImplicitArrayToString {
}
private String bar(int[] array) {
- return String.valueOf(array) + array.toString();
+ return String.valueOf(array ) + array.toString ();
}
private void noWarnOnCharArrays(char[] cs) {
@@ -35,14 +32,14 @@ public class ImplicitArrayToString {
}
private void warnOnStringBuilderAppend(int[] is) {
- new StringBuilder().append(is); // calls String.valueOf
+ new StringBuilder().append(is ); // calls String.valueOf
}
void foo2() {
- System.out.println("new String[10]" + new String[10]);
+ System.out.println("new String[10]" + new String[10] );
final String[] var = new String[10];
- System.out.println("new String[10]" + var);
- System.out.println("new String[10]" + meth());
+ System.out.println("new String[10]" + var );
+ System.out.println("new String[10]" + meth() );
}
private String[] meth() {
@@ -52,10 +49,10 @@ public class ImplicitArrayToString {
public static void main(String[] args) {
char[] charArray = new char[]{'A', 'B', 'C'};
System.out.println(charArray); // should not warn
- System.out.println(args); // should indeed warn
+ System.out.println(args ); // should indeed warn
}
void concatenation(int[] is) {
- String s = "string" + is + "string";
+ String s = "string" + is + "string";
}
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/implicit_array_to_string/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/implicit_array_to_string/expected.xml
deleted file mode 100644
index 5aba5b469e34..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/implicit_array_to_string/expected.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
- ImplicitArrayToString.java
- 13
- Implicit call to array '.toString()'
- Implicit call to 'toString()' on array <code>interfaces</code>
-
-
-
-
- ImplicitArrayToString.java
- 15
- Implicit call to array '.toString()'
- Implicit call to 'toString()' on array <code>interfaces</code>
-
-
-
-
- ImplicitArrayToString.java
- 17
- Implicit call to array '.toString()'
- Implicit call to 'toString()' on array <code>interfaces</code>
-
-
-
- ImplicitArrayToString.java
- 29
- Call to 'toString()' on array
- Implicit call to 'toString()' on array <code>array</code> #loc
-
-
-
- ImplicitArrayToString.java
- 29
- Call to 'toString()' on array
- Call to 'toString()' on array #loc
-
-
-
- ImplicitArrayToString.java
- 38
- Call to 'toString()' on array
- Implicit call to 'toString()' on array <code>is</code> #loc
-
-
-
- ImplicitArrayToString.java
- 42
- Call to 'toString()' on array
- Implicit call to 'toString()' on array <code>new String[10]</code> #loc
-
-
-
-
- ImplicitArrayToString.java
- 44
- Call to 'toString()' on array
- Implicit call to 'toString()' on array <code>var</code> #loc
-
-
-
-
- ImplicitArrayToString.java
- 45
- Call to 'toString()' on array
- Implicit call to 'toString()' on array returned by call to <code>meth()</code> #loc
-
-
-
- ImplicitArrayToString.java
- 55
- Call to 'toString()' on array
- Implicit call to 'toString()' on array <code>args</code> #loc
-
-
-
- ImplicitArrayToString.java
- 59
- Call to 'toString()' on array
- Implicit call to 'toString()' on array <code>is</code> #loc
-
-
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_array_read_write/MismatchedArrayReadWrite.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_array_read_write/MismatchedArrayReadWrite.java
index 167fdd57dbb9..5226c1bc66e0 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_array_read_write/MismatchedArrayReadWrite.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_array_read_write/MismatchedArrayReadWrite.java
@@ -263,4 +263,23 @@ class ParentRecorder {
public void treeEdge(int e, int g) {
parents[e] = g;
}
+}
+class Example {
+ private final int[] reducedToFull;
+ Example() {
+ reducedToFull = new int[]{1, 2, 4};
+ reducedToFull[2] = 3;
+ }
+ void method(String[] fullOrders, String[] reducedOrders) {
+ for (int j = 0; j < reducedOrders.length; j++) {
+ fullOrders[reducedToFull[j]] = reducedOrders[j];
+ }
+ }
+}
+class Example2 {
+ private final int[] is ;
+ Example2() {
+ is = new int[] {36, 42, 12};
+ is[1] = 27;
+ }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java
index f563cab3b3c1..bbe52a55c2a9 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java
@@ -3,7 +3,7 @@ package com.siyeh.igtest.errorhandling.new_exception_without_arguments;
class NewExceptionWithoutArguments {
void foo() {
- throw new RuntimeException();
+ throw new RuntimeException ();
}
void bar() {
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml
deleted file mode 100644
index 3d60c6a05598..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- NewExceptionWithoutArguments.java
- 6
- Exception constructor called without arguments
- <code>new RuntimeException()</code> without arguments #loc
-
-
-
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ImplicitArrayToStringInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ImplicitArrayToStringInspectionTest.java
index 16a22226a77e..4a197aeb4cc3 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ImplicitArrayToStringInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ImplicitArrayToStringInspectionTest.java
@@ -1,11 +1,42 @@
+// 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.
package com.siyeh.ig.bugs;
-import com.siyeh.ig.IGInspectionTestCase;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
-public class ImplicitArrayToStringInspectionTest extends IGInspectionTestCase {
+public class ImplicitArrayToStringInspectionTest extends LightInspectionTestCase {
- public void test() {
- doTest("com/siyeh/igtest/bugs/implicit_array_to_string",
- new ImplicitArrayToStringInspection());
+ public void testImplicitArrayToString() {
+ doTest();
+ }
+
+ @Nullable
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ return new ImplicitArrayToStringInspection();
+ }
+
+ @Override
+ protected String[] getEnvironmentClasses() {
+ return new String[] {
+ "package java.util;" +
+ "public class Formatter {" +
+ " public Formatter format(Locale l, String format, Object ... args) {" +
+ " return null;" +
+ " }" +
+ " public Formatter format(String format, Object ... args) {" +
+ " return null;" +
+ " }" +
+ "}",
+
+ "package java.io;" +
+ "public class PrintWriter extends Writer {" +
+ " public PrintWriter(OutputStream out) {}" +
+ " public PrintWriter format(String format, Object ... args) {" +
+ " return null;" +
+ " }" +
+ "}"
+ };
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java
index a2c90da22966..764991a86ca5 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java
@@ -1,12 +1,19 @@
+// 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.
package com.siyeh.ig.errorhandling;
-import com.siyeh.ig.IGInspectionTestCase;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
-public class NewExceptionWithoutArgumentsInspectionTest extends IGInspectionTestCase {
+public class NewExceptionWithoutArgumentsInspectionTest extends LightInspectionTestCase {
- public void test() {
- final NewExceptionWithoutArgumentsInspection tool = new NewExceptionWithoutArgumentsInspection();
- doTest("com/siyeh/igtest/errorhandling/new_exception_without_arguments", tool);
+ public void testNewExceptionWithoutArguments() {
+ doTest();
}
+ @Nullable
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ return new NewExceptionWithoutArgumentsInspection();
+ }
}
diff --git a/plugins/copyright/src/com/intellij/copyright/CopyrightManager.kt b/plugins/copyright/src/com/intellij/copyright/CopyrightManager.kt
index 04c50c4f90b9..da4c6e7e98b6 100644
--- a/plugins/copyright/src/com/intellij/copyright/CopyrightManager.kt
+++ b/plugins/copyright/src/com/intellij/copyright/CopyrightManager.kt
@@ -82,8 +82,13 @@ class CopyrightManager @JvmOverloads constructor(private val project: Project, s
override fun isSchemeFile(name: CharSequence) = !StringUtil.equals(name, "profiles_settings.xml")
- override fun getSchemeKey(attributeProvider: Function, fileNameWithoutExtension: String): String? {
- return super.getSchemeKey(attributeProvider, fileNameWithoutExtension) ?: fileNameWithoutExtension
+ override fun getSchemeKey(attributeProvider: Function, fileNameWithoutExtension: String): String {
+ val schemeKey = super.getSchemeKey(attributeProvider, fileNameWithoutExtension)
+ if (schemeKey != null) {
+ return schemeKey
+ }
+ LOG.warn("Name is not specified for scheme $fileNameWithoutExtension, file name will be used instead")
+ return fileNameWithoutExtension
}
}, schemeNameToFileName = OLD_NAME_CONVERTER, streamProvider = schemeManagerIprProvider)
diff --git a/plugins/devkit/src/testAssistant/TestDataReferenceContributor.java b/plugins/devkit/src/testAssistant/TestDataReferenceContributor.java
index 4034a6ee70f3..927f196b2521 100644
--- a/plugins/devkit/src/testAssistant/TestDataReferenceContributor.java
+++ b/plugins/devkit/src/testAssistant/TestDataReferenceContributor.java
@@ -70,7 +70,8 @@ public class TestDataReferenceContributor extends PsiReferenceContributor {
//ideally `literalExpression.getValue()` should be the right value for `stringValue`, but something is wrong with Kotlin
String stringValue;
if (literalExpression.getSourcePsi() == host) {
- stringValue = range.substring(host.getText());
+ stringValue = UastLiteralUtils.getValueIfStringLiteral(literalExpression);
+ if (stringValue == null) return PsiReference.EMPTY_ARRAY;
}
else {
StringBuilder chars = new StringBuilder();
@@ -87,7 +88,7 @@ public class TestDataReferenceContributor extends PsiReferenceContributor {
}
private static class TestDataReferenceSet extends FileReferenceSet {
- public TestDataReferenceSet(String str,
+ public TestDataReferenceSet(@NotNull String str,
@NotNull PsiElement element,
int startInElement,
@Nullable PsiReferenceProvider provider,
diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java
index 090afd44a4b5..47bbbd3f2d67 100644
--- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java
+++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java
@@ -13,13 +13,16 @@ import com.intellij.psi.scope.NameHint;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
+import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyLanguage;
+import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumDefinitionBody;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumTypeDefinition;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstantList;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
@@ -146,4 +149,24 @@ public class GrEnumTypeDefinitionImpl extends GrTypeDefinitionImpl implements Gr
public void accept(GroovyElementVisitor visitor) {
visitor.visitEnumDefinition(this);
}
+
+ @Override
+ public PsiElement add(@NotNull PsiElement psiElement) throws IncorrectOperationException {
+ if (!(psiElement instanceof GrEnumConstant)) return super.add(psiElement);
+ final GrTypeDefinitionBody body = getBody();
+ assert body != null;
+ GrEnumConstantList list = getEnumConstantList();
+ if (list != null) {
+ GrEnumConstant[] constants = list.getEnumConstants();
+ if (constants.length > 0) {
+ list.getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", null);
+ ASTNode elementNode = psiElement.getNode();
+ elementNode.addLeaf(TokenType.WHITE_SPACE, "\n", elementNode.getFirstChildNode());
+ return list.add(psiElement);
+ }
+ }
+
+ PsiElement brace = body.getLBrace();
+ return body.addAfter(psiElement, brace);
+ }
}
diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java
index 32069af4e48e..ff454dd1d457 100644
--- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java
+++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java
@@ -692,7 +692,7 @@ public abstract class GrTypeDefinitionImpl extends GrStubElementBase UElement?) : ULiteralExpression, JvmDeclarationUElement {
- override val value: Any?
- get() = grElement.value
+ override val value: Any? get() = grElement.value
+ override fun evaluate(): Any? = value
override val uastParent by lazy(parentProvider)
override val psi: PsiElement? = grElement
override val annotations: List = emptyList() //not implemented
@@ -85,6 +85,12 @@ class GrUNamedExpression(val grElement: GrAnnotationNameValuePair, val parentPro
override val psi = grElement
override val annotations: List = emptyList() //not implemented
+ override fun equals(other: Any?): Boolean {
+ if (other !is GrUNamedExpression) return false
+ return grElement == other.grElement
+ }
+
+ override fun hashCode(): Int = grElement.hashCode()
}
class GrUAnnotation(val grElement: GrAnnotation,
diff --git a/plugins/groovy/groovy-uast-tests/test/org/jetbrains/plugins/groovy/uast/GroovyUastApiTest.kt b/plugins/groovy/groovy-uast-tests/test/org/jetbrains/plugins/groovy/uast/GroovyUastApiTest.kt
index 580ea3376035..5282be94a93a 100644
--- a/plugins/groovy/groovy-uast-tests/test/org/jetbrains/plugins/groovy/uast/GroovyUastApiTest.kt
+++ b/plugins/groovy/groovy-uast-tests/test/org/jetbrains/plugins/groovy/uast/GroovyUastApiTest.kt
@@ -4,10 +4,9 @@
package org.jetbrains.plugins.groovy.uast
import junit.framework.TestCase
-import org.jetbrains.uast.UAnnotation
-import org.jetbrains.uast.UAnnotationEx
-import org.jetbrains.uast.UFile
+import org.jetbrains.uast.*
import org.jetbrains.uast.test.env.findElementByText
+import org.jetbrains.uast.test.env.findElementByTextFromPsi
import org.junit.Test
class GroovyUastApiTest : AbstractGroovyUastTest() {
@@ -34,4 +33,21 @@ class GroovyUastApiTest : AbstractGroovyUastTest() {
}
}
+ @Test
+ fun testStringLiteral() {
+ doTest("Annotations.groovy") { name, file ->
+ file.findElementByTextFromPsi("\"abc\"").let { literal ->
+ TestCase.assertTrue(literal.isStringLiteral())
+ TestCase.assertEquals("abc", literal.value)
+ TestCase.assertEquals("abc", literal.getValueIfStringLiteral())
+ }
+ file.findElementByTextFromPsi("123").let { literal ->
+ TestCase.assertFalse(literal.isStringLiteral())
+ TestCase.assertEquals(123, literal.value)
+ TestCase.assertEquals(null, literal.getValueIfStringLiteral())
+ }
+
+ }
+ }
+
}
\ No newline at end of file
diff --git a/plugins/groovy/groovy-uast-tests/test/org/jetbrains/plugins/groovy/uast/SimpleGroovyRenderingLogTest.kt b/plugins/groovy/groovy-uast-tests/test/org/jetbrains/plugins/groovy/uast/SimpleGroovyRenderingLogTest.kt
index 873c8dd72183..c1b6718e903c 100644
--- a/plugins/groovy/groovy-uast-tests/test/org/jetbrains/plugins/groovy/uast/SimpleGroovyRenderingLogTest.kt
+++ b/plugins/groovy/groovy-uast-tests/test/org/jetbrains/plugins/groovy/uast/SimpleGroovyRenderingLogTest.kt
@@ -14,4 +14,7 @@ class SimpleGroovyRenderingLogTest : AbstractGroovyRenderLogTest() {
@Test
fun testClassWithInners() = doTest("ClassWithInners.groovy")
+ @Test
+ fun testAnnotations() = doTest("Annotations.groovy")
+
}
\ No newline at end of file
diff --git a/plugins/groovy/groovy-uast-tests/testData/Annotations.groovy b/plugins/groovy/groovy-uast-tests/testData/Annotations.groovy
new file mode 100644
index 000000000000..d12b5582402b
--- /dev/null
+++ b/plugins/groovy/groovy-uast-tests/testData/Annotations.groovy
@@ -0,0 +1,12 @@
+@interface MyAnnotation {
+ String value()
+ String name() default ""
+ int count() default 0
+ Class> cls() default null
+}
+
+@MyAnnotation("abc")
+class A1{}
+
+@MyAnnotation(value = "ghi", name = "myName", count = 123, cls = String.class)
+class A3{}
\ No newline at end of file
diff --git a/plugins/groovy/groovy-uast-tests/testData/Annotations.log.txt b/plugins/groovy/groovy-uast-tests/testData/Annotations.log.txt
new file mode 100644
index 000000000000..f6968c324589
--- /dev/null
+++ b/plugins/groovy/groovy-uast-tests/testData/Annotations.log.txt
@@ -0,0 +1,20 @@
+UFile (package = )
+ UClass (name = MyAnnotation)
+ UMethod (name = value)
+ UMethod (name = name)
+ UMethod (name = count)
+ UMethod (name = cls)
+ UClass (name = A1)
+ UAnnotation (fqName = MyAnnotation)
+ UNamedExpression (name = null)
+ ULiteralExpression (value = "abc")
+ UClass (name = A3)
+ UAnnotation (fqName = MyAnnotation)
+ UNamedExpression (name = value)
+ ULiteralExpression (value = "ghi")
+ UNamedExpression (name = name)
+ ULiteralExpression (value = "myName")
+ UNamedExpression (name = count)
+ ULiteralExpression (value = 123)
+ UNamedExpression (name = cls)
+ UReferenceExpression
diff --git a/plugins/groovy/groovy-uast-tests/testData/Annotations.render.txt b/plugins/groovy/groovy-uast-tests/testData/Annotations.render.txt
new file mode 100644
index 000000000000..85a3430eb1da
--- /dev/null
+++ b/plugins/groovy/groovy-uast-tests/testData/Annotations.render.txt
@@ -0,0 +1,12 @@
+public abstract annotation MyAnnotation {
+ public abstract fun value() : java.lang.String = UastEmptyExpression
+ public abstract fun name() : java.lang.String = UastEmptyExpression
+ public abstract fun count() : int = UastEmptyExpression
+ public abstract fun cls() : java.lang.Class> = UastEmptyExpression
+}
+
+public class A1 {
+}
+
+public class A3 {
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateFieldFromUsageHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateFieldFromUsageHelper.java
index feb874b79eac..9a57a51f3d8f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateFieldFromUsageHelper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyCreateFieldFromUsageHelper.java
@@ -78,13 +78,13 @@ public class GroovyCreateFieldFromUsageHelper extends CreateFieldFromUsageHelper
}
@Override
- public PsiField insertFieldImpl(@NotNull PsiClass targetClass, @NotNull PsiField field, @Nullable PsiElement place) {
+ public GrField insertFieldImpl(@NotNull PsiClass targetClass, @NotNull PsiField field, @Nullable PsiElement place) {
if (targetClass instanceof GroovyScriptClass) {
PsiElement added = targetClass.getContainingFile().add(field.getParent());
- return (PsiField)((GrVariableDeclaration)added).getVariables()[0];
+ return (GrField)((GrVariableDeclaration)added).getVariables()[0];
}
else {
- return (PsiField)targetClass.add(field);
+ return (GrField)targetClass.add(field);
}
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateEnumConstantAction.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateEnumConstantAction.kt
new file mode 100644
index 000000000000..142e2d034169
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateEnumConstantAction.kt
@@ -0,0 +1,85 @@
+// 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.
+package org.jetbrains.plugins.groovy.annotator.intentions.elements
+
+import com.intellij.codeInsight.CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement
+import com.intellij.codeInsight.daemon.QuickFixBundle
+import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageBaseFix.positionCursor
+import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageBaseFix.startTemplate
+import com.intellij.codeInsight.daemon.impl.quickfix.EmptyExpression
+import com.intellij.codeInsight.template.TemplateBuilderImpl
+import com.intellij.lang.jvm.actions.CreateEnumConstantActionGroup
+import com.intellij.lang.jvm.actions.CreateFieldRequest
+import com.intellij.lang.jvm.actions.ExpectedTypes
+import com.intellij.lang.jvm.actions.JvmActionGroup
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.project.Project
+import com.intellij.psi.PsiFile
+import com.intellij.psi.util.PsiTreeUtil
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant
+
+internal class CreateEnumConstantAction(
+ target: GrTypeDefinition,
+ override val request: CreateFieldRequest
+) : CreateFieldActionBase(target, request) {
+
+ override fun getActionGroup(): JvmActionGroup = CreateEnumConstantActionGroup
+
+ override fun getText(): String = QuickFixBundle.message("create.enum.constant.from.usage.text", request.fieldName)
+
+ override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
+ val name = request.fieldName
+ val targetClass = target
+ val parameters = renderParameters(targetClass)
+ val text = if (parameters.isEmpty()) name else "$name($parameters)"
+ var enumConstant = renderConstant(project, text)
+
+ enumConstant = targetClass.add(enumConstant) as GrEnumConstant
+ if (parameters.isEmpty()) return
+
+ // start template
+ val builder = TemplateBuilderImpl(enumConstant)
+ val argumentList = enumConstant.argumentList!!
+ for (expression in argumentList.expressionArguments) {
+ builder.replaceElement(expression, EmptyExpression())
+ }
+ enumConstant = forcePsiPostprocessAndRestoreElement(enumConstant)
+ val template = builder.buildTemplate()
+
+ val newEditor = positionCursor(project, targetClass.containingFile, enumConstant) ?: return
+ val range = enumConstant.textRange
+ newEditor.document.deleteString(range.startOffset, range.endOffset)
+ startTemplate(newEditor, template, project)
+ }
+}
+
+internal fun renderConstant(project: Project, text: String): GrEnumConstant {
+ val elementFactory = GroovyPsiElementFactory.getInstance(project)
+ return elementFactory.createEnumConstantFromText(text)
+}
+
+internal fun renderParameters(targetClass: GrTypeDefinition): String {
+ val constructor = targetClass.constructors.firstOrNull() ?: return ""
+ val parameters = constructor.parameterList.parameters
+
+ return parameters.joinToString(",") { it.name ?: "" }
+}
+
+internal fun canCreateEnumConstant(targetClass: GrTypeDefinition, request: CreateFieldRequest): Boolean {
+ if (!targetClass.isEnum) return false
+
+ val lastConstant = targetClass.fields.filterIsInstance().lastOrNull()
+ if (lastConstant != null && PsiTreeUtil.hasErrorElements(lastConstant)) return false
+
+ return checkExpectedTypes(request.fieldType, targetClass, targetClass.project)
+}
+
+private fun checkExpectedTypes(types: ExpectedTypes, targetClass: GrTypeDefinition, project: Project): Boolean {
+ val constraints = createConstraints(project, types)
+ if (constraints.isEmpty()) return true
+ val enumType = GroovyPsiElementFactory.getInstance(project).createType(targetClass)
+ return constraints.any {
+ it.satisfied(enumType, targetClass)
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateFieldAction.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateFieldAction.kt
index fcec06175162..e651c53c9768 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateFieldAction.kt
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateFieldAction.kt
@@ -11,18 +11,22 @@ import com.intellij.lang.jvm.actions.*
import com.intellij.openapi.application.runWriteAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
-import com.intellij.psi.*
+import com.intellij.psi.PsiDocumentManager
+import com.intellij.psi.PsiFile
+import com.intellij.psi.PsiType
import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.psi.presentation.java.ClassPresentationUtil.getNameForClass
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.PsiUtil
import org.jetbrains.plugins.groovy.annotator.intentions.GroovyCreateFieldFromUsageHelper
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames
internal class CreateFieldAction(
- target: PsiClass,
+ target: GrTypeDefinition,
request: CreateFieldRequest,
private val constantField: Boolean
) : CreateFieldActionBase(target, request), JvmGroupIntentionAction {
@@ -53,7 +57,7 @@ internal val constantModifiers = setOf(
private class GroovyFieldRenderer(
val project: Project,
val constantField: Boolean,
- val targetClass: PsiClass,
+ val targetClass: GrTypeDefinition,
val request: CreateFieldRequest
) {
@@ -84,7 +88,7 @@ private class GroovyFieldRenderer(
startTemplate(field)
}
- private fun renderField(): PsiField {
+ private fun renderField(): GrField {
val elementFactory = GroovyPsiElementFactory.getInstance(project)
val field = elementFactory.createField(request.fieldName, PsiType.INT)
@@ -108,12 +112,12 @@ private class GroovyFieldRenderer(
return field
}
- private fun insertField(field: PsiField): PsiField {
+ private fun insertField(field: GrField): GrField {
return helper.insertFieldImpl(targetClass, field, null)
}
- private fun startTemplate(field: PsiField) {
+ private fun startTemplate(field: GrField) {
val targetFile = targetClass.containingFile ?: return
val newEditor = positionCursor(field.project, targetFile, field) ?: return
val substitutor = request.targetSubstitutor.toPsiSubstitutor(project)
@@ -128,7 +132,7 @@ private class MyTemplateListener(val project: Project, val editor: Editor, val f
override fun templateFinished(template: Template, brokenOff: Boolean) {
PsiDocumentManager.getInstance(project).commitDocument(editor.document)
val offset = editor.caretModel.offset
- val psiField = PsiTreeUtil.findElementOfClassAtOffset(file, offset, PsiField::class.java, false) ?: return
+ val psiField = PsiTreeUtil.findElementOfClassAtOffset(file, offset, GrField::class.java, false) ?: return
runWriteAction {
CodeStyleManager.getInstance(project).reformat(psiField)
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateFieldActionBase.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateFieldActionBase.kt
index be6491369066..118c1f1b5b04 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateFieldActionBase.kt
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateFieldActionBase.kt
@@ -5,10 +5,10 @@ import com.intellij.codeInsight.daemon.QuickFixBundle.message
import com.intellij.lang.jvm.actions.CreateFieldRequest
import com.intellij.lang.jvm.actions.JvmActionGroup
import com.intellij.lang.jvm.actions.JvmGroupIntentionAction
-import com.intellij.psi.PsiClass
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
internal abstract class CreateFieldActionBase(
- target: PsiClass,
+ target: GrTypeDefinition,
override val request: CreateFieldRequest
) : CreateMemberAction(target, request), JvmGroupIntentionAction {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateMemberAction.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateMemberAction.kt
index 902dacfdbf15..a13864cdc041 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateMemberAction.kt
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/CreateMemberAction.kt
@@ -6,13 +6,13 @@ import com.intellij.lang.jvm.JvmClass
import com.intellij.lang.jvm.actions.ActionRequest
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
-import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.util.createSmartPointer
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
internal abstract class CreateMemberAction(
- target: PsiClass,
+ target: GrTypeDefinition,
protected open val request: ActionRequest
) : IntentionAction {
@@ -22,7 +22,7 @@ internal abstract class CreateMemberAction(
return myTargetPointer.element != null && request.isValid
}
- protected val target: PsiClass
+ protected val target: GrTypeDefinition
get() = requireNotNull(myTargetPointer.element) {
"Don't access this property if isAvailable() returned false"
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/GroovyElementActionsFactory.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/GroovyElementActionsFactory.kt
index a0b07ed4fca9..bd24553c4f7e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/GroovyElementActionsFactory.kt
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/GroovyElementActionsFactory.kt
@@ -9,15 +9,19 @@ import com.intellij.openapi.util.text.StringUtil
class GroovyElementActionsFactory : JvmElementActionsFactory() {
override fun createAddFieldActions(targetClass: JvmClass, request: CreateFieldRequest): List {
- val javaClass = targetClass.toGroovyClassOrNull() ?: return emptyList()
+ val groovyClass = targetClass.toGroovyClassOrNull() ?: return emptyList()
val constantRequested = request.constant || javaClass.isInterface || request.modifiers.containsAll(constantModifiers)
val result = ArrayList()
if (constantRequested || StringUtil.isCapitalized(request.fieldName)) {
- result += CreateFieldAction(javaClass, request, true)
+ result += CreateFieldAction(groovyClass, request, true)
}
if (!constantRequested) {
- result += CreateFieldAction(javaClass, request, false)
+ result += CreateFieldAction(groovyClass, request, false)
+ }
+
+ if (canCreateEnumConstant(groovyClass, request)) {
+ result += CreateEnumConstantAction(groovyClass, request)
}
return result
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/jvmPsiUtil.kt b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/jvmPsiUtil.kt
index 37591c5e2b74..623bb7d247b0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/jvmPsiUtil.kt
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/elements/jvmPsiUtil.kt
@@ -7,8 +7,11 @@ import com.intellij.lang.jvm.actions.ExpectedType
import com.intellij.lang.jvm.actions.ExpectedTypes
import com.intellij.lang.jvm.types.JvmSubstitutor
import com.intellij.openapi.project.Project
-import com.intellij.psi.*
+import com.intellij.psi.JvmPsiConversionHelper
+import com.intellij.psi.PsiModifier
import com.intellij.psi.PsiModifier.ModifierConstant
+import com.intellij.psi.PsiSubstitutor
+import com.intellij.psi.PsiTypeParameter
import com.intellij.psi.impl.compiled.ClsClassImpl
import com.intellij.psi.impl.light.LightElement
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
@@ -39,7 +42,7 @@ internal fun JvmModifier.toPsiModifier(): String = when (this) {
*
* @return Java PsiClass or `null` if the receiver is not a Java PsiClass
*/
-internal fun JvmClass.toGroovyClassOrNull(): PsiClass? {
+internal fun JvmClass.toGroovyClassOrNull(): GrTypeDefinition? {
if (this !is GrTypeDefinition) return null
if (this is PsiTypeParameter) return null
if (this is ClsClassImpl) return null
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
index 867be3b76def..36fa061f5701 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
@@ -1,18 +1,4 @@
-/*
- * 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-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.
package org.jetbrains.plugins.groovy.lang.parameterInfo;
import com.intellij.codeInsight.lookup.LookupElement;
@@ -44,7 +30,7 @@ import java.util.Set;
public class GroovyAnnotationAttributeInfoHandler implements ParameterInfoHandlerWithTabActionSupport {
private static final Set ALLOWED_CLASSES = ContainerUtil.newHashSet(GrAnnotation.class);
- private static final Set> STOP_SEARCHING_CLASSES = Collections.singleton(GroovyFile.class);
+ private static final Set STOP_SEARCHING_CLASSES = Collections.singleton(GroovyFile.class);
@NotNull
@Override
@@ -72,7 +58,7 @@ public class GroovyAnnotationAttributeInfoHandler implements ParameterInfoHandle
@NotNull
@Override
- public Set extends Class> getArgListStopSearchClasses() {
+ public Set getArgListStopSearchClasses() {
return STOP_SEARCHING_CLASSES;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
index 53575d68adf9..c2933c8c26de 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
@@ -1,18 +1,4 @@
-/*
- * Copyright 2000-2013 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-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.
package org.jetbrains.plugins.groovy.lang.parameterInfo;
import com.intellij.codeInsight.CodeInsightSettings;
@@ -66,11 +52,11 @@ public class GroovyParameterInfoHandler implements ParameterInfoHandlerWithTabAc
return true;
}
- private static final Set extends Class> ourStopSearch = Collections.singleton(GrMethod.class);
+ private static final Set ourStopSearch = Collections.singleton(GrMethod.class);
@NotNull
@Override
- public Set extends Class> getArgListStopSearchClasses() {
+ public Set getArgListStopSearchClasses() {
return ourStopSearch;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
index 036d253471e3..665131f63ba9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
@@ -1,18 +1,4 @@
-/*
- * 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.
- */
+// 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.
package org.jetbrains.plugins.groovy.lang.parameterInfo;
import com.intellij.codeInsight.lookup.LookupElement;
@@ -68,7 +54,7 @@ public class GroovyTypeParameterInfoHandler implements ParameterInfoHandlerWithT
@NotNull
@Override
- public Set extends Class> getArgListStopSearchClasses() {
+ public Set getArgListStopSearchClasses() {
return STOP_SEARCHING_CLASSES;
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/fixes/CreateEnumConstantFromJavaUsageTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/fixes/CreateEnumConstantFromJavaUsageTest.groovy
new file mode 100644
index 000000000000..0b09fba41200
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/fixes/CreateEnumConstantFromJavaUsageTest.groovy
@@ -0,0 +1,73 @@
+// 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.
+
+package org.jetbrains.plugins.groovy.fixes
+
+import com.intellij.psi.impl.source.PostprocessReformattingAspect
+import groovy.transform.CompileStatic
+import org.jetbrains.plugins.groovy.lang.highlighting.GrHighlightingTestBase
+import org.jetbrains.plugins.groovy.util.TestUtils
+
+@CompileStatic
+class CreateEnumConstantFromJavaUsageTest extends GrHighlightingTestBase {
+ private static final String BEFORE = "Before.groovy"
+ private static final String AFTER = "After.groovy"
+ private static final String JAVA = "Area.java"
+ final String getBasePath() {
+ return TestUtils.testDataPath + 'fixes/createEnumConstantFromUsage/' + getTestName(true) + '/'
+ }
+
+ @Override
+ void setUp(){
+ super.setUp()
+ fixture.configureByFiles(JAVA, BEFORE)
+ fixture.enableInspections(customInspections)
+ }
+
+ private void doTest() {
+ fixture.with {
+ def fixes = filterAvailableIntentions('Create enum constant')
+ assert fixes.size() == 1
+ launchAction fixes.first()
+ PostprocessReformattingAspect.getInstance(project).doPostponedFormatting()
+ checkResultByFile(BEFORE, AFTER, true)
+ }
+ }
+
+ void testSimple() {
+ doTest()
+ }
+
+ void testSimple2() {
+ doTest()
+ }
+
+ void testEmptyEnum() {
+ doTest()
+ }
+
+ void testEmptyEnumWithMethods() {
+ doTest()
+ }
+
+ void testWithConstructorArguments() {
+ doTest()
+ }
+
+ void testWithStaticImport() {
+ doTest()
+ }
+
+ void testWithSwitch() {
+ doTest()
+ }
+
+ void testWithSwitch2() {
+ doTest()
+ }
+
+ void testWithVarargs() {
+ doTest()
+ }
+}
+
+
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/After.groovy
new file mode 100644
index 000000000000..0d10bae7ff08
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/After.groovy
@@ -0,0 +1,3 @@
+enum E {
+ EEE
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/Area.java
new file mode 100644
index 000000000000..279d578917a0
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/Area.java
@@ -0,0 +1,5 @@
+class C {
+ public void foo() {
+ E.EEE
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/Before.groovy
new file mode 100644
index 000000000000..0aeed819dc07
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnum/Before.groovy
@@ -0,0 +1,2 @@
+enum E {
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/After.groovy
new file mode 100644
index 000000000000..7fa6b20dc382
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/After.groovy
@@ -0,0 +1,5 @@
+enum E {
+ EEE
+
+ void bbar(){}
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/Area.java
new file mode 100644
index 000000000000..279d578917a0
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/Area.java
@@ -0,0 +1,5 @@
+class C {
+ public void foo() {
+ E.EEE
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/Before.groovy
new file mode 100644
index 000000000000..3252b7a625bc
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/emptyEnumWithMethods/Before.groovy
@@ -0,0 +1,3 @@
+enum E {
+ void bbar(){}
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/After.groovy
new file mode 100644
index 000000000000..ccf4af19156b
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/After.groovy
@@ -0,0 +1,4 @@
+enum E {
+ AAA,
+ EEE
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/Area.java
new file mode 100644
index 000000000000..279d578917a0
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/Area.java
@@ -0,0 +1,5 @@
+class C {
+ public void foo() {
+ E.EEE
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/Before.groovy
new file mode 100644
index 000000000000..863436657165
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple/Before.groovy
@@ -0,0 +1,3 @@
+enum E {
+ AAA
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/After.groovy
new file mode 100644
index 000000000000..35d7d812bcc1
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/After.groovy
@@ -0,0 +1,5 @@
+enum E {
+ AAA,
+ BBB,
+ EEE
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/Area.java
new file mode 100644
index 000000000000..279d578917a0
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/Area.java
@@ -0,0 +1,5 @@
+class C {
+ public void foo() {
+ E.EEE
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/Before.groovy
new file mode 100644
index 000000000000..17c2c184f761
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/simple2/Before.groovy
@@ -0,0 +1,4 @@
+enum E {
+ AAA,
+ BBB
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/After.groovy
new file mode 100644
index 000000000000..6397c29894bb
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/After.groovy
@@ -0,0 +1,11 @@
+enum Demo {
+ D1("foo"),
+ D2("bar"),
+ D3()
+
+ private String name
+
+ Demo(String name) {
+ this.name = name
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/Area.java
new file mode 100644
index 000000000000..26025ceff166
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/Area.java
@@ -0,0 +1,5 @@
+class C {
+ public void foo() {
+ Demo.D3
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/Before.groovy
new file mode 100644
index 000000000000..c542fc3a2fa2
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withConstructorArguments/Before.groovy
@@ -0,0 +1,10 @@
+enum Demo {
+ D1("foo"),
+ D2("bar")
+
+ private String name
+
+ Demo(String name) {
+ this.name = name
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/After.groovy
new file mode 100644
index 000000000000..a3bb9a990c39
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/After.groovy
@@ -0,0 +1,5 @@
+enum E {
+ AAA,
+ BBB,
+ CCC
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/Area.java
new file mode 100644
index 000000000000..c5f9c94eceea
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/Area.java
@@ -0,0 +1,16 @@
+import java.util.Arrays;
+import java.util.List;
+
+import static E.*;
+
+class AutomaticTypeInference {
+
+ AutomaticTypeInference(List gs) {
+ }
+
+ public static void main(String[] args) {
+
+ new AutomaticTypeInference(Arrays.asList(AAA, CCC));
+
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/Before.groovy
new file mode 100644
index 000000000000..17c2c184f761
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withStaticImport/Before.groovy
@@ -0,0 +1,4 @@
+enum E {
+ AAA,
+ BBB
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/After.groovy
new file mode 100644
index 000000000000..6397c29894bb
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/After.groovy
@@ -0,0 +1,11 @@
+enum Demo {
+ D1("foo"),
+ D2("bar"),
+ D3()
+
+ private String name
+
+ Demo(String name) {
+ this.name = name
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/Area.java
new file mode 100644
index 000000000000..abaac18368ce
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/Area.java
@@ -0,0 +1,9 @@
+class Show {
+
+ public void doSomething(Demo d) {
+ switch (d) {
+ case Demo.D3:
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/Before.groovy
new file mode 100644
index 000000000000..c542fc3a2fa2
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch/Before.groovy
@@ -0,0 +1,10 @@
+enum Demo {
+ D1("foo"),
+ D2("bar")
+
+ private String name
+
+ Demo(String name) {
+ this.name = name
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/After.groovy
new file mode 100644
index 000000000000..6397c29894bb
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/After.groovy
@@ -0,0 +1,11 @@
+enum Demo {
+ D1("foo"),
+ D2("bar"),
+ D3()
+
+ private String name
+
+ Demo(String name) {
+ this.name = name
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/Area.java
new file mode 100644
index 000000000000..7ea20e2b1eb1
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/Area.java
@@ -0,0 +1,9 @@
+class Show {
+
+ public void doSomething(Demo d) {
+ switch (d) {
+ case D3:
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/Before.groovy
new file mode 100644
index 000000000000..c542fc3a2fa2
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withSwitch2/Before.groovy
@@ -0,0 +1,10 @@
+enum Demo {
+ D1("foo"),
+ D2("bar")
+
+ private String name
+
+ Demo(String name) {
+ this.name = name
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/After.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/After.groovy
new file mode 100644
index 000000000000..d407d2da6088
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/After.groovy
@@ -0,0 +1,4 @@
+enum E {
+ AAA,
+ CCC
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/Area.java b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/Area.java
new file mode 100644
index 000000000000..da6746254679
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/Area.java
@@ -0,0 +1,13 @@
+import java.util.*;
+
+class AutomaticTypeInference {
+
+ AutomaticTypeInference(List gs) {
+ }
+
+ public static void main(String[] args) {
+
+ new AutomaticTypeInference(Arrays.asList(E.AAA, E.CCC));
+
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/Before.groovy b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/Before.groovy
new file mode 100644
index 000000000000..863436657165
--- /dev/null
+++ b/plugins/groovy/testdata/fixes/createEnumConstantFromUsage/withVarargs/Before.groovy
@@ -0,0 +1,3 @@
+enum E {
+ AAA
+}
\ No newline at end of file
diff --git a/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java b/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java
index c284d48e5e1f..b1c6d5919a5a 100644
--- a/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java
+++ b/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java
@@ -30,19 +30,19 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.GlobalSearchScopesCore;
-import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.Nullable;
import java.nio.file.Path;
import java.util.Collection;
+import java.util.Set;
class TestDirectory extends TestPackage {
public TestDirectory(JUnitConfiguration configuration, ExecutionEnvironment environment) {
@@ -55,16 +55,8 @@ class TestDirectory extends TestPackage {
final String dirName = getConfiguration().getPersistentData().getDirName();
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(dirName));
final Project project = getConfiguration().getProject();
- final GlobalSearchScope globalSearchScope;
- if (file == null) {
- globalSearchScope = GlobalSearchScope.EMPTY_SCOPE;
- }
- else {
- //package created by directory getDirectories(scope) should return the directory itself,
- // currently the parent directory should be specified for scope
- VirtualFile scopeDirectory = Registry.is("junit4.search.4.tests.all.in.scope", true) ? ObjectUtils.notNull(file.getParent(), file) : file;
- globalSearchScope = GlobalSearchScopesCore.directoryScope(project, scopeDirectory, true);
- }
+ final GlobalSearchScope globalSearchScope =
+ file == null ? GlobalSearchScope.EMPTY_SCOPE : GlobalSearchScopesCore.directoryScope(project, file, true);
return new SourceScope() {
@Override
public GlobalSearchScope getGlobalSearchScope() {
@@ -135,8 +127,38 @@ class TestDirectory extends TestPackage {
return "";
}
+
+ @Override
+ protected void collectClassesRecursively(TestClassFilter classFilter, Condition acceptClassCondition, Set classes) throws CantRunException {
+ collectClassesRecursively(getDirectory(getConfiguration().getPersistentData()), acceptClassCondition, classes);
+ }
+
+
+ private static void collectClassesRecursively(PsiDirectory directory,
+ Condition acceptAsTest,
+ Set classes) {
+ PsiDirectory[] subDirectories = ReadAction.compute(() -> directory.getSubdirectories());
+ for (PsiDirectory subDirectory : subDirectories) {
+ collectClassesRecursively(subDirectory, acceptAsTest, classes);
+ }
+ PsiFile[] files = ReadAction.compute(() -> directory.getFiles());
+ for (PsiFile file : files) {
+ if (file instanceof PsiClassOwner) {
+ for (PsiClass aClass : ReadAction.compute(() -> ((PsiClassOwner)file).getClasses())) {
+ collectInnerClasses(aClass, acceptAsTest, classes);
+ }
+ }
+ }
+ }
+
+
@Override
protected PsiPackage getPackage(JUnitConfiguration.Data data) throws CantRunException {
+ final PsiDirectory directory = getDirectory(data);
+ return ReadAction.compute(() -> JavaDirectoryService.getInstance().getPackageInSources(directory));
+ }
+
+ private PsiDirectory getDirectory(JUnitConfiguration.Data data) throws CantRunException {
final String dirName = data.getDirName();
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(dirName));
if (file == null) {
@@ -146,7 +168,7 @@ class TestDirectory extends TestPackage {
if (directory == null) {
throw new CantRunException("Directory \'" + dirName + "\' is not found");
}
- return ReadAction.compute(() -> JavaDirectoryService.getInstance().getPackageInSources(directory));
+ return directory;
}
@Override
diff --git a/plugins/junit/src/com/intellij/execution/junit/TestPackage.java b/plugins/junit/src/com/intellij/execution/junit/TestPackage.java
index 2b33f85427bb..721fc7a186f0 100644
--- a/plugins/junit/src/com/intellij/execution/junit/TestPackage.java
+++ b/plugins/junit/src/com/intellij/execution/junit/TestPackage.java
@@ -50,6 +50,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.file.Path;
import java.util.Arrays;
+import java.util.Set;
import java.util.function.Predicate;
public class TestPackage extends TestObject {
@@ -84,11 +85,8 @@ public class TestPackage extends TestObject {
LOG.assertTrue(classFilter.getBase() != null);
long start = System.currentTimeMillis();
if (Registry.is("junit4.search.4.tests.all.in.scope", true)) {
- PsiPackage aPackage = getPackage(data);
- if (aPackage != null) {
- collectClassesRecursively(aPackage, GlobalSearchScope.projectScope(myProject).intersectWith(classFilter.getScope()),
- aClass -> ReadAction.compute(() -> classFilter.isAccepted(aClass)));
- }
+ Condition acceptClassCondition = aClass -> ReadAction.compute(() -> classFilter.isAccepted(aClass));
+ collectClassesRecursively(classFilter, acceptClassCondition, myClasses);
}
else if (Registry.is("junit4.search.4.tests.in.classpath", false)) {
String packageName = getPackageName(data);
@@ -112,24 +110,6 @@ public class TestPackage extends TestObject {
}
}
- private void collectClassesRecursively(PsiPackage aPackage,
- GlobalSearchScope scope,
- Condition acceptAsTest) {
- PsiPackage[] psiPackages = ReadAction.compute(() -> aPackage.getSubPackages(scope));
- for (PsiPackage psiPackage : psiPackages) {
- collectClassesRecursively(psiPackage, scope, acceptAsTest);
- }
- PsiClass[] psiClasses = ReadAction.compute(() -> aPackage.getClasses(scope));
- for (PsiClass aClass : psiClasses) {
- if (Registry.is("junit4.accept.inner.classes", true)) {
- myClasses.addAll(ReadAction.compute(() -> JBTreeTraverser.of(PsiClass::getInnerClasses).withRoot(aClass).filter(acceptAsTest).toList()));
- }
- else if (acceptAsTest.value(aClass)) {
- myClasses.add(aClass);
- }
- }
- }
-
@Override
protected void onFound() {
@@ -161,6 +141,41 @@ public class TestPackage extends TestObject {
return getPackage(data).getQualifiedName();
}
+ protected void collectClassesRecursively(TestClassFilter classFilter,
+ Condition acceptClassCondition,
+ Set classes) throws CantRunException {
+ PsiPackage aPackage = getPackage(getConfiguration().getPersistentData());
+ if (aPackage != null) {
+ GlobalSearchScope scope = GlobalSearchScope.projectScope(getConfiguration().getProject()).intersectWith(classFilter.getScope());
+ collectClassesRecursively(aPackage, scope, acceptClassCondition, classes);
+ }
+ }
+
+ private static void collectClassesRecursively(PsiPackage aPackage,
+ GlobalSearchScope scope,
+ Condition acceptAsTest,
+ Set classes) {
+ PsiPackage[] psiPackages = ReadAction.compute(() -> aPackage.getSubPackages(scope));
+ for (PsiPackage psiPackage : psiPackages) {
+ collectClassesRecursively(psiPackage, scope, acceptAsTest, classes);
+ }
+ PsiClass[] psiClasses = ReadAction.compute(() -> aPackage.getClasses(scope));
+ for (PsiClass aClass : psiClasses) {
+ collectInnerClasses(aClass, acceptAsTest, classes);
+ }
+ }
+
+ protected static void collectInnerClasses(PsiClass aClass, Condition acceptAsTest, Set classes) {
+ if (Registry.is("junit4.accept.inner.classes", true)) {
+ classes
+ .addAll(ReadAction.compute(() -> JBTreeTraverser.of(PsiClass::getInnerClasses).withRoot(aClass).filter(acceptAsTest).toList()));
+ }
+ else if (acceptAsTest.value(aClass)) {
+ classes.add(aClass);
+ }
+ }
+
+
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters javaParameters = super.createJavaParameters();
diff --git a/plugins/properties/src/META-INF/plugin.xml b/plugins/properties/src/META-INF/plugin.xml
index 948290a060c2..fa319c69e8f3 100644
--- a/plugins/properties/src/META-INF/plugin.xml
+++ b/plugins/properties/src/META-INF/plugin.xml
@@ -131,7 +131,6 @@
com.intellij.lang.properties.PropertiesFilesManager
-
diff --git a/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleGrouper.java b/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleGrouper.java
index 70ca0b2b517e..535eb22c8e15 100644
--- a/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleGrouper.java
+++ b/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleGrouper.java
@@ -45,7 +45,7 @@ public class ResourceBundleGrouper implements TreeStructureProvider, DumbAware {
List dirPropertiesFiles = new SmartList<>();
for (AbstractTreeNode child : children) {
Object f = child.getValue();
- if (f instanceof PsiFile) {
+ if (f instanceof PsiFile && child.getClass() == PsiFileNode.class) { // process raw nodes only
PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile((PsiFile)f);
if (propertiesFile != null) {
dirPropertiesFiles.add(propertiesFile);
diff --git a/plugins/settings-repository/intellij.settingsRepository.iml b/plugins/settings-repository/intellij.settingsRepository.iml
index 15d7891ad260..1f00cf17223b 100644
--- a/plugins/settings-repository/intellij.settingsRepository.iml
+++ b/plugins/settings-repository/intellij.settingsRepository.iml
@@ -29,28 +29,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/plugins/settings-repository/lib/jackson-annotations-2.8.1-sources.jar b/plugins/settings-repository/lib/jackson-annotations-2.8.1-sources.jar
deleted file mode 100644
index b57c8d65c8eb..000000000000
Binary files a/plugins/settings-repository/lib/jackson-annotations-2.8.1-sources.jar and /dev/null differ
diff --git a/plugins/settings-repository/lib/jackson-annotations-2.8.1.jar b/plugins/settings-repository/lib/jackson-annotations-2.8.1.jar
deleted file mode 100644
index 5715db7dda80..000000000000
Binary files a/plugins/settings-repository/lib/jackson-annotations-2.8.1.jar and /dev/null differ
diff --git a/plugins/settings-repository/lib/jackson-core-2.8.1-sources.jar b/plugins/settings-repository/lib/jackson-core-2.8.1-sources.jar
deleted file mode 100644
index 996576151a08..000000000000
Binary files a/plugins/settings-repository/lib/jackson-core-2.8.1-sources.jar and /dev/null differ
diff --git a/plugins/settings-repository/lib/jackson-core-2.8.1.jar b/plugins/settings-repository/lib/jackson-core-2.8.1.jar
deleted file mode 100644
index 29230d46bdce..000000000000
Binary files a/plugins/settings-repository/lib/jackson-core-2.8.1.jar and /dev/null differ
diff --git a/plugins/settings-repository/lib/jackson-databind-2.8.1-sources.jar b/plugins/settings-repository/lib/jackson-databind-2.8.1-sources.jar
deleted file mode 100644
index d4b065428ac0..000000000000
Binary files a/plugins/settings-repository/lib/jackson-databind-2.8.1-sources.jar and /dev/null differ
diff --git a/plugins/settings-repository/lib/jackson-databind-2.8.1.jar b/plugins/settings-repository/lib/jackson-databind-2.8.1.jar
deleted file mode 100644
index c4c48016f212..000000000000
Binary files a/plugins/settings-repository/lib/jackson-databind-2.8.1.jar and /dev/null differ
diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java
index 676c1f6eb8d3..3f0b35bf4ad7 100644
--- a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java
+++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java
@@ -1,6 +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-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.
package com.intellij.tasks.generic;
import com.intellij.openapi.util.Comparing;
@@ -36,7 +34,6 @@ import static com.intellij.tasks.generic.TemplateVariable.FactoryVariable;
*/
@Tag("Generic")
public class GenericRepository extends BaseRepositoryImpl {
-
@NonNls public static final String SERVER_URL = "serverUrl";
@NonNls public static final String USERNAME = "username";
@NonNls public static final String PASSWORD = "password";
@@ -66,7 +63,6 @@ public class GenericRepository extends BaseRepositoryImpl {
private final List myPredefinedTemplateVariables = Arrays.asList(myServerTemplateVariable,
myUserNameTemplateVariable,
myPasswordTemplateVariable);
-
private String myLoginURL = "";
private String myTasksListUrl = "";
private String mySingleTaskUrl;
@@ -359,6 +355,9 @@ public class GenericRepository extends BaseRepositoryImpl {
}
)
public List getResponseHandlers() {
+ if (myResponseHandlersMap.isEmpty()) {
+ return Collections.emptyList();
+ }
return Collections.unmodifiableList(new ArrayList<>(myResponseHandlersMap.values()));
}
diff --git a/plugins/ui-designer/src/META-INF/plugin.xml b/plugins/ui-designer/src/META-INF/plugin.xml
index e457383bbe98..e926cb3227cb 100644
--- a/plugins/ui-designer/src/META-INF/plugin.xml
+++ b/plugins/ui-designer/src/META-INF/plugin.xml
@@ -155,7 +155,6 @@
com.intellij.uiDesigner.propertyInspector.DesignerToolWindowManager
-
com.intellij.ide.palette.impl.PaletteToolWindowManager
diff --git a/python/setup-test-environment/build.gradle b/python/setup-test-environment/build.gradle
index 9d62219a26dd..73608d42be8d 100644
--- a/python/setup-test-environment/build.gradle
+++ b/python/setup-test-environment/build.gradle
@@ -4,7 +4,7 @@ import java.nio.file.Files
import java.nio.file.Paths
plugins {
- id "com.jetbrains.python.envs" version "0.0.21"
+ id "com.jetbrains.python.envs" version "0.0.22"
}
/**
diff --git a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java
index b8af92234876..4c98c773f466 100644
--- a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java
+++ b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java
@@ -306,12 +306,18 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
if (myProcessHandler != null) {
myProcessHandler.destroyProcess();
}
- LOG.error(e);
+ if (logConnectionException(e)) {
+ LOG.error(e);
+ }
}
}
});
}
+ protected boolean logConnectionException(final Exception e) {
+ return true;
+ }
+
@Override
public void init() {
getSession().rebuildViews();
diff --git a/python/src/com/jetbrains/python/debugger/PyRemoteDebugProcess.java b/python/src/com/jetbrains/python/debugger/PyRemoteDebugProcess.java
index 23d4245fe81d..bed289715152 100644
--- a/python/src/com/jetbrains/python/debugger/PyRemoteDebugProcess.java
+++ b/python/src/com/jetbrains/python/debugger/PyRemoteDebugProcess.java
@@ -3,11 +3,10 @@ package com.jetbrains.python.debugger;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.ExecutionConsole;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.XDebugSession;
-import com.jetbrains.python.debugger.PyDebugProcess;
-import com.jetbrains.python.debugger.PyRemoteDebugProcessAware;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -19,6 +18,7 @@ import java.net.ServerSocket;
public class PyRemoteDebugProcess extends PyDebugProcess {
private final int myLocalPort;
private final String mySettraceCall;
+ private boolean isStopCalled = false;
public PyRemoteDebugProcess(@NotNull XDebugSession session,
@NotNull final ServerSocket serverSocket,
@@ -56,11 +56,22 @@ public class PyRemoteDebugProcess extends PyDebugProcess {
return "Waiting for connection";
}
+ @Override
+ protected boolean logConnectionException(Exception e) {
+ return !(isStopCalled && e.getMessage().contains("closed"));
+ }
+
@Override
protected void detachDebuggedProcess() {
waitForNextConnection(); // in case of remote debug we should wait for the next connection
}
+ @Override
+ public void stop() {
+ super.stop();
+ isStopCalled = true;
+ }
+
@Override
protected void beforeConnect() {
printToConsole(getCurrentStateMessage() + "\n", ConsoleViewContentType.SYSTEM_OUTPUT);
@@ -79,8 +90,8 @@ public class PyRemoteDebugProcess extends PyDebugProcess {
}
if (!isWaitingForConnection()) {
setWaitingForConnection(true);
-
- UIUtil.invokeLaterIfNeeded(() -> waitForConnection(getCurrentStateMessage(), getConnectionTitle()));
+ ApplicationManager.getApplication().invokeLater(() -> waitForConnection(getCurrentStateMessage(), getConnectionTitle()),
+ ModalityState.defaultModalityState());
}
}
diff --git a/python/testData/debug/test_remote.py b/python/testData/debug/test_remote.py
index 8bccbeb44c4f..d2a241213070 100644
--- a/python/testData/debug/test_remote.py
+++ b/python/testData/debug/test_remote.py
@@ -9,7 +9,7 @@ if __name__ == '__main__':
x = 0
- from pydev import pydevd
+ import pydevd
pydevd.settrace('localhost', port=port, stdoutToServer=True, stderrToServer=True)
x = 1
diff --git a/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java b/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java
index 23e9ecbcdb65..075d299abf72 100644
--- a/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java
+++ b/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java
@@ -17,6 +17,8 @@ package com.jetbrains.env.python.debug;
import com.google.common.collect.Sets;
import com.intellij.execution.ExecutionResult;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
@@ -241,8 +243,8 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask {
}
protected void clearAllBreakpoints() {
-
- UIUtil.invokeAndWaitIfNeeded((Runnable)() -> XDebuggerTestUtil.removeAllBreakpoints(getProject()));
+ ApplicationManager.getApplication()
+ .invokeLater(() -> XDebuggerTestUtil.removeAllBreakpoints(getProject()), ModalityState.defaultModalityState());
}
/**
diff --git a/python/testSrc/com/jetbrains/python/pyi/PyiParsingTest.java b/python/testSrc/com/jetbrains/python/pyi/PyiParsingTest.java
index 36737ee5610c..b4f690d4ede5 100644
--- a/python/testSrc/com/jetbrains/python/pyi/PyiParsingTest.java
+++ b/python/testSrc/com/jetbrains/python/pyi/PyiParsingTest.java
@@ -17,10 +17,7 @@ package com.jetbrains.python.pyi;
import com.intellij.testFramework.ParsingTestCase;
import com.intellij.testFramework.TestDataPath;
-import com.jetbrains.python.PythonDialectsTokenSetContributor;
-import com.jetbrains.python.PythonDialectsTokenSetProvider;
-import com.jetbrains.python.PythonTestUtil;
-import com.jetbrains.python.PythonTokenSetContributor;
+import com.jetbrains.python.*;
import com.jetbrains.python.psi.LanguageLevel;
/**
@@ -29,7 +26,7 @@ import com.jetbrains.python.psi.LanguageLevel;
@TestDataPath("$CONTENT_ROOT/../testData/pyi/parsing")
public class PyiParsingTest extends ParsingTestCase {
public PyiParsingTest() {
- super("pyi/parsing", "pyi", new PyiParserDefinition());
+ super("pyi/parsing", "pyi", new PyiParserDefinition(), new PythonParserDefinition());
}
@Override
diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml
index eae19984023e..aa2757c37c77 100644
--- a/resources/src/idea/JavaActions.xml
+++ b/resources/src/idea/JavaActions.xml
@@ -107,7 +107,7 @@
-
+
diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlDefaultAttributeValueInspection.java b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlDefaultAttributeValueInspection.java
index f54342306459..422b65287576 100644
--- a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlDefaultAttributeValueInspection.java
+++ b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlDefaultAttributeValueInspection.java
@@ -52,22 +52,27 @@ public class XmlDefaultAttributeValueInspection extends XmlSuppressableInspectio
String defaultValue = descriptor.getDefaultValue();
if (defaultValue != null && defaultValue.equals(value.getValue())) {
holder.registerProblem(value, "Redundant default attribute value assignment", ProblemHighlightType.LIKE_UNUSED_SYMBOL,
- new LocalQuickFix() {
- @Nls
- @NotNull
- @Override
- public String getFamilyName() {
- return XmlErrorMessages.message("remove.attribute.quickfix.family");
- }
+ createDeleteFix());
+ }
+ }
+ };
+ }
- @Override
- public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
- XmlAttribute attribute = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), XmlAttribute.class);
- if (attribute != null) {
- attribute.delete();
- }
- }
- });
+ @NotNull
+ private static LocalQuickFix createDeleteFix() {
+ return new LocalQuickFix() {
+ @Nls
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return XmlErrorMessages.message("remove.attribute.quickfix.family");
+ }
+
+ @Override
+ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+ XmlAttribute attribute = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), XmlAttribute.class);
+ if (attribute != null) {
+ attribute.delete();
}
}
};
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/HtmlFileElement.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/HtmlFileElement.java
index 3ff9ed89bef9..267fc26eb222 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/HtmlFileElement.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/HtmlFileElement.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.xml.XmlChildRole;
import com.intellij.psi.xml.XmlElementType;
+import org.jetbrains.annotations.NotNull;
public class HtmlFileElement extends FileElement implements XmlElementType {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.HtmlFileElement");
@@ -29,7 +30,7 @@ public class HtmlFileElement extends FileElement implements XmlElementType {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child.getElementType() == HTML_DOCUMENT) {
return XmlChildRole.HTML_DOCUMENT;
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/XmlFileElement.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/XmlFileElement.java
index 1296afa99d9f..37608b69bad2 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/XmlFileElement.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/XmlFileElement.java
@@ -21,6 +21,7 @@ import com.intellij.psi.tree.ChildRoleBase;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.xml.XmlChildRole;
import com.intellij.psi.xml.XmlElementType;
+import org.jetbrains.annotations.NotNull;
public class XmlFileElement extends FileElement implements XmlElementType {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.XmlFileElement");
@@ -34,7 +35,7 @@ public class XmlFileElement extends FileElement implements XmlElementType {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child.getElementType() == XML_DOCUMENT ||
child.getElementType() == HTML_DOCUMENT) {
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java
index aa38b9c767e3..1a83401caadd 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java
@@ -40,7 +40,7 @@ public class XmlAttlistDeclImpl extends XmlElementImpl implements XmlAttlistDecl
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child.getElementType() == XmlTokenType.XML_NAME) {
return XmlChildRole.XML_NAME;
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeDeclImpl.java
index f09b6892bbbb..d0701b466f64 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeDeclImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeDeclImpl.java
@@ -46,7 +46,7 @@ public class XmlAttributeDeclImpl extends XmlElementImpl implements XmlAttribute
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == XML_NAME) {
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java
index 318112c2f27b..e7547db11c79 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java
@@ -74,7 +74,7 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute, Hi
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == XmlTokenType.XML_NAME) {
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDoctypeImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDoctypeImpl.java
index 480dc926c952..94d35b597ba7 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDoctypeImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDoctypeImpl.java
@@ -66,7 +66,7 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == XmlTokenType.XML_DOCTYPE_PUBLIC) {
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java
index 769dc7d2ebd1..8aa102def25d 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java
@@ -101,7 +101,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument {
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == XmlElementType.XML_PROLOG) {
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentSpecImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentSpecImpl.java
index 6b041acd1d7e..4ba97010fc7e 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentSpecImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentSpecImpl.java
@@ -40,7 +40,7 @@ public class XmlElementContentSpecImpl extends XmlElementImpl implements XmlElem
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == XML_CONTENT_ANY) {
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementDeclImpl.java
index 39e9d622b64c..9e292ab81019 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementDeclImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementDeclImpl.java
@@ -42,7 +42,7 @@ public class XmlElementDeclImpl extends XmlElementImpl implements XmlElementDecl
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == XML_NAME) {
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlNotationDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlNotationDeclImpl.java
index 3a52fe8a804d..7e64cd975762 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlNotationDeclImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlNotationDeclImpl.java
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.xml.*;
import com.intellij.psi.tree.ChildRoleBase;
+import org.jetbrains.annotations.NotNull;
/**
* @author Mike
@@ -31,7 +32,7 @@ public class XmlNotationDeclImpl extends XmlElementImpl implements XmlNotationDe
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child.getElementType() == XML_ELEMENT_CONTENT_SPEC) {
return XmlChildRole.XML_ELEMENT_CONTENT_SPEC;
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java
index ee78a746f249..759cb81cf319 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java
@@ -47,7 +47,7 @@ public class XmlPrologImpl extends XmlElementImpl implements XmlProlog, XmlEleme
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
if (child.getElementType() == XML_DOCTYPE) {
return XmlChildRole.XML_DOCTYPE;
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
index 73f5936185b0..3c530fc6299e 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
@@ -549,7 +549,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag, HintedReferenc
}
@Override
- public int getChildRole(ASTNode child) {
+ public int getChildRole(@NotNull ASTNode child) {
LOG.assertTrue(child.getTreeParent() == this);
IElementType i = child.getElementType();
if (i == XmlTokenType.XML_NAME || i == XmlTokenType.XML_TAG_NAME) {