diff --git a/.idea/libraries/KotlinJavaRuntime.xml b/.idea/libraries/KotlinJavaRuntime.xml
index e89a0a33a6bb..54188de91d6e 100644
--- a/.idea/libraries/KotlinJavaRuntime.xml
+++ b/.idea/libraries/KotlinJavaRuntime.xml
@@ -1,11 +1,10 @@
-
+
+
-
-
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 2ce0a9819d8f..148813f1918e 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
### Building and Running from the IDE
To develop IntelliJ IDEA, you can use either IntelliJ IDEA Community Edition or IntelliJ IDEA Ultimate. To build and run the code:
* Run **getPlugins.sh** / **getPlugins.bat** from the project root directory to check out additional modules.
+* Install the **Kotlin plugin** from the plugin manager (version 0.12.613). Parts of IntelliJ IDEA are written in Kotlin, and you need the plugin to compile the code.
* Make sure you have the **Groovy** plugin enabled. Parts of IntelliJ IDEA are written in Groovy, and you will get compilation errors if you don't have the plugin enabled.
* Make sure you have the **UI Designer** plugin enabled. Most of IntelliJ IDEA's UI is built using the **UI Designer**, and the version you build will not run correctly if you don't have the plugin enabled.
* Open the project.
diff --git a/build.xml b/build.xml
index 8e6bdbcfa226..d4cd47e2fe3a 100644
--- a/build.xml
+++ b/build.xml
@@ -10,6 +10,7 @@
+
diff --git a/build/.gitignore b/build/.gitignore
index b6e2bc7704d0..39bb4e104911 100644
--- a/build/.gitignore
+++ b/build/.gitignore
@@ -1,2 +1,3 @@
/kotlinc/
/jdk/
+kotlin-plugin*.zip
diff --git a/build/download_kotlin.xml b/build/download_kotlin.xml
new file mode 100644
index 000000000000..36e0de7f21ba
--- /dev/null
+++ b/build/download_kotlin.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/gant.xml b/build/gant.xml
index 349c59a23129..8a7460997353 100644
--- a/build/gant.xml
+++ b/build/gant.xml
@@ -24,7 +24,7 @@
-
+
diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant
index 7d8cc30070c0..31f0f876af5d 100644
--- a/build/scripts/layouts.gant
+++ b/build/scripts/layouts.gant
@@ -592,6 +592,10 @@ public def layoutCommunityPlugins(String home) {
}
}
}
+
+ pluginDir("Kotlin") {
+ fileset(dir: "${home}/build/kotlinc/plugin/Kotlin")
+ }
}
}
@@ -692,6 +696,7 @@ def reorder(String home, String targetDirectory) {
arg(value: "${home}/lib")
classpath {
projectBuilder.moduleRuntimeClasspath(findModule("util"), false).each {
+ println(it)
pathelement(location: it)
}
}
diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant
index 942c59cf0a37..e301961d8804 100644
--- a/build/scripts/libLicenses.gant
+++ b/build/scripts/libLicenses.gant
@@ -295,3 +295,4 @@ jetbrainsLibrary("JPS")
jetbrainsLibrary("Maven Embedder")
jetbrainsLibrary("tcServiceMessages")
jetbrainsLibrary("optimizedFileManager.jar")
+jetbrainsLibrary("KotlinJavaRuntime")
diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant
index 1827cd54bda6..474b7c2a7e92 100644
--- a/build/scripts/utils.gant
+++ b/build/scripts/utils.gant
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+
+
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.jps.gant.JpsGantTool
@@ -24,6 +26,7 @@ import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.java.JpsJavaSdkType
import org.jetbrains.jps.model.library.JpsOrderRootType
import org.jetbrains.jps.model.module.JpsModule
+import org.jetbrains.jps.model.serialization.JpsModelSerializationDataService
includeTool << JpsGantTool
@@ -134,6 +137,15 @@ binding.setVariable("guessHome", {
binding.setVariable("loadProject", {
defineJdk("IDEA jdk", setupJdkPath("jdkHome", "$home/build/jdk/1.6", "JDK_16_x64"))
defineJdk("1.8", setupJdkPath("jdk8Home", "$home/build/jdk/1.8", "JDK_18_x64"))
+ def bundledKotlinPath = "$home/build/kotlinc"
+ if (!new File(bundledKotlinPath, "lib/kotlin-runtime.jar").exists()) {
+ bundledKotlinPath = "$home/community/build/kotlinc"
+ }
+ if (!new File(bundledKotlinPath, "lib/kotlin-runtime.jar").exists()) {
+ projectBuilder.error("Could not find Kotlin runtime at $bundledKotlinPath/lib/kotlin-runtime.jar")
+ return
+ }
+ setPathVariable("KOTLIN_BUNDLED", bundledKotlinPath)
projectBuilder.buildIncrementally = Boolean.parseBoolean(p("jps.build.incrementally", "false"))
def dataDirName = projectBuilder.buildIncrementally ? ".jps-incremental-build" : ".jps-build-data"
projectBuilder.dataStorageRoot = new File("$home/$dataDirName")
@@ -209,6 +221,11 @@ private void defineJdk(String jdkName, jdkHomePath) {
}
}
+private void setPathVariable(String name, String value) {
+ def pathVars = JpsModelSerializationDataService.getOrCreatePathVariablesConfiguration(global)
+ pathVars.addPathVariable(name, value)
+}
+
binding.setVariable("prepareOutputFolder", {
def targetFolder = projectBuilder.buildIncrementally ? "$home/out/incremental-build" : out
projectBuilder.targetFolder = targetFolder
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java
index 8bc65d9c7f28..3eba87e44a96 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,6 +80,7 @@ public class PopFrameAction extends DebuggerAction {
return;
}
+ debugProcess.getSession().setSteppingThrough(stackFrame.getStackFrameProxy().threadProxy());
if (!DebuggerSettings.EVALUATE_FINALLY_NEVER.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME)) {
List statements = getFinallyStatements(debuggerContext.getSourcePosition());
if (!statements.isEmpty()) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java
index a2e3129e634a..58c4ae70b651 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java
@@ -46,6 +46,7 @@ public class ResumeThreadAction extends DebuggerAction{
final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
public void contextAction() throws Exception {
+ debugProcess.getSession().getXDebugSession().sessionResumed();
debugProcess.createResumeThreadCommand(getSuspendContext(), thread).run();
debuggerTreeNode.calcValue();
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java
index 6346d831943f..04bf6d8aa302 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java
@@ -55,6 +55,7 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.unscramble.ThreadState;
import com.intellij.util.Alarm;
import com.intellij.util.TimeoutUtil;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.AbstractDebuggerSession;
import com.intellij.xdebugger.XDebugSession;
@@ -70,7 +71,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -109,7 +109,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
private final DebuggerContextImpl SESSION_EMPTY_CONTEXT;
//Thread, user is currently stepping through
- private final Set mySteppingThroughThreads = new HashSet();
+ private final Set mySteppingThroughThreads = ContainerUtil.newConcurrentSet();
protected final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
private boolean myModifiedClassesScanRequired = false;
@@ -118,6 +118,10 @@ public class DebuggerSession implements AbstractDebuggerSession {
return mySteppingThroughThreads.contains(threadProxy);
}
+ public boolean setSteppingThrough(ThreadReferenceProxyImpl threadProxy) {
+ return mySteppingThroughThreads.add(threadProxy);
+ }
+
@NotNull
public GlobalSearchScope getSearchScope() {
//noinspection ConstantConditions
@@ -567,10 +571,6 @@ public class DebuggerSession implements AbstractDebuggerSession {
}
private boolean shouldSetAsActiveContext(final SuspendContextImpl suspendContext) {
- // always switch context if it is not a breakpoint stop
- if (DebuggerUtilsEx.getEventDescriptors(suspendContext).isEmpty()) {
- return true;
- }
final ThreadReferenceProxyImpl newThread = suspendContext.getThread();
if (newThread == null || suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL || isSteppingThrough(newThread)) {
return true;
@@ -589,7 +589,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
@Override
public void resumed(final SuspendContextImpl suspendContext) {
- final SuspendContextImpl currentContext = getProcess().getSuspendManager().getPausedContext();
+ final SuspendContextImpl currentContext = isSteppingThrough(suspendContext.getThread()) ? null : getProcess().getSuspendManager().getPausedContext();
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
@Override
public void run() {
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java
index 1258db655d49..374f2072d571 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java
@@ -30,6 +30,7 @@ import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiFormatUtil;
+import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.Stack;
import com.intellij.util.indexing.FileBasedIndex;
@@ -385,6 +386,7 @@ public class ProjectBytecodeAnalysis {
private PsiAnnotation createAnnotationFromText(@NotNull final String text) throws IncorrectOperationException {
PsiAnnotation annotation = JavaPsiFacade.getElementFactory(myProject).createAnnotationFromText(text, null);
annotation.putUserData(INFERRED_ANNOTATION, Boolean.TRUE);
+ ((LightVirtualFile)annotation.getContainingFile().getViewProvider().getVirtualFile()).markReadOnly();
return annotation;
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaChainLookupElement.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaChainLookupElement.java
index cbc9653b6adf..c521d075cc69 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaChainLookupElement.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaChainLookupElement.java
@@ -16,8 +16,6 @@
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.lookup.*;
-import com.intellij.diagnostic.LogMessageEx;
-import com.intellij.diagnostic.AttachmentFactory;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.util.ClassConditionKey;
@@ -26,7 +24,6 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.impl.DebugUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.text.CharArrayUtil;
import gnu.trove.THashSet;
@@ -126,14 +123,7 @@ public class JavaChainLookupElement extends LookupElementDecorator() {
@Override
- public void navigate(MouseEvent e, PsiElement elt) {
- navigator.browse(e, elt);
+ public void navigate(final MouseEvent e, final PsiElement elt) {
+ DumbService.getInstance(elt.getProject()).withAlternativeResolveEnabled(new Runnable() {
+ @Override
+ public void run() {
+ navigator.browse(e, elt);
+ }
+ });
}
};
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
index d59feaa805a4..9bde59121c4f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
@@ -83,6 +83,7 @@ public class StaticImportMethodFix implements IntentionAction {
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
return PsiUtil.isLanguageLevel5OrHigher(file)
+ && file instanceof PsiJavaFile
&& myMethodCall.getElement() != null
&& myMethodCall.getElement().isValid()
&& myMethodCall.getElement().getMethodExpression().getQualifierExpression() == null
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java
index 36344aa00785..cea0b4f47bb8 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -198,9 +198,6 @@ public class AddOnDemandStaticImportAction extends BaseElementAtCaretIntentionAc
}
private static boolean isParameterizedReference(final PsiJavaCodeReferenceElement expression) {
- if (expression.getParameterList() == null) {
- return false;
- }
PsiReferenceParameterList parameterList = expression.getParameterList();
return parameterList != null && parameterList.getFirstChild() != null;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java
index 1e63ee0055ca..1c2d0ae16fda 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java
@@ -157,6 +157,7 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti
if (availability.resolved instanceof PsiClass) {
setText(CodeInsightBundle.message("intention.add.single.member.import.text", availability.qName));
} else {
+ if (!(element.getContainingFile() instanceof PsiJavaFile)) return false;
setText(CodeInsightBundle.message("intention.add.single.member.static.import.text", availability.qName));
}
}
@@ -198,7 +199,7 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti
if (resolved != null && findExistingImport(file, resolvedClass, referenceName) == null) {
if (resolved instanceof PsiClass) {
- ((PsiJavaFile) file).importClass((PsiClass) resolved);
+ ((PsiImportHolder) file).importClass((PsiClass) resolved);
} else {
PsiReferenceExpressionImpl.bindToElementViaStaticImport(resolvedClass, referenceName, ((PsiJavaFile)file).getImportList());
}
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/ReferencedElementsCollector.java b/java/java-impl/src/com/intellij/refactoring/inline/ReferencedElementsCollector.java
index fc1e2680c173..0372f065c0cb 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/ReferencedElementsCollector.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/ReferencedElementsCollector.java
@@ -23,7 +23,7 @@ import java.util.HashSet;
/**
* @author ven
*/
-public class ReferencedElementsCollector extends JavaRecursiveElementWalkingVisitor {
+public class ReferencedElementsCollector extends JavaRecursiveElementVisitor {
final HashSet myReferencedMembers = new HashSet();
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
index 385fe8b578ee..9a7ab1f1f15d 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
@@ -872,7 +872,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
}
PsiDeclarationStatement declaration = JavaPsiFacade.getInstance(project).getElementFactory()
- .createVariableDeclarationStatement(settings.getEnteredName(), selectedType.getType(), initializer);
+ .createVariableDeclarationStatement(settings.getEnteredName(), selectedType.getType(), initializer, container);
if (!isInsideLoop) {
declaration = addDeclaration(declaration, initializer);
LOG.assertTrue(expr1.isValid());
@@ -978,7 +978,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
if (initializer instanceof PsiNewExpression) {
final PsiNewExpression newExpression = (PsiNewExpression)initializer;
final PsiExpression tryToDetectDiamondNewExpr = ((PsiVariable)JavaPsiFacade.getElementFactory(initializer.getProject())
- .createVariableDeclarationStatement("x", expectedType, initializer).getDeclaredElements()[0])
+ .createVariableDeclarationStatement("x", expectedType, initializer, initializer).getDeclaredElements()[0])
.getInitializer();
if (tryToDetectDiamondNewExpr instanceof PsiNewExpression &&
PsiDiamondTypeUtil.canCollapseToDiamond((PsiNewExpression)tryToDetectDiamondNewExpr,
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java b/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java
index 99960483bfe7..235872ec67cb 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java
@@ -367,6 +367,12 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor
*/
@NotNull PsiImportStatement createImportStatementOnDemand(@NotNull @NonNls String packageName) throws IncorrectOperationException;
+ /**
+ * @see #createVariableDeclarationStatement(String, PsiType, PsiExpression, PsiElement)
+ */
+ @NotNull PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, @NotNull PsiType type, @Nullable PsiExpression initializer)
+ throws IncorrectOperationException;
+
/**
* Creates a local variable declaration statement with the specified name, type and initializer,
* optionally without reformatting the declaration.
@@ -374,11 +380,13 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor
* @param name the name of the variable to create.
* @param type the type of the variable to create.
* @param initializer the initializer for the variable.
+ * @param context the context for dummy holder
* @return the variable instance.
* @throws IncorrectOperationException if name is not a valid identifier or
* type is not a valid type.
*/
- @NotNull PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, @NotNull PsiType type, @Nullable PsiExpression initializer)
+ @NotNull PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, @NotNull PsiType type,
+ @Nullable PsiExpression initializer, @Nullable PsiElement context)
throws IncorrectOperationException;
/**
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java b/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java
index 7e0d61d1948f..0f1e76a79c20 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java
@@ -28,6 +28,7 @@ import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.*;
import com.intellij.psi.util.PsiFormatUtil;
+import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SmartList;
@@ -399,6 +400,7 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations
private static PsiAnnotation markAsExternalAnnotation(@NotNull PsiAnnotation annotation) {
annotation.putUserData(EXTERNAL_ANNO_MARKER, Boolean.TRUE);
+ ((LightVirtualFile)annotation.getContainingFile().getViewProvider().getVirtualFile()).markReadOnly();
return annotation;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java
index 8539b55835a6..2909317e370c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -118,15 +118,11 @@ public class PsiDiamondTypeUtil {
if (!(parent instanceof PsiJavaCodeReferenceElement)) {
return parent;
}
- final PsiJavaCodeReferenceElement javaCodeReferenceElement =
- (PsiJavaCodeReferenceElement) parent;
- final PsiReferenceParameterList referenceParameterList =
- (PsiReferenceParameterList) element;
+ final PsiJavaCodeReferenceElement javaCodeReferenceElement = (PsiJavaCodeReferenceElement) parent;
final StringBuilder text = new StringBuilder();
text.append(javaCodeReferenceElement.getQualifiedName());
text.append('<');
- final PsiTypeElement[] typeElements = referenceParameterList.getTypeParameterElements();
- final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(typeElements[0], PsiNewExpression.class);
+ final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class);
final PsiDiamondType.DiamondInferenceResult result = PsiDiamondTypeImpl.resolveInferredTypesNoCheck(newExpression, newExpression);
text.append(StringUtil.join(result.getInferredTypes(), new Function() {
@Override
@@ -135,10 +131,8 @@ public class PsiDiamondTypeUtil {
}
}, ","));
text.append('>');
- final PsiElementFactory elementFactory =
- JavaPsiFacade.getElementFactory(element.getProject());
- final PsiJavaCodeReferenceElement newReference =
- elementFactory.createReferenceFromText(text.toString(), element);
+ final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(element.getProject());
+ final PsiJavaCodeReferenceElement newReference = elementFactory.createReferenceFromText(text.toString(), element);
return CodeStyleManager.getInstance(javaCodeReferenceElement.getProject()).reformat(javaCodeReferenceElement.replace(newReference));
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
index ede86356fdfe..58169e20f193 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
@@ -609,9 +609,18 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
@NotNull
@Override
- public PsiDeclarationStatement createVariableDeclarationStatement(@NotNull String name,
+ public PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name,
@NotNull PsiType type,
@Nullable PsiExpression initializer) throws IncorrectOperationException {
+ return createVariableDeclarationStatement(name, type, initializer, null);
+ }
+
+ @NotNull
+ @Override
+ public PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name,
+ @NotNull PsiType type,
+ @Nullable PsiExpression initializer,
+ @Nullable PsiElement context) throws IncorrectOperationException {
if (!isIdentifier(name)) {
throw new IncorrectOperationException("\"" + name + "\" is not an identifier.");
}
@@ -620,7 +629,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
}
String text = "X " + name + (initializer != null ? " = x" : "") + ";";
- PsiDeclarationStatement statement = (PsiDeclarationStatement)createStatementFromText(text, null);
+ PsiDeclarationStatement statement = (PsiDeclarationStatement)createStatementFromText(text, context);
PsiVariable variable = (PsiVariable)statement.getDeclaredElements()[0];
replace(variable.getTypeElement(), createTypeElement(type), text);
diff --git a/java/java-tests/testData/psi/autodetect/bigFileWithOnlyErrorElements_DoNotProduceSOE.java b/java/java-tests/testData/psi/autodetect/bigFileWithOnlyErrorElements_DoNotProduceSOE.java
new file mode 100644
index 000000000000..6dbafa673282
Binary files /dev/null and b/java/java-tests/testData/psi/autodetect/bigFileWithOnlyErrorElements_DoNotProduceSOE.java differ
diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java
index 2e3269ff02b9..38225ac553f5 100644
--- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java
@@ -16,8 +16,11 @@
package com.intellij.psi.codeStyle.autodetect;
import com.intellij.JavaTestUtil;
+import com.intellij.formatting.Block;
import org.jetbrains.annotations.NotNull;
+import java.util.Iterator;
+
public class NewLineBlocksIteratorTest extends AbstractNewLineBlocksIteratorTest {
@NotNull
@@ -46,5 +49,13 @@ public class NewLineBlocksIteratorTest extends AbstractNewLineBlocksIteratorTest
checkNewLineBlocksStartOffsets(newLineBlocksStartOffsets);
}
+
+ public void testBigFileWithOnlyErrorElements_DoNotProduceSOE() {
+ configureByFile(getFileName() + ".java");
+ Iterator iterator = createNewLineBlocksIterator();
+ while (iterator.hasNext()) {
+ iterator.next();
+ }
+ }
}
diff --git a/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java b/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java
index 0a317ce4a497..e1bddda7f392 100644
--- a/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java
+++ b/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java
@@ -1,6 +1,7 @@
package com.intellij.refactoring.typeMigration.intentions;
import com.intellij.codeInsight.FileModificationService;
+import com.intellij.codeInsight.daemon.JavaErrorMessages;
import com.intellij.codeInsight.hint.HintManager;
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
import com.intellij.codeInsight.intention.impl.TypeExpression;
@@ -101,13 +102,26 @@ public class ChangeClassParametersIntention extends PsiElementBaseIntentionActio
if (!brokenOff) {
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
try {
- final PsiType targetParam = elementFactory.createTypeFromText(myNewType, aClass);
+ final PsiType targetParam = elementFactory.createTypeFromText(myNewType, typeElement);
+ if (!(targetParam instanceof PsiClassType)) {
+ HintManager.getInstance().showErrorHint(editor,
+ JavaErrorMessages.message("generics.type.argument.cannot.be.of.primitive.type"));
+ return;
+ }
+ final PsiClassType classType = (PsiClassType)targetParam;
+ final PsiClass target = classType.resolve();
+ if (target == null) {
+ HintManager.getInstance().showErrorHint(editor, JavaErrorMessages.message("cannot.resolve.symbol",
+ classType.getPresentableText()));
+ return;
+ }
final TypeMigrationRules myRules = new TypeMigrationRules(((PsiAnonymousClass)aClass).getBaseClassType());
final PsiSubstitutor substitutor = result.getSubstitutor().put(typeParameter, targetParam);
final PsiType targetClassType = elementFactory.createType(baseClass, substitutor);
myRules.setMigrationRootType(targetClassType);
myRules.setBoundScope(new LocalSearchScope(aClass));
- new TypeMigrationProcessor(project, ((PsiAnonymousClass)aClass).getBaseClassReference().getParameterList(), myRules).run();
+ TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, myRules,
+ ((PsiAnonymousClass)aClass).getBaseClassReference().getParameterList());
}
catch (IncorrectOperationException e) {
HintManager.getInstance().showErrorHint(editor, "Incorrect type");
diff --git a/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template b/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template
index 413db792c422..bdcaa88da7c2 100644
--- a/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template
+++ b/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template
@@ -5,6 +5,6 @@ public class X {
public int compareTo(String o) {
return 0;
}
- }
+ };
}
}
\ No newline at end of file
diff --git a/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template b/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template
index 96eb1b46dbd2..45429f9bbe36 100644
--- a/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template
+++ b/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template
@@ -1,10 +1,10 @@
public class X {
{
- new Comparable<Object>() {
+ new Comparable<Object>() {
@Override
public int compareTo(Object o) {
return 0;
}
- }
+ };
}
}
\ No newline at end of file
diff --git a/lib/.gitignore b/lib/.gitignore
new file mode 100644
index 000000000000..0ca1c5c32bae
--- /dev/null
+++ b/lib/.gitignore
@@ -0,0 +1,2 @@
+kotlin-runtime.jar
+kotlin-reflect.jar
diff --git a/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java b/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java
deleted file mode 100644
index 2889c14ea2e4..000000000000
--- a/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2000-2015 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.openapi.fileTypes;
-
-import com.intellij.lang.Language;
-import com.intellij.openapi.extensions.ExtensionPointName;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/** @deprecated use com.intellij.psi.compiled.ClassFileDecompilers or com.intellij.psi.LanguageSubstitutors API (to remove in IDEA 14) */
-@SuppressWarnings("deprecation")
-public interface ContentBasedFileSubstitutor {
- ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.contentBasedClassFileProcessor");
-
- boolean isApplicable(Project project, VirtualFile vFile);
-
- @NotNull
- String obtainFileText(Project project, VirtualFile file);
-
- @Nullable
- Language obtainLanguageForFile(VirtualFile file);
-}
diff --git a/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java b/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
index 719c23b46865..d80c41a325a2 100644
--- a/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
+++ b/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
@@ -34,6 +34,7 @@ import java.nio.charset.Charset;
public class LightVirtualFile extends LightVirtualFileBase {
private CharSequence myContent = "";
private Language myLanguage;
+ private boolean myReadOnly;
public LightVirtualFile() {
this("");
@@ -127,6 +128,7 @@ public class LightVirtualFile extends LightVirtualFileBase {
}
private void setContent(@NotNull CharSequence content) {
+ assert !myReadOnly;
//StringUtil.assertValidSeparators(content);
myContent = content;
}
@@ -136,6 +138,11 @@ public class LightVirtualFile extends LightVirtualFileBase {
return myContent;
}
+ public void markReadOnly() {
+ setWritable(false);
+ myReadOnly = true;
+ }
+
@Override
public String toString() {
return "LightVirtualFile: " + getPresentableUrl();
diff --git a/platform/diff-impl/src/com/intellij/diff/tools/ErrorDiffTool.java b/platform/diff-impl/src/com/intellij/diff/tools/ErrorDiffTool.java
index e9120e1284e3..1d835bc583ed 100644
--- a/platform/diff-impl/src/com/intellij/diff/tools/ErrorDiffTool.java
+++ b/platform/diff-impl/src/com/intellij/diff/tools/ErrorDiffTool.java
@@ -31,12 +31,12 @@ import com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.awt.*;
import java.util.List;
public class ErrorDiffTool implements FrameDiffTool {
@@ -69,8 +69,7 @@ public class ErrorDiffTool implements FrameDiffTool {
myContext = context;
myRequest = request;
- myPanel = new JPanel(new BorderLayout());
- myPanel.add(createComponent(request), BorderLayout.CENTER);
+ myPanel = JBUI.Panels.simplePanel(createComponent(request));
}
@NotNull
diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffPanel.java
index 862bcf897577..2730ddf23ac3 100644
--- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffPanel.java
+++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffPanel.java
@@ -21,11 +21,11 @@ import com.intellij.diff.tools.util.base.DiffPanelBase;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.project.Project;
import com.intellij.util.ui.AsyncProcessIcon;
+import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.awt.*;
import static com.intellij.diff.util.DiffUtil.createMessagePanel;
@@ -43,13 +43,8 @@ public class UnifiedDiffPanel extends DiffPanelBase {
@NotNull DataProvider provider,
@NotNull DiffContext context) {
super(project, provider, context);
-
myBusyIcon = new AsyncProcessIcon.Big("UnifiedDiff");
-
- JPanel centerPanel = new JPanel(new BorderLayout());
- centerPanel.add(myNotificationsPanel, BorderLayout.NORTH);
- centerPanel.add(content, BorderLayout.CENTER);
-
+ JPanel centerPanel = JBUI.Panels.simplePanel(content).addToTop(myNotificationsPanel);
myContentPanel.add(centerPanel, GOOD_CONTENT);
myContentPanel.add(myBusyIcon, LOADING_CONTENT);
myContentPanel.add(createMessagePanel("Can not calculate diff. " + DiffTooBigException.MESSAGE), TOO_BIG_CONTENT);
diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java
index d723d0c83fca..d2be844f7e66 100644
--- a/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java
+++ b/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java
@@ -19,10 +19,10 @@ import com.intellij.diff.DiffContext;
import com.intellij.diff.tools.util.base.DiffPanelBase;
import com.intellij.diff.util.DiffUtil;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import java.awt.*;
public class SimpleDiffPanel extends DiffPanelBase {
private static final String GOOD_CONTENT = "GoodContent";
@@ -32,10 +32,7 @@ public class SimpleDiffPanel extends DiffPanelBase {
@NotNull DataProvider dataProvider,
@NotNull DiffContext context) {
super(context.getProject(), dataProvider, context);
-
- JPanel centerPanel = new JPanel(new BorderLayout());
- centerPanel.add(myNotificationsPanel, BorderLayout.NORTH);
- centerPanel.add(editorPanel, BorderLayout.CENTER);
+ JPanel centerPanel = JBUI.Panels.simplePanel(editorPanel).addToTop(myNotificationsPanel);
myContentPanel.add(centerPanel, GOOD_CONTENT);
myContentPanel.add(DiffUtil.createMessagePanel("Error"), ERROR_CONTENT);
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java
index ed635890bd70..66f97400fb77 100644
--- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java
@@ -27,12 +27,12 @@ import com.intellij.openapi.ui.OptionAction;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.ui.components.labels.ActionLink;
import com.intellij.util.ui.JBUI;
+import com.intellij.util.ui.components.BorderLayoutPanel;
import net.miginfocom.swing.MigLayout;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
@@ -66,20 +66,18 @@ public class VcsPushDialog extends DialogWrapper {
@Override
protected JComponent createCenterPanel() {
- JComponent rootPanel = new JPanel(new BorderLayout(0, JBUI.scale(2)));
- rootPanel.add(myListPanel, BorderLayout.CENTER);
JPanel optionsPanel = new JPanel(new MigLayout("ins 0 0, flowx"));
for (VcsPushOptionsPanel panel : myAdditionalPanels.values()) {
optionsPanel.add(panel);
}
optionsPanel.setBorder(JBUI.Borders.emptyTop(6));
- JPanel panel = new JPanel(new BorderLayout());
- panel.add(optionsPanel);
+ BorderLayoutPanel panel = JBUI.Panels.simplePanel(optionsPanel);
if (!myController.isForcePushEnabled()) {
- panel.add(createForcePushInfoLabel(), BorderLayout.NORTH);
+ panel.addToTop(createForcePushInfoLabel());
}
- rootPanel.add(panel, BorderLayout.SOUTH);
- return rootPanel;
+ return JBUI.Panels.simplePanel(0, 2)
+ .addToCenter(myListPanel)
+ .addToBottom(panel);
}
@NotNull
@@ -100,10 +98,7 @@ public class VcsPushDialog extends DialogWrapper {
});
here.setFont(JBUI.Fonts.smallFont());
text.add(here);
- JPanel wrap = new JPanel(new BorderLayout());
- wrap.add(text, BorderLayout.EAST);
- wrap.setBorder(JBUI.Borders.emptyBottom(4));
- return wrap;
+ return JBUI.Panels.simplePanel().addToRight(text).withBorder(JBUI.Borders.emptyBottom(4));
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java
index b2817b0786e4..66759b08bdd2 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java
@@ -108,24 +108,6 @@ public class CompletionUtil {
return mainData != null ? mainData : ourGenericCompletionData;
}
- /** @see CompletionDataEP */
- @Deprecated
- public static void registerCompletionData(FileType fileType, NotNullLazyValue completionData) {
- ourCustomCompletionDatas.put(fileType, completionData);
- }
-
- /** @see CompletionDataEP */
- @Deprecated
- public static void registerCompletionData(FileType fileType, final CompletionData completionData) {
- registerCompletionData(fileType, new NotNullLazyValue() {
- @Override
- @NotNull
- protected CompletionData compute() {
- return completionData;
- }
- });
- }
-
@Nullable
public static CompletionData getCompletionDataByFileType(FileType fileType) {
for(CompletionDataEP ep: Extensions.getExtensions(CompletionDataEP.EP_NAME)) {
@@ -254,6 +236,11 @@ public class CompletionUtil {
return element == null ? psi : element;
}
+ /**
+ * Filters _names for strings that match given matcher and sorts them.
+ * "Start matching" items go first, then others.
+ * Within both groups names are sorted lexicographically in a case-insensitive way.
+ */
public static LinkedHashSet sortMatching(final PrefixMatcher matcher, Collection _names) {
ProgressManager.checkCanceled();
if (matcher.getPrefix().isEmpty()) {
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 010cd3150b5e..e8ab98dabda9 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
+import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
@@ -137,7 +138,7 @@ public class ShowParameterInfoContext implements CreateParameterInfoContext {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- if (editor.isDisposed()) return;
+ if (editor.isDisposed() || DumbService.isDumb(project)) return;
final Document document = editor.getDocument();
if (document.getTextLength() < elementStart) return;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java
index 1f135a5a1f61..a1a9ade9f7da 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java
@@ -139,6 +139,8 @@ class LookupUi {
myList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
+ if (myLookup.isLookupDisposed()) return;
+
myHintAlarm.cancelAllRequests();
final LookupElement item = myLookup.getCurrentItem();
diff --git a/platform/lang-impl/src/com/intellij/internal/DumpScreenConfigurationAction.java b/platform/lang-impl/src/com/intellij/internal/DumpScreenConfigurationAction.java
index 1b791fc1fbcf..53101069388d 100644
--- a/platform/lang-impl/src/com/intellij/internal/DumpScreenConfigurationAction.java
+++ b/platform/lang-impl/src/com/intellij/internal/DumpScreenConfigurationAction.java
@@ -22,7 +22,6 @@ import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.JBColor;
import com.intellij.ui.ScreenUtil;
-import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
@@ -73,7 +72,7 @@ public class DumpScreenConfigurationAction extends DumbAwareAction {
private static void append(StringBuilder sb, String name, Rectangle bounds) {
sb.append(name);
sb.append(": x=").append(bounds.x);
- sb.append(", y=").append(bounds.x);
+ sb.append(", y=").append(bounds.y);
sb.append(", width=").append(bounds.width);
sb.append(", height=").append(bounds.height);
sb.append("\n");
@@ -213,7 +212,6 @@ public class DumpScreenConfigurationAction extends DumbAwareAction {
}
g = g.create();
if (g instanceof Graphics2D) {
- Graphics2D g2d = (Graphics2D)g;
UISettings.setupAntialiasing(g);
}
for (int i = 0; i < myScreenList.size(); i++) {
diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/common/NewLineBlocksIterator.java b/platform/lang-impl/src/com/intellij/psi/formatter/common/NewLineBlocksIterator.java
index 5a170dfa0c0c..b42a109efb0f 100644
--- a/platform/lang-impl/src/com/intellij/psi/formatter/common/NewLineBlocksIterator.java
+++ b/platform/lang-impl/src/com/intellij/psi/formatter/common/NewLineBlocksIterator.java
@@ -71,19 +71,18 @@ public class NewLineBlocksIterator implements Iterator {
}
private void popUntilTopBlockStartOffsetGreaterOrEqual(final int lineStartOffset) {
- if (myStack.isEmpty()) return;
-
- Block current = myStack.peek();
- TextRange range = current.getTextRange();
- int currentStartOffset = range.getStartOffset();
- int currentEndOffset = range.getEndOffset();
-
- if (currentStartOffset < lineStartOffset) {
- myStack.pop();
- if (currentEndOffset > lineStartOffset) {
- pushAll(current);
+ while (!myStack.isEmpty()) {
+ Block current = myStack.peek();
+ TextRange range = current.getTextRange();
+ if (range.getStartOffset() < lineStartOffset) {
+ myStack.pop();
+ if (range.getEndOffset() > lineStartOffset) {
+ pushAll(current);
+ }
+ }
+ else {
+ break;
}
- popUntilTopBlockStartOffsetGreaterOrEqual(lineStartOffset);
}
}
diff --git a/platform/lang-impl/src/com/intellij/ui/debugger/extensions/ActionTracer.java b/platform/lang-impl/src/com/intellij/ui/debugger/extensions/ActionTracer.java
index 7b06cfab69fc..bc6d8267c89b 100644
--- a/platform/lang-impl/src/com/intellij/ui/debugger/extensions/ActionTracer.java
+++ b/platform/lang-impl/src/com/intellij/ui/debugger/extensions/ActionTracer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,10 +76,10 @@ public class ActionTracer implements UiDebuggerExtension, AnActionListener {
@Override
public void afterActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
- StringBuffer out = new StringBuffer();
+ StringBuilder out = new StringBuilder();
final ActionManager actionManager = ActionManager.getInstance();
final String id = actionManager.getId(action);
- out.append("id=" + id);
+ out.append("id=").append(id);
if (id != null) {
out.append(" shortcuts:");
final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(id);
diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
index f63b457222f0..67bfb2fed12f 100644
--- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
+++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
@@ -658,7 +658,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
public void holdSelection() {
myHeldSelection = getSelectionPaths();
- clearSelection();
}
public void unholdSelection() {
diff --git a/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java
index bbd26c870223..138363badd0a 100644
--- a/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java
+++ b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -261,7 +261,7 @@ public class FormBuilder {
}
/**
- * @deprecated use {@code setHorizontalGap} or {@code setFormLeftIndent}, to be removed in IDEA 16
+ * @deprecated use {@link #setHorizontalGap} or {@link #setFormLeftIndent}, to be removed in IDEA 16
*/
@Deprecated
public FormBuilder setIndent(int indent) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickList.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickList.java
index 1c79650c0a2b..9fa5ae29b14d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickList.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickList.java
@@ -31,14 +31,12 @@ public class QuickList extends ExternalizableSchemeAdapter {
public static final String SEPARATOR_ID = QUICK_LIST_PREFIX + "$Separator$";
private static final String ID_TAG = "id";
- private static final String READONLY_TAG = "readonly";
private static final String ACTION_TAG = "action";
private static final String DISPLAY_NAME_TAG = "display";
private static final String DESCRIPTION_TAG = "description";
private String myDescription;
private String[] myActionIds = ArrayUtil.EMPTY_STRING_ARRAY;
- private boolean myReadonly;
/**
* With read external to be called immediately after in mind
@@ -47,15 +45,10 @@ public class QuickList extends ExternalizableSchemeAdapter {
myName = "";
}
- public QuickList(@NotNull String name, @Nullable String description, String[] actionIds, boolean isReadonly) {
+ public QuickList(@NotNull String name, @Nullable String description, String[] actionIds) {
myName = name;
myDescription = StringUtil.nullize(description);
myActionIds = actionIds;
- myReadonly = isReadonly;
- }
-
- public boolean isReadonly() {
- return myReadonly;
}
@Nullable
@@ -106,9 +99,6 @@ public class QuickList extends ExternalizableSchemeAdapter {
if (myDescription != null) {
groupElement.setAttribute(DESCRIPTION_TAG, myDescription);
}
- if (myReadonly) {
- groupElement.setAttribute(READONLY_TAG, "true");
- }
for (String actionId : getActionIds()) {
groupElement.addContent(new Element(ACTION_TAG).setAttribute(ID_TAG, actionId));
@@ -118,7 +108,6 @@ public class QuickList extends ExternalizableSchemeAdapter {
public void readExternal(@NotNull Element element) {
myName = element.getAttributeValue(DISPLAY_NAME_TAG);
myDescription = StringUtil.nullize(element.getAttributeValue(DESCRIPTION_TAG));
- myReadonly = Boolean.valueOf(element.getAttributeValue(READONLY_TAG, "false")).booleanValue();
List actionElements = element.getChildren(ACTION_TAG);
myActionIds = new String[actionElements.size()];
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java
index 42b6d21f60ce..8608ce3fb617 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java
@@ -246,9 +246,7 @@ public final class ActionMenu extends JMenu {
}
public void menuSelected(MenuEvent e) {
- if (ActionPlaces.isPopupPlace(myPlace)) {
- new UsabilityHelper(ActionMenu.this, myDisposable);
- }
+ new UsabilityHelper(ActionMenu.this, myDisposable);
fillMenu();
}
}
@@ -348,15 +346,18 @@ public final class ActionMenu extends JMenu {
if (event instanceof ComponentEvent) {
ComponentEvent componentEvent = (ComponentEvent)event;
Component component = componentEvent.getComponent();
- if (event.getID() == ComponentEvent.COMPONENT_SHOWN &&
- component instanceof JWindow &&
- component.getParent() == SwingUtilities.windowForComponent(myComponent)) {
- Rectangle bounds = component.getBounds();
- myUpperTargetPoint = new Point(bounds.x, bounds.y);
- myLowerTargetPoint = new Point(bounds.x, bounds.y + bounds.height);
- if (myLastMousePoint.x > bounds.x) {
- myUpperTargetPoint.translate(bounds.width, 0);
- myLowerTargetPoint.translate(bounds.width, 0);
+ JPopupMenu popup = UIUtil.findParentByClass(component, JPopupMenu.class);
+ if (popup != null && popup.getInvoker() == myComponent) {
+ Rectangle bounds = popup.getBounds();
+ if (bounds.isEmpty()) return;
+ bounds.setLocation(popup.getLocationOnScreen());
+ if (myLastMousePoint.x < bounds.x) {
+ myUpperTargetPoint = new Point(bounds.x, bounds.y);
+ myLowerTargetPoint = new Point(bounds.x, bounds.y + bounds.height);
+ }
+ if (myLastMousePoint.x > bounds.x + bounds.width) {
+ myUpperTargetPoint = new Point(bounds.x + bounds.width, bounds.y);
+ myLowerTargetPoint = new Point(bounds.x + bounds.width, bounds.y + bounds.height);
}
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java
index e9eb88fec11d..702cb669baf9 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -150,8 +150,7 @@ public class ActionMenuItem extends JCheckBoxMenuItem {
updateIcon(action);
String id = ActionManager.getInstance().getId(action);
if (id != null) {
- Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(id);
- setAcceleratorFromShortcuts(shortcuts);
+ setAcceleratorFromShortcuts(KeymapManager.getInstance().getActiveKeymap().getShortcuts(id));
}
else {
final ShortcutSet shortcutSet = action.getShortcutSet();
@@ -161,7 +160,7 @@ public class ActionMenuItem extends JCheckBoxMenuItem {
}
}
- private void setAcceleratorFromShortcuts(final Shortcut[] shortcuts) {
+ private void setAcceleratorFromShortcuts(@NotNull Shortcut[] shortcuts) {
for (Shortcut shortcut : shortcuts) {
if (shortcut instanceof KeyboardShortcut) {
final KeyStroke firstKeyStroke = ((KeyboardShortcut)shortcut).getFirstKeyStroke();
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
index f679d23dbcde..98051d1ef8b2 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
@@ -44,6 +44,8 @@ import com.intellij.openapi.editor.ex.util.EditorUIUtil;
import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.openapi.editor.markup.*;
import com.intellij.openapi.project.DumbAwareAction;
+import com.intellij.openapi.project.DumbService;
+import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Ref;
@@ -1383,20 +1385,25 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
? renderer.getMiddleButtonClickAction()
: renderer.getClickAction();
}
- if (clickAction != null) {
- clickAction.actionPerformed(new AnActionEvent(e, myEditor.getDataContext(), "ICON_NAVIGATION", clickAction.getTemplatePresentation(),
- ActionManager.getInstance(),
- e.getModifiers()));
- e.consume();
- repaint();
- }
- else {
- ActiveGutterRenderer lineRenderer = getActiveRendererByMouseEvent(e);
- if (lineRenderer != null) {
- lineRenderer.doAction(myEditor, e);
- } else {
- fireEventToTextAnnotationListeners(e);
+ try {
+ if (clickAction != null) {
+ clickAction.actionPerformed(new AnActionEvent(e, myEditor.getDataContext(), "ICON_NAVIGATION", clickAction.getTemplatePresentation(),
+ ActionManager.getInstance(),
+ e.getModifiers()));
+ e.consume();
+ repaint();
}
+ else {
+ ActiveGutterRenderer lineRenderer = getActiveRendererByMouseEvent(e);
+ if (lineRenderer != null) {
+ lineRenderer.doAction(myEditor, e);
+ } else {
+ fireEventToTextAnnotationListeners(e);
+ }
+ }
+ }
+ catch (IndexNotReadyException e1) {
+ DumbService.getInstance(myEditor.getProject()).showDumbModeNotification("Navigation is not available during indexing");
}
}
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 380bf2c2233d..32e2987f75cf 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
@@ -885,8 +885,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
}
- private static boolean firstCharTyped = true;
-
private void initComponent() {
myPanel.setLayout(new BorderLayout());
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java
index 7e0b3e49b232..ec1ef112c860 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java
@@ -511,6 +511,7 @@ public class KeymapImpl extends ExternalizableSchemeAdapter implements Keymap {
return getKeymapManager().getActionBinding(actionId);
}
+ @NotNull
@Override
public Shortcut[] getShortcuts(String actionId) {
LinkedHashSet shortcuts = myActionId2ListOfShortcuts.get(actionId);
@@ -761,7 +762,7 @@ public class KeymapImpl extends ExternalizableSchemeAdapter implements Keymap {
* @return string representation of passed keystroke.
*/
public static String getKeyShortcutString(KeyStroke keyStroke) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
int modifiers = keyStroke.getModifiers();
if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
buf.append(SHIFT);
@@ -794,7 +795,7 @@ public class KeymapImpl extends ExternalizableSchemeAdapter implements Keymap {
* be used only for serializing of the MouseShortcut
*/
private static String getMouseShortcutString(MouseShortcut shortcut) {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
// modifiers
@@ -874,7 +875,7 @@ public class KeymapImpl extends ExternalizableSchemeAdapter implements Keymap {
@Override
- public HashMap> getConflicts(String actionId, KeyboardShortcut keyboardShortcut) {
+ public Map> getConflicts(String actionId, KeyboardShortcut keyboardShortcut) {
HashMap> result = new HashMap>();
String[] actionIds = getActionIds(keyboardShortcut.getFirstKeyStroke());
@@ -944,7 +945,7 @@ public class KeymapImpl extends ExternalizableSchemeAdapter implements Keymap {
@Override
public String[] getAbbreviations() {
- return new String[0];
+ return ArrayUtil.EMPTY_STRING_ARRAY;
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java
index 25351fbe2bb1..4e8f0647a13e 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java
@@ -60,7 +60,6 @@ import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.Alarm;
import com.intellij.util.IJSwingUtilities;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.FormBuilder;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
@@ -75,10 +74,8 @@ import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.*;
import java.util.List;
-import java.util.Set;
public class KeymapPanel extends JPanel implements SearchableConfigurable, Configurable.NoScroll, KeymapListener, Disposable {
private JComboBox myKeymapList;
@@ -539,7 +536,7 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
return;
}
- HashMap> conflicts = mySelectedKeymap.getConflicts(actionId, keyboardShortcut);
+ Map> conflicts = mySelectedKeymap.getConflicts(actionId, keyboardShortcut);
if (conflicts.size() > 0) {
int result = Messages.showYesNoCancelDialog(
this,
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsUi.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsUi.java
index 21531ff3a4e2..2fcb0c4c1c81 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsUi.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsUi.java
@@ -50,7 +50,7 @@ class QuickListsUi implements ConfigurableUi> {
@Override
public QuickList clone(@NotNull QuickList item, boolean forInPlaceEditing) {
- return new QuickList(item.getName(), item.getDescription(), item.getActionIds(), false);
+ return new QuickList(item.getName(), item.getDescription(), item.getActionIds());
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java
index 3142a2f2890f..971c297b815a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java
@@ -722,23 +722,23 @@ public final class SchemesManagerImpl schemes, @Nullable Condition removeCondition) {
+ public void setSchemes(@NotNull final List newSchemes, @Nullable Condition removeCondition) {
if (removeCondition == null) {
mySchemes.clear();
}
else {
- for (int i = schemes.size() - 1; i >= 0; i--) {
- T scheme = schemes.get(i);
+ for (int i = mySchemes.size() - 1; i >= 0; i--) {
+ T scheme = mySchemes.get(i);
if (removeCondition.value(scheme)) {
mySchemes.remove(i);
}
}
}
- retainExternalInfo(schemes);
+ retainExternalInfo(newSchemes);
- mySchemes.ensureCapacity(schemes.size());
- for (T scheme : schemes) {
+ mySchemes.ensureCapacity(newSchemes.size());
+ for (T scheme : newSchemes) {
mySchemes.add(scheme);
schemeAdded(scheme);
}
@@ -755,6 +755,10 @@ public final class SchemesManagerImpl schemes) {
+ if (schemeToInfo.isEmpty()) {
+ return;
+ }
+
schemeToInfo.retainEntries(new TObjectObjectProcedure() {
@Override
public boolean execute(ExternalizableScheme scheme, ExternalInfo info) {
@@ -852,7 +856,7 @@ public final class SchemesManagerImpl T findParentByClass(@NotNull Component c, Class cls) {
+ for (Component component = c; component != null; component = component.getParent()) {
+ if (cls.isAssignableFrom(component.getClass())) {
+ @SuppressWarnings({"unchecked"}) final T t = (T)component;
+ return t;
+ }
+ }
+ return null;
+ }
+
@NonNls
public static String getCssFontDeclaration(final Font font) {
return getCssFontDeclaration(font, null, null, null);
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
index 0e485f220f02..5f042f4c49ea 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
@@ -91,23 +91,22 @@ public class LineStatusTrackerDrawing {
final int x = r.x + r.width - 3;
final int endX = gutter.getWhitespaceSeparatorOffset();
- if (range.getInnerRanges() == null) { // actual painter
- if (r.height > 0) {
- paintRect(g, gutterColor, borderColor, x, r.y, endX, r.y + r.height);
+ final int y = lineToY(editor, range.getLine1());
+ final int endY = lineToY(editor, range.getLine2());
+
+ if (range.getInnerRanges() == null) { // Mode.DEFAULT
+ if (y != endY) {
+ paintRect(g, gutterColor, borderColor, x, y, endX, endY);
}
else {
- paintTriangle(g, gutterColor, borderColor, x, endX, r.y);
+ paintTriangle(g, gutterColor, borderColor, x, endX, y);
}
}
- else { // registry: diff.status.tracker.smart
- if (range.getType() == Range.DELETED) {
- final int y = lineToY(editor, range.getLine1());
+ else { // Mode.SMART
+ if (y == endY) {
paintTriangle(g, gutterColor, borderColor, x, endX, y);
}
else {
- final int y = lineToY(editor, range.getLine1());
- int endY = lineToY(editor, range.getLine2());
-
List innerRanges = range.getInnerRanges();
for (Range.InnerRange innerRange : innerRanges) {
if (innerRange.getType() == Range.DELETED) continue;
diff --git a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml
index 95c585fef36c..e82df033e4b4 100644
--- a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml
+++ b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml
@@ -500,37 +500,37 @@
com.siyeh.ipp.exceptions.DetailExceptionsIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.try.statements
com.siyeh.ipp.exceptions.ConvertCatchToThrowsIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.try.statements
com.siyeh.ipp.exceptions.SplitMultiCatchIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.try.statements
com.siyeh.ipp.exceptions.ReplaceArmWithTryFinallyIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.try.statements
com.siyeh.ipp.exceptions.MergeNestedTryStatementsIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.try.statements
com.siyeh.ipp.exceptions.SplitTryWithMultipleResourcesIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.try.statements
com.siyeh.ipp.exceptions.ObscureThrownExceptionsIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.declaration
com.siyeh.ipp.opassign.ReplaceWithOperatorAssignmentIntention
@@ -575,17 +575,17 @@
com.siyeh.ipp.asserttoif.AssertToIfIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.control.flow
com.siyeh.ipp.asserttoif.IfToAssertionIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.control.flow
com.siyeh.ipp.enumswitch.CreateEnumSwitchBranchesIntention
com.siyeh.IntentionPowerPackBundle
- intention.category.other
+ intention.category.control.flow
com.siyeh.ipp.constant.ConstantExpressionIntention
@@ -622,5 +622,10 @@
com.siyeh.IntentionPowerPackBundle
intention.category.other
+
+ com.siyeh.ipp.opassign.PostfixPrefixIntention
+ com.siyeh.IntentionPowerPackBundle
+ intention.category.other
+
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties b/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties
index 6a5d499f42da..505c62657666 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties
+++ b/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties
@@ -186,6 +186,7 @@ negate.conditional.intention.name=Negate '?:'
negate.conditional.intention.family.name=Negate Conditional
objects.require.non.null.intention.name=Use 'java.util.Objects.requireNonNull()' expression
objects.require.non.null.intention.family.name=Use 'java.util.Objects.requireNonNull()' Expression
+postfix.prefix.intention.family.name=Flip prefix/postfix expression
#hand made
demorgans.intention.name1=Replace '\\&\\&' with '||'
@@ -220,6 +221,7 @@ adapter.to.listener.intention.name=Replace extension of ''{0}'' with ''Listener'
obscure.thrown.exceptions.intention.name=Replace with ''throws {0}''
add.array.creation.expression.intention.name=Add ''new {0}''
change.variable.type.to.rhs.type.intention.name=Declare ''{0}'' with type ''{1}''
+postfix.prefix.intention.name=Replace with ''{0}''
#categories
@@ -235,6 +237,7 @@ intention.category.comments=Comments
intention.category.control.flow=Control Flow
intention.category.strings=Strings
intention.category.modifiers=Modifiers
+intention.category.try.statements=Try Statements
intention.category.other=Other
#warnings
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/opassign/PostfixPrefixIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/opassign/PostfixPrefixIntention.java
new file mode 100644
index 000000000000..ceddc5bcc595
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/opassign/PostfixPrefixIntention.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ipp.opassign;
+
+import com.intellij.psi.*;
+import com.siyeh.IntentionPowerPackBundle;import com.siyeh.ig.PsiReplacementUtil;
+import com.siyeh.ipp.base.MutablyNamedIntention;
+import com.siyeh.ipp.base.PsiElementPredicate;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class PostfixPrefixIntention extends MutablyNamedIntention {
+
+ @NotNull
+ @Override
+ protected PsiElementPredicate getElementPredicate() {
+ return new PsiElementPredicate() {
+ @Override
+ public boolean satisfiedBy(PsiElement element) {
+ if (element instanceof PsiPrefixExpression) {
+ final PsiPrefixExpression prefixExpression = (PsiPrefixExpression)element;
+ return prefixExpression.getOperand() != null;
+ }
+ return element instanceof PsiPostfixExpression;
+ }
+ };
+ }
+
+ @Override
+ protected String getTextForElement(PsiElement element) {
+ return IntentionPowerPackBundle.message("postfix.prefix.intention.name", getReplacementText(element));
+ }
+
+ @NotNull
+ private static String getReplacementText(PsiElement element) {
+ if (element instanceof PsiPrefixExpression) {
+ final PsiPrefixExpression prefixExpression = (PsiPrefixExpression)element;
+ final PsiExpression operand = prefixExpression.getOperand();
+ assert operand != null;
+ final PsiJavaToken sign = prefixExpression.getOperationSign();
+ return operand.getText() + sign.getText();
+ }
+ else {
+ final PsiPostfixExpression postfixExpression = (PsiPostfixExpression)element;
+ final PsiExpression operand = postfixExpression.getOperand();
+ final PsiJavaToken sign = postfixExpression.getOperationSign();
+ return sign.getText() + operand.getText();
+ }
+ }
+
+ @Override
+ protected void processIntention(@NotNull PsiElement element) {
+ final PsiExpression expression = (PsiExpression)element;
+ PsiReplacementUtil.replaceExpression(expression, getReplacementText(element));
+ }
+}
diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/after.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/after.java.template
new file mode 100644
index 000000000000..62ff7e5742d2
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/after.java.template
@@ -0,0 +1,5 @@
+public class X {
+ void f(int i) {
+ ++i;
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/before.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/before.java.template
new file mode 100644
index 000000000000..ce2d4d35c298
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/before.java.template
@@ -0,0 +1,5 @@
+public class X {
+ void f(int i) {
+ i++;
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/description.html b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/description.html
new file mode 100644
index 000000000000..6a031b16018b
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/description.html
@@ -0,0 +1,5 @@
+
+
+Replaces a postfix expression with a prefix expression and vice versa.
+
+
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Incomplete.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Incomplete.java
new file mode 100644
index 000000000000..e5e2497aa54f
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Incomplete.java
@@ -0,0 +1,5 @@
+class Incomplete {
+ void m(int i) {
+ ++
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple.java
new file mode 100644
index 000000000000..9595d54d7030
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple.java
@@ -0,0 +1,6 @@
+class Simple {
+
+ void m(int i) {
+ i++;
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple_after.java
new file mode 100644
index 000000000000..d23b2ee884d9
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple_after.java
@@ -0,0 +1,6 @@
+class Simple {
+
+ void m(int i) {
+ ++i;
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/opassign/PostfixPrefixIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/opassign/PostfixPrefixIntentionTest.java
new file mode 100644
index 000000000000..94dcb427d56e
--- /dev/null
+++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/opassign/PostfixPrefixIntentionTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ipp.opassign;
+
+import com.siyeh.IntentionPowerPackBundle;
+import com.siyeh.ipp.IPPTestCase;
+
+/**
+ * @see PostfixPrefixIntention
+ */
+public class PostfixPrefixIntentionTest extends IPPTestCase {
+ public void testSimple() { doTest(); }
+ public void testIncomplete() { assertIntentionNotAvailable(); }
+
+ @Override
+ protected String getIntentionName() {
+ return IntentionPowerPackBundle.message("postfix.prefix.intention.name", "++i");
+ }
+
+ @Override
+ protected String getRelativePath() {
+ return "opassign/postfix_prefix";
+ }
+}
diff --git a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageView.java b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageView.java
index 524076cf086f..3385d5ab01bf 100644
--- a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageView.java
+++ b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageView.java
@@ -32,6 +32,8 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.SystemInfo;
@@ -301,7 +303,7 @@ public class CoverageView extends BorderLayoutPanel implements DataProvider, Dis
}
}
- private class GoUpAction extends AnAction {
+ private class GoUpAction extends DumbAwareAction {
private final CoverageViewTreeStructure myTreeStructure;
diff --git a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java
index 6e59698622f8..c4b8ae410552 100644
--- a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java
+++ b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java
@@ -18,7 +18,6 @@ import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
@@ -44,7 +43,7 @@ public class CoverageViewManager implements PersistentStateComponent sourceRoots = Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
+ boolean skeletonsDirFound = false;
+ for (VirtualFile root : sourceRoots) {
+ if (root.equals(skeletonsDir)) {
+ skeletonsDirFound = true;
+ }
+ if (PythonSdkType.isSkeletonsPath(root.getPath()) && !skeletonsDirFound) {
+ modificator.removeRoot(root, OrderRootType.CLASSES);
+ changed = true;
+ }
+ }
+ if (!skeletonsDirFound) {
+ modificator.addRoot(skeletonsDir, OrderRootType.CLASSES);
+ changed = true;
+ }
+ }
+ }
+ return changed;
+ }
+
private static boolean wasOldRoot(@NotNull String root, @NotNull Collection oldRoots) {
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(root);
if (file != null) {
diff --git a/resources-en/src/search/searchableOptions.xml b/resources-en/src/search/searchableOptions.xml
index e00643e4f211..7665f8efb8d9 100644
--- a/resources-en/src/search/searchableOptions.xml
+++ b/resources-en/src/search/searchableOptions.xml
@@ -20084,7 +20084,7 @@
-
+
diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml
index e4cb9111458d..26bc49d9633c 100644
--- a/resources/src/META-INF/IdeaPlugin.xml
+++ b/resources/src/META-INF/IdeaPlugin.xml
@@ -763,22 +763,22 @@
com.intellij.codeInsight.intention.impl.AddNotNullAnnotationIntention
- Control Flow
+ Annotations
AddAnnotationFix
com.intellij.codeInsight.intention.impl.AddDeprecationAnnotationIntention
- Control Flow
+ Annotations
AddAnnotationFix
com.intellij.codeInsight.intention.impl.AddNullableAnnotationIntention
- Control Flow
+ Annotations
AddAnnotationFix
com.intellij.codeInspection.dataFlow.EditContractIntention
- Control Flow
+ Annotations
EditContractIntention
@@ -787,7 +787,7 @@
com.intellij.codeInsight.intention.impl.DeannotateIntentionAction
- Control Flow
+ Annotations
com.intellij.codeInsight.intention.impl.CreateSwitchIntention
@@ -876,7 +876,7 @@
com.intellij.codeInsight.intention.impl.AddOverrideAnnotationAction
- Declaration
+ Annotations
com.intellij.codeInsight.daemon.impl.quickfix.DelegateWithDefaultParamValueIntentionAction
@@ -961,7 +961,7 @@
com.intellij.codeInsight.intention.impl.BreakStringOnLineBreaksIntentionAction
- Other
+ Strings
@@ -985,7 +985,7 @@
com.intellij.codeInsight.intention.impl.SurroundAutoCloseableAction
- Declaration
+ Try Statements
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 d954fe827fa6..35fb5f08b580 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
@@ -713,11 +713,13 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
final boolean caseSensitive = isCaseSensitive();
for (final XmlAttribute attribute : attributes) {
- final LeafElement attrNameElement = (LeafElement)XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild(attribute.getNode());
- if (attrNameElement != null &&
- (caseSensitive && Comparing.equal(attrNameElement.getChars(), qname) ||
- !caseSensitive && Comparing.equal(attrNameElement.getChars(), qname, false))) {
- return attribute;
+ final ASTNode child = XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild(attribute.getNode());
+ if (child instanceof LeafElement) {
+ final LeafElement attrNameElement = (LeafElement)child;
+ if ((caseSensitive && Comparing.equal(attrNameElement.getChars(), qname) ||
+ !caseSensitive && Comparing.equal(attrNameElement.getChars(), qname, false))) {
+ return attribute;
+ }
}
}
return null;