mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.compiler.server;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -44,7 +44,7 @@ class BuildMessageDispatcher extends SimpleChannelInboundHandlerAdapter<CmdlineR
|
||||
private static final AttributeKey<SessionData> SESSION_DATA = AttributeKey.valueOf("BuildMessageDispatcher.sessionData");
|
||||
|
||||
private final Map<UUID, SessionData> mySessionDescriptors = new ConcurrentHashMap<UUID, SessionData>(16, 0.75f, 1);
|
||||
private final Set<UUID> myCanceledSessions = new ConcurrentHashSet<UUID>();
|
||||
private final Set<UUID> myCanceledSessions = ContainerUtil.newConcurrentSet();
|
||||
|
||||
public void registerBuildMessageHandler(@NotNull final RequestFuture<? extends BuilderMessageHandler> future, @Nullable CmdlineRemoteProto.Message.ControllerMessage params) {
|
||||
final BuilderMessageHandler wrappedHandler = new DelegatingMessageHandler() {
|
||||
|
||||
+25
-7
@@ -18,6 +18,8 @@ package com.intellij.debugger.settings;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.ui.tree.render.ArrayRenderer;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
|
||||
@@ -26,7 +28,7 @@ import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.*;
|
||||
|
||||
public class ArrayRendererConfigurable implements UnnamedConfigurable{
|
||||
public class ArrayRendererConfigurable implements UnnamedConfigurable, Configurable.NoScroll {
|
||||
private JTextField myEntriesLimit;
|
||||
private JTextField myStartIndex;
|
||||
private JTextField myEndIndex;
|
||||
@@ -50,17 +52,25 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{
|
||||
myEntriesLimit.setText(String.valueOf(myRenderer.ENTRIES_LIMIT));
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
public void apply() throws ConfigurationException {
|
||||
applyTo(myRenderer, true);
|
||||
}
|
||||
|
||||
private void applyTo(ArrayRenderer renderer, boolean showBigRangeWarning) {
|
||||
private void applyTo(ArrayRenderer renderer, boolean showBigRangeWarning) throws ConfigurationException {
|
||||
int newStartIndex = getInt(myStartIndex);
|
||||
int newEndIndex = getInt(myEndIndex);
|
||||
int newLimit = getInt(myEntriesLimit);
|
||||
|
||||
if (newStartIndex < 0) {
|
||||
throw new ConfigurationException(DebuggerBundle.message("error.array.renderer.configurable.start.index.less.than.zero"));
|
||||
}
|
||||
|
||||
if (newEndIndex < newStartIndex) {
|
||||
throw new ConfigurationException(DebuggerBundle.message("error.array.renderer.configurable.end.index.less.than.start"));
|
||||
}
|
||||
|
||||
if (newStartIndex >= 0 && newEndIndex >= 0) {
|
||||
if (newStartIndex >= newEndIndex) {
|
||||
if (newStartIndex > newEndIndex) {
|
||||
int currentStartIndex = renderer.START_INDEX;
|
||||
int currentEndIndex = renderer.END_INDEX;
|
||||
newEndIndex = newStartIndex + (currentEndIndex - currentStartIndex);
|
||||
@@ -116,9 +126,12 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{
|
||||
myPanel.add(endIndexLabel, new GridBagConstraints(2, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 8), 0, 0));
|
||||
myPanel.add(myEndIndex, new GridBagConstraints(3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
myPanel.add(entriesLimitLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 8), 0, 0));
|
||||
myPanel.add(entriesLimitLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 8), 0, 0));
|
||||
myPanel.add(myEntriesLimit, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 8), 0, 0));
|
||||
myPanel.add(new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count2")), new GridBagConstraints(2, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
myPanel.add(new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count2")), new GridBagConstraints(2, GridBagConstraints.RELATIVE, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0));
|
||||
|
||||
// push other components up
|
||||
myPanel.add(new JLabel(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
final DocumentListener listener = new DocumentListener() {
|
||||
private void updateEntriesLimit() {
|
||||
@@ -186,7 +199,12 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{
|
||||
|
||||
public boolean isModified() {
|
||||
ArrayRenderer cloneRenderer = myRenderer.clone();
|
||||
applyTo(cloneRenderer, false);
|
||||
try {
|
||||
applyTo(cloneRenderer, false);
|
||||
}
|
||||
catch (ConfigurationException e) {
|
||||
return true;
|
||||
}
|
||||
final boolean valuesEqual =
|
||||
(myRenderer.END_INDEX == cloneRenderer.END_INDEX) &&
|
||||
(myRenderer.START_INDEX == cloneRenderer.START_INDEX) &&
|
||||
|
||||
+1
-1
@@ -28,7 +28,6 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.containers.BidirectionalMap;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -39,6 +38,7 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class RefCountHolder {
|
||||
|
||||
@@ -43,7 +43,7 @@ import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.java.IJavaElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -1683,7 +1683,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
private static final Map<Pair<IElementType, IElementType>, Boolean> myCanStickJavaTokensMatrix =
|
||||
new ConcurrentHashMap<Pair<IElementType, IElementType>, Boolean>();
|
||||
ContainerUtil.newConcurrentMap();
|
||||
|
||||
public static boolean canStickChildrenTogether(final ASTNode child1, final ASTNode child2) {
|
||||
if (child1 == null || child2 == null) return true;
|
||||
|
||||
@@ -1252,7 +1252,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
private static final Key<String> MARK_KEY = Key.create("");
|
||||
|
||||
private PsiReferenceExpression[] addBracesWhenNeeded(PsiReferenceExpression[] refs) throws IncorrectOperationException {
|
||||
public PsiReferenceExpression[] addBracesWhenNeeded(PsiReferenceExpression[] refs) throws IncorrectOperationException {
|
||||
ArrayList<PsiReferenceExpression> refsVector = new ArrayList<PsiReferenceExpression>();
|
||||
ArrayList<PsiCodeBlock> addedBracesVector = new ArrayList<PsiCodeBlock>();
|
||||
myAddedClassInitializers = new HashMap<PsiField, PsiClassInitializer>();
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ public class InplaceIntroduceConstantPopup extends AbstractInplaceIntroduceField
|
||||
|
||||
@Override
|
||||
protected boolean startsOnTheSameElement(RefactoringActionHandler handler, PsiElement element) {
|
||||
return super.startsOnTheSameElement(handler, element) && handler instanceof IntroduceConstantHandler;
|
||||
return handler instanceof IntroduceConstantHandler && super.startsOnTheSameElement(handler, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ public class InplaceIntroduceFieldPopup extends AbstractInplaceIntroduceFieldPop
|
||||
|
||||
@Override
|
||||
protected boolean startsOnTheSameElement(RefactoringActionHandler handler, PsiElement element) {
|
||||
return super.startsOnTheSameElement(handler, element) && handler instanceof IntroduceFieldHandler;
|
||||
return handler instanceof IntroduceFieldHandler && super.startsOnTheSameElement(handler, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
|
||||
@Override
|
||||
protected boolean startsOnTheSameElement(RefactoringActionHandler handler, PsiElement element) {
|
||||
return super.startsOnTheSameElement(handler, element) && handler instanceof IntroduceParameterHandler;
|
||||
return handler instanceof IntroduceParameterHandler && super.startsOnTheSameElement(handler, element);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+85
-79
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package com.intellij.refactoring.introduceVariable;
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.codeInsight.completion.JavaCompletionUtil;
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.codeInsight.intention.impl.TypeExpression;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.unwrap.ScopeHighlighter;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
@@ -37,10 +36,7 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
@@ -77,6 +73,7 @@ import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -91,6 +88,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
|
||||
protected static final String REFACTORING_NAME = RefactoringBundle.message("introduce.variable.title");
|
||||
public static final Key<Boolean> NEED_PARENTHESIS = Key.create("NEED_PARENTHESIS");
|
||||
private JavaVariableInplaceIntroducer myInplaceIntroducer;
|
||||
|
||||
public static SuggestedNameInfo getSuggestedName(@Nullable PsiType type, @NotNull final PsiExpression expression) {
|
||||
return getSuggestedName(type, expression, expression);
|
||||
@@ -645,76 +643,74 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
final Pass<OccurrencesChooser.ReplaceChoice> callback = new Pass<OccurrencesChooser.ReplaceChoice>() {
|
||||
@Override
|
||||
public void pass(final OccurrencesChooser.ReplaceChoice choice) {
|
||||
final boolean allOccurences = choice == OccurrencesChooser.ReplaceChoice.ALL || choice == OccurrencesChooser.ReplaceChoice.NO_WRITE;
|
||||
final Ref<SmartPsiElementPointer<PsiVariable>> variable = new Ref<SmartPsiElementPointer<PsiVariable>>();
|
||||
|
||||
final Editor topLevelEditor;
|
||||
if (!InjectedLanguageManager.getInstance(project).isInjectedFragment(anchorStatement.getContainingFile())) {
|
||||
topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
||||
} else {
|
||||
topLevelEditor = editor;
|
||||
}
|
||||
|
||||
final IntroduceVariableSettings settings;
|
||||
final PsiElement chosenAnchor;
|
||||
if (choice != null) {
|
||||
chosenAnchor = chooseAnchor(allOccurences, choice == OccurrencesChooser.ReplaceChoice.NO_WRITE, nonWrite, anchorStatementIfAll, anchorStatement);
|
||||
settings = getSettings(project, topLevelEditor, expr, occurrences, typeSelectorManager, inFinalContext, hasWriteAccess, validator, chosenAnchor, choice);
|
||||
}
|
||||
else {
|
||||
settings = getSettings(project, topLevelEditor, expr, occurrences, typeSelectorManager, inFinalContext, hasWriteAccess, validator, anchorStatement, choice);
|
||||
chosenAnchor = chooseAnchor(settings.isReplaceAllOccurrences(), hasWriteAccess, nonWrite, anchorStatementIfAll, anchorStatement);
|
||||
}
|
||||
if (!settings.isOK()) {
|
||||
wasSucceed[0] = false;
|
||||
return;
|
||||
}
|
||||
typeSelectorManager.setAllOccurrences(allOccurences);
|
||||
final TypeExpression expression = new TypeExpression(project, allOccurences ? typeSelectorManager.getTypesForAll() : typeSelectorManager.getTypesForOne());
|
||||
final RangeMarker exprMarker = topLevelEditor.getDocument().createRangeMarker(expr.getTextRange());
|
||||
final SuggestedNameInfo suggestedName = getSuggestedName(settings.getSelectedType(), expr, chosenAnchor);
|
||||
final List<RangeMarker> occurrenceMarkers = new ArrayList<RangeMarker>();
|
||||
final boolean noWrite = choice == OccurrencesChooser.ReplaceChoice.NO_WRITE;
|
||||
for (PsiExpression occurrence : occurrences) {
|
||||
if (allOccurences || (noWrite && !PsiUtil.isAccessedForWriting(occurrence))) {
|
||||
occurrenceMarkers.add(topLevelEditor.getDocument().createRangeMarker(occurrence.getTextRange()));
|
||||
final boolean replaceAll = choice == OccurrencesChooser.ReplaceChoice.ALL || choice == OccurrencesChooser.ReplaceChoice.NO_WRITE;
|
||||
typeSelectorManager.setAllOccurrences(replaceAll);
|
||||
|
||||
final PsiElement chosenAnchor =
|
||||
chooseAnchor(replaceAll, choice == OccurrencesChooser.ReplaceChoice.NO_WRITE, nonWrite, anchorStatementIfAll, anchorStatement);
|
||||
final IntroduceVariableSettings settings =
|
||||
getSettings(project, editor, expr, occurrences, typeSelectorManager, inFinalContext, hasWriteAccess, validator, chosenAnchor, choice);
|
||||
|
||||
final boolean cantChangeFinalModifier = (hasWriteAccess || inFinalContext) && choice == OccurrencesChooser.ReplaceChoice.ALL;
|
||||
|
||||
final boolean noWrite = choice == OccurrencesChooser.ReplaceChoice.NO_WRITE;
|
||||
final List<PsiExpression> allOccurrences = new ArrayList<PsiExpression>();
|
||||
for (PsiExpression occurrence : occurrences) {
|
||||
if (expr.equals(occurrence) && expr.getParent() instanceof PsiExpressionStatement) continue;
|
||||
if (choice == OccurrencesChooser.ReplaceChoice.ALL || (noWrite && !PsiUtil.isAccessedForWriting(occurrence)) || expr.equals(occurrence)) {
|
||||
allOccurrences.add(occurrence);
|
||||
}
|
||||
}
|
||||
myInplaceIntroducer = new JavaVariableInplaceIntroducer(project,
|
||||
settings,
|
||||
chosenAnchor,
|
||||
editor, expr, cantChangeFinalModifier,
|
||||
allOccurrences.toArray(new PsiExpression[allOccurrences.size()]),
|
||||
typeSelectorManager,
|
||||
REFACTORING_NAME);
|
||||
if (myInplaceIntroducer.startInplaceIntroduceTemplate()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final RefactoringEventData beforeData = new RefactoringEventData();
|
||||
beforeData.addElement(expr);
|
||||
project.getMessageBus()
|
||||
.syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(REFACTORING_ID, beforeData);
|
||||
final String expressionText = expr.getText();
|
||||
final Runnable runnable = introduce(project, expr, topLevelEditor, chosenAnchor, occurrences, settings, variable);
|
||||
|
||||
CommandProcessor.getInstance().executeCommand(
|
||||
project,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
final Editor topLevelEditor ;
|
||||
if (!InjectedLanguageManager.getInstance(project).isInjectedFragment(anchorStatement.getContainingFile())) {
|
||||
topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
||||
} else {
|
||||
topLevelEditor = editor;
|
||||
}
|
||||
|
||||
PsiVariable variable = null;
|
||||
try {
|
||||
ApplicationManager.getApplication().runWriteAction(runnable);
|
||||
final IntroduceVariableSettings settings =
|
||||
getSettings(project, topLevelEditor, expr, occurrences, typeSelectorManager, inFinalContext, hasWriteAccess, validator, anchorStatement, choice);
|
||||
if (!settings.isOK()) {
|
||||
wasSucceed[0] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
final RefactoringEventData beforeData = new RefactoringEventData();
|
||||
beforeData.addElement(expr);
|
||||
project.getMessageBus()
|
||||
.syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(REFACTORING_ID, beforeData);
|
||||
|
||||
final PsiElement chosenAnchor =
|
||||
chooseAnchor(settings.isReplaceAllOccurrences(), hasWriteAccess, nonWrite, anchorStatementIfAll, anchorStatement);
|
||||
|
||||
variable = ApplicationManager.getApplication().runWriteAction(
|
||||
introduce(project, expr, topLevelEditor, chosenAnchor, occurrences, settings));
|
||||
}
|
||||
finally {
|
||||
final RefactoringEventData afterData = new RefactoringEventData();
|
||||
final SmartPsiElementPointer<PsiVariable> pointer = variable.get();
|
||||
afterData.addElement(pointer != null ? pointer.getElement() : null);
|
||||
afterData.addElement(variable);
|
||||
project.getMessageBus()
|
||||
.syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(REFACTORING_ID, afterData);
|
||||
}
|
||||
|
||||
if (isInplaceAvailableOnDataContext) {
|
||||
final PsiVariable elementToRename = variable.get().getElement();
|
||||
if (elementToRename != null) {
|
||||
topLevelEditor.getCaretModel().moveToOffset(elementToRename.getTextOffset());
|
||||
final boolean cantChangeFinalModifier = (hasWriteAccess || inFinalContext) && choice == OccurrencesChooser.ReplaceChoice.ALL;
|
||||
final JavaVariableInplaceIntroducer renamer =
|
||||
new JavaVariableInplaceIntroducer(project, expression, topLevelEditor, elementToRename, cantChangeFinalModifier,
|
||||
typeSelectorManager.getTypesForAll().length > 1, exprMarker, occurrenceMarkers,
|
||||
REFACTORING_NAME);
|
||||
renamer.initInitialText(expressionText);
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(topLevelEditor.getDocument());
|
||||
renamer.performInplaceRefactoring(new LinkedHashSet<String>(Arrays.asList(suggestedName.names)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}, REFACTORING_NAME, null);
|
||||
}
|
||||
@@ -724,16 +720,25 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
callback.pass(null);
|
||||
}
|
||||
else {
|
||||
OccurrencesChooser.<PsiExpression>simpleChooser(editor).showChooser(callback, occurrencesMap);
|
||||
OccurrencesChooser.ReplaceChoice choice = getOccurrencesChoice();
|
||||
if (choice != null) {
|
||||
callback.pass(choice);
|
||||
} else {
|
||||
OccurrencesChooser.<PsiExpression>simpleChooser(editor).showChooser(callback, occurrencesMap);
|
||||
}
|
||||
}
|
||||
return wasSucceed[0];
|
||||
}
|
||||
|
||||
protected OccurrencesChooser.ReplaceChoice getOccurrencesChoice() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected PsiElement chooseAnchor(boolean allOccurences,
|
||||
boolean hasWriteAccess,
|
||||
List<PsiExpression> nonWrite,
|
||||
PsiElement anchorStatementIfAll,
|
||||
PsiElement anchorStatement) {
|
||||
protected static PsiElement chooseAnchor(boolean allOccurences,
|
||||
boolean hasWriteAccess,
|
||||
List<PsiExpression> nonWrite,
|
||||
PsiElement anchorStatementIfAll,
|
||||
PsiElement anchorStatement) {
|
||||
if (allOccurences) {
|
||||
if (hasWriteAccess) {
|
||||
return RefactoringUtil.getAnchorElementForMultipleExpressions(nonWrite.toArray(new PsiExpression[nonWrite.size()]), null);
|
||||
@@ -792,13 +797,12 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
return parent3 instanceof JspHolderMethod;
|
||||
}
|
||||
|
||||
private static Runnable introduce(final Project project,
|
||||
final PsiExpression expr,
|
||||
final Editor editor,
|
||||
final PsiElement anchorStatement,
|
||||
final PsiExpression[] occurrences,
|
||||
final IntroduceVariableSettings settings,
|
||||
final Ref<SmartPsiElementPointer<PsiVariable>> variable) {
|
||||
public static Computable<PsiVariable> introduce(final Project project,
|
||||
final PsiExpression expr,
|
||||
final Editor editor,
|
||||
final PsiElement anchorStatement,
|
||||
final PsiExpression[] occurrences,
|
||||
final IntroduceVariableSettings settings) {
|
||||
final PsiElement container = anchorStatement.getParent();
|
||||
PsiElement child = anchorStatement;
|
||||
if (!RefactoringUtil.isLoopOrIf(container)) {
|
||||
@@ -837,8 +841,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
|
||||
final PsiCodeBlock newDeclarationScope = PsiTreeUtil.getParentOfType(container, PsiCodeBlock.class, false);
|
||||
final FieldConflictsResolver fieldConflictsResolver = new FieldConflictsResolver(settings.getEnteredName(), newDeclarationScope);
|
||||
return new Runnable() {
|
||||
public void run() {
|
||||
return new Computable<PsiVariable>() {
|
||||
@Override
|
||||
public PsiVariable compute() {
|
||||
try {
|
||||
PsiStatement statement = null;
|
||||
final boolean isInsideLoop = RefactoringUtil.isLoopOrIf(container);
|
||||
@@ -913,11 +918,12 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
declaration = (PsiDeclarationStatement)JavaCodeStyleManager.getInstance(project).shortenClassReferences(declaration);
|
||||
PsiVariable var = (PsiVariable) declaration.getDeclaredElements()[0];
|
||||
PsiUtil.setModifierProperty(var, PsiModifier.FINAL, settings.isDeclareFinal());
|
||||
variable.set(SmartPointerManager.getInstance(project).createSmartPsiElementPointer(var));
|
||||
fieldConflictsResolver.fix();
|
||||
return var;
|
||||
} catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private PsiDeclarationStatement addDeclaration(PsiDeclarationStatement declaration, PsiExpression initializer) {
|
||||
@@ -1165,6 +1171,6 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
|
||||
@Override
|
||||
public AbstractInplaceIntroducer getInplaceIntroducer() {
|
||||
return null;
|
||||
return myInplaceIntroducer;
|
||||
}
|
||||
}
|
||||
|
||||
+176
-154
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,6 @@ import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.command.impl.StartMarkAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
@@ -30,87 +29,70 @@ import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.scope.processor.VariablesProcessor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.introduce.inplace.InplaceVariableIntroducer;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.rename.ResolveSnapshotProvider;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.ui.NonFocusableCheckBox;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 12/8/10
|
||||
*/
|
||||
public class JavaVariableInplaceIntroducer extends InplaceVariableIntroducer<PsiExpression> {
|
||||
protected final Project myProject;
|
||||
private final SmartPsiElementPointer<PsiDeclarationStatement> myPointer;
|
||||
public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer {
|
||||
|
||||
private SmartPsiElementPointer<PsiDeclarationStatement> myPointer;
|
||||
|
||||
private JCheckBox myCanBeFinalCb;
|
||||
|
||||
private IntroduceVariableSettings mySettings;
|
||||
private SmartPsiElementPointer<PsiElement> myChosenAnchor;
|
||||
private final boolean myCantChangeFinalModifier;
|
||||
private final String myTitle;
|
||||
private String myExpressionText;
|
||||
protected final SmartTypePointer myDefaultType;
|
||||
protected final TypeExpression myExpression;
|
||||
|
||||
private boolean myHasTypeSuggestion;
|
||||
private ResolveSnapshotProvider.ResolveSnapshot myConflictResolver;
|
||||
private TypeExpression myExpression;
|
||||
private boolean myReplaceSelf;
|
||||
private boolean myDeleteSelf = true;
|
||||
|
||||
public JavaVariableInplaceIntroducer(final Project project,
|
||||
final TypeExpression expression,
|
||||
final Editor editor,
|
||||
@NotNull final PsiVariable elementToRename,
|
||||
IntroduceVariableSettings settings, PsiElement chosenAnchor, final Editor editor,
|
||||
final PsiExpression expr,
|
||||
final boolean cantChangeFinalModifier,
|
||||
final boolean hasTypeSuggestion,
|
||||
final RangeMarker exprMarker,
|
||||
final List<RangeMarker> occurrenceMarkers,
|
||||
final PsiExpression[] occurrences,
|
||||
final TypeSelectorManagerImpl selectorManager,
|
||||
final String title) {
|
||||
super(elementToRename, editor, project, title, new PsiExpression[0], null);
|
||||
myProject = project;
|
||||
super(project, editor, RefactoringUtil.outermostParenthesizedExpression(expr), null, occurrences, selectorManager, title);
|
||||
mySettings = settings;
|
||||
myChosenAnchor = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(chosenAnchor);
|
||||
myCantChangeFinalModifier = cantChangeFinalModifier;
|
||||
myHasTypeSuggestion = selectorManager.getTypesForAll().length > 1;
|
||||
myTitle = title;
|
||||
setExprMarker(exprMarker);
|
||||
setOccurrenceMarkers(occurrenceMarkers);
|
||||
final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(elementToRename, PsiDeclarationStatement.class);
|
||||
myPointer = declarationStatement != null ? SmartPointerManager.getInstance(project).createSmartPsiElementPointer(declarationStatement) : null;
|
||||
editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
|
||||
if (occurrenceMarkers != null) {
|
||||
final ArrayList<RangeMarker> rangeMarkers = new ArrayList<RangeMarker>(occurrenceMarkers);
|
||||
rangeMarkers.add(exprMarker);
|
||||
editor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY,
|
||||
rangeMarkers.toArray(new RangeMarker[rangeMarkers.size()]));
|
||||
}
|
||||
myExpression = expression;
|
||||
final PsiType defaultType = elementToRename.getType();
|
||||
myDefaultType = SmartTypePointerManager.getInstance(project).createSmartTypePointer(defaultType);
|
||||
setAdvertisementText(getAdvertisementText(declarationStatement, defaultType, hasTypeSuggestion));
|
||||
}
|
||||
myExpression = new TypeExpression(myProject, isReplaceAllOccurrences()
|
||||
? myTypeSelectorManager.getTypesForAll()
|
||||
: myTypeSelectorManager.getTypesForOne());
|
||||
|
||||
public void initInitialText(String text) {
|
||||
myExpressionText = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StartMarkAction startRename() throws StartMarkAction.AlreadyStartedException {
|
||||
return StartMarkAction.start(myEditor, myProject, getCommandName());
|
||||
final List<RangeMarker> rangeMarkers = getOccurrenceMarkers();
|
||||
editor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY,
|
||||
rangeMarkers.toArray(new RangeMarker[rangeMarkers.size()]));
|
||||
myReplaceSelf = myExpr.getParent() instanceof PsiExpressionStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,7 +104,7 @@ public class JavaVariableInplaceIntroducer extends InplaceVariableIntroducer<Psi
|
||||
|
||||
@Nullable
|
||||
protected PsiVariable getVariable() {
|
||||
final PsiDeclarationStatement declarationStatement = myPointer.getElement();
|
||||
final PsiDeclarationStatement declarationStatement = myPointer != null ? myPointer.getElement() : null;
|
||||
if (declarationStatement != null) {
|
||||
PsiElement[] declaredElements = declarationStatement.getDeclaredElements();
|
||||
return declaredElements.length == 0 ? null : (PsiVariable)declaredElements[0];
|
||||
@@ -131,101 +113,94 @@ public class JavaVariableInplaceIntroducer extends InplaceVariableIntroducer<Psi
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveOffsetAfter(boolean success) {
|
||||
try {
|
||||
if (success) {
|
||||
final Document document = myEditor.getDocument();
|
||||
@Nullable final PsiVariable psiVariable = getVariable();
|
||||
if (psiVariable == null) {
|
||||
return;
|
||||
}
|
||||
LOG.assertTrue(psiVariable.isValid());
|
||||
TypeSelectorManagerImpl.typeSelected(psiVariable.getType(), myDefaultType.getType());
|
||||
if (myCanBeFinalCb != null) {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = psiVariable.hasModifierProperty(PsiModifier.FINAL);
|
||||
}
|
||||
adjustLine(psiVariable, document);
|
||||
protected String getActionName() {
|
||||
return "IntroduceVariable";
|
||||
}
|
||||
|
||||
int startOffset = getExprMarker() != null && getExprMarker().isValid() ? getExprMarker().getStartOffset() : psiVariable.getTextOffset();
|
||||
final PsiFile file = psiVariable.getContainingFile();
|
||||
final PsiReference referenceAt = file.findReferenceAt(startOffset);
|
||||
if (referenceAt != null && referenceAt.resolve() instanceof PsiVariable) {
|
||||
startOffset = referenceAt.getElement().getTextRange().getEndOffset();
|
||||
}
|
||||
else {
|
||||
final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(psiVariable, PsiDeclarationStatement.class);
|
||||
if (declarationStatement != null) {
|
||||
startOffset = declarationStatement.getTextRange().getEndOffset();
|
||||
}
|
||||
}
|
||||
myEditor.getCaretModel().moveToOffset(startOffset);
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
if (psiVariable.getInitializer() != null) {
|
||||
appendTypeCasts(getOccurrenceMarkers(), file, myProject, psiVariable);
|
||||
}
|
||||
if (myConflictResolver != null && myInsertedName != null && isIdentifier(myInsertedName, psiVariable.getLanguage())) {
|
||||
myConflictResolver.apply(psiVariable.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
RangeMarker exprMarker = getExprMarker();
|
||||
if (exprMarker != null && exprMarker.isValid()) {
|
||||
myEditor.getCaretModel().moveToOffset(exprMarker.getStartOffset());
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
}
|
||||
if (myExpressionText != null) {
|
||||
if (!ReadonlyStatusHandler.ensureDocumentWritable(myProject, InjectedLanguageUtil.getTopLevelEditor(myEditor).getDocument())) return;
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
final PsiDeclarationStatement element = myPointer.getElement();
|
||||
if (element != null) {
|
||||
final PsiElement[] vars = element.getDeclaredElements();
|
||||
if (vars.length > 0 && vars[0] instanceof PsiVariable) {
|
||||
final PsiFile containingFile = element.getContainingFile();
|
||||
//todo pull up method restore state
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(myProject);
|
||||
final RangeMarker exprMarker = getExprMarker();
|
||||
if (exprMarker != null) {
|
||||
myExpr = AbstractJavaInplaceIntroducer.restoreExpression(containingFile, (PsiVariable)vars[0], elementFactory, exprMarker, myExpressionText);
|
||||
if (myExpr != null && myExpr.isPhysical()) {
|
||||
myExprMarker = createMarker(myExpr);
|
||||
}
|
||||
}
|
||||
List<RangeMarker> markers = getOccurrenceMarkers();
|
||||
for (RangeMarker occurrenceMarker : markers) {
|
||||
if (getExprMarker() != null && occurrenceMarker.getStartOffset() == getExprMarker().getStartOffset() && myExpr != null) {
|
||||
continue;
|
||||
}
|
||||
AbstractJavaInplaceIntroducer
|
||||
.restoreExpression(containingFile, (PsiVariable)vars[0], elementFactory, occurrenceMarker, myExpressionText);
|
||||
}
|
||||
final PsiExpression initializer = ((PsiVariable)vars[0]).getInitializer();
|
||||
if (initializer != null && Comparing.strEqual(initializer.getText(), myExpressionText) && myExpr == null) {
|
||||
element.replace(JavaPsiFacade.getInstance(myProject).getElementFactory().createStatementFromText(myExpressionText, element));
|
||||
} else {
|
||||
element.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myEditor.putUserData(ReassignVariableUtil.DECLARATION_KEY, null);
|
||||
for (RangeMarker occurrenceMarker : getOccurrenceMarkers()) {
|
||||
occurrenceMarker.dispose();
|
||||
}
|
||||
myEditor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY, null);
|
||||
if (getExprMarker() != null) getExprMarker().dispose();
|
||||
@Override
|
||||
protected void restoreState(PsiVariable psiField) {
|
||||
if (myDeleteSelf) return;
|
||||
super.restoreState(psiField);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean ensureValid() {
|
||||
final PsiVariable variable = getVariable();
|
||||
return variable != null && isIdentifier(getInputName(), variable.getLanguage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performCleanup() {
|
||||
super.performCleanup();
|
||||
super.restoreState(getVariable());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteTemplateField(PsiVariable variable) {
|
||||
if (!myDeleteSelf) return;
|
||||
if (myReplaceSelf) {
|
||||
variable.replace(variable.getInitializer());
|
||||
} else {
|
||||
super.deleteTemplateField(variable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performIntroduce() {
|
||||
final PsiVariable psiVariable = getVariable();
|
||||
if (psiVariable == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TypeSelectorManagerImpl.typeSelected(psiVariable.getType(), myTypeSelectorManager.getDefaultType());
|
||||
if (myCanBeFinalCb != null) {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = psiVariable.hasModifierProperty(PsiModifier.FINAL);
|
||||
}
|
||||
|
||||
final Document document = myEditor.getDocument();
|
||||
LOG.assertTrue(psiVariable.isValid());
|
||||
adjustLine(psiVariable, document);
|
||||
|
||||
int startOffset = getExprMarker() != null && getExprMarker().isValid() ? getExprMarker().getStartOffset() : psiVariable.getTextOffset();
|
||||
final PsiFile file = psiVariable.getContainingFile();
|
||||
final PsiReference referenceAt = file.findReferenceAt(startOffset);
|
||||
if (referenceAt != null && referenceAt.resolve() instanceof PsiVariable) {
|
||||
startOffset = referenceAt.getElement().getTextRange().getEndOffset();
|
||||
}
|
||||
else {
|
||||
final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(psiVariable, PsiDeclarationStatement.class);
|
||||
if (declarationStatement != null) {
|
||||
startOffset = declarationStatement.getTextRange().getEndOffset();
|
||||
}
|
||||
}
|
||||
|
||||
myEditor.getCaretModel().moveToOffset(startOffset);
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
if (psiVariable.getInitializer() != null) {
|
||||
appendTypeCasts(getOccurrenceMarkers(), file, myProject, psiVariable);
|
||||
}
|
||||
if (myConflictResolver != null && myInsertedName != null && isIdentifier(myInsertedName, psiVariable.getLanguage())) {
|
||||
myConflictResolver.apply(psiVariable.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceAllOccurrences() {
|
||||
return mySettings.isReplaceAllOccurrences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplaceAllOccurrences(boolean allOccurrences) {}
|
||||
|
||||
@Override
|
||||
protected boolean startsOnTheSameElement(RefactoringActionHandler handler, PsiElement element) {
|
||||
return handler instanceof IntroduceVariableHandler && super.startsOnTheSameElement(handler, element);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected JComponent getComponent() {
|
||||
@@ -265,8 +240,27 @@ public class JavaVariableInplaceIntroducer extends InplaceVariableIntroducer<Psi
|
||||
}
|
||||
|
||||
protected void addAdditionalVariables(TemplateBuilderImpl builder) {
|
||||
final PsiTypeElement typeElement = getVariable().getTypeElement();
|
||||
builder.replaceElement(typeElement, "Variable_Type", AbstractJavaInplaceIntroducer.createExpression(myExpression, typeElement.getText()), true, true);
|
||||
final PsiVariable variable = getVariable();
|
||||
if (variable != null) {
|
||||
final PsiTypeElement typeElement = variable.getTypeElement();
|
||||
if (typeElement != null) {
|
||||
builder.replaceElement(typeElement, "Variable_Type", AbstractJavaInplaceIntroducer.createExpression(myExpression, typeElement.getText()), true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void collectAdditionalElementsToRename(List<Pair<PsiElement, TextRange>> stringUsages) {
|
||||
if (isReplaceAllOccurrences()) {
|
||||
for (PsiExpression expression : getOccurrences()) {
|
||||
LOG.assertTrue(expression.isValid(), expression.getText());
|
||||
stringUsages.add(Pair.<PsiElement, TextRange>create(expression, new TextRange(0, expression.getTextLength())));
|
||||
}
|
||||
} else if (getExpr() != null && !myReplaceSelf) {
|
||||
final PsiExpression expr = getExpr();
|
||||
LOG.assertTrue(expr.isValid(), expr.getText());
|
||||
stringUsages.add(Pair.<PsiElement, TextRange>create(expr, new TextRange(0, expr.getTextLength())));
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendTypeCasts(List<RangeMarker> occurrenceMarkers,
|
||||
@@ -353,21 +347,49 @@ public class JavaVariableInplaceIntroducer extends InplaceVariableIntroducer<Psi
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected String getTitle() {
|
||||
return myTitle;
|
||||
@Override
|
||||
protected PsiVariable createFieldToStartTemplateOn(String[] names, PsiType psiType) {
|
||||
final PsiVariable variable = ApplicationManager.getApplication().runWriteAction(
|
||||
IntroduceVariableBase.introduce(myProject, myExpr, myEditor, myChosenAnchor.getElement(), getOccurrences(), mySettings));
|
||||
PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(myEditor.getDocument());
|
||||
final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(variable, PsiDeclarationStatement.class);
|
||||
myPointer = declarationStatement != null ? SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(declarationStatement) : null;
|
||||
myEditor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
|
||||
setAdvertisementText(getAdvertisementText(declarationStatement, variable.getType(), myHasTypeSuggestion));
|
||||
final PsiIdentifier identifier = variable.getNameIdentifier();
|
||||
if (identifier != null) {
|
||||
myEditor.getCaretModel().moveToOffset(identifier.getTextOffset());
|
||||
}
|
||||
try {
|
||||
myDeleteSelf = false;
|
||||
restoreState(variable);
|
||||
}
|
||||
finally {
|
||||
myDeleteSelf = true;
|
||||
}
|
||||
initOccurrencesMarkers();
|
||||
return variable;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static String getAdvertisementText(final boolean hasTypeSuggestion) {
|
||||
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
|
||||
if (hasTypeSuggestion) {
|
||||
final Shortcut[] shortcuts = keymap.getShortcuts("PreviousTemplateVariable");
|
||||
if (shortcuts.length > 0) {
|
||||
return "Press " + shortcuts[0] + " to change type";
|
||||
@Override
|
||||
protected int getCaretOffset() {
|
||||
final PsiVariable variable = getVariable();
|
||||
if (variable != null) {
|
||||
final PsiIdentifier identifier = variable.getNameIdentifier();
|
||||
if (identifier != null) {
|
||||
return identifier.getTextOffset();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return super.getCaretOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] suggestNames(PsiType defaultType, String propName) {
|
||||
return IntroduceVariableBase.getSuggestedName(defaultType, myExpr).names;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VariableKind getVariableKind() {
|
||||
return VariableKind.LOCAL_VARIABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ import com.intellij.psi.impl.source.tree.AstBufferUtil;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.PairProcessor;
|
||||
import com.intellij.util.WalkingState;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
@@ -187,12 +185,12 @@ public class SliceLeafAnalyzer {
|
||||
return new FactoryMap<SliceNode, Collection<PsiElement>>() {
|
||||
@Override
|
||||
protected Map<SliceNode, Collection<PsiElement>> createMap() {
|
||||
return new ConcurrentHashMap<SliceNode, Collection<PsiElement>>(ContainerUtil.<SliceNode>identityStrategy());
|
||||
return ContainerUtil.newConcurrentMap(ContainerUtil.<SliceNode>identityStrategy());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<PsiElement> create(SliceNode key) {
|
||||
return new ConcurrentHashSet<PsiElement>(LEAF_ELEMENT_EQUALITY);
|
||||
return ContainerUtil.newConcurrentSet(LEAF_ELEMENT_EQUALITY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,21 +30,22 @@ import com.intellij.psi.impl.file.PsiPackageImpl;
|
||||
import com.intellij.psi.impl.java.stubs.index.JavaFullClassNameIndex;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Author: dmitrylomov
|
||||
*/
|
||||
public class JavaFileManagerImpl implements JavaFileManager, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.file.impl.JavaFileManagerImpl");
|
||||
private final ConcurrentHashMap<GlobalSearchScope, PsiClass> myCachedObjectClassMap = new ConcurrentHashMap<GlobalSearchScope, PsiClass>();
|
||||
private final ConcurrentMap<GlobalSearchScope, PsiClass> myCachedObjectClassMap = ContainerUtil.newConcurrentMap();
|
||||
private final PsiManagerEx myManager;
|
||||
private volatile Set<String> myNontrivialPackagePrefixes = null;
|
||||
private boolean myDisposed = false;
|
||||
@@ -127,7 +128,7 @@ public class JavaFileManagerImpl implements JavaFileManager, Disposable {
|
||||
if (cached == null) {
|
||||
cached = findClassInIndex(qName, scope);
|
||||
if (cached != null) {
|
||||
cached = myCachedObjectClassMap.cacheOrGet(scope, cached);
|
||||
cached = ConcurrencyUtil.cacheOrGet(myCachedObjectClassMap, scope, cached);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ public interface PsiJavaParserFacade {
|
||||
PsiDocComment createDocCommentFromText(@NotNull String docCommentText) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java class from the specified text.
|
||||
* Creates a Java class with a dummy name from the specified body text (the text between the braces).
|
||||
*
|
||||
* @param text the text of the class to create.
|
||||
* @param text the body text of the class to create.
|
||||
* @param context the PSI element used as context for resolving references which cannot be resolved
|
||||
* within the class.
|
||||
* @return the created class instance.
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import gnu.trove.THashMap;
|
||||
@@ -1043,7 +1042,7 @@ public class TypeConversionUtil {
|
||||
return getMaybeSuperClassSubstitutor(superClassCandidate, derivedClassCandidate, derivedSubstitutor, null);
|
||||
}
|
||||
|
||||
private static final Set<String> ourReportedSuperClassSubstitutorExceptions = new ConcurrentHashSet<String>();
|
||||
private static final Set<String> ourReportedSuperClassSubstitutorExceptions = ContainerUtil.newConcurrentSet();
|
||||
|
||||
/**
|
||||
* Calculates substitutor that binds type parameters in <code>superClass</code> with
|
||||
|
||||
@@ -30,17 +30,16 @@ import com.intellij.openapi.util.NotNullLazyKey;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.util.containers.ConcurrentList;
|
||||
import com.intellij.util.containers.ConcurrentWeakHashMap;
|
||||
import com.intellij.util.containers.ConcurrentWeakKeySoftValueHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class ControlFlowFactory {
|
||||
// psiElements hold weakly, controlFlows softly
|
||||
private final ConcurrentMap<PsiElement, Reference<ConcurrentList<ControlFlowContext>>> cachedFlows = new ConcurrentWeakHashMap<PsiElement, Reference<ConcurrentList<ControlFlowContext>>>();
|
||||
private final ConcurrentMap<PsiElement, ConcurrentList<ControlFlowContext>> cachedFlows = new ConcurrentWeakKeySoftValueHashMap<PsiElement, ConcurrentList<ControlFlowContext>>(100, 0.75f, Runtime.getRuntime().availableProcessors(),
|
||||
ContainerUtil.<PsiElement>canonicalStrategy());
|
||||
|
||||
private static final NotNullLazyKey<ControlFlowFactory, Project> INSTANCE_KEY = ServiceManager.createLazyKey(ControlFlowFactory.class);
|
||||
|
||||
@@ -62,16 +61,10 @@ public class ControlFlowFactory {
|
||||
cachedFlows.clear();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void registerSubRange(final PsiElement codeFragment, final ControlFlowSubRange flow, final boolean evaluateConstantIfConfition,
|
||||
final ControlFlowPolicy policy) {
|
||||
registerSubRange(codeFragment, flow, evaluateConstantIfConfition, true, policy);
|
||||
}
|
||||
|
||||
public void registerSubRange(final PsiElement codeFragment,
|
||||
final ControlFlowSubRange flow,
|
||||
final boolean evaluateConstantIfConfition,
|
||||
boolean enableShortCircuit, final ControlFlowPolicy policy) {
|
||||
void registerSubRange(final PsiElement codeFragment,
|
||||
final ControlFlowSubRange flow,
|
||||
final boolean evaluateConstantIfConfition,
|
||||
boolean enableShortCircuit, final ControlFlowPolicy policy) {
|
||||
registerControlFlow(codeFragment, flow, evaluateConstantIfConfition, enableShortCircuit, policy);
|
||||
}
|
||||
|
||||
@@ -90,6 +83,7 @@ public class ControlFlowFactory {
|
||||
this.controlFlow = controlFlow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
@@ -99,6 +93,7 @@ public class ControlFlowFactory {
|
||||
return isFor(that);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = policy.hashCode();
|
||||
result = 31 * result + (evaluateConstantIfCondition ? 1 : 0);
|
||||
@@ -106,7 +101,10 @@ public class ControlFlowFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isFor(@NotNull ControlFlowPolicy policy, final boolean evaluateConstantIfCondition, final boolean enableShortCircuit, long modificationCount) {
|
||||
private boolean isFor(@NotNull ControlFlowPolicy policy,
|
||||
final boolean evaluateConstantIfCondition,
|
||||
final boolean enableShortCircuit,
|
||||
long modificationCount) {
|
||||
if (modificationCount != this.modificationCount) return false;
|
||||
if (!policy.equals(this.policy)) return false;
|
||||
if (enableShortCircuit != this.enableShortCircuit) return false;
|
||||
@@ -171,11 +169,10 @@ public class ControlFlowFactory {
|
||||
|
||||
@NotNull
|
||||
private ConcurrentList<ControlFlowContext> getOrCreateCachedFlowsForElement(@NotNull PsiElement element) {
|
||||
Reference<ConcurrentList<ControlFlowContext>> cachedRef = cachedFlows.get(element);
|
||||
ConcurrentList<ControlFlowContext> cached = com.intellij.reference.SoftReference.dereference(cachedRef);
|
||||
ConcurrentList<ControlFlowContext> cached = cachedFlows.get(element);
|
||||
if (cached == null) {
|
||||
cached = ContainerUtil.createConcurrentList();
|
||||
cachedFlows.put(element, new SoftReference<ConcurrentList<ControlFlowContext>>(cached));
|
||||
cachedFlows.put(element, cached);
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,6 @@ import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
@@ -177,7 +176,7 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx {
|
||||
public PsiPackage findPackage(@NotNull String qualifiedName) {
|
||||
ConcurrentMap<String, PsiPackage> cache = SoftReference.dereference(myPackageCache);
|
||||
if (cache == null) {
|
||||
myPackageCache = new SoftReference<ConcurrentMap<String, PsiPackage>>(cache = new ConcurrentHashMap<String, PsiPackage>());
|
||||
myPackageCache = new SoftReference<ConcurrentMap<String, PsiPackage>>(cache = ContainerUtil.newConcurrentMap());
|
||||
}
|
||||
|
||||
PsiPackage aPackage = cache.get(qualifiedName);
|
||||
|
||||
@@ -35,19 +35,22 @@ import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements PsiElementFactory {
|
||||
private PsiClass myArrayClass;
|
||||
private PsiClass myArrayClass15;
|
||||
private final ConcurrentHashMap<GlobalSearchScope, PsiClassType> myCachedObjectType = new ConcurrentHashMap<GlobalSearchScope, PsiClassType>();
|
||||
private final ConcurrentMap<GlobalSearchScope, PsiClassType> myCachedObjectType =
|
||||
ContainerUtil.newConcurrentMap();
|
||||
|
||||
public PsiElementFactoryImpl(final PsiManagerEx manager) {
|
||||
super(manager);
|
||||
@@ -408,7 +411,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
PsiClass aClass = JavaPsiFacade.getInstance(myManager.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, resolveScope);
|
||||
if (aClass != null) {
|
||||
cachedObjectType = new PsiImmediateClassType(aClass, PsiSubstitutor.EMPTY);
|
||||
cachedObjectType = myCachedObjectType.cacheOrGet(resolveScope, cachedObjectType);
|
||||
cachedObjectType = ConcurrencyUtil.cacheOrGet(myCachedObjectType, resolveScope, cachedObjectType);
|
||||
return cachedObjectType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,6 +375,7 @@ public class PsiSuperMethodImplUtil {
|
||||
Project project = aClass == null ? method.getProject() : aClass.getProject();
|
||||
// cache Cls method hierarchy until root changed
|
||||
Object dependency = method instanceof PsiCompiledElement ? ProjectRootModificationTracker.getInstance(project) :
|
||||
!method.isPhysical() ? method :
|
||||
PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT;
|
||||
return CachedValueProvider.Result.create(result, dependency);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
{
|
||||
new <caret>C();
|
||||
new C();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
{
|
||||
C c = new C();
|
||||
c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
{
|
||||
C c = new <caret>C();
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new C();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
{
|
||||
final C c1 = new C();
|
||||
C c = c1;
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
c1;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C c = new <caret>C();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C c = new <caret>C();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
{
|
||||
Object c1 = new C();
|
||||
C c = (C) c1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
{
|
||||
Integer c1 = (Integer) new C();
|
||||
C c = (C) c1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C c = new <caret>C();
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C c = new <caret>C();
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C c = <caret>new C();
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C c = <caret>new C();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C c = new <caret>C();
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
{
|
||||
C expr = new C();
|
||||
C c = expr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
(new <caret>C());
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C expr = new C();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
{
|
||||
int[] a = new int[1];
|
||||
a[1] = 42;
|
||||
System.out.println(a<caret>[1]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
{
|
||||
int[] a = new int[1];
|
||||
a[1] = 42;
|
||||
int x = a[1];
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Bar {}
|
||||
class Foo {
|
||||
static Bar bar;
|
||||
}
|
||||
class C {
|
||||
{
|
||||
Bar b = Foo.ba<caret>r;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Bar {}
|
||||
class Foo {
|
||||
static Bar bar;
|
||||
}
|
||||
class C {
|
||||
{
|
||||
Bar expr = Foo.bar;
|
||||
Bar b = expr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
{
|
||||
C c = new <caret>C();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
{
|
||||
C
|
||||
|
||||
c1 = new C();
|
||||
C c = c1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
{
|
||||
int[] a = new int[1];
|
||||
a[1] = 42;
|
||||
System.out.println(a<caret>[1]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
{
|
||||
int[] a = new int[1];
|
||||
int x = a[1];
|
||||
x = 42;
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,6 +3,6 @@ import java.io.File;
|
||||
class Test {
|
||||
java.io.File[] get() {return null;}
|
||||
{
|
||||
File[] files = get();
|
||||
File[] i = get();
|
||||
}
|
||||
}
|
||||
+4
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,13 +40,12 @@ import java.util.List;
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class OverrideImplementTest extends LightCodeInsightTestCase {
|
||||
public class OverrideImplement15Test extends LightCodeInsightTestCase {
|
||||
private static final String BASE_DIR = "/codeInsight/overrideImplement/";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
protected LanguageLevel getLanguageLevel() {
|
||||
return LanguageLevel.JDK_1_5;
|
||||
}
|
||||
|
||||
public void testSimple() { doTest(true); }
|
||||
@@ -68,15 +67,6 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
|
||||
public void testResolveTypeParamConflict() { doTest(false); }
|
||||
public void testRawInheritance() { doTest(false); }
|
||||
|
||||
public void testImplementExtensionMethods() { doTest8(false, true); }
|
||||
public void testOverrideExtensionMethods() { doTest8(false, false); }
|
||||
public void testDoNotImplementExtensionMethods() { doTest8(false, true); }
|
||||
public void testSkipUnknownAnnotations() { doTest8(false, true); }
|
||||
|
||||
|
||||
public void testOverrideInInterface() { doTest8(false, false); }
|
||||
public void testMultipleInheritedThrows() {doTest8(false, false);}
|
||||
|
||||
public void testLongFinalParameterList() {
|
||||
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();
|
||||
try {
|
||||
@@ -149,11 +139,6 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
|
||||
|
||||
private void doTest(boolean copyJavadoc) { doTest(copyJavadoc, null); }
|
||||
|
||||
private void doTest8(boolean copyJavadoc, @Nullable Boolean toImplement) {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doTest(copyJavadoc, toImplement);
|
||||
}
|
||||
|
||||
private void doTest(boolean copyJavadoc, @Nullable Boolean toImplement) {
|
||||
String name = getTestName(false);
|
||||
configureByFile(BASE_DIR + "before" + name + ".java");
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.codeInsight;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class OverrideImplementTest extends LightCodeInsightFixtureTestCase {
|
||||
private static final String BASE_DIR = "/codeInsight/overrideImplement/";
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return JavaTestUtil.getRelativeJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testImplementExtensionMethods() { doTest(true); }
|
||||
public void testOverrideExtensionMethods() { doTest(false); }
|
||||
public void testDoNotImplementExtensionMethods() { doTest(true); }
|
||||
public void testSkipUnknownAnnotations() { doTest(true); }
|
||||
|
||||
public void testOverrideInInterface() { doTest(false); }
|
||||
public void testMultipleInheritedThrows() {doTest(false);}
|
||||
|
||||
public void "test overriding overloaded method"() {
|
||||
myFixture.addClass """package bar;
|
||||
interface A {
|
||||
void foo(Foo2 f);
|
||||
void foo(Foo1 f);
|
||||
}
|
||||
"""
|
||||
myFixture.addClass "package bar; class Foo1 {}"
|
||||
myFixture.addClass "package bar; class Foo2 {}"
|
||||
def file = myFixture.addClass("""package bar;
|
||||
class Test implements A {
|
||||
public void foo(Foo1 f) {}
|
||||
<caret>
|
||||
}
|
||||
""").containingFile.virtualFile
|
||||
myFixture.configureFromExistingVirtualFile(file)
|
||||
|
||||
invokeAction(true)
|
||||
|
||||
myFixture.checkResult """package bar;
|
||||
class Test implements A {
|
||||
public void foo(Foo1 f) {}
|
||||
|
||||
@Override
|
||||
public void foo(Foo2 f) {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
private void doTest(boolean toImplement) {
|
||||
String name = getTestName(false);
|
||||
myFixture.configureByFile(BASE_DIR + "before" + name + ".java");
|
||||
invokeAction(toImplement)
|
||||
myFixture.checkResultByFile(BASE_DIR + "after" + name + ".java");
|
||||
}
|
||||
|
||||
private void invokeAction(boolean toImplement) {
|
||||
int offset = myFixture.getEditor().getCaretModel().getOffset();
|
||||
PsiClass psiClass = PsiTreeUtil.findElementOfClassAtOffset(myFixture.getFile(), offset, PsiClass.class, false);
|
||||
assert psiClass != null;
|
||||
OverrideImplementUtil.chooseAndOverrideOrImplementMethods(getProject(), myFixture.getEditor(), psiClass, toImplement);
|
||||
}
|
||||
}
|
||||
@@ -289,6 +289,44 @@ class Test {
|
||||
assert !myFixture.filterAvailableIntentions("Import Class")
|
||||
}
|
||||
|
||||
public void "test allow to add import from javadoc"() {
|
||||
myFixture.configureByText 'a.java', '''
|
||||
class Test {
|
||||
|
||||
/**
|
||||
* {@link java.lang.Ma<caret>th}
|
||||
*/
|
||||
void run() {
|
||||
}
|
||||
}
|
||||
'''
|
||||
reimportClass()
|
||||
myFixture.checkResult '''\
|
||||
import java.lang.Math;
|
||||
|
||||
class Test {
|
||||
|
||||
/**
|
||||
* {@link Math}
|
||||
*/
|
||||
void run() {
|
||||
}
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
public void "test do not allow to add import in package-info file"() {
|
||||
myFixture.configureByText 'package-info.java', '''
|
||||
|
||||
/**
|
||||
* {@link java.lang.Ma<caret>th}
|
||||
*/
|
||||
package com.rocket.test;
|
||||
'''
|
||||
assert myFixture.filterAvailableIntentions('Replace qualified name').isEmpty()
|
||||
}
|
||||
|
||||
|
||||
private def importClass() {
|
||||
myFixture.launchAction(myFixture.findSingleIntention("Import Class"))
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.scalacheck.Arbitrary.arbitrary
|
||||
import org.scalacheck.Gen._
|
||||
import org.scalacheck.Prop.forAll
|
||||
import org.scalacheck._
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
/**
|
||||
* Run this class to generate randomized tests for IDEA VFS/document/PSI/index subsystem interaction using ScalaCheck.
|
||||
@@ -37,11 +37,13 @@ object IndexTestGenerator {
|
||||
const(Gc),
|
||||
const(Commit),
|
||||
const(Save),
|
||||
for (withImport <- arbitrary[Boolean]; viaDocument <- arbitrary[Boolean]) yield TextChange(viaDocument, withImport),
|
||||
for (load <- arbitrary[Boolean]) yield UpdatePsiClassRef(load),
|
||||
for (load <- arbitrary[Boolean]) yield UpdatePsiFileRef(load),
|
||||
for (load <- arbitrary[Boolean]) yield UpdateASTNodeRef(load),
|
||||
for (load <- arbitrary[Boolean]) yield UpdateDocumentRef(load)
|
||||
for (withImport <- arbitrary[Boolean];
|
||||
viaDocument <- arbitrary[Boolean])
|
||||
yield TextChange(viaDocument, withImport),
|
||||
arbitrary[Boolean] map UpdatePsiClassRef,
|
||||
arbitrary[Boolean] map UpdatePsiFileRef,
|
||||
arbitrary[Boolean] map UpdateASTNodeRef,
|
||||
arbitrary[Boolean] map UpdateDocumentRef
|
||||
)
|
||||
val propIndexTest = forAll(Gen.nonEmptyListOf(genAction)) { actions =>
|
||||
new IndexTestSeq(actions).isSuccessful
|
||||
@@ -56,16 +58,19 @@ case class IndexTestSeq(actions: List[Action]) {
|
||||
def printClass: String = {
|
||||
val sb = StringBuilder.newBuilder
|
||||
sb.append(prefix)
|
||||
sb.append("\n" +
|
||||
"public void \"" + testName + "\"() {\n" +
|
||||
"def vFile =\n myFixture.addFileToProject(\"Foo.java\", \"class Foo {}\").virtualFile\n" +
|
||||
"def lastPsiName = \"Foo\"\n" +
|
||||
"long counterBefore\n" +
|
||||
"Document document\n" +
|
||||
"PsiFile psiFile\n" +
|
||||
"ASTNode astNode\n" +
|
||||
"PsiClass psiClass\n" +
|
||||
"def scope = GlobalSearchScope.allScope(project)\n")
|
||||
sb.append(
|
||||
s"""
|
||||
|public void "$testName"() {
|
||||
|def vFile =
|
||||
| myFixture.addFileToProject("Foo.java", "class Foo {}").virtualFile
|
||||
|def lastPsiName = "Foo"
|
||||
|long counterBefore
|
||||
|Document document
|
||||
|PsiFile psiFile
|
||||
|ASTNode astNode
|
||||
|PsiClass psiClass
|
||||
|def scope = GlobalSearchScope.allScope(project)
|
||||
|""".stripMargin)
|
||||
var changeId = 0
|
||||
var docClassName = "Foo"
|
||||
for (action <- actions) {
|
||||
@@ -74,7 +79,10 @@ case class IndexTestSeq(actions: List[Action]) {
|
||||
case Gc =>
|
||||
sb.append("PlatformTestUtil.tryGcSoftlyReachableObjects()\n")
|
||||
case Commit =>
|
||||
sb.append("PsiDocumentManager.getInstance(project).commitAllDocuments()\nlastPsiName = \"" + docClassName + "\"\n")
|
||||
sb.append(
|
||||
s"""PsiDocumentManager.getInstance(project).commitAllDocuments()
|
||||
|lastPsiName = "$docClassName"
|
||||
|""".stripMargin)
|
||||
case Save =>
|
||||
sb.append("FileDocumentManager.instance.saveAllDocuments()\n")
|
||||
case UpdatePsiClassRef(load) =>
|
||||
@@ -89,46 +97,60 @@ case class IndexTestSeq(actions: List[Action]) {
|
||||
case TextChange(viaDocument, withImport) =>
|
||||
changeId += 1
|
||||
docClassName = "Foo" + changeId
|
||||
val newText = (if (withImport) "import zoo.Zoo; " else "") + "class " + docClassName + " {}"
|
||||
val newText = (if (withImport) "import zoo.Zoo; " else "") + s"class $docClassName {}"
|
||||
|
||||
sb.append("counterBefore =\n psiManager.modificationTracker.javaStructureModificationCount\n")
|
||||
sb.append(
|
||||
"""counterBefore =
|
||||
| psiManager.modificationTracker.javaStructureModificationCount
|
||||
| """.stripMargin)
|
||||
|
||||
if (viaDocument) {
|
||||
sb.append("FileDocumentManager.instance.getDocument(vFile).text =\n \"" + newText + "\"\n")
|
||||
sb.append(
|
||||
s"""FileDocumentManager.instance.getDocument(vFile).text =
|
||||
| "$newText"
|
||||
|""".stripMargin)
|
||||
} else {
|
||||
sb.append("//todo remove if statement or replace with its content \n")
|
||||
sb.append("if (FileDocumentManager.instance.unsavedDocuments) {\n FileDocumentManager.instance.saveAllDocuments()\n}\n")
|
||||
sb.append("VfsUtil.saveText(vFile, \"" + newText + "\")\n")
|
||||
sb.append(
|
||||
s"""//todo remove if statement or replace with its content
|
||||
|if (FileDocumentManager.instance.unsavedDocuments) {
|
||||
| FileDocumentManager.instance.saveAllDocuments()
|
||||
|}
|
||||
|VfsUtil.saveText(vFile, "$newText")
|
||||
|""".stripMargin)
|
||||
}
|
||||
|
||||
sb.append(
|
||||
"// todo replace if statement with assertions\n" +
|
||||
"if (!PsiDocumentManager.getInstance(project).uncommittedDocuments) {\n" +
|
||||
" lastPsiName = \"" + docClassName + "\"\n" +
|
||||
" assert counterBefore !=\n psiManager.modificationTracker.javaStructureModificationCount\n" +
|
||||
"}\n")
|
||||
s"""// todo replace if statement with assertions
|
||||
|if (!PsiDocumentManager.getInstance(project).uncommittedDocuments) {
|
||||
| lastPsiName = "$docClassName"
|
||||
| assert counterBefore !=
|
||||
| psiManager.modificationTracker.javaStructureModificationCount
|
||||
|}
|
||||
|""".stripMargin)
|
||||
}
|
||||
}
|
||||
sb.append("}\n}")
|
||||
sb.toString()
|
||||
}
|
||||
|
||||
val prefix = "import com.intellij.lang.ASTNode\n" +
|
||||
"import com.intellij.openapi.command.WriteCommandAction\n" +
|
||||
"import com.intellij.openapi.editor.Document\n" +
|
||||
"import com.intellij.openapi.fileEditor.FileDocumentManager\n" +
|
||||
"import com.intellij.openapi.util.Ref\n" +
|
||||
"import com.intellij.openapi.vfs.VfsUtil\n" +
|
||||
"import com.intellij.psi.*\n" +
|
||||
"import com.intellij.psi.search.GlobalSearchScope\n" +
|
||||
"import com.intellij.testFramework.PlatformTestUtil\n" +
|
||||
"import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase\n" +
|
||||
"import com.intellij.util.ObjectUtils\n" +
|
||||
"import org.jetbrains.annotations.NotNull\n" +
|
||||
"class DummyTest extends JavaCodeInsightFixtureTestCase {\n" +
|
||||
"protected void invokeTestRunnable(Runnable runnable) {\n" +
|
||||
" WriteCommandAction.runWriteCommandAction(project, runnable)\n" +
|
||||
"}\n"
|
||||
val prefix =
|
||||
s"""import com.intellij.lang.ASTNode
|
||||
|import com.intellij.openapi.command.WriteCommandAction
|
||||
|import com.intellij.openapi.editor.Document
|
||||
|import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
|import com.intellij.openapi.util.Ref
|
||||
|import com.intellij.openapi.vfs.VfsUtil
|
||||
|import com.intellij.psi.*
|
||||
|import com.intellij.psi.search.GlobalSearchScope
|
||||
|import com.intellij.testFramework.PlatformTestUtil
|
||||
|import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
|
||||
|import com.intellij.util.ObjectUtils
|
||||
|import org.jetbrains.annotations.NotNull
|
||||
|class DummyTest extends JavaCodeInsightFixtureTestCase {
|
||||
|protected void invokeTestRunnable(Runnable runnable) {
|
||||
| WriteCommandAction.runWriteCommandAction(project, runnable)
|
||||
|}
|
||||
|""".stripMargin
|
||||
|
||||
val testName: String = "test please write a meaningful description here"
|
||||
|
||||
@@ -139,21 +161,20 @@ case class IndexTestSeq(actions: List[Action]) {
|
||||
val test = new GroovyClassLoader().parseClass(classText).newInstance().asInstanceOf[TestCase]
|
||||
test.setName(testName)
|
||||
val result: TestResult = test.run()
|
||||
for (failure <- ContainerUtil.toList(result.failures()).asScala) {
|
||||
println (failure.trace())
|
||||
}
|
||||
for (failure <- ContainerUtil.toList(result.errors()).asScala) {
|
||||
println (failure.trace())
|
||||
}
|
||||
if (!result.wasSuccessful()) {
|
||||
val successful: Boolean = result.wasSuccessful()
|
||||
|
||||
if (!successful) {
|
||||
ContainerUtil.toList(result.failures()).foreach(failure => println(failure.trace()))
|
||||
ContainerUtil.toList(result.errors()).foreach(failure => println(failure.trace()))
|
||||
println(classText)
|
||||
}
|
||||
result.wasSuccessful()
|
||||
|
||||
successful
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Action
|
||||
sealed trait Action
|
||||
case object Gc extends Action
|
||||
case object Commit extends Action
|
||||
case object Save extends Action
|
||||
|
||||
+5
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -72,6 +72,10 @@ public abstract class AbstractJavaInplaceIntroduceTest extends AbstractInplaceIn
|
||||
@Override
|
||||
protected AbstractInplaceIntroducer invokeRefactoring() {
|
||||
final MyIntroduceHandler introduceHandler = createIntroduceHandler();
|
||||
return invokeRefactoring(introduceHandler);
|
||||
}
|
||||
|
||||
protected AbstractInplaceIntroducer invokeRefactoring(MyIntroduceHandler introduceHandler) {
|
||||
final PsiExpression expression = getExpressionFromEditor();
|
||||
if (expression != null) {
|
||||
introduceHandler.invokeImpl(LightPlatformTestCase.getProject(), expression, getEditor());
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiLiteralExpression;
|
||||
import com.intellij.psi.PsiLocalVariable;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer;
|
||||
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableHandler;
|
||||
import com.intellij.testFramework.MapDataContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTest {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected PsiExpression getExpressionFromEditor() {
|
||||
final PsiExpression expression = super.getExpressionFromEditor();
|
||||
if (expression != null) {
|
||||
return expression;
|
||||
}
|
||||
final PsiExpression expr = PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiExpression.class);
|
||||
return expr instanceof PsiLiteralExpression ? expr : null;
|
||||
}
|
||||
|
||||
public void testFromExpression() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
|
||||
type("expr");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testRanges() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
|
||||
type("expr");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testFromParenthesis() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
|
||||
type("expr");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testCast() throws Exception {
|
||||
doTestTypeChange("Integer");
|
||||
}
|
||||
|
||||
public void testCastToObject() throws Exception {
|
||||
doTestTypeChange("Object");
|
||||
}
|
||||
|
||||
public void testEscapePosition() {
|
||||
doTestStopEditing(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer introducer) {
|
||||
invokeEditorAction(IdeActions.ACTION_EDITOR_ESCAPE);
|
||||
invokeEditorAction(IdeActions.ACTION_EDITOR_ESCAPE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testEscapePositionIfTyped() {
|
||||
doTestStopEditing(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer introducer) {
|
||||
type("fooBar");
|
||||
invokeEditorAction(IdeActions.ACTION_EDITOR_ESCAPE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testWritable() throws Exception {
|
||||
doTestReplaceChoice(OccurrencesChooser.ReplaceChoice.ALL);
|
||||
}
|
||||
|
||||
public void testNoWritable() throws Exception {
|
||||
doTestReplaceChoice(OccurrencesChooser.ReplaceChoice.NO_WRITE);
|
||||
}
|
||||
|
||||
public void testAllInsertFinal() throws Exception {
|
||||
doTestReplaceChoice(OccurrencesChooser.ReplaceChoice.ALL);
|
||||
}
|
||||
|
||||
public void testAllIncomplete() throws Exception {
|
||||
doTestReplaceChoice(OccurrencesChooser.ReplaceChoice.ALL);
|
||||
}
|
||||
|
||||
public void testStopEditing() {
|
||||
doTestStopEditing(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer introducer) {
|
||||
invokeEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT);
|
||||
invokeEditorAction(IdeActions.ACTION_EDITOR_ENTER);
|
||||
invokeEditorAction(IdeActions.ACTION_EDITOR_ENTER);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doTestStopEditing(Pass<AbstractInplaceIntroducer> pass) {
|
||||
String name = getTestName(true);
|
||||
configureByFile(getBasePath() + name + getExtension());
|
||||
final boolean enabled = getEditor().getSettings().isVariableInplaceRenameEnabled();
|
||||
try {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
getEditor().getSettings().setVariableInplaceRenameEnabled(true);
|
||||
|
||||
final AbstractInplaceIntroducer introducer = invokeRefactoring();
|
||||
pass.pass(introducer);
|
||||
checkResultByFile(getBasePath() + name + "_after" + getExtension());
|
||||
}
|
||||
finally {
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
|
||||
if (state != null) {
|
||||
state.gotoEnd(true);
|
||||
}
|
||||
getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
private void doTestTypeChange(final String newType) {
|
||||
final Pass<AbstractInplaceIntroducer> typeChanger = new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
|
||||
type(newType);
|
||||
}
|
||||
};
|
||||
String name = getTestName(true);
|
||||
configureByFile(getBasePath() + name + getExtension());
|
||||
final boolean enabled = getEditor().getSettings().isVariableInplaceRenameEnabled();
|
||||
try {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
getEditor().getSettings().setVariableInplaceRenameEnabled(true);
|
||||
|
||||
final AbstractInplaceIntroducer introducer = invokeRefactoring();
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
|
||||
assert state != null;
|
||||
state.previousTab();
|
||||
typeChanger.pass(introducer);
|
||||
state.gotoEnd(false);
|
||||
checkResultByFile(getBasePath() + name + "_after" + getExtension());
|
||||
}
|
||||
finally {
|
||||
getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
private void doTestReplaceChoice(OccurrencesChooser.ReplaceChoice choice) {
|
||||
doTestReplaceChoice(choice, null);
|
||||
}
|
||||
|
||||
private void doTestReplaceChoice(OccurrencesChooser.ReplaceChoice choice, Pass<AbstractInplaceIntroducer> pass) {
|
||||
String name = getTestName(true);
|
||||
configureByFile(getBasePath() + name + getExtension());
|
||||
final boolean enabled = getEditor().getSettings().isVariableInplaceRenameEnabled();
|
||||
try {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
getEditor().getSettings().setVariableInplaceRenameEnabled(true);
|
||||
|
||||
MyIntroduceHandler handler = createIntroduceHandler();
|
||||
((MyIntroduceVariableHandler)handler).setChoice(choice);
|
||||
final AbstractInplaceIntroducer introducer = invokeRefactoring(handler);
|
||||
if (pass != null) {
|
||||
pass.pass(introducer);
|
||||
}
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
|
||||
assert state != null;
|
||||
state.gotoEnd(false);
|
||||
checkResultByFile(getBasePath() + name + "_after" + getExtension());
|
||||
}
|
||||
finally {
|
||||
getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
private static void invokeEditorAction(String actionId) {
|
||||
EditorActionManager.getInstance().getActionHandler(actionId)
|
||||
.execute(getEditor(), getEditor().getCaretModel().getCurrentCaret(), new MapDataContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/refactoring/inplaceIntroduceVariable/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MyIntroduceHandler createIntroduceHandler() {
|
||||
return new MyIntroduceVariableHandler();
|
||||
}
|
||||
|
||||
public static class MyIntroduceVariableHandler extends IntroduceVariableHandler implements MyIntroduceHandler {
|
||||
private OccurrencesChooser.ReplaceChoice myChoice = null;
|
||||
|
||||
public void setChoice(OccurrencesChooser.ReplaceChoice choice) {
|
||||
myChoice = choice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean invokeImpl(Project project, @NotNull PsiExpression selectedExpr, Editor editor) {
|
||||
return super.invokeImpl(project, selectedExpr, editor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean invokeImpl(Project project, PsiLocalVariable localVariable, Editor editor) {
|
||||
return super.invokeImpl(project, localVariable, editor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OccurrencesChooser.ReplaceChoice getOccurrencesChoice() {
|
||||
return myChoice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInplaceAvailableInTestMode() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-9
@@ -1131,18 +1131,23 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
public void visitLiteralExpression(final PsiLiteralExpression const1) {
|
||||
final PsiLiteralExpression const2 = (PsiLiteralExpression)myMatchingVisitor.getElement();
|
||||
|
||||
MatchingHandler handler = (MatchingHandler)const1.getUserData(CompiledPattern.HANDLER_KEY);
|
||||
|
||||
final MatchingHandler handler = (MatchingHandler)const1.getUserData(CompiledPattern.HANDLER_KEY);
|
||||
if (handler instanceof SubstitutionHandler) {
|
||||
int offset = 0;
|
||||
int length = const2.getTextLength();
|
||||
final String text = const2.getText();
|
||||
final PsiType type1 = const1.getType();
|
||||
if (type1 != null && !type1.equals(const2.getType())) {
|
||||
myMatchingVisitor.setResult(false);
|
||||
}
|
||||
else {
|
||||
int offset = 0;
|
||||
int length = const2.getTextLength();
|
||||
final String text = const2.getText();
|
||||
|
||||
if (length > 2 && text.charAt(0) == '"' && text.charAt(length - 1) == '"') {
|
||||
length--;
|
||||
offset++;
|
||||
if (length > 2 && text.charAt(0) == '"' && text.charAt(length - 1) == '"') {
|
||||
length--;
|
||||
offset++;
|
||||
}
|
||||
myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(const2, offset, length, myMatchingVisitor.getMatchContext()));
|
||||
}
|
||||
myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(const2, offset, length, myMatchingVisitor.getMatchContext()));
|
||||
}
|
||||
else if (handler != null) {
|
||||
myMatchingVisitor.setResult(handler.match(const1, const2, myMatchingVisitor.getMatchContext()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,6 +28,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
@@ -36,7 +37,7 @@ import java.util.concurrent.Executor;
|
||||
*/
|
||||
@ChannelHandler.Sharable
|
||||
final class ProtobufClientMessageHandler<T extends ProtobufResponseHandler> extends SimpleChannelInboundHandler<MessageLite> {
|
||||
private final ConcurrentHashMap<UUID, RequestFuture<T>> myHandlers = new ConcurrentHashMap<UUID, RequestFuture<T>>(16, 0.75f, 1);
|
||||
private final ConcurrentMap<UUID, RequestFuture<T>> myHandlers = new ConcurrentHashMap<UUID, RequestFuture<T>>(16, 0.75f, 1);
|
||||
@NotNull
|
||||
private final UUIDGetter myUuidGetter;
|
||||
private final SimpleProtobufClient myClient;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,6 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutor;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.io.MappingFailedException;
|
||||
@@ -1230,7 +1229,7 @@ public class IncProjectBuilder {
|
||||
private static CompileContext createContextWrapper(final CompileContext delegate) {
|
||||
final ClassLoader loader = delegate.getClass().getClassLoader();
|
||||
final UserDataHolderBase localDataHolder = new UserDataHolderBase();
|
||||
final Set<Object> deletedKeysSet = new ConcurrentHashSet<Object>();
|
||||
final Set<Object> deletedKeysSet = ContainerUtil.newConcurrentSet();
|
||||
final Class<UserDataHolder> dataHolderInterface = UserDataHolder.class;
|
||||
final Class<MessageHandler> messageHandlerInterface = MessageHandler.class;
|
||||
return (CompileContext)Proxy.newProxyInstance(loader, new Class[]{CompileContext.class}, new InvocationHandler() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,13 +20,14 @@ import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsServiceManagerImpl extends JpsServiceManager {
|
||||
private final ConcurrentHashMap<Class, Object> myServices = new ConcurrentHashMap<Class, Object>(16, 0.75f, 1);
|
||||
private final ConcurrentHashMap<Class, List<?>> myExtensions = new ConcurrentHashMap<Class, List<?>>(16, 0.75f, 1);
|
||||
private final ConcurrentMap<Class, Object> myServices = new ConcurrentHashMap<Class, Object>(16, 0.75f, 1);
|
||||
private final ConcurrentMap<Class, List<?>> myExtensions = new ConcurrentHashMap<Class, List<?>>(16, 0.75f, 1);
|
||||
|
||||
@Override
|
||||
public <T> T getService(Class<T> serviceClass) {
|
||||
|
||||
+3
-4
@@ -29,7 +29,6 @@ import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.concurrency.AtomicFieldUpdater;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.Topic;
|
||||
@@ -53,8 +52,8 @@ import java.util.List;
|
||||
public class SeverityRegistrar implements JDOMExternalizable, Comparator<HighlightSeverity> {
|
||||
@NonNls private static final String INFO_TAG = "info";
|
||||
@NonNls private static final String COLOR_ATTRIBUTE = "color";
|
||||
private final Map<String, SeverityBasedTextAttributes> myMap = new ConcurrentHashMap<String, SeverityBasedTextAttributes>();
|
||||
private final Map<String, Color> myRendererColors = new ConcurrentHashMap<String, Color>();
|
||||
private final Map<String, SeverityBasedTextAttributes> myMap = ContainerUtil.newConcurrentMap();
|
||||
private final Map<String, Color> myRendererColors = ContainerUtil.newConcurrentMap();
|
||||
public static final Topic<Runnable> SEVERITIES_CHANGED_TOPIC =
|
||||
Topic.create("SEVERITIES_CHANGED_TOPIC", Runnable.class, Topic.BroadcastDirection.TO_PARENT);
|
||||
@NotNull private final MessageBus myMessageBus;
|
||||
@@ -62,7 +61,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
private volatile OrderMap myOrderMap;
|
||||
private JDOMExternalizableStringList myReadOrder;
|
||||
|
||||
private static final Map<String, HighlightInfoType> STANDARD_SEVERITIES = new ConcurrentHashMap<String, HighlightInfoType>();
|
||||
private static final Map<String, HighlightInfoType> STANDARD_SEVERITIES = ContainerUtil.newConcurrentMap();
|
||||
|
||||
public SeverityRegistrar(@NotNull MessageBus messageBus) {
|
||||
myMessageBus = messageBus;
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
*/
|
||||
public final class TextAttributesKey implements Comparable<TextAttributesKey> {
|
||||
private static final TextAttributes NULL_ATTRIBUTES = new TextAttributes();
|
||||
private static final ConcurrentMap<String, TextAttributesKey> ourRegistry = new ConcurrentHashMap<String, TextAttributesKey>();
|
||||
private static final ConcurrentMap<String, TextAttributesKey> ourRegistry = ContainerUtil.newConcurrentMap();
|
||||
private static final NullableLazyValue<TextAttributeKeyDefaultsProvider> ourDefaultsProvider = new VolatileNullableLazyValue<TextAttributeKeyDefaultsProvider>() {
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.KeyedLazyInstance;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -40,7 +39,7 @@ public class KeyedExtensionCollector<T, KeyT> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.KeyedExtensionCollector");
|
||||
|
||||
private final Map<String, List<T>> myExplicitExtensions = new THashMap<String, List<T>>();
|
||||
private final ConcurrentMap<String, List<T>> myCache = new ConcurrentHashMap<String, List<T>>();
|
||||
private final ConcurrentMap<String, List<T>> myCache = ContainerUtil.newConcurrentMap();
|
||||
|
||||
@NonNls private final String lock;
|
||||
|
||||
|
||||
@@ -22,9 +22,11 @@ import com.intellij.openapi.util.NotNullLazyKey;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.util.UserDataHolderEx;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
@@ -120,12 +122,22 @@ public abstract class CachedValuesManager {
|
||||
* Create a cached value with the given provider and non-tracked return value, store it in PSI element's user data. If it's already stored, reuse it.
|
||||
* @return The cached value
|
||||
*/
|
||||
public static <T> T getCachedValue(@NotNull PsiElement psi, @NotNull CachedValueProvider<T> provider) {
|
||||
public static <T> T getCachedValue(@NotNull final PsiElement psi, @NotNull final CachedValueProvider<T> provider) {
|
||||
CachedValuesManager manager = getManager(psi.getProject());
|
||||
return manager.getCachedValue(psi, manager.<T>getKeyForClass(provider.getClass()), provider, false);
|
||||
return manager.getCachedValue(psi, manager.<T>getKeyForClass(provider.getClass()), new CachedValueProvider<T>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Result<T> compute() {
|
||||
Result<T> result = provider.compute();
|
||||
if (result != null && !psi.isPhysical()) {
|
||||
return Result.create(result.getValue(), ArrayUtil.append(result.getDependencyItems(), psi));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
private final ConcurrentMap<String, Key<CachedValue>> keyForProvider = new ConcurrentHashMap<String, Key<CachedValue>>();
|
||||
private final ConcurrentMap<String, Key<CachedValue>> keyForProvider = ContainerUtil.newConcurrentMap();
|
||||
@NotNull
|
||||
public <T> Key<CachedValue<T>> getKeyForClass(@NotNull Class<?> providerClass) {
|
||||
String name = providerClass.getName();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
*/
|
||||
public class SingletonInstancesCache {
|
||||
|
||||
private static final ConcurrentMap<String, Object> CACHE = new ConcurrentHashMap<String, Object>();
|
||||
private static final ConcurrentMap<String, Object> CACHE = ContainerUtil.newConcurrentMap();
|
||||
|
||||
private SingletonInstancesCache() {
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusFactory;
|
||||
import com.intellij.util.pico.IdeaPicoContainer;
|
||||
@@ -46,7 +46,7 @@ public class MockComponentManager extends UserDataHolderBase implements Componen
|
||||
|
||||
public MockComponentManager(@Nullable PicoContainer parent, @NotNull Disposable parentDisposable) {
|
||||
myPicoContainer = new IdeaPicoContainer(parent) {
|
||||
private final Set<Object> myDisposableComponents = new ConcurrentHashSet<Object>();
|
||||
private final Set<Object> myDisposableComponents = ContainerUtil.newConcurrentSet();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
||||
+6
-3
@@ -21,7 +21,10 @@ import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.components.ex.ComponentManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.openapi.progress.*;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -29,7 +32,7 @@ import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusFactory;
|
||||
import com.intellij.util.pico.ConstructorInjectionComponentAdapter;
|
||||
@@ -53,7 +56,7 @@ import java.util.Map;
|
||||
public abstract class ComponentManagerImpl extends UserDataHolderBase implements ComponentManagerEx, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.components.ComponentManager");
|
||||
|
||||
private final Map<Class, Object> myInitializedComponents = new ConcurrentHashMap<Class, Object>();
|
||||
private final Map<Class, Object> myInitializedComponents = ContainerUtil.newConcurrentMap();
|
||||
|
||||
private boolean myComponentsCreated = false;
|
||||
|
||||
|
||||
+4
-2
@@ -23,12 +23,14 @@ import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.DoubleArrayList;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class AbstractProgressIndicatorBase extends UserDataHolderBase implements ProgressIndicatorStacked {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.util.ProgressIndicatorBase");
|
||||
|
||||
@@ -69,7 +71,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements
|
||||
myRunning = true;
|
||||
}
|
||||
|
||||
private static final ConcurrentHashSet<Class> ourReportedReuseExceptions = new ConcurrentHashSet<Class>(2);
|
||||
private static final Set<Class> ourReportedReuseExceptions = ContainerUtil.newConcurrentSet();
|
||||
|
||||
protected boolean isReuseable() {
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import com.intellij.psi.impl.source.tree.FileElement;
|
||||
import com.intellij.psi.templateLanguages.OuterLanguageElement;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
@@ -39,7 +39,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public abstract class MultiplePsiFilesPerDocumentFileViewProvider extends SingleRootFileViewProvider {
|
||||
private final ConcurrentMap<Language, PsiFile> myRoots = new ConcurrentHashMap<Language, PsiFile>(1, ConcurrentHashMap.DEFAULT_LOAD_FACTOR, 1);
|
||||
private final ConcurrentMap<Language, PsiFile> myRoots = ContainerUtil.newConcurrentMap(1, 0.75f, 1);
|
||||
private MultiplePsiFilesPerDocumentFileViewProvider myOriginal = null;
|
||||
|
||||
public MultiplePsiFilesPerDocumentFileViewProvider(PsiManager manager, VirtualFile virtualFile, boolean eventSystemEnabled) {
|
||||
|
||||
@@ -47,7 +47,6 @@ import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -67,7 +66,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
protected final Project myProject;
|
||||
private final PsiManager myPsiManager;
|
||||
private final DocumentCommitProcessor myDocumentCommitProcessor;
|
||||
protected final Set<Document> myUncommittedDocuments = new ConcurrentHashSet<Document>();
|
||||
protected final Set<Document> myUncommittedDocuments = ContainerUtil.newConcurrentSet();
|
||||
private final Map<Document, CharSequence> myLastCommittedTexts = ContainerUtil.newConcurrentMap();
|
||||
|
||||
private volatile boolean myIsCommitInProgress;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolderEx;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class DocumentMarkupModel {
|
||||
private static ConcurrentMap<Project, MarkupModelImpl> getMarkupModelMap(@NotNull Document document) {
|
||||
ConcurrentMap<Project, MarkupModelImpl> markupModelMap = document.getUserData(MARKUP_MODEL_MAP_KEY);
|
||||
if (markupModelMap == null) {
|
||||
ConcurrentMap<Project, MarkupModelImpl> newMap = new ConcurrentHashMap<Project, MarkupModelImpl>();
|
||||
ConcurrentMap<Project, MarkupModelImpl> newMap = ContainerUtil.newConcurrentMap();
|
||||
markupModelMap = ((UserDataHolderEx)document).putUserDataIfAbsent(MARKUP_MODEL_MAP_KEY, newMap);
|
||||
}
|
||||
return markupModelMap;
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
package com.intellij.openapi.extensions.impl;
|
||||
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.pico.ConstructorInjectionComponentAdapter;
|
||||
import gnu.trove.THashMap;
|
||||
@@ -46,7 +46,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
|
||||
private final AreaPicoContainerImpl myPicoContainer;
|
||||
private final Throwable myCreationTrace;
|
||||
private final Map<String,ExtensionPointImpl> myExtensionPoints = new ConcurrentHashMap<String, ExtensionPointImpl>();
|
||||
private final Map<String, ExtensionPointImpl> myExtensionPoints = ContainerUtil.newConcurrentMap();
|
||||
private final Map<String,Throwable> myEPTraces = DEBUG_REGISTRATION ? new THashMap<String, Throwable>():null;
|
||||
private final MultiMap<String, ExtensionPointAvailabilityListener> myAvailabilityListeners = new MultiMap<String, ExtensionPointAvailabilityListener>();
|
||||
private final List<Runnable> mySuspendedListenerActions = new ArrayList<Runnable>();
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import com.intellij.openapi.externalSystem.model.internal.InternalExternalProjec
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ExternalProjectsDataStorage implements SettingsSavingComponent {
|
||||
private final Project myProject;
|
||||
@NotNull
|
||||
private final Map<Pair<ProjectSystemId, String>, InternalExternalProjectInfo> myExternalRootProjects =
|
||||
new ConcurrentHashMap<Pair<ProjectSystemId, String>, InternalExternalProjectInfo>();
|
||||
ContainerUtil.newConcurrentMap();
|
||||
|
||||
public static ExternalProjectsDataStorage getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, ExternalProjectsDataStorage.class);
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,11 +17,11 @@ package com.intellij.openapi.externalSystem.service.remote;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
|
||||
import com.intellij.openapi.externalSystem.service.RemoteExternalSystemService;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
import com.intellij.util.Producer;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -41,7 +41,7 @@ public abstract class AbstractRemoteExternalSystemService<S extends ExternalSyst
|
||||
{
|
||||
|
||||
private final ConcurrentMap<ExternalSystemTaskType, Set<ExternalSystemTaskId>> myTasksInProgress =
|
||||
new ConcurrentHashMap<ExternalSystemTaskType, Set<ExternalSystemTaskId>>();
|
||||
ContainerUtil.newConcurrentMap();
|
||||
|
||||
private final AtomicReference<S> mySettings = new AtomicReference<S>();
|
||||
|
||||
|
||||
+22
-8
@@ -1,13 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.externalSystem.service.remote;
|
||||
|
||||
import com.intellij.execution.rmi.RemoteObject;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent;
|
||||
import com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
import com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Collections;
|
||||
@@ -25,7 +39,7 @@ public class ExternalSystemProgressNotificationManagerImpl extends RemoteObject
|
||||
|
||||
private final ConcurrentMap<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>/* EMPTY_SET as a sign of 'all ids' */>
|
||||
myListeners
|
||||
= new ConcurrentHashMap<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>>();
|
||||
= ContainerUtil.newConcurrentMap();
|
||||
|
||||
@Override
|
||||
public boolean addNotificationListener(@NotNull ExternalSystemTaskNotificationListener listener) {
|
||||
@@ -41,7 +55,7 @@ public class ExternalSystemProgressNotificationManagerImpl extends RemoteObject
|
||||
ids = myListeners.get(listener);
|
||||
}
|
||||
else {
|
||||
ids = myListeners.putIfAbsent(listener, new ConcurrentHashSet<ExternalSystemTaskId>());
|
||||
ids = myListeners.putIfAbsent(listener, ContainerUtil.<ExternalSystemTaskId>newConcurrentSet());
|
||||
}
|
||||
}
|
||||
return ids.add(taskId);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.SdkResolveScopeProvider;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -41,8 +41,9 @@ public class LibraryScopeCache {
|
||||
}
|
||||
|
||||
private final Project myProject;
|
||||
private final ConcurrentMap<List<Module>, GlobalSearchScope> myLibraryScopes = new ConcurrentHashMap<List<Module>, GlobalSearchScope>();
|
||||
private final ConcurrentMap<String, GlobalSearchScope> mySdkScopes = new ConcurrentHashMap<String, GlobalSearchScope>();
|
||||
private final ConcurrentMap<List<Module>, GlobalSearchScope> myLibraryScopes =
|
||||
ContainerUtil.newConcurrentMap();
|
||||
private final ConcurrentMap<String, GlobalSearchScope> mySdkScopes = ContainerUtil.newConcurrentMap();
|
||||
|
||||
public LibraryScopeCache(Project project) {
|
||||
myProject = project;
|
||||
|
||||
+3
-4
@@ -64,7 +64,6 @@ import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
@@ -82,6 +81,7 @@ import java.beans.PropertyChangeListener;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -127,9 +127,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
private volatile int myCount;
|
||||
private volatile boolean myHasPsiElements;
|
||||
private boolean myLookupUpdated;
|
||||
private final ConcurrentHashMap<LookupElement, CompletionSorterImpl> myItemSorters =
|
||||
new ConcurrentHashMap<LookupElement, CompletionSorterImpl>(
|
||||
ContainerUtil.<LookupElement>identityStrategy());
|
||||
private final ConcurrentMap<LookupElement, CompletionSorterImpl> myItemSorters =
|
||||
ContainerUtil.newConcurrentMap(ContainerUtil.<LookupElement>identityStrategy());
|
||||
private final PropertyChangeListener myLookupManagerListener;
|
||||
private final Queue<Runnable> myAdvertiserChanges = new ConcurrentLinkedQueue<Runnable>();
|
||||
private final int myStartCaret;
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -85,7 +85,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
private final int myEndOffset;
|
||||
private final TextRange myPriorityRange;
|
||||
private final boolean myIgnoreSuppressed;
|
||||
private final ConcurrentMap<PsiFile, List<InspectionResult>> result = new ConcurrentHashMap<PsiFile, List<InspectionResult>>();
|
||||
private final ConcurrentMap<PsiFile, List<InspectionResult>> result = ContainerUtil.newConcurrentMap();
|
||||
private static final String PRESENTABLE_NAME = DaemonBundle.message("pass.inspection");
|
||||
private volatile List<HighlightInfo> myInfos = Collections.emptyList();
|
||||
private final String myShortcutText;
|
||||
|
||||
+1
-1
@@ -554,7 +554,7 @@ public class PassExecutorService implements Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
private static final ConcurrentHashMap<Thread, Integer> threads = new ConcurrentHashMap<Thread, Integer>();
|
||||
private static final ConcurrentMap<Thread, Integer> threads = new ConcurrentHashMap<Thread, Integer>();
|
||||
private static int getThreadNum() {
|
||||
return ConcurrencyUtil.cacheOrGet(threads, Thread.currentThread(), threads.size());
|
||||
}
|
||||
|
||||
+8
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,7 @@ import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -54,10 +54,12 @@ import java.util.*;
|
||||
class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>, SpeedSearchFilter<IntentionActionWithTextCaching> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.IntentionListStep");
|
||||
|
||||
private final Set<IntentionActionWithTextCaching> myCachedIntentions = new ConcurrentHashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
|
||||
private final Set<IntentionActionWithTextCaching> myCachedErrorFixes = new ConcurrentHashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
|
||||
private final Set<IntentionActionWithTextCaching> myCachedInspectionFixes = new ConcurrentHashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
|
||||
private final Set<IntentionActionWithTextCaching> myCachedGutters = new ConcurrentHashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
|
||||
private final Set<IntentionActionWithTextCaching> myCachedIntentions =
|
||||
ContainerUtil.newConcurrentSet(ACTION_TEXT_AND_CLASS_EQUALS);
|
||||
private final Set<IntentionActionWithTextCaching> myCachedErrorFixes =
|
||||
ContainerUtil.newConcurrentSet(ACTION_TEXT_AND_CLASS_EQUALS);
|
||||
private final Set<IntentionActionWithTextCaching> myCachedInspectionFixes = ContainerUtil.newConcurrentSet(ACTION_TEXT_AND_CLASS_EQUALS);
|
||||
private final Set<IntentionActionWithTextCaching> myCachedGutters = ContainerUtil.newConcurrentSet(ACTION_TEXT_AND_CLASS_EQUALS);
|
||||
private final IntentionManagerSettings mySettings;
|
||||
@Nullable
|
||||
private final IntentionHintComponent myIntentionHintComponent;
|
||||
|
||||
@@ -52,7 +52,6 @@ import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.popup.AbstractPopup;
|
||||
import com.intellij.util.CollectConsumer;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentWeakHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
@@ -118,8 +117,8 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable,
|
||||
private boolean myChangeGuard;
|
||||
private volatile LookupArranger myArranger;
|
||||
private LookupArranger myPresentableArranger;
|
||||
private final Map<LookupElement, PrefixMatcher> myMatchers = new ConcurrentHashMap<LookupElement, PrefixMatcher>(
|
||||
ContainerUtil.<LookupElement>identityStrategy());
|
||||
private final Map<LookupElement, PrefixMatcher> myMatchers =
|
||||
ContainerUtil.newConcurrentMap(ContainerUtil.<LookupElement>identityStrategy());
|
||||
private final Map<LookupElement, Font> myCustomFonts = new ConcurrentWeakHashMap<LookupElement, Font>(
|
||||
ContainerUtil.<LookupElement>identityStrategy());
|
||||
private boolean myStartCompletionWhenNothingMatches;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.ParameterizedCachedValue;
|
||||
import com.intellij.psi.util.ParameterizedCachedValueProvider;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xmlb.annotations.MapAnnotation;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import org.jdom.Element;
|
||||
@@ -42,6 +42,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -59,7 +60,8 @@ public class ProjectFacetManagerImpl extends ProjectFacetManagerEx implements Pe
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ProjectFacetManagerImpl");
|
||||
private ProjectFacetManagerState myState = new ProjectFacetManagerState();
|
||||
private final Project myProject;
|
||||
private final ConcurrentHashMap<FacetTypeId<?>, ParameterizedCachedValue<Boolean,FacetTypeId<?>>> myCachedHasFacets = new ConcurrentHashMap<FacetTypeId<?>, ParameterizedCachedValue<Boolean, FacetTypeId<?>>>();
|
||||
private final ConcurrentMap<FacetTypeId<?>, ParameterizedCachedValue<Boolean, FacetTypeId<?>>> myCachedHasFacets =
|
||||
ContainerUtil.newConcurrentMap();
|
||||
private final ParameterizedCachedValueProvider<Boolean,FacetTypeId<?>> myCachedValueProvider;
|
||||
|
||||
public ProjectFacetManagerImpl(Project project) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,8 +27,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.SequentialModalProgressTask;
|
||||
import com.intellij.util.SequentialTask;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -69,7 +68,7 @@ public class FormattingProgressTask extends SequentialModalProgressTask implemen
|
||||
TOTAL_WEIGHT = weight;
|
||||
}
|
||||
|
||||
private final ConcurrentMap<EventType, Collection<Runnable>> myCallbacks = new ConcurrentHashMap<EventType, Collection<Runnable>>();
|
||||
private final ConcurrentMap<EventType, Collection<Runnable>> myCallbacks = ContainerUtil.newConcurrentMap();
|
||||
|
||||
private final WeakReference<VirtualFile> myFile;
|
||||
private final WeakReference<Document> myDocument;
|
||||
@@ -139,7 +138,7 @@ public class FormattingProgressTask extends SequentialModalProgressTask implemen
|
||||
private Collection<Runnable> getCallbacks(@NotNull EventType eventType) {
|
||||
Collection<Runnable> result = myCallbacks.get(eventType);
|
||||
if (result == null) {
|
||||
Collection<Runnable> candidate = myCallbacks.putIfAbsent(eventType, result = new ConcurrentHashSet<Runnable>());
|
||||
Collection<Runnable> candidate = myCallbacks.putIfAbsent(eventType, result = ContainerUtil.newConcurrentSet());
|
||||
if (candidate != null) {
|
||||
result = candidate;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.indexing.FindSymbolParameters;
|
||||
import com.intellij.util.indexing.IdFilter;
|
||||
@@ -49,6 +48,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Contributor-based goto model
|
||||
@@ -85,7 +85,7 @@ public abstract class ContributorsBasedGotoByModel implements ChooseByNameModelE
|
||||
return !ChooseByNameBase.ourLoadNamesEachTime;
|
||||
}
|
||||
|
||||
private final ConcurrentHashMap<ChooseByNameContributor, TIntHashSet> myContributorToItsSymbolsMap = new ConcurrentHashMap<ChooseByNameContributor, TIntHashSet>();
|
||||
private final ConcurrentMap<ChooseByNameContributor, TIntHashSet> myContributorToItsSymbolsMap = ContainerUtil.newConcurrentMap();
|
||||
private volatile IdFilter myIdFilter;
|
||||
private volatile boolean myIdFilterForLibraries;
|
||||
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree.injected;
|
||||
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.Map;
|
||||
public class ClassMapCachingNulls<T> {
|
||||
private final Map<Class, T[]> myBackingMap;
|
||||
private final T[] myEmptyArray;
|
||||
private final Map<Class, T[]> myMap = new ConcurrentHashMap<Class, T[]>();
|
||||
private final Map<Class, T[]> myMap = ContainerUtil.newConcurrentMap();
|
||||
|
||||
public ClassMapCachingNulls(@NotNull Map<Class, T[]> backingMap, T[] emptyArray) {
|
||||
myBackingMap = backingMap;
|
||||
|
||||
+28
-22
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -473,10 +473,8 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
final RangeMarker exprMarker = getExprMarker();
|
||||
if (exprMarker != null) {
|
||||
myExpr = restoreExpression(containingFile, psiField, exprMarker, myExprText);
|
||||
if (myExpr != null && myExpr.isPhysical()) {
|
||||
myExprMarker = createMarker(myExpr);
|
||||
}
|
||||
}
|
||||
|
||||
if (myLocalMarker != null) {
|
||||
final PsiElement refVariableElement = containingFile.findElementAt(myLocalMarker.getStartOffset());
|
||||
if (refVariableElement != null) {
|
||||
@@ -509,6 +507,9 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
}
|
||||
}
|
||||
|
||||
if (myExpr != null && myExpr.isPhysical()) {
|
||||
myExprMarker = createMarker(myExpr);
|
||||
}
|
||||
myOccurrenceMarkers = null;
|
||||
deleteTemplateField(psiField);
|
||||
}
|
||||
@@ -523,24 +524,7 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
|
||||
@Override
|
||||
protected boolean performRefactoring() {
|
||||
final String newName = getInputName();
|
||||
if (getLocalVariable() == null && myExpr == null ||
|
||||
newName == null ||
|
||||
getLocalVariable() != null && !getLocalVariable().isValid() ||
|
||||
myExpr != null && !myExpr.isValid()) {
|
||||
super.moveOffsetAfter(false);
|
||||
return false;
|
||||
}
|
||||
if (getLocalVariable() != null) {
|
||||
new WriteCommandAction(myProject, getCommandName(), getCommandName()) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
getLocalVariable().setName(myLocalName);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
if (!isIdentifier(newName, myExpr != null ? myExpr.getLanguage() : getLocalVariable().getLanguage())) return false;
|
||||
if (!ensureValid()) return false;
|
||||
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -562,6 +546,28 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean ensureValid() {
|
||||
final String newName = getInputName();
|
||||
if (getLocalVariable() == null && myExpr == null ||
|
||||
newName == null ||
|
||||
getLocalVariable() != null && !getLocalVariable().isValid() ||
|
||||
myExpr != null && !myExpr.isValid()) {
|
||||
super.moveOffsetAfter(false);
|
||||
return false;
|
||||
}
|
||||
if (getLocalVariable() != null) {
|
||||
new WriteCommandAction(myProject, getCommandName(), getCommandName()) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
getLocalVariable().setName(myLocalName);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
if (!isIdentifier(newName, myExpr != null ? myExpr.getLanguage() : getLocalVariable().getLanguage())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void moveOffsetAfter(boolean success) {
|
||||
if (getLocalVariable() != null && getLocalVariable().isValid()) {
|
||||
|
||||
+8
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -639,6 +639,11 @@ public abstract class InplaceRefactoring {
|
||||
|
||||
protected abstract boolean performRefactoring();
|
||||
|
||||
/**
|
||||
* if brokenOff but not canceled
|
||||
*/
|
||||
protected void performCleanup() {}
|
||||
|
||||
private void addVariable(final PsiReference reference,
|
||||
final PsiElement selectedElement,
|
||||
final TemplateBuilderImpl builder,
|
||||
@@ -847,6 +852,8 @@ public abstract class InplaceRefactoring {
|
||||
super.templateFinished(template, brokenOff);
|
||||
if (!brokenOff) {
|
||||
bind = performRefactoring();
|
||||
} else {
|
||||
performCleanup();
|
||||
}
|
||||
moveOffsetAfter(!brokenOff);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.stubs.SerializationManagerEx;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.*;
|
||||
import com.intellij.util.io.DataOutputStream;
|
||||
@@ -129,7 +128,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
private final FileDocumentManager myFileDocumentManager;
|
||||
private final FileTypeManagerImpl myFileTypeManager;
|
||||
private final SerializationManagerEx mySerializationManagerEx;
|
||||
private final ConcurrentHashSet<ID<?, ?>> myUpToDateIndicesForUnsavedOrTransactedDocuments = new ConcurrentHashSet<ID<?, ?>>();
|
||||
private final Set<ID<?, ?>> myUpToDateIndicesForUnsavedOrTransactedDocuments = ContainerUtil.newConcurrentSet();
|
||||
private volatile SmartFMap<Document, PsiFile> myTransactionMap = SmartFMap.emptyMap();
|
||||
|
||||
@Nullable private final String myConfigPath;
|
||||
@@ -139,7 +138,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
private volatile int myLocalModCount;
|
||||
private volatile int myFilesModCount;
|
||||
private final AtomicInteger myUpdatingFiles = new AtomicInteger();
|
||||
private final ConcurrentHashSet<Project> myProjectsBeingUpdated = new ConcurrentHashSet<Project>();
|
||||
private final Set<Project> myProjectsBeingUpdated = ContainerUtil.newConcurrentSet();
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) private volatile boolean myInitialized;
|
||||
// need this variable for memory barrier
|
||||
@@ -1874,7 +1873,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
}
|
||||
|
||||
private final class ChangedFilesCollector extends VirtualFileAdapter implements BulkFileListener {
|
||||
private final Set<VirtualFile> myFilesToUpdate = new ConcurrentHashSet<VirtualFile>();
|
||||
private final Set<VirtualFile> myFilesToUpdate = ContainerUtil.newConcurrentSet();
|
||||
private final Queue<InvalidationTask> myFutureInvalidations = new ConcurrentLinkedQueue<InvalidationTask>();
|
||||
|
||||
private final ManagingFS myManagingFS = ManagingFS.getInstance();
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.openapi.vfs.newvfs.FileAttribute;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.FSRecords;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentIntObjectMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
@@ -40,6 +39,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -62,7 +62,7 @@ public class IndexingStamp {
|
||||
private static final long INDEX_DATA_OUTDATED_STAMP = -2L;
|
||||
|
||||
private static final int VERSION = 13;
|
||||
private static final ConcurrentHashMap<ID<?, ?>, Long> ourIndexIdToCreationStamp = new ConcurrentHashMap<ID<?, ?>, Long>();
|
||||
private static final ConcurrentMap<ID<?, ?>, Long> ourIndexIdToCreationStamp = ContainerUtil.newConcurrentMap();
|
||||
static final int INVALID_FILE_ID = 0;
|
||||
private static volatile long ourLastStamp; // ensure any file index stamp increases
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ public interface IdeActions {
|
||||
@NonNls String ACTION_EDITOR_SPLIT = "EditorSplitLine";
|
||||
@NonNls String ACTION_EDITOR_MOVE_LINE_START = "EditorLineStart";
|
||||
@NonNls String ACTION_EDITOR_MOVE_LINE_END = "EditorLineEnd";
|
||||
@NonNls String ACTION_EDITOR_MOVE_LINE_START_WITH_SELECTION = "EditorLineStartWithSelection";
|
||||
@NonNls String ACTION_EDITOR_MOVE_LINE_END_WITH_SELECTION = "EditorLineEndWithSelection";
|
||||
@NonNls String ACTION_EDITOR_SELECT_WORD_AT_CARET = "EditorSelectWord";
|
||||
@NonNls String ACTION_EDITOR_UNSELECT_WORD_AT_CARET = "EditorUnSelectWord";
|
||||
@NonNls String ACTION_EDITOR_BACKSPACE = "EditorBackSpace";
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileListener;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -33,7 +33,8 @@ import java.util.Map;
|
||||
* @author max
|
||||
*/
|
||||
public abstract class NewVirtualFileSystem extends VirtualFileSystem implements FileSystemInterface, CachingVirtualFileSystem {
|
||||
private final Map<VirtualFileListener, VirtualFileListener> myListenerWrappers = new ConcurrentHashMap<VirtualFileListener, VirtualFileListener>();
|
||||
private final Map<VirtualFileListener, VirtualFileListener> myListenerWrappers =
|
||||
ContainerUtil.newConcurrentMap();
|
||||
|
||||
@Nullable
|
||||
public abstract VirtualFile findFileByPathIfCached(@NotNull @NonNls final String path);
|
||||
|
||||
+8
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
@@ -22,6 +23,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorLastActionTracker;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.keymap.impl.ModifierKeyDoubleClickHandler;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -38,7 +40,9 @@ public class CloneCaretActionHandler extends EditorActionHandler {
|
||||
IdeActions.ACTION_EDITOR_CLONE_CARET_ABOVE,
|
||||
IdeActions.ACTION_EDITOR_CLONE_CARET_BELOW,
|
||||
IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT_WITH_SELECTION,
|
||||
IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT_WITH_SELECTION
|
||||
IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT_WITH_SELECTION,
|
||||
IdeActions.ACTION_EDITOR_MOVE_LINE_START_WITH_SELECTION,
|
||||
IdeActions.ACTION_EDITOR_MOVE_LINE_END_WITH_SELECTION
|
||||
));
|
||||
|
||||
private final boolean myCloneAbove;
|
||||
@@ -54,6 +58,9 @@ public class CloneCaretActionHandler extends EditorActionHandler {
|
||||
|
||||
@Override
|
||||
protected void doExecute(Editor editor, @Nullable Caret targetCaret, DataContext dataContext) {
|
||||
if (ModifierKeyDoubleClickHandler.getInstance().isRunningAction() && !isRepeatedActionInvocation()) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.add.carets.using.double.ctrl");
|
||||
}
|
||||
if (targetCaret != null) {
|
||||
targetCaret.clone(myCloneAbove);
|
||||
return;
|
||||
|
||||
+1
-1
@@ -207,12 +207,12 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
int firstVisibleOffset = myEditor.logicalPositionToOffset(myEditor.xyToLogicalPosition(new Point(0, clip.y - myEditor.getLineHeight())));
|
||||
int lastVisibleOffset = myEditor.logicalPositionToOffset(myEditor.xyToLogicalPosition(new Point(0, clip.y + clip.height + myEditor.getLineHeight())));
|
||||
paintFoldingBackground(g, clip);
|
||||
paintFoldingLines((Graphics2D)g, clip);
|
||||
paintLineMarkersBackground(g, clip);
|
||||
paintBackground(g, clip, getLineMarkerAreaOffset(), getLineMarkerAreaWidth());
|
||||
paintEditorBackgrounds(g, clip, firstVisibleOffset, lastVisibleOffset);
|
||||
paintAnnotations(g, clip);
|
||||
paintLineMarkers(g, firstVisibleOffset, lastVisibleOffset);
|
||||
paintFoldingLines((Graphics2D)g, clip);
|
||||
paintFoldingTree(g, clip, firstVisibleOffset, lastVisibleOffset);
|
||||
paintLineNumbers(g, clip);
|
||||
}
|
||||
|
||||
+2
-2
@@ -67,8 +67,8 @@ import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.PairProcessor;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ConcurrentWeakValueHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -94,7 +94,7 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Virt
|
||||
private static final Key<VirtualFile> FILE_KEY = Key.create("FILE_KEY");
|
||||
private static final Key<Boolean> MUST_RECOMPUTE_FILE_TYPE = Key.create("Must recompute file type");
|
||||
|
||||
private final Set<Document> myUnsavedDocuments = new ConcurrentHashSet<Document>();
|
||||
private final Set<Document> myUnsavedDocuments = ContainerUtil.newConcurrentSet();
|
||||
private final Map<VirtualFile, Document> myDocuments = new ConcurrentWeakValueHashMap<VirtualFile, Document>();
|
||||
|
||||
private final MessageBus myBus;
|
||||
|
||||
@@ -92,6 +92,8 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
ModifierKeyDoubleClickHandler.getInstance().registerAction(IdeActions.ACTION_EDITOR_CLONE_CARET_BELOW, KeyEvent.VK_CONTROL, KeyEvent.VK_DOWN);
|
||||
ModifierKeyDoubleClickHandler.getInstance().registerAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT_WITH_SELECTION, KeyEvent.VK_CONTROL, KeyEvent.VK_LEFT);
|
||||
ModifierKeyDoubleClickHandler.getInstance().registerAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT_WITH_SELECTION, KeyEvent.VK_CONTROL, KeyEvent.VK_RIGHT);
|
||||
ModifierKeyDoubleClickHandler.getInstance().registerAction(IdeActions.ACTION_EDITOR_MOVE_LINE_START_WITH_SELECTION, KeyEvent.VK_CONTROL, KeyEvent.VK_HOME);
|
||||
ModifierKeyDoubleClickHandler.getInstance().registerAction(IdeActions.ACTION_EDITOR_MOVE_LINE_END_WITH_SELECTION, KeyEvent.VK_CONTROL, KeyEvent.VK_END);
|
||||
}
|
||||
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
|
||||
+34
-22
@@ -25,7 +25,7 @@ import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.util.Clock;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.TIntIntHashMap;
|
||||
import gnu.trove.TIntIntProcedure;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -45,10 +45,20 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
* SearchEverywhere behaviour remains intact.
|
||||
*/
|
||||
public class ModifierKeyDoubleClickHandler {
|
||||
private static final TIntIntHashMap KEY_CODE_TO_MODIFIER_MAP = new TIntIntHashMap();
|
||||
static {
|
||||
KEY_CODE_TO_MODIFIER_MAP.put(KeyEvent.VK_ALT, InputEvent.ALT_MASK);
|
||||
KEY_CODE_TO_MODIFIER_MAP.put(KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK);
|
||||
KEY_CODE_TO_MODIFIER_MAP.put(KeyEvent.VK_META, InputEvent.META_MASK);
|
||||
KEY_CODE_TO_MODIFIER_MAP.put(KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK);
|
||||
}
|
||||
|
||||
private static final ModifierKeyDoubleClickHandler INSTANCE = new ModifierKeyDoubleClickHandler();
|
||||
|
||||
private final ConcurrentMap<String, IdeEventQueue.EventDispatcher> myDispatchers = new ConcurrentHashMap<String, IdeEventQueue.EventDispatcher>();
|
||||
|
||||
private final ConcurrentMap<String, IdeEventQueue.EventDispatcher> myDispatchers =
|
||||
ContainerUtil.newConcurrentMap();
|
||||
private boolean myIsRunningAction;
|
||||
|
||||
private ModifierKeyDoubleClickHandler() { }
|
||||
|
||||
public static ModifierKeyDoubleClickHandler getInstance() {
|
||||
@@ -78,15 +88,11 @@ public class ModifierKeyDoubleClickHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyDispatcher implements IdeEventQueue.EventDispatcher {
|
||||
private static final TIntIntHashMap KEY_CODE_TO_MODIFIER_MAP = new TIntIntHashMap();
|
||||
static {
|
||||
KEY_CODE_TO_MODIFIER_MAP.put(KeyEvent.VK_ALT, InputEvent.ALT_MASK);
|
||||
KEY_CODE_TO_MODIFIER_MAP.put(KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK);
|
||||
KEY_CODE_TO_MODIFIER_MAP.put(KeyEvent.VK_META, InputEvent.META_MASK);
|
||||
KEY_CODE_TO_MODIFIER_MAP.put(KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK);
|
||||
}
|
||||
public boolean isRunningAction() {
|
||||
return myIsRunningAction;
|
||||
}
|
||||
|
||||
private class MyDispatcher implements IdeEventQueue.EventDispatcher {
|
||||
private final String myActionId;
|
||||
private final int myModifierKeyCode;
|
||||
private final int myActionKeyCode;
|
||||
@@ -196,17 +202,23 @@ public class ModifierKeyDoubleClickHandler {
|
||||
}
|
||||
|
||||
private void run(KeyEvent event) {
|
||||
final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
|
||||
final AnAction action = actionManager.getAction(myActionId);
|
||||
final AnActionEvent anActionEvent = new AnActionEvent(event,
|
||||
DataManager.getInstance().getDataContext(IdeFocusManager.findInstance().getFocusOwner()),
|
||||
ActionPlaces.MAIN_MENU,
|
||||
action.getTemplatePresentation(),
|
||||
actionManager,
|
||||
0);
|
||||
actionManager.fireBeforeActionPerformed(action, anActionEvent.getDataContext(), anActionEvent);
|
||||
action.actionPerformed(anActionEvent);
|
||||
actionManager.fireAfterActionPerformed(action, anActionEvent.getDataContext(), anActionEvent);
|
||||
myIsRunningAction = true;
|
||||
try {
|
||||
final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
|
||||
final AnAction action = actionManager.getAction(myActionId);
|
||||
final AnActionEvent anActionEvent = new AnActionEvent(event,
|
||||
DataManager.getInstance().getDataContext(IdeFocusManager.findInstance().getFocusOwner()),
|
||||
ActionPlaces.MAIN_MENU,
|
||||
action.getTemplatePresentation(),
|
||||
actionManager,
|
||||
0);
|
||||
actionManager.fireBeforeActionPerformed(action, anActionEvent.getDataContext(), anActionEvent);
|
||||
action.actionPerformed(anActionEvent);
|
||||
actionManager.fireAfterActionPerformed(action, anActionEvent.getDataContext(), anActionEvent);
|
||||
}
|
||||
finally {
|
||||
myIsRunningAction = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isActionBound() {
|
||||
|
||||
+1
-2
@@ -34,7 +34,6 @@ import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
|
||||
import com.intellij.psi.PsiLock;
|
||||
import com.intellij.ui.SystemNotifications;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ConcurrentLongObjectMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.SmartHashSet;
|
||||
@@ -70,7 +69,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable {
|
||||
// the active indicator for the thread id
|
||||
private static final ConcurrentLongObjectMap<ProgressIndicator> currentIndicators = ContainerUtil.createConcurrentLongObjectMap();
|
||||
// threads which are running under canceled indicator
|
||||
static final Set<Thread> threadsUnderCanceledIndicator = new ConcurrentHashSet<Thread>();
|
||||
static final Set<Thread> threadsUnderCanceledIndicator = ContainerUtil.newConcurrentSet();
|
||||
|
||||
// active (i.e. which have executeProcessUnderProgress() method running) indicators which are not inherited from StandardProgressIndicator.
|
||||
// for them an extra processing thread (see myCheckCancelledFuture) has to be run to call their non-standard checkCanceled() method
|
||||
|
||||
+2
-2
@@ -32,7 +32,6 @@ import com.intellij.openapi.vfs.pointers.VirtualFilePointerListener;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
@@ -533,7 +532,8 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
}
|
||||
|
||||
private static class DelegatingDisposable implements Disposable {
|
||||
private static final ConcurrentMap<Disposable, DelegatingDisposable> ourInstances = new ConcurrentHashMap<Disposable, DelegatingDisposable>(ContainerUtil.<Disposable>identityStrategy());
|
||||
private static final ConcurrentMap<Disposable, DelegatingDisposable> ourInstances =
|
||||
ContainerUtil.newConcurrentMap(ContainerUtil.<Disposable>identityStrategy());
|
||||
private final TObjectIntHashMap<VirtualFilePointerImpl> myCounts = new TObjectIntHashMap<VirtualFilePointerImpl>();
|
||||
private final Disposable myParent;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.VfsImplUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class JarFileSystemImpl extends JarFileSystem {
|
||||
|
||||
public JarFileSystemImpl() {
|
||||
boolean noCopy = SystemProperties.getBooleanProperty("idea.jars.nocopy", !SystemInfo.isWindows);
|
||||
myNoCopyJarPaths = noCopy ? null : new ConcurrentHashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
|
||||
myNoCopyJarPaths = noCopy ? null : ContainerUtil.newConcurrentSet(FileUtil.PATH_HASHING_STRATEGY);
|
||||
|
||||
// to prevent platform .jar files from copying
|
||||
boolean runningFromDist = new File(PathManager.getLibPath(), "openapi.jar").exists();
|
||||
|
||||
+3
-2
@@ -33,7 +33,7 @@ import com.intellij.openapi.vfs.newvfs.FileAttribute;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.FileNameCache;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.io.*;
|
||||
import com.intellij.util.io.DataOutputStream;
|
||||
@@ -48,6 +48,7 @@ import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@@ -136,7 +137,7 @@ public class FSRecords implements Forceable {
|
||||
|
||||
static class DbConnection {
|
||||
private static boolean ourInitialized;
|
||||
private static final ConcurrentHashMap<String, Integer> myAttributeIds = new ConcurrentHashMap<String, Integer>();
|
||||
private static final ConcurrentMap<String, Integer> myAttributeIds = ContainerUtil.newConcurrentMap();
|
||||
|
||||
private static PersistentStringEnumerator myNames;
|
||||
private static Storage myAttributes;
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ package com.intellij.openapi.vfs.tracker;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -178,7 +178,7 @@ public class VirtualFileTrackerImpl implements VirtualFileTracker {
|
||||
Set<VirtualFileListener> listeners = map.get(fileUrl);
|
||||
|
||||
if (listeners == null) {
|
||||
listeners = new ConcurrentHashSet<VirtualFileListener>();
|
||||
listeners = ContainerUtil.newConcurrentSet();
|
||||
map.put(fileUrl, listeners);
|
||||
}
|
||||
return listeners;
|
||||
|
||||
@@ -427,7 +427,6 @@ public class DockManagerImpl extends DockManager implements PersistentStateCompo
|
||||
private DockWindow createWindowFor(@Nullable String id, DockContainer container) {
|
||||
String windowId = id != null ? id : String.valueOf(myWindowIdCounter++);
|
||||
DockWindow window = new DockWindow(windowId, myProject, container, container instanceof DockContainer.Dialog);
|
||||
Disposer.register(container, window);
|
||||
window.setDimensionKey("dock-window-" + windowId);
|
||||
myWindows.put(container, window);
|
||||
return window;
|
||||
|
||||
@@ -61,6 +61,7 @@ editing.completion.changeSorting=Changing completion variants sorting
|
||||
editing.completion.postfix=Postfix completion
|
||||
editing.select.word=Syntax aware selection
|
||||
editing.incremental.search=Editor incremental search
|
||||
editing.add.carets.using.double.ctrl=Multiple carets
|
||||
codeassists.quickjavadoc=Quick Documentation popup
|
||||
codeassists.quickdefinition=Quick Definition lookup
|
||||
codeassists.quickdefinition.lookup=Quick Definition in lookup lists
|
||||
|
||||
@@ -252,6 +252,9 @@
|
||||
<action id="GotoPreviousError">
|
||||
<keyboard-shortcut first-keystroke="shift meta QUOTE" />
|
||||
</action>
|
||||
<action id="MaximizeToolWindow">
|
||||
<keyboard-shortcut first-keystroke="shift meta SEMICOLON"/>
|
||||
</action>
|
||||
<action id="GotoFile">
|
||||
<keyboard-shortcut first-keystroke="meta alt O" />
|
||||
</action>
|
||||
|
||||
+18
-24
@@ -30,12 +30,11 @@ import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.util.PatternUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -290,15 +289,16 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
assertNotNull(project);
|
||||
assertFalse(project.equals(PlainTextFileType.INSTANCE));
|
||||
|
||||
final Set<VirtualFile> detectorCalled = new ConcurrentHashSet<VirtualFile>();
|
||||
final Set<VirtualFile> detectorCalled = ContainerUtil.newConcurrentSet();
|
||||
FileTypeRegistry.FileTypeDetector detector = new FileTypeRegistry.FileTypeDetector() {
|
||||
@Nullable
|
||||
@Override
|
||||
public FileType detect(@NotNull VirtualFile file, @NotNull ByteSequence firstBytes, @Nullable CharSequence firstCharsIfText) {
|
||||
detectorCalled.add(file);
|
||||
String text = firstCharsIfText.toString();
|
||||
if (text.startsWith("TYPE:")) return FileTypeRegistry.getInstance().findFileTypeByName(StringUtil.trimStart(text, "TYPE:"));
|
||||
return null;
|
||||
FileType result = text.startsWith("TYPE:") ? FileTypeRegistry.getInstance().findFileTypeByName(StringUtil.trimStart(text, "TYPE:")) : null;
|
||||
System.out.println("T: my detector run for "+file.getName()+"; result: "+(result == null ? null : result.getName()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -312,35 +312,29 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
File f = new File(d, "xx.asfdasdfas");
|
||||
FileUtil.writeToFile(f, "akjdhfksdjgf");
|
||||
VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f);
|
||||
((NewVirtualFile)vFile).markDirty();
|
||||
vFile.refresh(false, false);
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
myFileTypeManager.drainReDetectQueue();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
ensureRedetected(vFile, detectorCalled);
|
||||
assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof PlainTextFileType);
|
||||
assertTrue(detectorCalled.contains(vFile));
|
||||
detectorCalled.clear();
|
||||
|
||||
VfsUtil.saveText(vFile, "TYPE:IDEA_MODULE");
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
myFileTypeManager.drainReDetectQueue();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
assertTrue(detectorCalled.contains(vFile));
|
||||
detectorCalled.clear();
|
||||
ensureRedetected(vFile, detectorCalled);
|
||||
assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof ModuleFileType);
|
||||
|
||||
VfsUtil.saveText(vFile, "TYPE:IDEA_PROJECT");
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
myFileTypeManager.drainReDetectQueue();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
assertTrue(detectorCalled.contains(vFile));
|
||||
detectorCalled.clear();
|
||||
ensureRedetected(vFile, detectorCalled);
|
||||
assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof ProjectFileType);
|
||||
}
|
||||
finally {
|
||||
Extensions.getRootArea().getExtensionPoint(FileTypeRegistry.FileTypeDetector.EP_NAME).unregisterExtension(detector);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureRedetected(VirtualFile vFile, Set<VirtualFile> detectorCalled) {
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
myFileTypeManager.drainReDetectQueue();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
vFile.getFileType();
|
||||
assertTrue(detectorCalled.contains(vFile));
|
||||
detectorCalled.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.CollectionQuery;
|
||||
import com.intellij.util.EmptyQuery;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
@@ -64,7 +63,7 @@ public class RootIndex {
|
||||
};
|
||||
|
||||
private final Map<String, List<VirtualFile>> myDirectoriesByPackageNameCache = ContainerUtil.newConcurrentMap();
|
||||
private final Set<String> myNonExistentPackages = new ConcurrentHashSet<String>();
|
||||
private final Set<String> myNonExistentPackages = ContainerUtil.newConcurrentSet();
|
||||
private final InfoCache myInfoCache;
|
||||
private final List<JpsModuleSourceRootType<?>> myRootTypes = ContainerUtil.newArrayList();
|
||||
private final TObjectIntHashMap<JpsModuleSourceRootType<?>> myRootTypeId = new TObjectIntHashMap<JpsModuleSourceRootType<?>>();
|
||||
|
||||
+17
-2
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.remoteServer.impl.runtime;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
@@ -21,7 +36,7 @@ import com.intellij.remoteServer.runtime.deployment.debug.DebugConnectionDataNot
|
||||
import com.intellij.remoteServer.runtime.deployment.debug.DebugConnector;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ParameterizedRunnable;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -41,7 +56,7 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
|
||||
private volatile ServerRuntimeInstance<D> myRuntimeInstance;
|
||||
private final Map<String, DeploymentImpl> myRemoteDeployments = new HashMap<String, DeploymentImpl>();
|
||||
private final Map<String, DeploymentImpl> myLocalDeployments = new HashMap<String, DeploymentImpl>();
|
||||
private final Map<String, DeploymentLogManagerImpl> myLogManagers = new ConcurrentHashMap<String, DeploymentLogManagerImpl>();
|
||||
private final Map<String, DeploymentLogManagerImpl> myLogManagers = ContainerUtil.newConcurrentMap();
|
||||
|
||||
public ServerConnectionImpl(RemoteServer<?> server,
|
||||
ServerConnector connector,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user