diff --git a/.idea/libraries/jna.xml b/.idea/libraries/jna.xml
index 7a9e4319d055..d9fed3852d8f 100644
--- a/.idea/libraries/jna.xml
+++ b/.idea/libraries/jna.xml
@@ -3,7 +3,6 @@
-
diff --git a/colorSchemes/src/colorSchemes/Darcula.xml b/colorSchemes/src/colorSchemes/Darcula.xml
index 8356b0f6137a..bd7b3ac8efd0 100644
--- a/colorSchemes/src/colorSchemes/Darcula.xml
+++ b/colorSchemes/src/colorSchemes/Darcula.xml
@@ -1113,6 +1113,11 @@
+
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapFile.java b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapFile.java
index db0a0fbba311..da6bdbcc6fa7 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapFile.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapFile.java
@@ -15,6 +15,8 @@
*/
package com.intellij.debugger.impl;
+import org.jetbrains.annotations.NotNull;
+
import java.io.File;
/**
@@ -23,9 +25,10 @@ import java.io.File;
* Time: 2:23:38 PM
*/
public class HotSwapFile {
+ @NotNull
final File file;
- public HotSwapFile(File file) {
+ public HotSwapFile(@NotNull File file) {
this.file = file;
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java
index b7cd3f9ef9a1..7347b430cacd 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java
@@ -157,7 +157,12 @@ public class HotSwapManager extends AbstractProjectComponent {
private void reloadClasses(DebuggerSession session, Map classesToReload, HotSwapProgress progress) {
final long newSwapTime = System.currentTimeMillis();
new ReloadClassesWorker(session, progress).reloadClasses(classesToReload);
- setTimeStamp(session, newSwapTime);
+ if (progress.isCancelled()) {
+ session.setModifiedClassesScanRequired(true);
+ }
+ else {
+ setTimeStamp(session, newSwapTime);
+ }
}
public static Map> findModifiedClasses(List sessions, Map> generatedPaths) {
@@ -220,7 +225,13 @@ public class HotSwapManager extends AbstractProjectComponent {
swapProgress.setTitle(DebuggerBundle.message("progress.hotswap.scanning.classes"));
scanClassesCommand.run();
- return swapProgress.isCancelled() ? new HashMap>() : modifiedClasses;
+ if (swapProgress.isCancelled()) {
+ for (DebuggerSession session : sessions) {
+ session.setModifiedClassesScanRequired(true);
+ }
+ return new HashMap>();
+ }
+ return modifiedClasses;
}
public static void reloadModifiedClasses(final Map> modifiedClasses, final HotSwapProgress reloadClassesProgress) {
@@ -240,6 +251,10 @@ public class HotSwapManager extends AbstractProjectComponent {
debuggerSession, modifiedClasses.get(debuggerSession), reloadClassesProgress
);
}
+
+ protected void commandCancelled() {
+ debuggerSession.setModifiedClassesScanRequired(true);
+ }
});
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/MultiProcessCommand.java b/java/debugger/impl/src/com/intellij/debugger/impl/MultiProcessCommand.java
index db146c9aabf6..9fe6b8c390ff 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/MultiProcessCommand.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/MultiProcessCommand.java
@@ -19,11 +19,11 @@ import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.openapi.util.Pair;
-import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
public class MultiProcessCommand implements Runnable{
- private final List> myCommands = new ArrayList>();
+ private final List> myCommands = new LinkedList>();
public void run() {
while(true) {
@@ -40,7 +40,10 @@ public class MultiProcessCommand implements Runnable{
public void cancel() {
synchronized(myCommands) {
- myCommands.clear();
+ while (!myCommands.isEmpty()) {
+ Pair pair = myCommands.remove(0);
+ pair.getSecond().notifyCancelled();
+ }
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java b/java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java
index d8d8dd469c43..2898e3f10dd9 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java
@@ -31,6 +31,7 @@ import com.intellij.util.ui.UIUtil;
import com.sun.jdi.ReferenceType;
import org.jetbrains.annotations.Nullable;
+import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
@@ -113,35 +114,44 @@ class ReloadClassesWorker {
try {
RedefineProcessor redefineProcessor = new RedefineProcessor(virtualMachineProxy);
- int processedClassesCount = 0;
- for (final String qualifiedName : modifiedClasses.keySet()) {
- processedClassesCount++;
+ int processedEntriesCount = 0;
+ for (final Map.Entry entry : modifiedClasses.entrySet()) {
+ if (redefineProcessor.getProcessedClassesCount() == 0 && myProgress.isCancelled()) {
+ // once at least one class has been actually reloaded, do not interrupt the whole process
+ break;
+ }
+ processedEntriesCount++;
+ final String qualifiedName = entry.getKey();
if (qualifiedName != null) {
myProgress.setText(qualifiedName);
- myProgress.setFraction(processedClassesCount / (double)modifiedClasses.size());
+ myProgress.setFraction(processedEntriesCount / (double)modifiedClasses.size());
}
- final HotSwapFile fileDescr = modifiedClasses.get(qualifiedName);
- final byte[] content;
try {
- content = FileUtil.loadFileBytes(fileDescr.file);
+ redefineProcessor.processClass(qualifiedName, entry.getValue().file);
}
catch (IOException e) {
reportProblem(qualifiedName, e);
- continue;
}
- redefineProcessor.processClass(qualifiedName, content);
}
+
+ if (redefineProcessor.getProcessedClassesCount() == 0 && myProgress.isCancelled()) {
+ // once at least one class has been actually reloaded, do not interrupt the whole process
+ return;
+ }
+
redefineProcessor.processPending();
myProgress.setFraction(1);
final int partiallyRedefinedClassesCount = redefineProcessor.getPartiallyRedefinedClassesCount();
if (partiallyRedefinedClassesCount == 0) {
- myProgress.addMessage(myDebuggerSession, MessageCategory.INFORMATION,
- DebuggerBundle.message("status.classes.reloaded", redefineProcessor.getProcessedClassesCount()));
+ myProgress.addMessage(
+ myDebuggerSession, MessageCategory.INFORMATION, DebuggerBundle.message("status.classes.reloaded", redefineProcessor.getProcessedClassesCount())
+ );
}
else {
- final String message = DebuggerBundle.message("status.classes.not.all.versions.reloaded", partiallyRedefinedClassesCount,
- redefineProcessor.getProcessedClassesCount());
+ final String message = DebuggerBundle.message(
+ "status.classes.not.all.versions.reloaded", partiallyRedefinedClassesCount, redefineProcessor.getProcessedClassesCount()
+ );
myProgress.addMessage(myDebuggerSession, MessageCategory.WARNING, message);
}
@@ -233,10 +243,13 @@ class ReloadClassesWorker {
myVirtualMachineProxy = virtualMachineProxy;
}
- public void processClass(String qualifiedName, byte[] content) throws Throwable {
+ public void processClass(String qualifiedName, File file) throws Throwable {
final List vmClasses = myVirtualMachineProxy.classesByName(qualifiedName);
- if (vmClasses.isEmpty()) return;
+ if (vmClasses.isEmpty()) {
+ return;
+ }
+ final byte[] content = FileUtil.loadFileBytes(file);
if (vmClasses.size() == 1) {
myRedefineMap.put(vmClasses.get(0), content);
if (myRedefineMap.size() >= CLASSES_CHUNK_SIZE) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java
index 9c61c8c73fe5..19f94cbe8658 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java
@@ -269,8 +269,7 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent {
return result.get();
}
- private static void reloadModifiedClasses(final Map> modifiedClasses,
- final HotSwapProgressImpl progress) {
+ private static void reloadModifiedClasses(final Map> modifiedClasses, final HotSwapProgressImpl progress) {
ProgressManager.getInstance().runProcess(new Runnable() {
public void run() {
HotSwapManager.reloadModifiedClasses(modifiedClasses, progress);
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
index 15bb4fe3bd4c..6cf4070150cb 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
@@ -324,7 +324,7 @@ public class HighlightUtil extends HighlightUtilBase {
static boolean isIntersection(PsiTypeElement castTypeElement, PsiType castType) {
if (castType instanceof PsiIntersectionType) return true;
- return PsiTreeUtil.getChildrenOfType(castTypeElement, PsiTypeElement.class) != null;
+ return castType instanceof PsiClassType && PsiTreeUtil.getChildrenOfType(castTypeElement, PsiTypeElement.class) != null;
}
@Nullable
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/Constants.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/Constants.java
deleted file mode 100644
index 7a326a70d4c7..000000000000
--- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/Constants.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.intellij.codeInsight.completion.methodChains;
-
-/**
- * @author Dmitry Batkovich
- */
-public final class Constants {
-
- private Constants() {
- }
-
- /**
- * magic numbers
- */
- public static final int SINGLETON_MAGIC_RATIO = 100;
-
- public static final int SINGLETON_MAGIC_RATIO2 = 5;
-
- public static final int CHAIN_SEARCH_MAGIC_RATIO = 12;
-
-}
diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/ClassFileData.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/ClassFileData.java
deleted file mode 100644
index 10508d039791..000000000000
--- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/ClassFileData.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package com.intellij.compilerOutputIndex.impl;
-
-import com.intellij.codeInsight.completion.methodChains.ChainCompletionStringUtil;
-import com.intellij.compilerOutputIndex.api.fs.AsmUtil;
-import org.jetbrains.asm4.ClassReader;
-import org.jetbrains.asm4.ClassVisitor;
-import org.jetbrains.asm4.MethodVisitor;
-import org.jetbrains.asm4.Opcodes;
-import org.jetbrains.asm4.tree.ClassNode;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Dmitry Batkovich
- */
-public class ClassFileData {
- private final List myMethodDatas;
-
- public ClassFileData(final ClassNode classNode) {
- this(classNode, true);
- }
-
- public ClassFileData(final ClassNode classNode, final boolean checkForPrimitiveReturn) {
- myMethodDatas = new ArrayList();
- classNode.accept(new ClassVisitor(Opcodes.ASM4) {
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name,
- final String desc,
- final String signature,
- final String[] exceptions) {
- final MethodDataAccumulator methodDataAccumulator = new MethodDataAccumulator(checkForPrimitiveReturn);
- myMethodDatas.add(methodDataAccumulator.getMethodData());
- return methodDataAccumulator;
- }
- });
- }
-
- public List getMethodDatas() {
- return myMethodDatas;
- }
-
- public static class MethodData {
- private final List myMethodInsnSignatures = new ArrayList();
-
- private void addSign(final MethodInsnSignature signature) {
- myMethodInsnSignatures.add(signature);
- }
-
- public List getMethodInsnSignatures() {
- return myMethodInsnSignatures;
- }
- }
-
- private static class MethodDataAccumulator extends MethodVisitor {
- private final MethodData myMethodData = new MethodData();
- private final boolean myCheckForPrimitiveReturn;
-
- public MethodDataAccumulator(final boolean checkForPrimitiveReturn) {
- super(Opcodes.ASM4);
- myCheckForPrimitiveReturn = checkForPrimitiveReturn;
- }
-
- private MethodData getMethodData() {
- return myMethodData;
- }
-
- @Override
- public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {
- if (MethodIncompleteSignature.CONSTRUCTOR_METHOD_NAME.equals(name)) {
- return;
- }
- final String ownerClassName = AsmUtil.getQualifiedClassName(owner);
- if (ChainCompletionStringUtil.isPrimitiveOrArrayOfPrimitives(ownerClassName)) {
- return;
- }
- if (myCheckForPrimitiveReturn) {
- final String returnType = AsmUtil.getReturnType(desc);
- if (ChainCompletionStringUtil.isPrimitiveOrArrayOfPrimitives(returnType)) {
- return;
- }
- }
- myMethodData.addSign(new MethodInsnSignature(opcode, owner, name, desc));
- }
- }
-
- public static class MethodInsnSignature {
- private final int myOpcode;
- private final String myOwner;
- private final String myName;
- private final String myDesc;
-
- private MethodInsnSignature(final int opcode, final String owner, final String name, final String desc) {
- myOpcode = opcode;
- myOwner = owner;
- myName = name;
- myDesc = desc;
- }
-
- public int getOpcode() {
- return myOpcode;
- }
-
- public String getOwner() {
- return myOwner;
- }
-
- public String getName() {
- return myName;
- }
-
- public String getDesc() {
- return myDesc;
- }
- }
-}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/CompilerOutputBaseGramsIndex.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/CompilerOutputBaseGramsIndex.java
deleted file mode 100644
index b5a183a45eaf..000000000000
--- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/CompilerOutputBaseGramsIndex.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.intellij.compilerOutputIndex.impl;
-
-import com.google.common.collect.HashMultiset;
-import com.google.common.collect.Multiset;
-import com.intellij.compilerOutputIndex.api.indexer.CompilerOutputBaseIndex;
-import com.intellij.openapi.project.Project;
-import com.intellij.util.indexing.StorageException;
-import com.intellij.util.indexing.ValueContainer;
-import com.intellij.util.io.KeyDescriptor;
-
-import java.util.TreeSet;
-
-/**
- * @author Dmitry Batkovich
- */
-public abstract class CompilerOutputBaseGramsIndex extends CompilerOutputBaseIndex> {
-
- protected CompilerOutputBaseGramsIndex(final KeyDescriptor keyDescriptor, final Project project) {
- super(keyDescriptor, new GuavaHashMultiSetExternalizer(MethodIncompleteSignature.createKeyDescriptor()), project);
- }
-
- public TreeSet getValues(final K key) {
- try {
- final ValueContainer> valueContainer = myIndex.getData(key);
- final Multiset rawValues = HashMultiset.create();
- valueContainer.forEach(new ValueContainer.ContainerAction>() {
- @Override
- public boolean perform(final int id, final Multiset values) {
- for (final Multiset.Entry entry : values.entrySet()) {
- rawValues.add(entry.getElement(), entry.getCount());
- }
- return true;
- }
- });
- return rawValuesToValues(rawValues);
- } catch (StorageException e) {
- throw new RuntimeException();
- }
- }
-
- private static TreeSet rawValuesToValues(final Multiset rawValues) {
- final TreeSet values = new TreeSet();
- for (final Multiset.Entry entry : rawValues.entrySet()) {
- values.add(new UsageIndexValue(entry.getElement(), entry.getCount()));
- }
- return values;
- }
-}
diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/Bigram.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/Bigram.java
deleted file mode 100644
index f5f4ff87a095..000000000000
--- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/Bigram.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.intellij.compilerOutputIndex.impl.bigram;
-
-import com.intellij.openapi.util.Pair;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author Dmitry Batkovich
- */
-public class Bigram extends Pair {
- public Bigram(@NotNull final E first, @NotNull final E second) {
- super(first, second);
- }
-
- public Bigram swap() {
- return new Bigram(second, first);
- }
-
- @Override
- public String toString() {
- return String.format("%s - %s", first, second);
- }
-}
diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/BigramMethodsUsageIndex.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/BigramMethodsUsageIndex.java
deleted file mode 100644
index 31bf75fef612..000000000000
--- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/BigramMethodsUsageIndex.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.intellij.compilerOutputIndex.impl.bigram;
-
-import com.google.common.collect.HashMultiset;
-import com.google.common.collect.Multiset;
-import com.intellij.compilerOutputIndex.api.fs.AsmUtil;
-import com.intellij.compilerOutputIndex.api.indexer.CompilerOutputIndexer;
-import com.intellij.compilerOutputIndex.impl.ClassFileData;
-import com.intellij.compilerOutputIndex.impl.CompilerOutputBaseGramsIndex;
-import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignature;
-import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignatureChain;
-import com.intellij.openapi.project.Project;
-import com.intellij.util.SmartList;
-import com.intellij.util.indexing.DataIndexer;
-import com.intellij.util.indexing.ID;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.asm4.ClassReader;
-import org.jetbrains.asm4.Opcodes;
-import org.jetbrains.asm4.tree.ClassNode;
-
-import java.util.*;
-
-/**
- * @author Dmitry Batkovich
- */
-public class BigramMethodsUsageIndex extends CompilerOutputBaseGramsIndex {
- public static BigramMethodsUsageIndex getInstance(final Project project) {
- return CompilerOutputIndexer.getInstance(project).getIndex(BigramMethodsUsageIndex.class);
- }
-
- public BigramMethodsUsageIndex( final Project project) {
- super(MethodIncompleteSignature.createKeyDescriptor(), project);
- }
-
- @Override
- protected ID> getIndexId() {
- return generateIndexId("BigramMethodsUsage");
- }
-
- @Override
- protected int getVersion() {
- return 0;
- }
-
- @Override
- protected DataIndexer,ClassNode> getIndexer() {
- //
- // not fair way, but works fast
- //
- return new DataIndexer, ClassNode>() {
- @NotNull
- @Override
- public Map> map(final ClassNode inputData) {
- final Map> map =
- new HashMap>();
- for (final ClassFileData.MethodData data : new ClassFileData(inputData).getMethodDatas()) {
- final SimpleBigramsExtractor extractor = new SimpleBigramsExtractor(new SimpleBigramsExtractor.BigramMethodIncompleteSignatureProcessor() {
- @Override
- public void process(final Bigram bigram) {
- final MethodIncompleteSignature secondGram = bigram.getSecond();
- Multiset occurrences = map.get(secondGram);
- if (occurrences == null) {
- occurrences = HashMultiset.create();
- map.put(secondGram, occurrences);
- }
- occurrences.add(bigram.getFirst());
- }
- });
- for (final ClassFileData.MethodInsnSignature ms : data.getMethodInsnSignatures()) {
- final List methodInvocations = new SmartList();
- final String ownerClassName = AsmUtil.getQualifiedClassName(ms.getOwner());
- final String returnType = AsmUtil.getReturnType(ms.getDesc());
-
- if (ms.getName().equals(MethodIncompleteSignature.CONSTRUCTOR_METHOD_NAME)) {
- methodInvocations.add(MethodIncompleteSignature.constructor(ownerClassName));
- }
- else {
- methodInvocations.add(new MethodIncompleteSignature(ownerClassName, returnType, ms.getName(), ms.getOpcode() == Opcodes.INVOKESTATIC));
- }
- extractor.addChain(new MethodIncompleteSignatureChain(methodInvocations));
- }
- }
- return map;
- }
- };
- }
-
-}
diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/SimpleBigramsExtractor.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/SimpleBigramsExtractor.java
deleted file mode 100644
index d231a07e0f18..000000000000
--- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/SimpleBigramsExtractor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.intellij.compilerOutputIndex.impl.bigram;
-
-import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignature;
-import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignatureChain;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-/**
-* @author Dmitry Batkovich
-*/
-class SimpleBigramsExtractor {
- private final Map myHolder = new HashMap();
- private final BigramMethodIncompleteSignatureProcessor myProcessor;
-
- public SimpleBigramsExtractor(final BigramMethodIncompleteSignatureProcessor processor) {
- myProcessor = processor;
- }
-
- public void addChain(final MethodIncompleteSignatureChain chain) {
- if (chain.isEmpty()) {
- return;
- }
- final MethodIncompleteSignature firstInvocation = chain.getFirstInvocation();
- assert firstInvocation != null;
- final MethodIncompleteSignature head = firstInvocation.isStatic() ? null : myHolder.get(firstInvocation.getOwner());
- for (final Bigram bigram : toBigrams(head, chain)) {
- myProcessor.process(bigram);
- }
- final MethodIncompleteSignature lastInvocation = chain.getLastInvocation();
- assert lastInvocation != null;
- myHolder.put(lastInvocation.getReturnType(), lastInvocation);
- }
-
- private static Collection> toBigrams(final @Nullable MethodIncompleteSignature head,
- final @NotNull MethodIncompleteSignatureChain chain) {
- MethodIncompleteSignature currentLast = null;
- if (head != null) {
- currentLast = head;
- }
- final List> bigrams = new ArrayList>(chain.size());
- for (final MethodIncompleteSignature current : chain.list()) {
- if (currentLast != null) {
- bigrams.add(new Bigram(currentLast, current));
- }
- currentLast = current;
- }
- return bigrams;
- }
-
- public interface BigramMethodIncompleteSignatureProcessor {
- void process(Bigram bigram);
- }
-}
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
index 0591b8f27d47..ea5a668221af 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
@@ -1661,7 +1661,7 @@ public class JavaDocInfoGenerator {
return length;
}
- if (type instanceof PsiDisjunctionType) {
+ if (type instanceof PsiDisjunctionType || type instanceof PsiIntersectionType) {
if (!generateLink) {
final String text = StringUtil.escapeXml(type.getCanonicalText());
buffer.append(text);
@@ -1669,9 +1669,17 @@ public class JavaDocInfoGenerator {
}
else {
int length = 0;
- for (PsiType psiType : ((PsiDisjunctionType)type).getDisjunctions()) {
+ final String separator = type instanceof PsiDisjunctionType ? " | " : " & ";
+ final List componentTypes;
+ if (type instanceof PsiIntersectionType) {
+ componentTypes = Arrays.asList(((PsiIntersectionType)type).getConjuncts());
+ }
+ else {
+ componentTypes = ((PsiDisjunctionType)type).getDisjunctions();
+ }
+ for (PsiType psiType : componentTypes) {
if (length > 0) {
- buffer.append(" | ");
+ buffer.append(separator);
length += 3;
}
length += generateType(buffer, psiType, context, generateLink);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
index de5d470e8e69..7ff660151a47 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
@@ -219,6 +219,9 @@ public class InferenceSession {
}
}
+ for (InferenceVariable inferenceVariable : myInferenceVariables.values()) {
+ inferenceVariable.ignoreInstantiation();
+ }
mySiteSubstitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor, true);
for (InferenceVariable inferenceVariable : myInferenceVariables.values()) {
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther2/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther2/TestCompletion.java
new file mode 100644
index 000000000000..91049125c874
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther2/TestCompletion.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+interface PsiManager {
+
+}
+interface PsiElement {
+ PsiManager getManager();
+}
+interface PsiClass extends PsiElement {
+}
+interface PsiMethod extends PsiElement {
+ PsiClass getContainingClass();
+}
+interface PsiMethodCallExpression extends PsiElement {
+ PsiMethod resolveMethod();
+}
+public class TestCompletion {
+
+ public void method() {
+ PsiManager m =
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther2/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther2/TestIndex.java
new file mode 100644
index 000000000000..d67745925689
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther2/TestIndex.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+public class TestIndex {
+
+ public void statMethod(PsiMethodCallExpression e) {
+ e.resolveMethod().getContainingClass().getManager();
+ e.resolveMethod().getContainingClass().getManager();
+ e.resolveMethod().getContainingClass().getManager();
+ e.resolveMethod().getContainingClass().getManager();
+ e.resolveMethod().getContainingClass().getManager();
+ }
+}
+interface PsiManager {
+
+}
+interface PsiElement {
+ PsiManager getManager();
+}
+interface PsiClass extends PsiElement {
+}
+interface PsiMethod extends PsiElement {
+ PsiClass getContainingClass();
+}
+interface PsiMethodCallExpression extends PsiElement {
+ PsiMethod resolveMethod();
+}
diff --git a/java/java-tests/testSrc/com/intellij/patterns/VirtualFilePatternsTest.groovy b/java/java-tests/testSrc/com/intellij/patterns/VirtualFilePatternsTest.groovy
new file mode 100644
index 000000000000..18d5622132b6
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/patterns/VirtualFilePatternsTest.groovy
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.patterns
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
+/**
+ * @author peter
+ */
+public class VirtualFilePatternsTest extends LightCodeInsightFixtureTestCase {
+
+ public void testWithSuperParent() {
+ def file = myFixture.addFileToProject("foo/bar.txt", "").virtualFile
+ assert PlatformPatterns.virtualFile().withSuperParent(1, PlatformPatterns.virtualFile().withName("foo")).accepts(file)
+ assert !PlatformPatterns.virtualFile().withSuperParent(1, PlatformPatterns.virtualFile().withName("bar")).accepts(file)
+ assert !PlatformPatterns.virtualFile().withSuperParent(2, PlatformPatterns.virtualFile().withName("bar")).accepts(file)
+ assert !PlatformPatterns.virtualFile().withSuperParent(10, PlatformPatterns.virtualFile().withName("bar")).accepts(file)
+ assert !PlatformPatterns.virtualFile().withSuperParent(10, PlatformPatterns.virtualFile().withName("foo")).accepts(file)
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterInEditorTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterInEditorTest.java
index de3e88e4e6c1..7355feba87e3 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterInEditorTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterInEditorTest.java
@@ -23,13 +23,13 @@ import org.jetbrains.annotations.NotNull;
import java.io.IOException;
/**
- * Is intended to test formatting in editor behavior, i.e. check how formatting affects things like caret position, selection etc.
- *
+ * Is intended to test formatting in editor behavior, i.e. check how formatting affects things like caret position, selection etc.
+ *
* @author Denis Zhdanov
* @since 6/1/11 6:17 PM
*/
public class JavaFormatterInEditorTest extends LightPlatformCodeInsightTestCase {
-
+
public void testCaretPositionOnLongLineWrapping() throws IOException {
// Inspired by IDEA-70242
getCurrentCodeStyleSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
@@ -39,7 +39,7 @@ public class JavaFormatterInEditorTest extends LightPlatformCodeInsightTestCase
"\n" +
"class Test {\n" +
"}",
-
+
"import static java.util.concurrent\n" +
" .atomic.AtomicInteger.*;\n" +
"\n" +
@@ -47,10 +47,59 @@ public class JavaFormatterInEditorTest extends LightPlatformCodeInsightTestCase
"}"
);
}
-
+
+ public void testCaretPositionPreserved_WhenOnSameLineWithWhiteSpacesOnly() throws IOException {
+ String text = "class Test {\n" +
+ " void test() {\n" +
+ " \n" +
+ " }\n" +
+ "}";
+ doTest(text, text);
+
+ String before = "class Test {\n" +
+ " void test() {\n" +
+ " \n" +
+ " }\n" +
+ "}";
+ doTest(before, text);
+ }
+
+ public void testCaretPositionPreserved_WhenSomeFormattingNeeded() throws IOException {
+ String before = "public class Test {\n" +
+ " int a;\n" +
+ " \n" +
+ " public static void main(String[] args) {\n" +
+ " \n" +
+ " }\n" +
+ "\n" +
+ " static final long j = 2;\n" +
+ "}";
+ String after = "public class Test {\n" +
+ " int a;\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " \n" +
+ " }\n" +
+ "\n" +
+ " static final long j = 2;\n" +
+ "}";
+ doTest(before, after);
+
+ before = "public class Test {\n" +
+ " int a;\n" +
+ " \n" +
+ " public static void main(String[] args) {\n" +
+ " \n" +
+ " }\n" +
+ "\n" +
+ " static final long j = 2;\n" +
+ "}";
+ doTest(before, after);
+ }
+
public void doTest(@NotNull String before, @NotNull String after) throws IOException {
configureFromFileText(getTestName(false) + ".java", before);
CodeStyleManager.getInstance(getProject()).reformatText(getFile(), 0, getEditor().getDocument().getTextLength());
checkResultByText(after);
}
-}
+}
\ No newline at end of file
diff --git a/lib/jna-platform.jar b/lib/jna-platform.jar
deleted file mode 100644
index 4b3d567c6209..000000000000
Binary files a/lib/jna-platform.jar and /dev/null differ
diff --git a/lib/required_for_dist.txt b/lib/required_for_dist.txt
index f7e7e48ef0b0..5f749bcff7f8 100644
--- a/lib/required_for_dist.txt
+++ b/lib/required_for_dist.txt
@@ -21,7 +21,6 @@ jgoodies-forms.jar
jgoodies-looks-2.4.2.jar
jh.jar
jna-utils.jar
-jna-platform.jar
jna.jar
jsch-0.1.50.jar
jsr166e.jar
diff --git a/platform/core-api/src/com/intellij/patterns/TreeElementPattern.java b/platform/core-api/src/com/intellij/patterns/TreeElementPattern.java
index 9f843d7cb88c..084be74c0031 100644
--- a/platform/core-api/src/com/intellij/patterns/TreeElementPattern.java
+++ b/platform/core-api/src/com/intellij/patterns/TreeElementPattern.java
@@ -118,7 +118,7 @@ public abstract class TreeElementPattern processor) {
ParentType parent = t;
for (int i = 0; i < level; i++) {
- if (parent == null) return false;
+ if (parent == null) return true;
parent = getParent(parent);
}
return processor.process(parent, context);
diff --git a/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java b/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java
index b342e2b8bde9..4fe378ce9076 100644
--- a/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java
+++ b/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java
@@ -259,13 +259,13 @@ public class PsiTreeUtil {
}
@NotNull
- public static Collection findChildrenOfType(@Nullable PsiElement element, @NotNull Class aClass) {
+ public static Collection findChildrenOfType(@Nullable PsiElement element, @NotNull Class extends T> aClass) {
return findChildrenOfAnyType(element, aClass);
}
@NotNull
public static Collection findChildrenOfAnyType(@Nullable final PsiElement element,
- @NotNull final Class... classes) {
+ @NotNull final Class extends T>... classes) {
if (element == null) {
return ContainerUtil.emptyList();
}
diff --git a/platform/icons/src/javaee/web_xml.png b/platform/icons/src/javaee/web_xml.png
index 760533d662db..ac51ed31cff8 100644
Binary files a/platform/icons/src/javaee/web_xml.png and b/platform/icons/src/javaee/web_xml.png differ
diff --git a/platform/icons/src/javaee/web_xml@2x.png b/platform/icons/src/javaee/web_xml@2x.png
new file mode 100644
index 000000000000..a849ced5c3f4
Binary files /dev/null and b/platform/icons/src/javaee/web_xml@2x.png differ
diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/FontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/FontOptions.java
index 3d19b28fd8f9..b66eef0c68bd 100644
--- a/platform/lang-impl/src/com/intellij/application/options/colors/FontOptions.java
+++ b/platform/lang-impl/src/com/intellij/application/options/colors/FontOptions.java
@@ -27,24 +27,26 @@ import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.ListSpeedSearch;
import com.intellij.ui.components.JBCheckBox;
-import com.intellij.ui.components.JBList;
-import com.intellij.ui.components.JBMovePanel;
import com.intellij.util.EventDispatcher;
-import com.intellij.util.containers.ContainerUtilRt;
-import com.intellij.util.ui.GridBag;
+import com.intellij.util.ReflectionUtil;
import com.intellij.util.ui.UIUtil;
+import net.miginfocom.swing.MigLayout;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import javax.swing.event.*;
+import javax.swing.event.DocumentEvent;
+import javax.swing.plaf.basic.ComboPopup;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.util.*;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
public class FontOptions extends JPanel implements OptionsPanel{
@@ -55,162 +57,95 @@ public class FontOptions extends JPanel implements OptionsPanel{
@NotNull private final ColorAndFontOptions myOptions;
- @NotNull private final DefaultListModel myAllFontsModel = new DefaultListModel();
- @NotNull private final JBList myAllFontsList = new JBList(myAllFontsModel);
- @NotNull private final DefaultListModel mySelectedFontsModel = new DefaultListModel();
- @NotNull private final JBList mySelectedFontsList = new JBList(mySelectedFontsModel);
- @NotNull private final JBMovePanel myFontsControl = new JBMovePanel(myAllFontsList, mySelectedFontsList) {
- @SuppressWarnings("SSBasedInspection")
- @Override
- public void paint(Graphics g) {
- super.paint(g);
- if (myFontNames == null) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- initFontTables();
- }
- });
- }
- }
- };
-
- @NotNull private final JTextField myEditorFontSizeField = new MyTextField(4);
- @NotNull private final JTextField myLineSpacingField = new MyTextField(4);
+ @NotNull private final JTextField myEditorFontSizeField = new JTextField(4);
+ @NotNull private final JTextField myLineSpacingField = new JTextField(4);
+ private final FontNameCombo myPrimaryCombo = new FontNameCombo(null);
+ private final JCheckBox myUseSecondaryFontCheckbox = new JCheckBox(ApplicationBundle.message("secondary.font"));
+ private final FontNameCombo mySecondaryCombo = new FontNameCombo(null);
@NotNull private final JBCheckBox myOnlyMonospacedCheckBox =
new JBCheckBox(ApplicationBundle.message("checkbox.show.only.monospaced.fonts"));
- @Nullable private final Dimension myPreferredSize;
private boolean myIsInSchemeChange;
- private final String myTitle;
+
public FontOptions(ColorAndFontOptions options) {
this(options, ApplicationBundle.message("group.editor.font"));
}
protected FontOptions(@NotNull ColorAndFontOptions options, final String title) {
- super(new GridBagLayout());
+ setLayout(new MigLayout("ins 0, gap 5, flowx"));
+ Insets borderInsets = new Insets(IdeBorderFactory.TITLED_BORDER_TOP_INSET,
+ IdeBorderFactory.TITLED_BORDER_LEFT_INSET,
+ 0,
+ IdeBorderFactory.TITLED_BORDER_RIGHT_INSET);
+ setBorder(IdeBorderFactory.createTitledBorder(title, false, borderInsets));
myOptions = options;
- myTitle = title;
- add(createEditorFontPanel(), new GridBag().weightx(1).weighty(1).fillCell().coverLine());
+ add(myOnlyMonospacedCheckBox, "sgx b, sx 2");
+
+ add(new JLabel(ApplicationBundle.message("primary.font")), "newline, ax right");
+ add(myPrimaryCombo, "sgx b");
+ add(new JLabel(ApplicationBundle.message("editbox.font.size")), "gapleft 20");
+ add(myEditorFontSizeField);
+ add(new JLabel(ApplicationBundle.message("editbox.line.spacing")), "gapleft 20");
+ add(myLineSpacingField);
+
add(new JLabel(ApplicationBundle.message("label.fallback.fonts.list.description"),
MessageType.INFO.getDefaultIcon(),
- SwingConstants.LEFT),
- new GridBag().anchor(GridBagConstraints.WEST));
- myFontsControl.setShowButtons(JBMovePanel.ButtonType.LEFT, JBMovePanel.ButtonType.RIGHT);
- myFontsControl.setListLabels(ApplicationBundle.message("title.font.available"), ApplicationBundle.message("title.font.selected"));
- myFontsControl.setEnabled(false); // Disable the controls until fonts are loaded.
- myFontsControl.setLeftInsertionStrategy(JBMovePanel.NATURAL_ORDER);
+ SwingConstants.LEFT), "newline, sx 5");
+ add(myUseSecondaryFontCheckbox, "newline, ax right");
+ add(mySecondaryCombo, "sgx b");
+
+ myOnlyMonospacedCheckBox.setBorder(null);
+ myUseSecondaryFontCheckbox.setBorder(null);
+ mySecondaryCombo.setEnabled(false);
+
myOnlyMonospacedCheckBox.setSelected(EditorColorsManager.getInstance().isUseOnlyMonospacedFonts());
- new ListSpeedSearch(myAllFontsList);
- new ListSpeedSearch(mySelectedFontsList);
-
- // Almost all other color scheme pages use the following pattern:
- //
- // __________________________________________
- // | color keys | color and font settings |
- //
- // Here page's height is calculated on the 'color and font settings' preferred height (debugged a lot to ensure that).
- // The idea is to configure current page to use the same height as other pages. That's why we set it up to use the same preferred
- // size as 'color and font settings' control.
- myPreferredSize = new ColorAndFontDescriptionPanel().getPreferredSize();
- if (myFontNames != null) {
- onFontsInit();
- }
- initListeners();
- }
-
- @Override
- public Dimension getMinimumSize() {
- return getPreferredSize();
- }
-
- @Override
- public Dimension getPreferredSize() {
- return myPreferredSize == null ? super.getPreferredSize() : myPreferredSize;
- }
-
- private void initListeners() {
myOnlyMonospacedCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- boolean onlyMonospaced = myOnlyMonospacedCheckBox.isSelected();
- EditorColorsManager.getInstance().setUseOnlyMonospacedFonts(onlyMonospaced);
- onFontsInit();
+ EditorColorsManager.getInstance().setUseOnlyMonospacedFonts(myOnlyMonospacedCheckBox.isSelected());
+ myPrimaryCombo.updateModel();
+ mySecondaryCombo.updateModel();
}
});
-
- mySelectedFontsModel.addListDataListener(new ListDataListener() {
+ myUseSecondaryFontCheckbox.addActionListener(new ActionListener() {
@Override
- public void intervalAdded(ListDataEvent e) {
+ public void actionPerformed(ActionEvent e) {
+ mySecondaryCombo.setEnabled(myUseSecondaryFontCheckbox.isSelected());
syncFontFamilies();
}
-
- @Override
- public void intervalRemoved(ListDataEvent e) {
- syncFontFamilies();
- }
-
- @Override
- public void contentsChanged(ListDataEvent e) {
- syncFontFamilies();
- }
-
- private void syncFontFamilies() {
- if (myIsInSchemeChange) {
- return;
- }
- FontPreferences fontPreferences = getFontPreferences();
- fontPreferences.clearFonts();
- Enumeration elements = mySelectedFontsModel.elements();
- while (elements.hasMoreElements()) {
- String fontFamily = (String)elements.nextElement();
- // Don't save a single 'default' font family at the font preferences.
- if (mySelectedFontsModel.getSize() > 1 || !FontPreferences.DEFAULT_FONT_NAME.equals(fontFamily)) {
- fontPreferences.addFontFamily(fontFamily);
- }
- }
- }
});
-
- mySelectedFontsList.addListSelectionListener(new ListSelectionListener() {
+ ItemListener itemListener = new ItemListener() {
@Override
- public void valueChanged(ListSelectionEvent e) {
- Object value = mySelectedFontsList.getSelectedValue();
- if (value != null) {
- boolean toRestore = myIsInSchemeChange;
- myIsInSchemeChange = true;
- try {
- myEditorFontSizeField.setText(String.valueOf(getFontPreferences().getSize((String)value)));
- }
- finally {
- myIsInSchemeChange = toRestore;
- }
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ syncFontFamilies();
}
}
- });
+ };
+ myPrimaryCombo.addItemListener(itemListener);
+ mySecondaryCombo.addItemListener(itemListener);
+
+ ActionListener actionListener = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ syncFontFamilies();
+ }
+ };
+ myPrimaryCombo.addActionListener(actionListener);
+ mySecondaryCombo.addActionListener(actionListener);
myEditorFontSizeField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void textChanged(DocumentEvent event) {
if (myIsInSchemeChange || !SwingUtilities.isEventDispatchThread()) return;
- try {
- int fontSize = Integer.parseInt(myEditorFontSizeField.getText());
- if (fontSize < 1) fontSize = 1;
- if (fontSize > OptionsConstants.MAX_EDITOR_FONT_SIZE) fontSize = OptionsConstants.MAX_EDITOR_FONT_SIZE;
- Object selectedFont = mySelectedFontsList.getSelectedValue();
- if (selectedFont != null) {
- FontPreferences fontPreferences = getFontPreferences();
- fontPreferences.register((String)selectedFont, fontSize);
- }
- }
- catch (NumberFormatException e) {
- // OK, ignore
- }
- finally {
- updateDescription(true);
+ Object selectedFont = myPrimaryCombo.getSelectedItem();
+ if (selectedFont instanceof String) {
+ FontPreferences fontPreferences = getFontPreferences();
+ fontPreferences.register((String)selectedFont, getFontSizeFromField());
}
+ updateDescription(true);
}
});
@@ -218,26 +153,57 @@ public class FontOptions extends JPanel implements OptionsPanel{
@Override
public void textChanged(DocumentEvent event) {
if (myIsInSchemeChange) return;
- float lineSpacing = 1;
- try {
- lineSpacing = Float.parseFloat(myLineSpacingField.getText());
- }
- catch (NumberFormatException e) {
- // OK, ignore
- }
- finally {
- if (lineSpacing <= 0) lineSpacing = 1;
- if (lineSpacing > 30) lineSpacing = 30;
- if (getLineSpacing() != lineSpacing) {
- setCurrentLineSpacing(lineSpacing);
- }
- updateDescription(true);
+ float lineSpacing = getLineSpacingFromField();
+ if (getLineSpacing() != lineSpacing) {
+ setCurrentLineSpacing(lineSpacing);
}
+ updateDescription(true);
}
});
-
}
+ private int getFontSizeFromField() {
+ try {
+ return Math.min(OptionsConstants.MAX_EDITOR_FONT_SIZE, Math.max(1, Integer.parseInt(myEditorFontSizeField.getText())));
+ }
+ catch (NumberFormatException e) {
+ return OptionsConstants.DEFAULT_EDITOR_FONT_SIZE;
+ }
+ }
+
+ private float getLineSpacingFromField() {
+ try {
+ return Math.min(30, Math.max(1, Float.parseFloat(myLineSpacingField.getText())));
+ } catch (NumberFormatException e){
+ return 1;
+ }
+ }
+
+ private void syncFontFamilies() {
+ if (myIsInSchemeChange) {
+ return;
+ }
+ FontPreferences fontPreferences = getFontPreferences();
+ fontPreferences.clearFonts();
+ String primaryFontFamily = (String)myPrimaryCombo.getSelectedItem();
+ String secondaryFontFamily = mySecondaryCombo.isEnabled() ? (String)mySecondaryCombo.getSelectedItem() : null;
+ int fontSize = getFontSizeFromField();
+ if (primaryFontFamily != null ) {
+ if (!FontPreferences.DEFAULT_FONT_NAME.equals(primaryFontFamily)) {
+ fontPreferences.addFontFamily(primaryFontFamily);
+ }
+ fontPreferences.register(primaryFontFamily, fontSize);
+ }
+ if (secondaryFontFamily != null) {
+ if (!FontPreferences.DEFAULT_FONT_NAME.equals(secondaryFontFamily)){
+ fontPreferences.addFontFamily(secondaryFontFamily);
+ }
+ fontPreferences.register(secondaryFontFamily, fontSize);
+ }
+ updateDescription(true);
+ }
+
+
public static void showReadOnlyMessage(JComponent parent, final boolean sharedScheme) {
if (!sharedScheme) {
Messages.showMessageDialog(
@@ -262,65 +228,25 @@ public class FontOptions extends JPanel implements OptionsPanel{
myIsInSchemeChange = true;
myLineSpacingField.setText(Float.toString(getLineSpacing()));
- mySelectedFontsModel.clear();
FontPreferences fontPreferences = getFontPreferences();
List fontFamilies = fontPreferences.getEffectiveFontFamilies();
- Set selectedFonts = ContainerUtilRt.newHashSet();
- Object selectedValue = mySelectedFontsList.getSelectedValue();
- mySelectedFontsModel.clear();
- if (fontFamilies.isEmpty()) {
- // Add default font.
- mySelectedFontsModel.addElement(fontPreferences.getFontFamily());
- selectedFonts.add(fontPreferences.getFontFamily());
- }
- else {
- for (String fontFamily : fontFamilies) {
- mySelectedFontsModel.addElement(fontFamily);
- selectedFonts.add(fontFamily);
- }
- }
-
- int newSelectionIndex = 0;
- if (selectedValue != null) {
- newSelectionIndex = Math.max(0, mySelectedFontsModel.indexOf(selectedValue));
- }
- mySelectedFontsList.setSelectedIndex(newSelectionIndex);
-
- for (int i = myAllFontsModel.size() - 1; i >= 0; i--) {
- if (selectedFonts.contains(myAllFontsModel.getElementAt(i))) {
- myAllFontsModel.remove(i);
- }
- }
+ myPrimaryCombo.setSelectedItem(fontPreferences.getFontFamily());
+ boolean isThereSecondaryFont = fontFamilies.size() > 1;
+ myUseSecondaryFontCheckbox.setSelected(isThereSecondaryFont);
+ mySecondaryCombo.setSelectedItem(isThereSecondaryFont ? fontFamilies.get(1) : null);
myEditorFontSizeField.setText(String.valueOf(fontPreferences.getSize(fontPreferences.getFontFamily())));
- boolean enabled = !ColorAndFontOptions.isReadOnly(myOptions.getSelectedScheme());
- myOnlyMonospacedCheckBox.setEnabled(enabled);
- myLineSpacingField.setEnabled(enabled);
- myEditorFontSizeField.setEditable(enabled);
- myFontsControl.setEnabled(enabled);
+ boolean readOnly = ColorAndFontOptions.isReadOnly(myOptions.getSelectedScheme());
+ myPrimaryCombo.setEnabled(!readOnly);
+ mySecondaryCombo.setEnabled(isThereSecondaryFont && !readOnly);
+ myOnlyMonospacedCheckBox.setEnabled(!readOnly);
+ myLineSpacingField.setEnabled(!readOnly);
+ myEditorFontSizeField.setEditable(!readOnly);
+ myUseSecondaryFontCheckbox.setEnabled(!readOnly);
myIsInSchemeChange = false;
}
- private void onFontsInit() {
- assert myFontNames != null;
- Object selectedValue = myAllFontsList.getSelectedValue();
- myAllFontsModel.clear();
- List availableFonts = myOnlyMonospacedCheckBox.isSelected() ? myMonospacedFontNames : myFontNames;
- int newSelectionIndex = 0;
- int i = 0;
- for (String name : availableFonts) {
- if (!mySelectedFontsModel.contains(name)) { // Don't bother with performance here in assumption that fallback fonts sequence is short
- myAllFontsModel.addElement(name);
- if (name.equals(selectedValue)) {
- newSelectionIndex = i;
- }
- i++;
- }
- }
- myAllFontsList.setSelectedIndex(newSelectionIndex);
- }
-
@NotNull
protected FontPreferences getFontPreferences() {
return getCurrentScheme().getFontPreferences();
@@ -352,44 +278,13 @@ public class FontOptions extends JPanel implements OptionsPanel{
return myOptions.getSelectedScheme();
}
- private JPanel createEditorFontPanel() {
- JPanel editorFontPanel = new JPanel(new GridBagLayout());
- Insets borderInsets = new Insets(IdeBorderFactory.TITLED_BORDER_TOP_INSET,
- IdeBorderFactory.TITLED_BORDER_LEFT_INSET,
- 0,
- IdeBorderFactory.TITLED_BORDER_RIGHT_INSET);
- editorFontPanel.setBorder(IdeBorderFactory.createTitledBorder(myTitle, false, borderInsets));
-
- Insets insets = new Insets(0, 0, 5, 0);
- GridBag constraints = new GridBag().insets(insets);
- editorFontPanel.add(myOnlyMonospacedCheckBox, constraints);
-
- insets.left = 8;
- editorFontPanel.add(new JLabel(ApplicationBundle.message("editbox.font.size")), constraints);
-
- insets.left = 2;
- editorFontPanel.add(myEditorFontSizeField, constraints);
-
- insets.left = 8;
- editorFontPanel.add(new JLabel(ApplicationBundle.message("editbox.line.spacing")), constraints);
-
- insets.left = 2;
- editorFontPanel.add(myLineSpacingField, constraints);
-
- editorFontPanel.add(new JLabel(""), new GridBag().insets(insets).weightx(1).fillCellHorizontally().coverLine());
-
- editorFontPanel.add(myFontsControl, new GridBag().weightx(1).weighty(1).fillCell().coverLine().insets(insets));
-
- return editorFontPanel;
- }
-
@SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"})
- private void initFontTables() {
+ private void initFontTables(FontNameCombo popupCallback) {
if (myFontNames == null) {
myFontNames = new ArrayList();
myMonospacedFontNames = new ArrayList();
- ProgressManager.getInstance().runProcessWithProgressSynchronously(new InitFontsRunnable(), ApplicationBundle.message("progress.analyzing.fonts"), false, null);
+ ProgressManager.getInstance().runProcessWithProgressSynchronously(new InitFontsRunnable(popupCallback), ApplicationBundle.message("progress.analyzing.fonts"), false, null);
}
}
@@ -421,18 +316,13 @@ public class FontOptions extends JPanel implements OptionsPanel{
return new HashSet();
}
- private static class MyTextField extends JTextField {
- private MyTextField(int size) {
- super(size);
- }
-
- @Override
- public Dimension getMinimumSize() {
- return getPreferredSize();
- }
- }
-
private class InitFontsRunnable implements Runnable {
+ private final FontNameCombo myPopupCallback;
+
+ private InitFontsRunnable(FontNameCombo popupCallback) {
+ myPopupCallback = popupCallback;
+ }
+
@Override
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
@@ -482,9 +372,93 @@ public class FontOptions extends JPanel implements OptionsPanel{
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
- onFontsInit();
+ myPrimaryCombo.updateModel();
+ mySecondaryCombo.updateModel();
+ myPopupCallback.showPopup();
}
});
}
}
+
+ private class FontNameCombo extends JComboBox {
+ private final DefaultComboBoxModel myModel;
+ private Boolean myMonospacedOnly = null;
+
+ private FontNameCombo(String selectedName) {
+ setModel(myModel = new DefaultComboBoxModel());
+ updateModel();
+ setSelectedItem(selectedName);
+ }
+
+ private void updateModel() {
+ if (myFontNames == null || myMonospacedFontNames == null) return;
+
+ if (myMonospacedOnly == null || myMonospacedOnly.booleanValue() != EditorColorsManager.getInstance().isUseOnlyMonospacedFonts()) {
+ myMonospacedOnly = EditorColorsManager.getInstance().isUseOnlyMonospacedFonts();
+
+ Object tmp = getSelectedItem();
+ myModel.removeAllElements();
+ List toAdd = myMonospacedOnly ? myMonospacedFontNames : myFontNames;
+ for (Object o : toAdd) {
+ myModel.addElement(o);
+ }
+ if (myModel.getIndexOf(tmp) != -1) {
+ setSelectedItem(tmp);
+ } else {
+ setSelectedItem(FontPreferences.DEFAULT_FONT_NAME);
+ }
+
+ fireActionEvent();
+ revalidate();
+ repaint();
+ }
+ }
+
+ @Override
+ public void setSelectedItem(Object anObject) {
+ if (myModel.getSize() == 0 && anObject != null) {
+ myModel.addElement(anObject);
+ }
+ super.setSelectedItem(anObject);
+ }
+
+
+ @Nullable
+ private JList getPopupList() {
+ ComboPopup popup = ReflectionUtil.getField(getUI().getClass(), getUI(), ComboPopup.class, "popup");
+ return (popup != null) ? popup.getList() : null;
+ }
+
+ @Override
+ public void firePopupMenuWillBecomeVisible() {
+ super.firePopupMenuWillBecomeVisible();
+ if (myFontNames == null) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ initFontTables(FontNameCombo.this);
+ }
+ });
+ }
+ final JList list = getPopupList();
+ if (list != null && !(list.getCellRenderer() instanceof MyListCellRenderer)) {
+ list.setCellRenderer(new MyListCellRenderer());
+ }
+ }
+ }
+
+ private static class MyListCellRenderer extends DefaultListCellRenderer {
+ public Component getListCellRendererComponent(
+ JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
+ Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ if (value instanceof String) {
+ c.setFont(new Font((String) value, Font.PLAIN, 14));
+ }
+ return c;
+ }
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java
index 8ae675bf464e..f7e134f41f0a 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java
@@ -32,23 +32,31 @@ public class CapitalizeAndUnderscoreMacro extends MacroBase {
super("capitalizeAndUnderscore", CodeInsightBundle.message("macro.capitalizeAndUnderscore.string"));
}
+ protected CapitalizeAndUnderscoreMacro(String name, String description) {
+ super(name, description);
+ }
+
@Override
protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) {
String text = getTextResult(params, context, true);
if (text != null && text.length() > 0) {
final String[] words = NameUtil.nameToWords(text);
boolean insertUnderscore = false;
- final StringBuffer buf = new StringBuffer();
+ final StringBuilder buf = new StringBuilder();
for (String word : words) {
if (insertUnderscore) {
buf.append("_");
} else {
insertUnderscore = true;
}
- buf.append(StringUtil.toUpperCase(word));
+ buf.append(convertCase(word));
}
return new TextResult(buf.toString());
}
return null;
}
+
+ protected String convertCase(String word) {
+ return StringUtil.toUpperCase(word);
+ }
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceIntroduceConstantPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/SnakeCaseMacro.java
similarity index 57%
rename from plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceIntroduceConstantPanel.java
rename to platform/lang-impl/src/com/intellij/codeInsight/template/macro/SnakeCaseMacro.java
index 5bd7e5bf48df..9e5d8ac25106 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceIntroduceConstantPanel.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/SnakeCaseMacro.java
@@ -13,24 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.refactoring.introduce.constant;
-
-import com.intellij.ui.components.JBCheckBox;
-
-import javax.swing.*;
+package com.intellij.codeInsight.template.macro;
/**
- * Created by Max Medvedev on 8/29/13
+ * @author yole
*/
-public class GrInplaceIntroduceConstantPanel {
- private JBCheckBox myMoveToAnotherClassJBCheckBox;
- private JPanel myRootPane;
-
- public boolean isMoveToAnotherClass() {
- return myMoveToAnotherClassJBCheckBox.isSelected();
+public class SnakeCaseMacro extends CapitalizeAndUnderscoreMacro {
+ public SnakeCaseMacro() {
+ super("snakeCase", "snakeCase(String)");
}
- public JComponent getRootPane() {
- return myRootPane;
+ @Override
+ protected String convertCase(String word) {
+ return word.toLowerCase();
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
index 2c01b0480bad..dc02b9e6642b 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
@@ -38,6 +38,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.actions.TextComponentEditorAction;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileEditor.impl.EditorHistoryManager;
+import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.keymap.MacKeymapUtil;
import com.intellij.openapi.options.Configurable;
@@ -217,8 +218,10 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
private void run(KeyEvent event) {
final ActionManager actionManager = ActionManager.getInstance();
- final AnAction action = actionManager.getAction("SearchEverywhere");
-
+ final AnAction action = actionManager.getAction(IdeActions.ACTION_SEARCH_EVERYWHERE);
+ if (KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE).length > 0) {
+ return;
+ }
final AnActionEvent anActionEvent = new AnActionEvent(event,
DataManager.getInstance().getDataContext(IdeFocusManager.findInstance().getFocusOwner()),
ActionPlaces.UNKNOWN,
@@ -314,10 +317,17 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
}
private void initTooltip(JLabel label) {
- label.setToolTipText("Search Everywhere
Press " +
- "Double " +
- (SystemInfo.isMac ? MacKeymapUtil.SHIFT : "Shift") +
- " to access
- Classes
- Files
- Tool Windows
- Actions
- Settings");
+ final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE);
+ final String shortcutText;
+ if (shortcuts.length == 0) {
+ shortcutText = "Double " + (SystemInfo.isMac ? MacKeymapUtil.SHIFT : "Shift");
+ } else {
+ shortcutText = KeymapUtil.getShortcutsText(shortcuts);
+ }
+
+ label.setToolTipText("Search Everywhere
Press "
+ + shortcutText
+ + " to access
- Classes
- Files
- Tool Windows
- Actions
- Settings");
}
@@ -589,7 +599,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
initSearchActions(myBalloon, myPopupField);
IdeFocusManager focusManager = IdeFocusManager.getInstance(e.getProject());
focusManager.requestFocus(myPopupField.getTextEditor(), true);
-// FeatureUsageTracker.getInstance().triggerFeatureUsed("SearchEverywhere");
+// FeatureUsageTracker.getInstance().triggerFeatureUsed(IdeActions.ACTION_SEARCH_EVERYWHERE);
}
private void initSearchActions(JBPopup balloon, MySearchTextField searchTextField) {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
index 87a489b2e1df..92eaec73b035 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
@@ -181,7 +181,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
// So, if 'virtual space in editor' is enabled, we save target visual column. Caret indent is ensured otherwise
int visualColumnToRestore = -1;
String caretIndentToRestore = null;
- RangeMarker caretRangeMarker = null;
+ RangeMarker beforeCaretRangeMarker = null;
if (editor != null) {
Document document = editor.getDocument();
@@ -202,7 +202,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
if (fixCaretPosition) {
visualColumnToRestore = editor.getCaretModel().getVisualPosition().column;
caretIndentToRestore = document.getText(TextRange.create(lineStartOffset, caretOffset));
- caretRangeMarker = document.createRangeMarker(lineStartOffset, caretOffset);
+ beforeCaretRangeMarker = document.createRangeMarker(0, lineStartOffset);
}
}
@@ -261,11 +261,11 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
}
}
else {
- if (caretRangeMarker == null || !caretRangeMarker.isValid() || caretIndentToRestore == null) {
+ if (beforeCaretRangeMarker == null || !beforeCaretRangeMarker.isValid() || caretIndentToRestore == null) {
return;
}
- int offset = caretRangeMarker.getStartOffset();
- caretRangeMarker.dispose();
+ int offset = beforeCaretRangeMarker.getEndOffset();
+ beforeCaretRangeMarker.dispose();
if (editor.getCaretModel().getVisualPosition().column == visualColumnToRestore) {
return;
}
@@ -484,10 +484,10 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
*
*
*
- * This method inserts that dummy comment (fallback to identifier xxx, see {@link CodeStyleManagerImpl#createDummy(PsiFile)})
+ * This method inserts that dummy comment (fallback to identifier xxx, see {@link CodeStyleManagerImpl#createDummy(PsiFile)})
* if necessary (if target line contains white space symbols only).
*
-
+
* Note: it's expected that the whole white space region that contains given offset is processed in a way that all
* {@link RangeMarker range markers} registered for the given offset are expanded to the whole white space region.
* E.g. there is a possible case that particular range marker serves for defining formatting range, hence, its start/end offsets
diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java
index 04a67b29b829..444bc492aa81 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ import java.util.List;
// This prevents languages with polyadic expressions or sequences
// from reusing it, use simpleChooser instead.
public abstract class OccurrencesChooser {
- public static enum ReplaceChoice {
+ public enum ReplaceChoice {
NO("Replace this occurrence only"), NO_WRITE("Replace all occurrences but write"), ALL("Replace all {0} occurrences");
private final String myDescription;
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
index 33f23494b341..fc7335595a10 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import com.intellij.lang.refactoring.NamesValidator;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.command.impl.FinishMarkAction;
@@ -327,7 +328,7 @@ public abstract class InplaceRefactoring {
new WriteCommandAction(myProject, getCommandName()) {
@Override
- protected void run(com.intellij.openapi.application.Result result) throws Throwable {
+ protected void run(Result result) throws Throwable {
startTemplate(builder);
}
}.execute();
diff --git a/platform/lang-impl/src/com/intellij/ui/EditorTextFieldActionPromoter.java b/platform/lang-impl/src/com/intellij/ui/EditorTextFieldActionPromoter.java
index 3199328d847b..f7ae9d6e0a83 100644
--- a/platform/lang-impl/src/com/intellij/ui/EditorTextFieldActionPromoter.java
+++ b/platform/lang-impl/src/com/intellij/ui/EditorTextFieldActionPromoter.java
@@ -44,21 +44,12 @@ public class EditorTextFieldActionPromoter implements ActionPromoter {
private static final Comparator ACTIONS_COMPARATOR = new Comparator() {
@Override
public int compare(AnAction o1, AnAction o2) {
- if (o1 instanceof EditorAction && o2 instanceof EditorAction) {
- return 0;
- }
- if (o1 instanceof TextComponentEditorAction) {
- return -1;
- }
- if (o2 instanceof TextComponentEditorAction) {
- return 1;
- }
- if (o1 instanceof EditorAction) {
- return 1;
- }
- if (o2 instanceof EditorAction) {
- return -1;
- }
+ boolean textFieldAction1 = o1 instanceof TextComponentEditorAction;
+ boolean textFieldAction2 = o2 instanceof TextComponentEditorAction;
+ boolean plainEditorAction1 = o1 instanceof EditorAction && !textFieldAction1;
+ boolean plainEditorAction2 = o2 instanceof EditorAction && !textFieldAction2;
+ if (textFieldAction1 && plainEditorAction2) return -1;
+ if (textFieldAction2 && plainEditorAction1) return 1;
return 0;
}
};
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
index 26daca8b29c5..568abafab1cc 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -267,4 +267,5 @@ public interface IdeActions {
String MOVE_TO_ANOTHER_CHANGE_LIST = "ChangesView.Move";
String ACTION_RECENT_FILES = "RecentFiles";
+ String ACTION_SEARCH_EVERYWHERE = "SearchEverywhere";
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
index 31d14f5bb13e..a5fce164751f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
@@ -37,7 +37,6 @@ import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IdRunnable;
-import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.ex.WindowManagerEx;
@@ -80,9 +79,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
/**
* This array contains Rectangles which define bounds of the corresponding
- * components in the toolbar. This list can be considerer as a cache of the
+ * components in the toolbar. This list can be consider as a cache of the
* Rectangle objects that are used in calculation of preferred sizes and
- * layouting of components.
+ * components layout.
*/
private final List myComponentBounds = new ArrayList();
@@ -123,7 +122,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
private ActionButton mySecondaryActionsButton;
private final KeymapManagerEx myKeymapManager;
- private int myFirstOusideIndex = -1;
+ private int myFirstOutsideIndex = -1;
private JBPopup myPopup;
private JComponent myTargetComponent;
@@ -183,7 +182,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
myTimerListener = new MyTimerListener();
myWeakTimerListener = new WeakTimerListener(actionManager, myTimerListener);
// If the panel doesn't handle mouse event then it will be passed to its parent.
- // It means that if the panel is in slidindg mode then the focus goes to the editor
+ // It means that if the panel is in sliding mode then the focus goes to the editor
// and panel will be automatically hidden.
enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.COMPONENT_EVENT_MASK | AWTEvent.CONTAINER_EVENT_MASK);
setMiniMode(false);
@@ -300,7 +299,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
add(mySecondaryActionsButton);
}
- if (Registry.is("search.everywhere.enabled") && (ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || ActionPlaces.NAVIGATION_BAR.equals(myPlace))) {
+ if ((ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || ActionPlaces.NAVIGATION_BAR.equals(myPlace))) {
final AnAction searchEverywhereAction = ActionManager.getInstance().getAction("SearchEverywhere");
if (searchEverywhereAction != null) {
try {
@@ -520,7 +519,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
if (full) {
if (myAutoPopupRec == null) {
myAutoPopupRec = new Rectangle(eachX, eachY, sizeToFit.width - eachX - 1, sizeToFit.height - 1);
- myFirstOusideIndex = i;
+ myFirstOutsideIndex = i;
}
eachBound.x = Integer.MAX_VALUE;
eachBound.y = Integer.MAX_VALUE;
@@ -562,7 +561,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
if (full) {
if (myAutoPopupRec == null) {
myAutoPopupRec = new Rectangle(eachX, eachY, sizeToFit.width - 1, sizeToFit.height - eachY - 1);
- myFirstOusideIndex = i;
+ myFirstOutsideIndex = i;
}
eachBound.x = Integer.MAX_VALUE;
eachBound.y = Integer.MAX_VALUE;
@@ -575,7 +574,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
private void calculateBoundsWrapImpl(Dimension sizeToFit, List bounds) {
- // We have to gracefull handle case when toolbar was not layed out yet.
+ // We have to graceful handle case when toolbar was not laid out yet.
// In this case we calculate bounds as it is a NOWRAP toolbar.
if (getWidth() == 0 || getHeight() == 0) {
try {
@@ -611,7 +610,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
final Rectangle each = bounds.get(i);
- each.setBounds(xOffset, maxWidth, yOffset, maxHeight);
+ each.setBounds(xOffset, yOffset, maxWidth, maxHeight);
xOffset += maxWidth;
}
@@ -632,7 +631,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
final Rectangle each = bounds.get(i);
- each.setBounds(xOffset, maxWidth, yOffset, maxHeight);
+ each.setBounds(xOffset, yOffset, maxWidth, maxHeight);
yOffset += maxHeight;
}
@@ -642,7 +641,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
if (myOrientation == SwingConstants.HORIZONTAL) {
// Calculate row height
int rowHeight = 0;
- final Dimension[] dims = new Dimension[componentCount]; // we will use this dimesions later
+ final Dimension[] dims = new Dimension[componentCount]; // we will use this dimensions later
for (int i = 0; i < componentCount; i++) {
dims[i] = getChildPreferredSize(i);
final int height = dims[i].height;
@@ -670,7 +669,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
else {
// Calculate row width
int rowWidth = 0;
- final Dimension[] dims = new Dimension[componentCount]; // we will use this dimesions later
+ final Dimension[] dims = new Dimension[componentCount]; // we will use this dimensions later
for (int i = 0; i < componentCount; i++) {
dims[i] = getChildPreferredSize(i);
final int width = dims[i].width;
@@ -717,13 +716,12 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
calculateBoundsAutoImp(size2Fit, bounds);
}
else {
- throw new IllegalStateException("unknonw layoutPolicy: " + myLayoutPolicy);
+ throw new IllegalStateException("unknown layoutPolicy: " + myLayoutPolicy);
}
if (getComponentCount() > 0 && size2Fit.width < Integer.MAX_VALUE) {
final Component component = getComponent(getComponentCount() - 1);
if (component instanceof JComponent && ((JComponent)component).getClientProperty("SEARCH_EVERYWHERE") == Boolean.TRUE) {
- final Rectangle rect = bounds.get(bounds.size() - 1);
int max = 0;
for (int i = 0; i < bounds.size() - 2; i++) {
max = Math.max(max, bounds.get(i).height);
@@ -799,7 +797,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final Insets i = getInsets();
if (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula()) {
if (getParent() != null) {
- final JBColor col = new JBColor(Color.GRAY, Gray._111);
+ final JBColor col = new JBColor(Gray._128, Gray._111);
final Graphics2D g2 = (Graphics2D)g;
if (myOrientation == SwingConstants.HORIZONTAL) {
UIUtil.drawDoubleSpaceDottedLine(g2, i.top + 2, getParent().getSize().height - 2 - i.top - i.bottom, 3, col, false);
@@ -1029,7 +1027,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
else {
final DefaultActionGroup outside = new DefaultActionGroup();
- for (int i = myFirstOusideIndex; i < myVisibleActions.size(); i++) {
+ for (int i = myFirstOutsideIndex; i < myVisibleActions.size(); i++) {
outside.add(myVisibleActions.get(i));
}
group = outside;
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/LocalFsFinder.java b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/LocalFsFinder.java
index ec12a86d2667..c02c77b83469 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/LocalFsFinder.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/LocalFsFinder.java
@@ -64,7 +64,8 @@ public class LocalFsFinder implements FileLookup.Finder, FileLookup {
return null;
}
- public String normalize(@NotNull final String path) {
+ public String normalize(@NotNull String path) {
+ path = FileUtil.expandUserHome(path);
final File file = new File(path);
if (file.isAbsolute()) return file.getAbsolutePath();
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
index 8ae71c56629f..06a8f792b4ce 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
@@ -31,7 +31,6 @@ import com.intellij.openapi.keymap.MacKeymapUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.*;
-import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.*;
@@ -170,10 +169,14 @@ public class EditorsSplitters extends IdePanePanel {
painter.appendLine("No files are open").underlined(new JBColor(isDarkBackground ? Gray._210 : Gray._150, Gray._100));
- if (Registry.is("search.everywhere.enabled")) {
- painter.appendLine("Search Everywhere with Double " + (SystemInfo.isMac ? MacKeymapUtil.SHIFT : "Shift"))
- .smaller().withBullet();
+ final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE);
+ final String everywhere;
+ if (shortcuts.length == 0) {
+ everywhere = "Search Everywhere with Double " + (SystemInfo.isMac ? MacKeymapUtil.SHIFT : "Shift");
+ } else {
+ everywhere = "Search Everywhere " + KeymapUtil.getShortcutsText(shortcuts);
}
+ painter.appendLine(everywhere).smaller().withBullet();
if (!isProjectViewVisible()) {
painter.appendLine("Open Project View with " + KeymapUtil.getShortcutText(new KeyboardShortcut(
diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties
index fd0bdd300faa..577a0766460c 100644
--- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties
+++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties
@@ -475,6 +475,8 @@ error.illegal.scheme.name=Illegal scheme name
error.a.scheme.with.this.name.already.exists.or.was.deleted.without.applying.the.changes=A scheme with this name already exists or was deleted without applying the changes
title.select.font=Select Font
checkbox.show.only.monospaced.fonts=Show only monospaced fonts
+primary.font=Primary font:
+secondary.font=Secondary font:
editbox.enter.tag.name=Enter tag name:
title.tag.name=Tag Name
title.xml=XML
@@ -503,9 +505,7 @@ title.colors.and.fonts=Colors \\& Fonts
progress.analysing.font=Analysing font: {0}
button.edit.scopes=Edit Scopes...
group.editor.font=Editor Font
-title.font.available=Available fonts:
-title.font.selected=Selected fonts:
-label.fallback.fonts.list.description=The ide tries to use the next font from 'Selected fonts' list for displaying a symbol if the current font fails to do that
+label.fallback.fonts.list.description=If primary font fails IDE tries to use the secondary one
quickdoc.tooltip.font.size.by.wheel=Slider or Ctrl+Wheel change font size
label.font.size=Font size:
label.font.name=Name:
diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties
index e3581ee694ec..c2a3376be978 100644
--- a/platform/platform-resources-en/src/misc/registry.properties
+++ b/platform/platform-resources-en/src/misc/registry.properties
@@ -298,7 +298,6 @@ enable.graph.inference=false
comment.by.line.bulk.lines.trigger=100
scene.builder.start.executable=true
-search.everywhere.enabled=true
junit_sm_runner=false
testng_sm_runner=false
show.flex.debug.design.view=false
diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml
index a232b2858ee0..99595f0058b8 100644
--- a/platform/platform-resources/src/META-INF/LangExtensions.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensions.xml
@@ -432,6 +432,7 @@
+
@@ -663,7 +664,7 @@
+ order="after hide-hints" id="hide-search"/>
diff --git a/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java b/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java
index 715834f27595..493b21d85306 100644
--- a/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java
@@ -129,7 +129,8 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
"SelectionStartLine",
"SelectionEndLine",
"SelectionStartColumn",
- "SelectionEndColumn"
+ "SelectionEndColumn",
+ "PyInterpreterDirectory"
);
public PathMacrosImpl() {
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/AbstractGradleCompletionContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/AbstractGradleCompletionContributor.java
new file mode 100644
index 000000000000..4b8120d013bb
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/AbstractGradleCompletionContributor.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.gradle.codeInsight;
+
+import com.intellij.codeInsight.completion.CompletionContributor;
+import com.intellij.patterns.ElementPattern;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.util.GradleConstants;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCommandArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
+
+import static com.intellij.patterns.PlatformPatterns.psiElement;
+import static com.intellij.patterns.PlatformPatterns.psiFile;
+import static com.intellij.patterns.StandardPatterns.string;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 11/1/13
+ */
+public abstract class AbstractGradleCompletionContributor extends CompletionContributor {
+ protected static final ElementPattern GRADLE_FILE_PATTERN = psiElement()
+ .inFile(psiFile().withName(string().endsWith('.' + GradleConstants.EXTENSION)));
+
+ @Nullable
+ protected String findNamedArgumentValue(@Nullable GrCommandArgumentList argumentList, @NotNull String label) {
+ if (argumentList == null) return null;
+ GrNamedArgument namedArgument = argumentList.findNamedArgument(label);
+ if (namedArgument == null) return null;
+
+ GrExpression expression = namedArgument.getExpression();
+ if (!(expression instanceof GrLiteralImpl)) return null;
+ Object value = GrLiteralImpl.class.cast(expression).getValue();
+ return value == null ? null : String.valueOf(value);
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/maven/codeInsight/completion/MavenDependenciesGradleCompletionContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/maven/codeInsight/completion/MavenDependenciesGradleCompletionContributor.java
index c269c9e1da83..16328aed56e2 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/maven/codeInsight/completion/MavenDependenciesGradleCompletionContributor.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/maven/codeInsight/completion/MavenDependenciesGradleCompletionContributor.java
@@ -22,19 +22,20 @@ import com.intellij.icons.AllIcons;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.PatternCondition;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.indices.MavenArtifactSearchResult;
import org.jetbrains.idea.maven.indices.MavenArtifactSearcher;
import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager;
import org.jetbrains.idea.maven.model.MavenArtifactInfo;
import org.jetbrains.idea.maven.model.MavenId;
+import org.jetbrains.plugins.gradle.codeInsight.AbstractGradleCompletionContributor;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCommandArgumentList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
import java.util.List;
@@ -44,27 +45,31 @@ import static com.intellij.patterns.PlatformPatterns.psiElement;
* @author Vladislav.Soroka
* @since 10/31/13
*/
-public class MavenDependenciesGradleCompletionContributor extends CompletionContributor {
+public class MavenDependenciesGradleCompletionContributor extends AbstractGradleCompletionContributor {
private static final String GROUP_LABEL = "group";
private static final String NAME_LABEL = "name";
private static final String VERSION_LABEL = "version";
- private static final PatternCondition EXPRESSION_PATTERN_CONDITION =
- new PatternCondition("withInvokedExpressionText") {
+ private static final ElementPattern DEPENDENCIES_CALL_PATTERN = psiElement()
+ .inside(true, psiElement(GrMethodCallExpression.class).with(new PatternCondition("withInvokedExpressionText") {
@Override
public boolean accepts(@NotNull GrMethodCallExpression expression, ProcessingContext context) {
GrExpression grExpression = expression.getInvokedExpression();
return grExpression != null && "dependencies".equals(grExpression.getText());
}
- };
+ }));
- private static final ElementPattern
- IN_BASIC_DEPENDENCY_NOTATION = psiElement().withSuperParent(
- 5, psiElement(GrMethodCallExpression.class).with(EXPRESSION_PATTERN_CONDITION));
+ private static final ElementPattern IN_BASIC_DEPENDENCY_NOTATION = psiElement()
+ .and(GRADLE_FILE_PATTERN)
+ .withParent(GrLiteral.class)
+ .withSuperParent(2, psiElement(GrCommandArgumentList.class))
+ .and(DEPENDENCIES_CALL_PATTERN);
- private static final ElementPattern
- IN_MAP_DEPENDENCY_NOTATION = psiElement().withSuperParent(
- 6, psiElement(GrMethodCallExpression.class).with(EXPRESSION_PATTERN_CONDITION));
+ private static final ElementPattern IN_MAP_DEPENDENCY_NOTATION = psiElement()
+ .and(GRADLE_FILE_PATTERN)
+ .withParent(GrLiteral.class)
+ .withSuperParent(2, psiElement(GrNamedArgument.class))
+ .and(DEPENDENCIES_CALL_PATTERN);
public MavenDependenciesGradleCompletionContributor() {
@@ -144,16 +149,4 @@ public class MavenDependenciesGradleCompletionContributor extends CompletionCont
}
});
}
-
- @Nullable
- private static String findNamedArgumentValue(@Nullable GrCommandArgumentList argumentList, @NotNull String label) {
- if (argumentList == null) return null;
- GrNamedArgument namedArgument = argumentList.findNamedArgument(label);
- if (namedArgument == null) return null;
-
- GrExpression expression = namedArgument.getExpression();
- if (!(expression instanceof GrLiteralImpl)) return null;
- Object value = GrLiteralImpl.class.cast(expression).getValue();
- return value == null ? null : String.valueOf(value);
- }
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleDependenciesContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleDependenciesContributor.java
index d4cf0cdfa983..e3070d5cb8d6 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleDependenciesContributor.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleDependenciesContributor.java
@@ -25,18 +25,12 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
import java.util.List;
-import java.util.Set;
/**
* @author Denis Zhdanov
* @since 8/14/13 12:58 PM
*/
public class GradleDependenciesContributor implements GradleMethodContextContributor {
- private final static Set BUILD_SCRIPT_BLOCKS = ContainerUtil.newHashSet(
- "subprojects",
- "allprojects",
- "buildscript"
- );
@Override
public void process(@NotNull List methodCallInfo,
@@ -48,11 +42,6 @@ public class GradleDependenciesContributor implements GradleMethodContextContrib
String methodCall = ContainerUtil.getLastItem(methodCallInfo);
if (methodCall == null) return;
- if (methodCallInfo.size() > 1 && BUILD_SCRIPT_BLOCKS.contains(methodCall)) {
- methodCallInfo.remove(methodCallInfo.size() - 1);
- methodCall = ContainerUtil.getLastItem(methodCallInfo);
- }
-
if (!StringUtil.equals(methodCall, "dependencies")) return;
final GroovyPsiManager psiManager = GroovyPsiManager.getInstance(place.getProject());
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleResolverUtil.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleResolverUtil.java
index 0d0bbe9fe959..a1376f32ea78 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleResolverUtil.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleResolverUtil.java
@@ -155,19 +155,19 @@ public class GradleResolverUtil {
int argsCount = getGrMethodArumentsCount(args);
argsCount++; // Configuration name is delivered as an argument.
- for (PsiMethod method : handlerClass.findMethodsByName(methodName, false)) {
- if (method.getParameterList().getParametersCount() == argsCount) {
+ // handle setter's shortcut facilities
+ final String setter = GroovyPropertyUtils.getSetterName(methodName);
+ for (PsiMethod method : handlerClass.findMethodsByName(setter, false)) {
+ if (method.getParameterList().getParametersCount() == 1) {
builder.setNavigationElement(method);
return;
}
}
- // handle setter's shortcut facilities
- final String setter = GroovyPropertyUtils.getSetterName(methodName);
- for (PsiMethod method : handlerClass.findMethodsByName(setter, false)) {
- if (method.getParameterList().getParametersCount() == 1) {
- builder.setNavigationElement(method);
- return;
+ for (PsiMethod method : handlerClass.findMethodsByName(methodName, false)) {
+ if (method.getParameterList().getParametersCount() == argsCount) {
+ builder.setNavigationElement(method);
+ return;
}
}
@@ -186,10 +186,22 @@ public class GradleResolverUtil {
@NotNull ResolveState state,
@NotNull PsiElement place,
@NotNull String... fqNames) {
+ processDeclarations(null, psiManager, processor, state, place, fqNames);
+ }
+
+ public static void processDeclarations(@Nullable String methodName,
+ @NotNull GroovyPsiManager psiManager,
+ @NotNull PsiScopeProcessor processor,
+ @NotNull ResolveState state,
+ @NotNull PsiElement place,
+ @NotNull String... fqNames) {
for (String fqName : fqNames) {
PsiClass psiClass = psiManager.findClassWithCache(fqName, place.getResolveScope());
if (psiClass != null) {
psiClass.processDeclarations(processor, state, null, place);
+ if (methodName != null) {
+ processMethod(methodName, psiClass, processor, state, place);
+ }
}
}
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleRootContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleRootContributor.java
index 61856bc0ba9c..bdbfc1ddc6f7 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleRootContributor.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleRootContributor.java
@@ -68,6 +68,8 @@ public class GradleRootContributor implements GradleMethodContextContributor {
}
GroovyPsiManager psiManager = GroovyPsiManager.getInstance(place.getProject());
- GradleResolverUtil.processDeclarations(psiManager, processor, state, place, GradleCommonClassNames.GRADLE_API_PROJECT);
+ GradleResolverUtil.processDeclarations(methodCallInfo.size() > 0 ? methodCallInfo.get(0) : null,
+ psiManager, processor, state, place,
+ GradleCommonClassNames.GRADLE_API_PROJECT);
}
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java
index fa50f36f7bed..2cb97484470b 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.gradle.service.resolve;
import com.intellij.psi.*;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.gradle.util.GradleConstants;
@@ -27,6 +28,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor;
import java.util.List;
+import java.util.Set;
/**
* @author Denis Zhdanov
@@ -34,6 +36,15 @@ import java.util.List;
*/
public class GradleScriptContributor extends NonCodeMembersContributor {
+ public final static Set BUILD_PROJECT_SCRIPT_BLOCKS = ContainerUtil.newHashSet(
+ "project",
+ "configure",
+ "subprojects",
+ "allprojects",
+ "buildscript"
+ );
+
+
@Override
public void processDynamicElements(@NotNull PsiType qualifierType,
PsiClass aClass,
@@ -67,6 +78,11 @@ public class GradleScriptContributor extends NonCodeMembersContributor {
}
}
+ final String methodCall = ContainerUtil.getLastItem(methodInfo);
+ if (methodInfo.size() > 1 && BUILD_PROJECT_SCRIPT_BLOCKS.contains(methodCall)) {
+ methodInfo.remove(methodInfo.size() - 1);
+ }
+
for (GradleMethodContextContributor contributor : GradleMethodContextContributor.EP_NAME.getExtensions()) {
contributor.process(methodInfo, processor, state, place);
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleTaskContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleTaskContributor.java
index 80f2adb3d469..908ad3832ef9 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleTaskContributor.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleTaskContributor.java
@@ -59,13 +59,13 @@ public class GradleTaskContributor implements GradleMethodContextContributor {
processTaskAddition(methodCallInfo.get(0), GradleCommonClassNames.GRADLE_API_TASK_CONTAINER, processor, state, place);
}
else {
- processTaskTypeParameter(processor, state, place);
+ processTaskTypeParameter(methodCallInfo.get(0), processor, state, place);
}
GradleImplicitContributor.processImplicitDeclarations(processor, state, place);
}
else if (methodCallInfo.size() >= 3) {
- processTaskTypeParameter(processor, state, place);
+ processTaskTypeParameter(methodCallInfo.get(0), processor, state, place);
GradleImplicitContributor.processImplicitDeclarations(processor, state, place);
@@ -76,7 +76,7 @@ public class GradleTaskContributor implements GradleMethodContextContributor {
}
}
- private static void processTaskTypeParameter(@NotNull PsiScopeProcessor processor,
+ private static void processTaskTypeParameter(@NotNull String methodCall, @NotNull PsiScopeProcessor processor,
@NotNull ResolveState state,
@NotNull PsiElement place) {
final int taskTypeParameterLevel = 3;
@@ -98,7 +98,7 @@ public class GradleTaskContributor implements GradleMethodContextContributor {
PsiImmediateClassType immediateClassType = (PsiImmediateClassType)psiType;
for (PsiType type : immediateClassType.getParameters()) {
GroovyPsiManager psiManager = GroovyPsiManager.getInstance(place.getProject());
- GradleResolverUtil.processDeclarations(psiManager, processor, state, place, type.getCanonicalText());
+ GradleResolverUtil.processDeclarations(methodCall, psiManager, processor, state, place, type.getCanonicalText());
}
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrAbstractInplaceIntroducer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrAbstractInplaceIntroducer.java
new file mode 100644
index 000000000000..32004067b0ca
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrAbstractInplaceIntroducer.java
@@ -0,0 +1,277 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.refactoring.introduce;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.RangeMarker;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Computable;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer;
+import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
+import com.intellij.util.Function;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.GroovyFileType;
+import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
+import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
+
+import java.util.List;
+
+
+/**
+ * Created by Max Medvedev on 10/28/13
+ */
+public abstract class GrAbstractInplaceIntroducer extends AbstractInplaceIntroducer {
+
+ private SmartTypePointer myTypePointer;
+ private OccurrencesChooser.ReplaceChoice myReplaceChoice;
+
+ private RangeMarker myVarMarker;
+ private final PsiFile myFile;
+
+ private final GrIntroduceContext myContext;
+
+ public GrAbstractInplaceIntroducer(String title,
+ OccurrencesChooser.ReplaceChoice replaceChoice,
+ GrIntroduceContext context) {
+ super(context.getProject(), context.getEditor(), context.getExpression(), context.getVar(), context.getOccurrences(), title, GroovyFileType.GROOVY_FILE_TYPE);
+ myReplaceChoice = replaceChoice;
+ myContext = context;
+ myFile = context.getPlace().getContainingFile();
+ }
+
+ public GrIntroduceContext getContext() {
+ return myContext;
+ }
+
+ @Override
+ public void setReplaceAllOccurrences(boolean allOccurrences) {
+ throw new IncorrectOperationException("don't invoke this method");
+ }
+
+ @Override
+ public GrExpression restoreExpression(PsiFile containingFile, GrVariable variable, RangeMarker marker, String exprText) {
+ if (exprText == null) return null;
+ if (variable == null || !variable.isValid()) return null;
+ final PsiElement refVariableElement = containingFile.findElementAt(marker.getStartOffset());
+ final PsiElement refVariableElementParent = refVariableElement != null ? refVariableElement.getParent() : null;
+ GrExpression expression =
+ refVariableElementParent instanceof GrNewExpression && refVariableElement.getNode().getElementType() == GroovyTokenTypes.kNEW
+ ? (GrNewExpression)refVariableElementParent
+ : PsiTreeUtil.getParentOfType(refVariableElement, GrReferenceExpression.class);
+ if (expression instanceof GrReferenceExpression && !(expression.getParent() instanceof GrMethodCall)) {
+ final String referenceName = ((GrReferenceExpression)expression).getReferenceName();
+ if (((GrReferenceExpression)expression).resolve() == variable ||
+ Comparing.strEqual(variable.getName(), referenceName) ||
+ Comparing.strEqual(exprText, referenceName)) {
+ return (GrExpression)expression
+ .replace(GroovyPsiElementFactory.getInstance(myProject).createExpressionFromText(exprText, variable));
+ }
+ }
+ if (expression == null) {
+ expression = PsiTreeUtil.getParentOfType(refVariableElement, GrExpression.class);
+ }
+ while (expression instanceof GrReferenceExpression) {
+ final PsiElement parent = expression.getParent();
+ if (parent instanceof GrMethodCallExpression) {
+ if (parent.getText().equals(exprText)) return (GrExpression)parent;
+ }
+ if (parent instanceof GrExpression) {
+ expression = (GrExpression)parent;
+ if (expression.getText().equals(exprText)) {
+ return expression;
+ }
+ }
+ else {
+ return null;
+ }
+ }
+ if (expression != null && expression.isValid() && expression.getText().equals(exprText)) {
+ return expression;
+ }
+
+ if (refVariableElementParent instanceof GrExpression && refVariableElementParent.getText().equals(exprText)) {
+ return (GrExpression)refVariableElementParent;
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void updateTitle(@Nullable GrVariable variable, String value) {
+ if (variable == null) {
+ super.updateTitle(variable, value);
+ }
+ else {
+ final String variableText = variable.getParent().getText();
+ final PsiElement identifier = variable.getNameIdentifierGroovy();
+ final int startOffsetInParent = identifier.getStartOffsetInParent() + variable.getStartOffsetInParent();
+ setPreviewText(
+ variableText.substring(0, startOffsetInParent) + value + variableText.substring(startOffsetInParent + identifier.getTextLength()));
+ revalidate();
+ }
+ }
+
+ @Override
+ protected void updateTitle(@Nullable GrVariable variable) {
+ if (variable == null) return;
+ setPreviewText(variable.getParent().getText());
+ revalidate();
+ }
+
+ @Nullable
+ @Override
+ protected PsiElement getNameIdentifier() {
+ return ((GrVariable)myElementToRename).getNameIdentifierGroovy();
+ }
+
+ @Override
+ protected GrVariable getVariable() {
+ if (myVarMarker == null) return null;
+
+ int offset = myVarMarker.getStartOffset();
+ PsiElement at = myFile.findElementAt(offset);
+ GrVariable var = PsiTreeUtil.getParentOfType(at, GrVariable.class);
+ return var;
+ }
+
+ @Override
+ protected void performIntroduce() {
+ final List markers = getOccurrenceMarkers();
+ GrIntroduceContext context = new GrIntroduceContext() {
+ @NotNull
+ @Override
+ public Project getProject() {
+ return myProject;
+ }
+
+ @Override
+ public Editor getEditor() {
+ return myEditor;
+ }
+
+ @Nullable
+ @Override
+ public GrExpression getExpression() {
+ return (GrExpression)getExpr();
+ }
+
+ @Nullable
+ @Override
+ public GrVariable getVar() {
+ return getLocalVariable();
+ }
+
+ @Nullable
+ @Override
+ public StringPartInfo getStringPart() {
+ return null;
+ }
+
+ @NotNull
+ @Override
+ public PsiElement[] getOccurrences() {
+ List result = ContainerUtil.map(markers, new Function() {
+ @Override
+ public PsiElement fun(RangeMarker marker) {
+ return GroovyRefactoringUtil.findElementInRange(myFile, marker.getStartOffset(), marker.getEndOffset(), GrExpression.class);
+ }
+ });
+ return PsiUtilCore.toPsiElementArray(result);
+ }
+
+ @Override
+ public PsiElement getScope() {
+ return myScope;
+ }
+
+ @NotNull
+ @Override
+ public PsiElement getPlace() {
+ GrExpression expression = getExpression();
+ return expression != null ? expression : getLocalVariable();
+ }
+ };
+ runRefactoring(context, getSettings(), true);
+ }
+
+ @Nullable
+ @Override
+ protected GrVariable createFieldToStartTemplateOn(boolean replaceAll, String[] names) {
+
+ final Settings settings = getInitialSettingsForInplace(myContext, myReplaceChoice, names);
+ if (settings == null) return null;
+
+ SmartPsiElementPointer pointer = ApplicationManager.getApplication().runWriteAction(new Computable>() {
+ @Override
+ public SmartPsiElementPointer compute() {
+ GrVariable var = runRefactoring(myContext, settings, false);
+ return var != null ? SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(var) : null;
+ }
+ });
+
+ if (pointer != null) {
+ GrVariable var = pointer.getElement();
+ if (var != null) {
+ myVarMarker = myContext.getEditor().getDocument().createRangeMarker(var.getTextRange());
+ }
+ return var;
+ }
+ else {
+ return null;
+ }
+ }
+
+ protected abstract GrVariable runRefactoring(GrIntroduceContext context, Settings settings, boolean processUsages);
+
+ @Nullable
+ protected abstract Settings getInitialSettingsForInplace(@NotNull GrIntroduceContext context,
+ @NotNull OccurrencesChooser.ReplaceChoice choice,
+ String[] names);
+
+ @Override
+ public boolean isReplaceAllOccurrences() {
+ return myReplaceChoice != OccurrencesChooser.ReplaceChoice.NO || myContext.getOccurrences().length == 1;
+ }
+
+ protected abstract Settings getSettings();
+
+ @Override
+ protected void restoreState(GrVariable psiField) {
+ PsiType declaredType = psiField.getDeclaredType();
+ myTypePointer = declaredType != null ? SmartTypePointerManager.getInstance(myProject).createSmartTypePointer(declaredType) : null;
+ super.restoreState(psiField);
+ }
+
+ @Nullable
+ protected PsiType getSelectedType() {
+ return myTypePointer != null ? myTypePointer.getType() : null;
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
index ec3aefa1c717..a9c3182ff9d5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
@@ -32,7 +32,6 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pass;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.wm.WindowManager;
@@ -77,7 +76,7 @@ import java.util.*;
import static org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.skipParentheses;
/**
- * @author Maxim.Medvedev
+ * Created by Max Medvedev on 10/29/13
*/
public abstract class GrIntroduceHandlerBase implements RefactoringActionHandler {
private static final Logger LOG = Logger.getInstance(GrIntroduceHandlerBase.class);
@@ -144,15 +143,8 @@ public abstract class GrIntroduceHandlerBase occurrenceMarkers,
- RangeMarker varRangeMarker,
- @Nullable RangeMarker expressionRangeMarker,
- @Nullable RangeMarker stringPartRangeMarker);
-
- protected abstract Settings getSettingsForInplace(GrIntroduceContext context, OccurrencesChooser.ReplaceChoice choice);
+ protected abstract GrAbstractInplaceIntroducer getIntroducer(@NotNull GrIntroduceContext context,
+ OccurrencesChooser.ReplaceChoice choice);
public static Map> fillChoice(GrIntroduceContext context) {
HashMap> map = ContainerUtil.newLinkedHashMap();
@@ -296,7 +288,8 @@ public abstract class GrIntroduceHandlerBase callback, Editor editor);
public GrIntroduceContext getContext(@NotNull Project project,
- @NotNull Editor editor,
- @Nullable GrExpression expression,
- @Nullable GrVariable variable,
- @Nullable StringPartInfo stringPart,
- @NotNull PsiElement scope) {
+ @NotNull Editor editor,
+ @Nullable GrExpression expression,
+ @Nullable GrVariable variable,
+ @Nullable StringPartInfo stringPart,
+ @NotNull PsiElement scope) {
if (variable != null) {
final List list = Collections.synchronizedList(new ArrayList());
ReferencesSearch.search(variable, new LocalSearchScope(scope)).forEach(new Processor() {
@@ -348,48 +341,6 @@ public abstract class GrIntroduceHandlerBase callback = new Pass() {
- @Override
- public void pass(final OccurrencesChooser.ReplaceChoice choice) {
-
- final Settings settings = isInplace ? getSettingsForInplace(context, choice) : showDialog(context);
- if (settings == null) return;
-
- CommandProcessor.getInstance().executeCommand(project, new Runnable() {
- public void run() {
- List occurrences = ContainerUtil.newArrayList();
- Document document = editor.getDocument();
- for (PsiElement element : context.getOccurrences()) {
- occurrences.add(createRange(document, element));
- }
- RangeMarker expressionRangeMarker = createRange(document, context.getExpression());
- RangeMarker stringPartRangeMarker = createRange(document, context.getStringPart());
- RangeMarker varRangeMarker = createRange(document, context.getVar());
-
- SmartPsiElementPointer pointer =
- ApplicationManager.getApplication().runWriteAction(new Computable>() {
- @Override
- public SmartPsiElementPointer compute() {
- GrVariable var = runRefactoring(context, settings);
- return var != null
- ? SmartPointerManager.getInstance(context.getProject()).createSmartPsiElementPointer(var)
- : null;
- }
- });
- GrVariable var = pointer != null ? pointer.getElement() : null;
-
- if (isInplace && var != null) {
- GrInplaceIntroducer introducer = getIntroducer(var, context, settings, occurrences, varRangeMarker, expressionRangeMarker, stringPartRangeMarker);
- LinkedHashSet suggestions = introducer.suggestNames(context);
- PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
- introducer.performInplaceRefactoring(suggestions);
- }
- }
- }, getRefactoringName(), getRefactoringName());
- }
- };
-
if (isInplace(context.getEditor(), context.getPlace())) {
Map> occurrencesMap = fillChoice(context);
new OccurrencesChooser