Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2015-06-29 19:20:38 +03:00
81 changed files with 576 additions and 289 deletions
+3 -4
View File
@@ -1,11 +1,10 @@
<component name="libraryTable">
<library name="KotlinJavaRuntime">
<CLASSES>
<root url="jar://$PROJECT_DIR$/build/kotlinc/lib/kotlin-runtime.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/build/kotlinc/lib/kotlin-runtime-sources.jar!/" />
</SOURCES>
<SOURCES />
</library>
</component>
+1
View File
@@ -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.
+1
View File
@@ -10,6 +10,7 @@
<target name="init">
<mkdir dir="${out.dir}"/>
<mkdir dir="${tmp.dir}"/>
<ant dir="build" antfile="download_kotlin.xml"/>
</target>
<macrodef name="call_gant">
+1
View File
@@ -1,2 +1,3 @@
/kotlinc/
/jdk/
kotlin-plugin*.zip
+37
View File
@@ -0,0 +1,37 @@
<project name="Download Kotlin" default="extract">
<property name="kotlin.version" value="0.12.613"/>
<property name="kotlin.build.type.id" value="Kotlin_M12_Idea142branch150version"/>
<property name="kotlin.build.selector" value=".lastSuccessful"/>
<target name="check_present">
<pathconvert property="kotlin.path" setonempty="false" pathsep=" ">
<path>
<fileset dir="${basedir}" includes="kotlin-plugin-${kotlin.version}*.zip"/>
</path>
</pathconvert>
</target>
<target name="download" depends="check_present" unless="kotlin.path">
<loadresource property="kotlin.build.number">
<url url="https://teamcity.jetbrains.com/guestAuth/app/rest/buildTypes/id:${kotlin.build.type.id}/builds/status:SUCCESS,count:1/number"/>
</loadresource>
<echo message="Downloading Kotlin build ${kotlin.build.number}"/>
<property name="kotlin.path" value="${basedir}/kotlin-plugin-${kotlin.build.number}.zip"/>
<get src="https://teamcity.jetbrains.com/guestAuth/repository/download/${kotlin.build.type.id}/${kotlin.build.number}/kotlin-plugin-${kotlin.build.number}.zip"
dest="${kotlin.path}"/>
</target>
<target name="extract" depends="download">
<unzip src="${kotlin.path}" dest="${basedir}/kotlinc/plugin"/>
<unzip src="${kotlin.path}" dest="${basedir}">
<patternset includes="Kotlin/kotlinc/**"/>
<globmapper from="Kotlin/*" to="*"/>
</unzip>
<unzip src="${kotlin.path}" dest="${basedir}/kotlinc/jps">
<patternset includes="Kotlin/lib/jps/**"/>
<globmapper from="Kotlin/lib/jps/*" to="*"/>
</unzip>
</target>
</project>
+1 -1
View File
@@ -24,7 +24,7 @@
<fileset dir="${project.home}/build/kotlinc/lib" erroronmissingdir="false">
<include name="kotlin-runtime.jar"/>
</fileset>
<fileset dir="${project.home}/build/kotlinc/plugin" erroronmissingdir="false">
<fileset dir="${project.home}/build/kotlinc/plugin/Kotlin/lib" erroronmissingdir="false">
<include name="kotlin-plugin.jar"/>
</fileset>
<fileset dir="${idea.lib}">
+5
View File
@@ -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)
}
}
+1
View File
@@ -295,3 +295,4 @@ jetbrainsLibrary("JPS")
jetbrainsLibrary("Maven Embedder")
jetbrainsLibrary("tcServiceMessages")
jetbrainsLibrary("optimizedFileManager.jar")
jetbrainsLibrary("KotlinJavaRuntime")
+17
View File
@@ -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
@@ -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<PsiStatement> statements = getFinallyStatements(debuggerContext.getSourcePosition());
if (!statements.isEmpty()) {
@@ -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();
}
@@ -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<ThreadReferenceProxyImpl> mySteppingThroughThreads = new HashSet<ThreadReferenceProxyImpl>();
private final Set<ThreadReferenceProxyImpl> 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() {
@@ -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;
}
}
@@ -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<LookupElement
final char atTail = document.getCharsSequence().charAt(context.getTailOffset() - 1);
if (atTail != ';') {
LOG.error(LogMessageEx.createEvent("Unexpected character",
"atTail=" + atTail + "\n" +
"offset=" + context.getTailOffset() + "\n" +
"item=" + this + "\n" +
"item.class=" + this.getClass() + "\n" +
DebugUtil.currentStackTrace(),
AttachmentFactory.createAttachment(context.getDocument())));
return;
}
document.replaceString(context.getTailOffset() - 1, context.getTailOffset(), ".");
@@ -64,8 +64,13 @@ public class MarkerType {
myTooltip = tooltip;
handler = new GutterIconNavigationHandler<PsiElement>() {
@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);
}
});
}
};
}
@@ -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
@@ -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;
}
@@ -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());
}
@@ -23,7 +23,7 @@ import java.util.HashSet;
/**
* @author ven
*/
public class ReferencedElementsCollector extends JavaRecursiveElementWalkingVisitor {
public class ReferencedElementsCollector extends JavaRecursiveElementVisitor {
final HashSet<PsiMember> myReferencedMembers = new HashSet<PsiMember>();
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
@@ -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,
@@ -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 <code>name</code> is not a valid identifier or
* <code>type</code> 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;
/**
@@ -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;
}
@@ -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<PsiType, String>() {
@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));
}
@@ -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);
@@ -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<Block> iterator = createNewLineBlocksIterator();
while (iterator.hasNext()) {
iterator.next();
}
}
}
@@ -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");
@@ -5,6 +5,6 @@ public class X {
public int compareTo(String o) {
return 0;
}
}
};
}
}
@@ -1,10 +1,10 @@
public class X {
{
new Comparable<<spam>Object</spam>>() {
new Comparable<<spot>Object</spot>>() {
@Override
public int compareTo(Object o) {
return 0;
}
}
};
}
}
+2
View File
@@ -0,0 +1,2 @@
kotlin-runtime.jar
kotlin-reflect.jar
@@ -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<ContentBasedFileSubstitutor> 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);
}
@@ -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();
@@ -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
@@ -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);
@@ -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);
@@ -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
@@ -108,24 +108,6 @@ public class CompletionUtil {
return mainData != null ? mainData : ourGenericCompletionData;
}
/** @see CompletionDataEP */
@Deprecated
public static void registerCompletionData(FileType fileType, NotNullLazyValue<CompletionData> completionData) {
ourCustomCompletionDatas.put(fileType, completionData);
}
/** @see CompletionDataEP */
@Deprecated
public static void registerCompletionData(FileType fileType, final CompletionData completionData) {
registerCompletionData(fileType, new NotNullLazyValue<CompletionData>() {
@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<String> sortMatching(final PrefixMatcher matcher, Collection<String> _names) {
ProgressManager.checkCanceled();
if (matcher.getPrefix().isEmpty()) {
@@ -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;
@@ -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();
@@ -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++) {
@@ -71,19 +71,18 @@ public class NewLineBlocksIterator implements Iterator<Block> {
}
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);
}
}
@@ -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);
@@ -658,7 +658,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
public void holdSelection() {
myHeldSelection = getSelectionPaths();
clearSelection();
}
public void unholdSelection() {
@@ -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) {
@@ -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<Element> actionElements = element.getChildren(ACTION_TAG);
myActionIds = new String[actionElements.size()];
@@ -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);
}
}
}
@@ -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();
@@ -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");
}
}
@@ -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());
@@ -511,6 +511,7 @@ public class KeymapImpl extends ExternalizableSchemeAdapter implements Keymap {
return getKeymapManager().getActionBinding(actionId);
}
@NotNull
@Override
public Shortcut[] getShortcuts(String actionId) {
LinkedHashSet<Shortcut> 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 <code>MouseShortcut</code>
*/
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<String, ArrayList<KeyboardShortcut>> getConflicts(String actionId, KeyboardShortcut keyboardShortcut) {
public Map<String, ArrayList<KeyboardShortcut>> getConflicts(String actionId, KeyboardShortcut keyboardShortcut) {
HashMap<String, ArrayList<KeyboardShortcut>> result = new HashMap<String, ArrayList<KeyboardShortcut>>();
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
@@ -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<String, ArrayList<KeyboardShortcut>> conflicts = mySelectedKeymap.getConflicts(actionId, keyboardShortcut);
Map<String, ArrayList<KeyboardShortcut>> conflicts = mySelectedKeymap.getConflicts(actionId, keyboardShortcut);
if (conflicts.size() > 0) {
int result = Messages.showYesNoCancelDialog(
this,
@@ -50,7 +50,7 @@ class QuickListsUi implements ConfigurableUi<List<QuickList>> {
@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
@@ -722,23 +722,23 @@ public final class SchemesManagerImpl<T extends Scheme, E extends Externalizable
}
@Override
public void setSchemes(@NotNull final List<T> schemes, @Nullable Condition<T> removeCondition) {
public void setSchemes(@NotNull final List<T> newSchemes, @Nullable Condition<T> 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<T extends Scheme, E extends Externalizable
}
private void retainExternalInfo(@NotNull final List<T> schemes) {
if (schemeToInfo.isEmpty()) {
return;
}
schemeToInfo.retainEntries(new TObjectObjectProcedure<ExternalizableScheme, ExternalInfo>() {
@Override
public boolean execute(ExternalizableScheme scheme, ExternalInfo info) {
@@ -852,7 +856,7 @@ public final class SchemesManagerImpl<T extends Scheme, E extends Externalizable
@Override
public void setCurrentSchemeName(@Nullable String schemeName) {
myCurrentSchemeName = schemeName;
myCurrentScheme = schemeName == null ? null : findSchemeByName(schemeName);
myCurrentScheme = null;
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -17,12 +17,12 @@ package com.intellij.openapi.ui.playback.commands;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.AnActionListener;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.ui.playback.PlaybackContext;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TimedOutCallback;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.wm.IdeFocusManager;
import javax.swing.*;
@@ -57,7 +57,7 @@ public class ActionCommand extends TypeCommand {
final KeyboardShortcut ks = (KeyboardShortcut)each;
final KeyStroke first = ks.getFirstKeyStroke();
final KeyStroke second = ks.getSecondKeyStroke();
if (first != null && second == null) {
if (second == null) {
stroke = KeyStroke.getKeyStroke(first.getKeyCode(), first.getModifiers(), false);
break;
}
@@ -135,7 +135,7 @@ public class ActionCommand extends TypeCommand {
for (Shortcut each : shortcuts) {
if (each instanceof KeyboardShortcut) {
keyStroke = ((KeyboardShortcut)each).getFirstKeyStroke();
if (keyStroke != null) break;
break;
}
}
@@ -1108,7 +1108,11 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
// call update last, to let children a chance to update their cache first
if (node instanceof Node && node != getModelRoot() && isVisible == UsageViewTreeCellRenderer.RowLocation.INSIDE_VISIBLE_RECT) {
((Node)node).update(this);
try {
((Node)node).update(this);
}
catch (IndexNotReadyException ignore) {
}
}
}
@@ -2048,6 +2048,16 @@ public class UIUtil {
return null;
}
public static <T extends JComponent> T findParentByClass(@NotNull Component c, Class<T> 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);
@@ -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<Range.InnerRange> innerRanges = range.getInnerRanges();
for (Range.InnerRange innerRange : innerRanges) {
if (innerRange.getType() == Range.DELETED) continue;
@@ -500,37 +500,37 @@
<intentionAction>
<className>com.siyeh.ipp.exceptions.DetailExceptionsIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.try.statements</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.ConvertCatchToThrowsIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.try.statements</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.SplitMultiCatchIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.try.statements</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.ReplaceArmWithTryFinallyIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.try.statements</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.MergeNestedTryStatementsIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.try.statements</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.SplitTryWithMultipleResourcesIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.try.statements</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.ObscureThrownExceptionsIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.opassign.ReplaceWithOperatorAssignmentIntention</className>
@@ -575,17 +575,17 @@
<intentionAction>
<className>com.siyeh.ipp.asserttoif.AssertToIfIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.asserttoif.IfToAssertionIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.enumswitch.CreateEnumSwitchBranchesIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.constant.ConstantExpressionIntention</className>
@@ -622,5 +622,10 @@
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.opassign.PostfixPrefixIntention</className>
<bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
</extensions>
</idea-plugin>
@@ -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
@@ -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));
}
}
@@ -0,0 +1,5 @@
public class X {
void f(int i) {
++i;
}
}
@@ -0,0 +1,5 @@
public class X {
void f(int i) {
<spot>i++</spot>;
}
}
@@ -0,0 +1,5 @@
<html>
<body>
Replaces a postfix expression with a prefix expression and vice versa.
</body>
</html>
@@ -0,0 +1,5 @@
class Incomplete {
void m(int i) {
++<caret>
}
}
@@ -0,0 +1,6 @@
class Simple {
void m(int i) {
<caret>i++;
}
}
@@ -0,0 +1,6 @@
class Simple {
void m(int i) {
++i;
}
}
@@ -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";
}
}
@@ -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;
@@ -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<CoverageVie
myProject = project;
myDataManager = dataManager;
ToolWindow toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, true, ToolWindowAnchor.RIGHT, myProject);
ToolWindow toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, true, ToolWindowAnchor.RIGHT, myProject, true);
toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowCoverage);
toolWindow.setSplitMode(true, null);
myContentManager = toolWindow.getContentManager();
@@ -27,11 +27,11 @@ import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.actions.CloseAction;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdkType;
@@ -78,7 +78,7 @@ public class GroovyConsole {
myProcessHandler = handler;
}
public void execute(@NotNull String command) {
private void doExecute(@NotNull String command) {
// dirty hack
if (first) {
first = false;
@@ -94,8 +94,14 @@ public class GroovyConsole {
send(myProcessHandler, StringUtil.replace(command, "\n", "###\\n"));
}
public boolean stop() {
return ExecutionManager.getInstance(myProject).getContentManager().removeRunContent(defaultExecutor, myContentDescriptor);
public void execute(@NotNull String command) {
if (!StringUtil.isEmptyOrSpaces(command)) doExecute(command);
ExecutionManager.getInstance(myProject).getContentManager().toFrontRunContent(defaultExecutor, myContentDescriptor);
}
public void stop() {
myProcessHandler.destroyProcess(); // use force
ExecutionManager.getInstance(myProject).getContentManager().removeRunContent(defaultExecutor, myContentDescriptor);
}
private static void send(@NotNull ProcessHandler processHandler, @NotNull String command) {
@@ -163,7 +169,13 @@ public class GroovyConsole {
actionGroup.add(new BuildAndRestartConsoleAction(module, project, defaultExecutor, descriptor, restarter(project, contentFile)));
actionGroup.addSeparator();
actionGroup.addAll(consoleView.createConsoleActions());
actionGroup.add(new CloseAction(defaultExecutor, descriptor, project));
actionGroup.add(new CloseAction(defaultExecutor, descriptor, project) {
@Override
public void actionPerformed(AnActionEvent e) {
processHandler.destroyProcess(); // use force
super.actionPerformed(e);
}
});
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, false);
toolbar.setTargetComponent(consoleViewComponent);
@@ -172,19 +184,30 @@ public class GroovyConsole {
ui.add(consoleViewComponent, BorderLayout.CENTER);
ui.add(toolbar.getComponent(), BorderLayout.WEST);
consoleView.attachToProcess(processHandler);
project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
@Override
public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
if (file.equals(contentFile)) {
// if file was closed then kill process and hide console content
console.stop();
}
}
});
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
if (contentFile.getUserData(GROOVY_CONSOLE) == console) {
// process terminated either by closing file or by close action
contentFile.putUserData(GROOVY_CONSOLE, null);
}
}
});
processHandler.startNotify();
ExecutionManager.getInstance(project).getContentManager().showRunContent(defaultExecutor, descriptor);
contentFile.putUserData(GROOVY_CONSOLE, console);
consoleView.attachToProcess(processHandler);
processHandler.startNotify();
ExecutionManager.getInstance(project).getContentManager().showRunContent(defaultExecutor, descriptor);
return console;
}
@@ -198,7 +221,12 @@ public class GroovyConsole {
final String exePath = ((JavaSdkType)sdkType).getVMExecutablePath(sdk);
final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(exePath, javaParameters, true);
final Process process = commandLine.createProcess();
return new OSProcessHandler(process, commandLine.getCommandLineString());
return new OSProcessHandler(process, commandLine.getCommandLineString()) {
@Override
public boolean isSilentlyDestroyOnClose() {
return true;
}
};
}
catch (ExecutionException e) {
LOG.warn(e);
@@ -23,6 +23,7 @@ import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,7 +35,8 @@ import javax.swing.*;
public final class GroovyConsoleRootType extends ConsoleRootType {
public static final AnAction executeAction = new GrExecuteCommandAction();
public static final AnAction EXECUTE_ACTION = new GrExecuteCommandAction();
public static final String CONTENT_ID = "groovy_console";
@NotNull
public static GroovyConsoleRootType getInstance() {
@@ -56,10 +58,21 @@ public final class GroovyConsoleRootType extends ConsoleRootType {
return !GroovyConsoleStateService.getInstance(project).isProjectConsole(element);
}
@NotNull
@Override
public String getContentPathName(@NotNull String id) {
assert id == CONTENT_ID;
return CONTENT_ID;
}
@Nullable
@Override
public String substituteName(@NotNull Project project, @NotNull VirtualFile file) {
return GroovyConsoleStateService.getInstance(project).getSelectedModuleTitle(file);
final String name = file.getName();
final String moduleTitle = GroovyConsoleStateService.getInstance(project).getSelectedModuleTitle(file);
return name.startsWith(CONTENT_ID)
? StringUtil.replace(name, CONTENT_ID, moduleTitle == null ? "unknown" : moduleTitle)
: String.format("%s-%s", moduleTitle, name);
}
@Override
@@ -71,11 +84,11 @@ public final class GroovyConsoleRootType extends ConsoleRootType {
if (!(fileEditor instanceof TextEditor)) continue;
final Editor editor = ((TextEditor)fileEditor).getEditor();
final JPanel panel = new EditorHeaderComponent();
final DefaultActionGroup actionGroup = new DefaultActionGroup(new GrSelectModuleAction(projectConsole, file));
final DefaultActionGroup actionGroup = new DefaultActionGroup(EXECUTE_ACTION, new GrSelectModuleAction(projectConsole, file));
final ActionToolbar menu = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true);
panel.add(menu.getComponent());
editor.setHeaderComponent(panel);
executeAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, editor.getComponent());
EXECUTE_ACTION.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, editor.getComponent());
}
}
}
@@ -15,6 +15,7 @@
*/
package org.jetbrains.plugins.groovy.console.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -29,6 +30,10 @@ import org.jetbrains.plugins.groovy.console.GroovyConsole;
public class GrExecuteCommandAction extends AnAction {
public GrExecuteCommandAction() {
super(AllIcons.Toolwindows.ToolWindowRun);
}
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
@@ -49,7 +49,7 @@ public class GrNewConsoleAction extends AnAction {
final VirtualFile contentFile = ConsoleHistoryController.getContentFile(
GroovyConsoleRootType.getInstance(),
"groovy-console",
GroovyConsoleRootType.CONTENT_ID,
ScratchFileService.Option.create_new_always
);
assert contentFile != null;
@@ -70,12 +70,11 @@ public class GrSelectModuleAction extends AnAction {
public void consume(Module module) {
final Module existingModule = myProjectConsole.getSelectedModule(myFile);
if (module.equals(existingModule)) return;
final GroovyConsole groovyConsole = myFile.getUserData(GroovyConsole.GROOVY_CONSOLE);
if (groovyConsole == null || groovyConsole.stop()) {
myProjectConsole.setFileModule(myFile, module);
myFile.putUserData(GroovyConsole.GROOVY_CONSOLE, null);
ProjectView.getInstance(project).refresh();
}
final GroovyConsole existingConsole = myFile.getUserData(GroovyConsole.GROOVY_CONSOLE);
if (existingConsole != null) existingConsole.stop();
myProjectConsole.setFileModule(myFile, module);
myFile.putUserData(GroovyConsole.GROOVY_CONSOLE, null);
ProjectView.getInstance(project).refresh();
}
}, e.getDataContext());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 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.
@@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy.lang.surroundWith;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression;
@@ -26,12 +27,16 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryE
* @author Max Medvedev
*/
public class NotAndParenthesesSurrounder extends GroovyExpressionSurrounder {
@Override
protected TextRange surroundExpression(GrExpression expression, PsiElement context) {
GrUnaryExpression result = (GrUnaryExpression)GroovyPsiElementFactory.getInstance(expression.getProject()).createExpressionFromText("!(a)", context);
GroovyExpressionSurrounder.replaceToOldExpression(((GrParenthesizedExpression)result.getOperand()).getOperand(), expression);
result = (GrUnaryExpression)expression.replaceWithExpression(result, true);
return new TextRange(result.getTextRange().getEndOffset(), result.getTextRange().getEndOffset());
protected TextRange surroundExpression(@NotNull GrExpression expression, @NotNull PsiElement context) {
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(expression.getProject());
final GrUnaryExpression template = (GrUnaryExpression)factory.createExpressionFromText("!(a)", context);
assert template.getOperand() != null;
GroovyExpressionSurrounder.replaceToOldExpression(((GrParenthesizedExpression)template.getOperand()).getOperand(), expression);
final GrExpression result = expression.replaceWithExpression(template, true);
final int endOffset = result.getTextRange().getEndOffset();
return new TextRange(endOffset, endOffset);
}
@Override
+1
View File
@@ -318,6 +318,7 @@ def create_fork(original_name):
child_process = getattr(os, original_name)() # fork
if not child_process:
import pydevd
pydevd.threadingCurrentThread().__pydevd_main_thread = True
pydevd.settrace_forked()
return child_process
+2 -1
View File
@@ -424,7 +424,8 @@ class PyDB:
'Error in debugger: Found PyDBDaemonThread not marked with is_pydev_daemon_thread=True.\n')
if isThreadAlive(t):
return True
if not t.isDaemon() or hasattr(t, "__pydevd_main_thread"):
return True
return False
@@ -19,6 +19,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
@@ -34,6 +35,7 @@ import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.PathMappingSettings;
import com.jetbrains.python.PyBundle;
@@ -193,6 +195,7 @@ public class PythonSdkUpdater implements StartupActivity {
boolean changed = addNewSysPathEntries(sdk, modificator, sysPath);
changed = removeSourceRoots(sdk, modificator) || changed;
changed = removeDuplicateClassRoots(sdk, modificator) || changed;
changed = updateSkeletonsPath(sdk, modificator) || changed;
if (changed) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
@@ -257,6 +260,36 @@ public class PythonSdkUpdater implements StartupActivity {
return false;
}
/**
* Updates binary skeletons path in the Python SDK table.
*/
private static boolean updateSkeletonsPath(@NotNull Sdk sdk, @NotNull SdkModificator modificator) {
boolean changed = false;
final String skeletonsPath = PythonSdkType.getSkeletonsPath(PathManager.getSystemPath(), sdk.getHomePath());
if (skeletonsPath != null) {
final VirtualFile skeletonsDir = StandardFileSystems.local().refreshAndFindFileByPath(skeletonsPath);
if (skeletonsDir != null) {
LOG.info("Binary skeletons directory for SDK \"" + sdk.getName() + "\" (" + sdk.getHomePath() + "): " + skeletonsDir.getPath());
final List<VirtualFile> 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<VirtualFile> oldRoots) {
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(root);
if (file != null) {
@@ -20084,7 +20084,7 @@
<option name="flag" hit="Undefined Flag" />
<option name="undefined" hit="Undefined Flag" />
</configurable>
<configurable id="com.jetbrains.python.templateLanguages.TemplateLanguageModulesConfigurable" configurable_name="Python Template Languages">
<configurable id="com.jetbrains.python.templateLanguages.PyTemplateLanguageModulesConfigurable" configurable_name="Python Template Languages">
<option name="" hit="" />
<option name="languages" hit="Python Template Languages" />
<option name="python" hit="Python Template Languages" />
+8 -8
View File
@@ -763,22 +763,22 @@
</intentionAction>
<intentionAction>
<className>com.intellij.codeInsight.intention.impl.AddNotNullAnnotationIntention</className>
<category>Control Flow</category>
<category>Annotations</category>
<descriptionDirectoryName>AddAnnotationFix</descriptionDirectoryName>
</intentionAction>
<intentionAction>
<className>com.intellij.codeInsight.intention.impl.AddDeprecationAnnotationIntention</className>
<category>Control Flow</category>
<category>Annotations</category>
<descriptionDirectoryName>AddAnnotationFix</descriptionDirectoryName>
</intentionAction>
<intentionAction>
<className>com.intellij.codeInsight.intention.impl.AddNullableAnnotationIntention</className>
<category>Control Flow</category>
<category>Annotations</category>
<descriptionDirectoryName>AddAnnotationFix</descriptionDirectoryName>
</intentionAction>
<intentionAction>
<className>com.intellij.codeInspection.dataFlow.EditContractIntention</className>
<category>Control Flow</category>
<category>Annotations</category>
<descriptionDirectoryName>EditContractIntention</descriptionDirectoryName>
</intentionAction>
<intentionAction>
@@ -787,7 +787,7 @@
</intentionAction>
<intentionAction>
<className>com.intellij.codeInsight.intention.impl.DeannotateIntentionAction</className>
<category>Control Flow</category>
<category>Annotations</category>
</intentionAction>
<intentionAction>
<className>com.intellij.codeInsight.intention.impl.CreateSwitchIntention</className>
@@ -876,7 +876,7 @@
</intentionAction>
<intentionAction>
<className>com.intellij.codeInsight.intention.impl.AddOverrideAnnotationAction</className>
<category>Declaration</category>
<category>Annotations</category>
</intentionAction>
<intentionAction>
<className>com.intellij.codeInsight.daemon.impl.quickfix.DelegateWithDefaultParamValueIntentionAction</className>
@@ -961,7 +961,7 @@
<intentionAction>
<className>com.intellij.codeInsight.intention.impl.BreakStringOnLineBreaksIntentionAction</className>
<category>Other</category>
<category>Strings</category>
</intentionAction>
@@ -985,7 +985,7 @@
<intentionAction>
<className>com.intellij.codeInsight.intention.impl.SurroundAutoCloseableAction</className>
<category>Declaration</category>
<category>Try Statements</category>
</intentionAction>
<lang.parserDefinition language="JAVA" implementationClass="com.intellij.lang.java.JavaParserDefinition"/>
@@ -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;