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-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -255,7 +255,7 @@ public class PositionManagerImpl implements PositionManager {
|
||||
baseClassNameRef.set(parentClassName);
|
||||
}
|
||||
else {
|
||||
LOG.error("The name of a parent of a local (anonymous) class is null");
|
||||
LOG.error("The name of a parent " + topLevelClass + " of a local (anonymous) class " + psiClass + " is null");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+6
-2
@@ -455,9 +455,11 @@ public class GenericsHighlightUtil {
|
||||
HighlightUtil.formatClass(superContainingClass),
|
||||
JavaHighlightUtil.formatMethod(superMethod),
|
||||
HighlightUtil.formatClass(superContainingClass, false));
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(classIdentifier).descriptionAndTooltip(message)
|
||||
.create();
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createImplementMethodsFix(aClass));
|
||||
return info;
|
||||
}
|
||||
|
||||
if (isDefault || !isAbstract && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
@@ -471,9 +473,11 @@ public class GenericsHighlightUtil {
|
||||
HighlightUtil.formatClass(containingClass) +
|
||||
" and " +
|
||||
HighlightUtil.formatClass(superContainingClass);
|
||||
return HighlightInfo
|
||||
final HighlightInfo info = HighlightInfo
|
||||
.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(inheritUnrelatedDefaultsMessage)
|
||||
.create();
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createImplementMethodsFix(aClass));
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -718,6 +718,7 @@ public class RefactoringUtil {
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.FINAL, false);
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.SYNCHRONIZED, false);
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.NATIVE, false);
|
||||
PsiUtil.setModifierProperty(method, PsiModifier.PUBLIC, false);
|
||||
removeFinalParameters(method);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ interface Bar<T> { }
|
||||
interface Base<T> { }
|
||||
|
||||
class Foo<T,U> implements Base<U> {
|
||||
void ge<caret>t(Bar<U> bar) { }
|
||||
public void ge<caret>t(Bar<U> bar) { }
|
||||
}
|
||||
+25
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.codeInsight.folding.CodeFoldingManager;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.testFramework.TestFileType;
|
||||
@@ -55,7 +56,31 @@ public class FoldingProcessingOnDocumentModificationTest extends AbstractEditorT
|
||||
assertFalse(foldRegion.isExpanded());
|
||||
}
|
||||
|
||||
public void testCollapseAllHappensBeforeFirstCodeFoldingPass() throws Exception {
|
||||
init("class Foo {\n" +
|
||||
" void m() {\n" +
|
||||
" System.out.println();\n" +
|
||||
" System.out.println();\n" +
|
||||
" }\n" +
|
||||
"}", TestFileType.JAVA);
|
||||
|
||||
buildInitialFoldRegions();
|
||||
executeAction(IdeActions.ACTION_COLLAPSE_ALL_REGIONS);
|
||||
runFoldingPass(true);
|
||||
assertEquals(1, myEditor.getFoldingModel().getAllFoldRegions().length);
|
||||
}
|
||||
|
||||
private static void buildInitialFoldRegions() {
|
||||
CodeFoldingManager.getInstance(getProject()).buildInitialFoldings(myEditor);
|
||||
}
|
||||
|
||||
private static void updateFoldRegions() {
|
||||
CodeFoldingManager.getInstance(getProject()).updateFoldRegions(myEditor);
|
||||
}
|
||||
|
||||
private static void runFoldingPass(boolean firstTime) {
|
||||
Runnable runnable = CodeFoldingManager.getInstance(getProject()).updateFoldRegionsAsync(myEditor, firstTime);
|
||||
assertNotNull(runnable);
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 210 B |
Binary file not shown.
|
After Width: | Height: | Size: 282 B |
@@ -49,11 +49,15 @@ import com.intellij.util.Producer;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PasteHandler extends EditorActionHandler implements EditorTextInsertHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.PasteHandler");
|
||||
@@ -73,6 +77,9 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
|
||||
|
||||
@Override
|
||||
public void execute(final Editor editor, final DataContext dataContext, @Nullable final Producer<Transferable> producer) {
|
||||
final Transferable transferable = EditorModificationUtil.getContentsToPasteToEditor(producer);
|
||||
if (transferable == null) return;
|
||||
|
||||
if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return;
|
||||
|
||||
final Document document = editor.getDocument();
|
||||
@@ -80,15 +87,18 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
|
||||
return;
|
||||
}
|
||||
|
||||
DataContext context = dataContext;
|
||||
if (producer != null) {
|
||||
context = new DataContext() {
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return PasteAction.TRANSFERABLE_PROVIDER.is(dataId) ? producer : dataContext.getData(dataId);
|
||||
}
|
||||
};
|
||||
}
|
||||
DataContext context = new DataContext() {
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return PasteAction.TRANSFERABLE_PROVIDER.is(dataId) ? new Producer<Transferable>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Transferable produce() {
|
||||
return transferable;
|
||||
}
|
||||
} : dataContext.getData(dataId);
|
||||
}
|
||||
};
|
||||
|
||||
final Project project = editor.getProject();
|
||||
if (project == null || editor.isColumnMode() || editor.getCaretModel().getCaretCount() > 1) {
|
||||
@@ -114,7 +124,7 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
|
||||
return;
|
||||
}
|
||||
}
|
||||
doPaste(editor, project, file, document, producer);
|
||||
doPaste(editor, project, file, document, transferable);
|
||||
}
|
||||
catch (ReadOnlyFragmentModificationException e) {
|
||||
EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(document).handle(e);
|
||||
@@ -128,152 +138,137 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
|
||||
final Project project,
|
||||
final PsiFile file,
|
||||
final Document document,
|
||||
final Producer<Transferable> producer) {
|
||||
Transferable content = null;
|
||||
@NotNull final Transferable content) {
|
||||
CopyPasteManager.getInstance().stopKillRings();
|
||||
|
||||
String text = null;
|
||||
try {
|
||||
text = (String)content.getTransferData(DataFlavor.stringFlavor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
editor.getComponent().getToolkit().beep();
|
||||
}
|
||||
if (text == null) return;
|
||||
|
||||
if (producer != null) {
|
||||
content = producer.produce();
|
||||
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
|
||||
final Map<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> extraData = new HashMap<CopyPastePostProcessor, List<? extends TextBlockTransferableData>>();
|
||||
Collection<TextBlockTransferableData> allValues = new ArrayList<TextBlockTransferableData>();
|
||||
|
||||
DumbService.getInstance(project).setAlternativeResolveEnabled(true);
|
||||
try {
|
||||
for (CopyPastePostProcessor<? extends TextBlockTransferableData> processor : Extensions.getExtensions(CopyPastePostProcessor.EP_NAME)) {
|
||||
List<? extends TextBlockTransferableData> data = processor.extractTransferableData(content);
|
||||
if (!data.isEmpty()) {
|
||||
extraData.put(processor, data);
|
||||
allValues.addAll(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DumbService.getInstance(project).setAlternativeResolveEnabled(false);
|
||||
}
|
||||
|
||||
text = TextBlockTransferable.convertLineSeparators(editor, text, allValues);
|
||||
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
final SelectionModel selectionModel = editor.getSelectionModel();
|
||||
final int col = caretModel.getLogicalPosition().column;
|
||||
|
||||
// There is a possible case that we want to perform paste while there is an active selection at the editor and caret is located
|
||||
// inside it (e.g. Ctrl+A is pressed while caret is not at the zero column). We want to insert the text at selection start column
|
||||
// then, hence, inserted block of text should be indented according to the selection start as well.
|
||||
final int blockIndentAnchorColumn;
|
||||
final int caretOffset = caretModel.getOffset();
|
||||
if (selectionModel.hasSelection() && caretOffset >= selectionModel.getSelectionStart()) {
|
||||
blockIndentAnchorColumn = editor.offsetToLogicalPosition(selectionModel.getSelectionStart()).column;
|
||||
}
|
||||
else {
|
||||
CopyPasteManager manager = CopyPasteManager.getInstance();
|
||||
if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) {
|
||||
content = manager.getContents();
|
||||
if (content != null) {
|
||||
manager.stopKillRings();
|
||||
}
|
||||
}
|
||||
blockIndentAnchorColumn = col;
|
||||
}
|
||||
|
||||
if (content != null) {
|
||||
String text = null;
|
||||
try {
|
||||
text = (String)content.getTransferData(DataFlavor.stringFlavor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
editor.getComponent().getToolkit().beep();
|
||||
}
|
||||
if (text == null) return;
|
||||
// We assume that EditorModificationUtil.insertStringAtCaret() is smart enough to remove currently selected text (if any).
|
||||
|
||||
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
RawText rawText = RawText.fromTransferable(content);
|
||||
String newText = text;
|
||||
for (CopyPastePreProcessor preProcessor : Extensions.getExtensions(CopyPastePreProcessor.EP_NAME)) {
|
||||
newText = preProcessor.preprocessOnPaste(project, file, editor, newText, rawText);
|
||||
}
|
||||
int indentOptions = text.equals(newText) ? settings.REFORMAT_ON_PASTE : CodeInsightSettings.REFORMAT_BLOCK;
|
||||
text = newText;
|
||||
|
||||
final Map<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> extraData = new HashMap<CopyPastePostProcessor, List<? extends TextBlockTransferableData>>();
|
||||
Collection<TextBlockTransferableData> allValues = new ArrayList<TextBlockTransferableData>();
|
||||
|
||||
DumbService.getInstance(project).setAlternativeResolveEnabled(true);
|
||||
try {
|
||||
for (CopyPastePostProcessor<? extends TextBlockTransferableData> processor : Extensions.getExtensions(CopyPastePostProcessor.EP_NAME)) {
|
||||
List<? extends TextBlockTransferableData> data = processor.extractTransferableData(content);
|
||||
if (!data.isEmpty()) {
|
||||
extraData.put(processor, data);
|
||||
allValues.addAll(data);
|
||||
}
|
||||
if (LanguageFormatting.INSTANCE.forContext(file) == null && indentOptions != CodeInsightSettings.NO_REFORMAT) {
|
||||
indentOptions = CodeInsightSettings.INDENT_BLOCK;
|
||||
}
|
||||
|
||||
final String _text = text;
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EditorModificationUtil.insertStringAtCaret(editor, _text, false, true);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DumbService.getInstance(project).setAlternativeResolveEnabled(false);
|
||||
}
|
||||
);
|
||||
|
||||
text = TextBlockTransferable.convertLineSeparators(editor, text, allValues);
|
||||
int length = text.length();
|
||||
int offset = caretModel.getOffset() - length;
|
||||
if (offset < 0) {
|
||||
length += offset;
|
||||
offset = 0;
|
||||
}
|
||||
final RangeMarker bounds = document.createRangeMarker(offset, offset + length);
|
||||
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
final SelectionModel selectionModel = editor.getSelectionModel();
|
||||
final int col = caretModel.getLogicalPosition().column;
|
||||
caretModel.moveToOffset(bounds.getEndOffset());
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
selectionModel.removeSelection();
|
||||
|
||||
// There is a possible case that we want to perform paste while there is an active selection at the editor and caret is located
|
||||
// inside it (e.g. Ctrl+A is pressed while caret is not at the zero column). We want to insert the text at selection start column
|
||||
// then, hence, inserted block of text should be indented according to the selection start as well.
|
||||
final int blockIndentAnchorColumn;
|
||||
final int caretOffset = caretModel.getOffset();
|
||||
if (selectionModel.hasSelection() && caretOffset >= selectionModel.getSelectionStart()) {
|
||||
blockIndentAnchorColumn = editor.offsetToLogicalPosition(selectionModel.getSelectionStart()).column;
|
||||
}
|
||||
else {
|
||||
blockIndentAnchorColumn = col;
|
||||
}
|
||||
final Ref<Boolean> indented = new Ref<Boolean>(Boolean.FALSE);
|
||||
for (Map.Entry<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> e : extraData.entrySet()) {
|
||||
//noinspection unchecked
|
||||
e.getKey().processTransferableData(project, editor, bounds, caretOffset, indented, e.getValue());
|
||||
}
|
||||
|
||||
// We assume that EditorModificationUtil.insertStringAtCaret() is smart enough to remove currently selected text (if any).
|
||||
boolean pastedTextContainsWhiteSpacesOnly =
|
||||
CharArrayUtil.shiftForward(document.getCharsSequence(), bounds.getStartOffset(), " \n\t") >= bounds.getEndOffset();
|
||||
|
||||
RawText rawText = RawText.fromTransferable(content);
|
||||
String newText = text;
|
||||
for (CopyPastePreProcessor preProcessor : Extensions.getExtensions(CopyPastePreProcessor.EP_NAME)) {
|
||||
newText = preProcessor.preprocessOnPaste(project, file, editor, newText, rawText);
|
||||
}
|
||||
int indentOptions = text.equals(newText) ? settings.REFORMAT_ON_PASTE : CodeInsightSettings.REFORMAT_BLOCK;
|
||||
text = newText;
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (!pastedTextContainsWhiteSpacesOnly && (virtualFile == null || !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile))) {
|
||||
final int indentOptions1 = indentOptions;
|
||||
|
||||
if (LanguageFormatting.INSTANCE.forContext(file) == null && indentOptions != CodeInsightSettings.NO_REFORMAT) {
|
||||
indentOptions = CodeInsightSettings.INDENT_BLOCK;
|
||||
}
|
||||
|
||||
final String _text = text;
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EditorModificationUtil.insertStringAtCaret(editor, _text, false, true);
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document);
|
||||
switch (indentOptions1) {
|
||||
case CodeInsightSettings.INDENT_BLOCK:
|
||||
if (!indented.get()) {
|
||||
indentBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset(), blockIndentAnchorColumn);
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeInsightSettings.INDENT_EACH_LINE:
|
||||
if (!indented.get()) {
|
||||
indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset());
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeInsightSettings.REFORMAT_BLOCK:
|
||||
indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); // this is needed for example when inserting a comment before method
|
||||
reformatBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
int length = text.length();
|
||||
int offset = caretModel.getOffset() - length;
|
||||
if (offset < 0) {
|
||||
length += offset;
|
||||
offset = 0;
|
||||
}
|
||||
final RangeMarker bounds = document.createRangeMarker(offset, offset + length);
|
||||
|
||||
if (bounds.isValid()) {
|
||||
caretModel.moveToOffset(bounds.getEndOffset());
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
selectionModel.removeSelection();
|
||||
|
||||
final Ref<Boolean> indented = new Ref<Boolean>(Boolean.FALSE);
|
||||
for (Map.Entry<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> e : extraData.entrySet()) {
|
||||
//noinspection unchecked
|
||||
e.getKey().processTransferableData(project, editor, bounds, caretOffset, indented, e.getValue());
|
||||
}
|
||||
|
||||
boolean pastedTextContainsWhiteSpacesOnly =
|
||||
CharArrayUtil.shiftForward(document.getCharsSequence(), bounds.getStartOffset(), " \n\t") >= bounds.getEndOffset();
|
||||
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (!pastedTextContainsWhiteSpacesOnly && (virtualFile == null || !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile))) {
|
||||
final int indentOptions1 = indentOptions;
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document);
|
||||
switch (indentOptions1) {
|
||||
case CodeInsightSettings.INDENT_BLOCK:
|
||||
if (!indented.get()) {
|
||||
indentBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset(), blockIndentAnchorColumn);
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeInsightSettings.INDENT_EACH_LINE:
|
||||
if (!indented.get()) {
|
||||
indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset());
|
||||
}
|
||||
break;
|
||||
|
||||
case CodeInsightSettings.REFORMAT_BLOCK:
|
||||
indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); // this is needed for example when inserting a comment before method
|
||||
reformatBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (bounds.isValid()) {
|
||||
caretModel.moveToOffset(bounds.getEndOffset());
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
selectionModel.removeSelection();
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, TextRange.create(bounds));
|
||||
}
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, TextRange.create(bounds));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -281,6 +281,13 @@ public class FoldingUpdate {
|
||||
}
|
||||
|
||||
public static class FoldingMap extends MultiMap<PsiElement, FoldingDescriptor>{
|
||||
public FoldingMap() {
|
||||
}
|
||||
|
||||
public FoldingMap(FoldingMap map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<PsiElement, Collection<FoldingDescriptor>> createMap() {
|
||||
|
||||
+11
-8
@@ -76,11 +76,14 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
FoldingModelEx foldingModel = (FoldingModelEx)myEditor.getFoldingModel();
|
||||
Map<TextRange,Boolean> rangeToExpandStatusMap = newTroveMap();
|
||||
|
||||
removeInvalidRegions(info, foldingModel, rangeToExpandStatusMap);
|
||||
// FoldingUpdate caches instances of our object, so they must be immutable.
|
||||
FoldingUpdate.FoldingMap elementsToFold = new FoldingUpdate.FoldingMap(myElementsToFoldMap);
|
||||
|
||||
removeInvalidRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap);
|
||||
|
||||
Map<FoldRegion, Boolean> shouldExpand = newTroveMap();
|
||||
Map<FoldingGroup, Boolean> groupExpand = newTroveMap();
|
||||
List<FoldRegion> newRegions = addNewRegions(info, foldingModel, rangeToExpandStatusMap, shouldExpand, groupExpand);
|
||||
List<FoldRegion> newRegions = addNewRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap, shouldExpand, groupExpand);
|
||||
|
||||
applyExpandStatus(newRegions, shouldExpand, groupExpand);
|
||||
}
|
||||
@@ -100,14 +103,14 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
|
||||
private List<FoldRegion> addNewRegions(@NotNull EditorFoldingInfo info,
|
||||
@NotNull FoldingModelEx foldingModel,
|
||||
@NotNull Map<TextRange, Boolean> rangeToExpandStatusMap,
|
||||
FoldingUpdate.FoldingMap elementsToFold, @NotNull Map<TextRange, Boolean> rangeToExpandStatusMap,
|
||||
@NotNull Map<FoldRegion, Boolean> shouldExpand,
|
||||
@NotNull Map<FoldingGroup, Boolean> groupExpand) {
|
||||
List<FoldRegion> newRegions = newArrayList();
|
||||
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject);
|
||||
for (PsiElement element : myElementsToFoldMap.keySet()) {
|
||||
for (PsiElement element : elementsToFold.keySet()) {
|
||||
ProgressManager.checkCanceled();
|
||||
final Collection<FoldingDescriptor> descriptors = myElementsToFoldMap.get(element);
|
||||
final Collection<FoldingDescriptor> descriptors = elementsToFold.get(element);
|
||||
for (FoldingDescriptor descriptor : descriptors) {
|
||||
FoldingGroup group = descriptor.getGroup();
|
||||
TextRange range = descriptor.getRange();
|
||||
@@ -165,7 +168,7 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
|
||||
private void removeInvalidRegions(@NotNull EditorFoldingInfo info,
|
||||
@NotNull FoldingModelEx foldingModel,
|
||||
@NotNull Map<TextRange, Boolean> rangeToExpandStatusMap) {
|
||||
FoldingUpdate.FoldingMap elementsToFold, @NotNull Map<TextRange, Boolean> rangeToExpandStatusMap) {
|
||||
List<FoldRegion> toRemove = newArrayList();
|
||||
InjectedLanguageManager injectedManager = InjectedLanguageManager.getInstance(myProject);
|
||||
for (FoldRegion region : foldingModel.getAllFoldRegions()) {
|
||||
@@ -176,7 +179,7 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
if (isInjected != myForInjected) continue;
|
||||
}
|
||||
final Collection<FoldingDescriptor> descriptors;
|
||||
if (element != null && !(descriptors = myElementsToFoldMap.get(element)).isEmpty()) {
|
||||
if (element != null && !(descriptors = elementsToFold.get(element)).isEmpty()) {
|
||||
boolean matchingDescriptorFound = false;
|
||||
FoldingDescriptor[] array = descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
|
||||
for (FoldingDescriptor descriptor : array) {
|
||||
@@ -194,7 +197,7 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
myElementsToFoldMap.remove(element, descriptor);
|
||||
elementsToFold.remove(element, descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,7 +95,7 @@ public abstract class RunTab implements DataProvider, Disposable {
|
||||
logConsoleManager = new LogConsoleManagerBase(myProject, mySearchScope) {
|
||||
@Override
|
||||
protected Icon getDefaultIcon() {
|
||||
return AllIcons.Debugger.Console;
|
||||
return AllIcons.Debugger.Console_log;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1682,10 +1682,10 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
myProgressIndicator, new Processor<Object>() {
|
||||
@Override
|
||||
public boolean process(Object o) {
|
||||
if (o instanceof PsiElement && !(((PsiElement)o).getParent() instanceof PsiFile)) {
|
||||
if (isSymbol(o)) {
|
||||
final PsiElement element = (PsiElement)o;
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (!myListModel.contains(o) &&
|
||||
if (!myListModel.contains(o) && !symbols.contains(o) &&
|
||||
//some elements are non-physical like DB columns
|
||||
(file == null || (file.getVirtualFile() != null && (includeLibs || scope.accept(file.getVirtualFile()))))) {
|
||||
symbols.add(o);
|
||||
@@ -1698,6 +1698,16 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
return symbols;
|
||||
}
|
||||
|
||||
protected boolean isSymbol(Object o) {
|
||||
if (o instanceof PsiElement) {
|
||||
final PsiElement e = (PsiElement)o;
|
||||
//todo[kb] need a better way to avoid mixing java classes with symbols. Same to other languages where
|
||||
//todo[kb] symbol provider returns classes. We need kind of suppressor API & EP here.
|
||||
return !e.getLanguage().is(Language.findLanguageByID("JAVA")) || !(e.getParent() instanceof PsiFile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private SearchResult getClasses(String pattern, boolean includeLibs, final int max, ChooseByNamePopup chooseByNamePopup) {
|
||||
final SearchResult classes = new SearchResult();
|
||||
if (chooseByNamePopup == null) {
|
||||
|
||||
@@ -197,6 +197,17 @@ public class EditorModificationUtil {
|
||||
zeroWidthBlockSelectionAtCaretColumn(editor, caretLine, caretLine);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Transferable getContentsToPasteToEditor(@Nullable Producer<Transferable> producer) {
|
||||
if (producer == null) {
|
||||
CopyPasteManager manager = CopyPasteManager.getInstance();
|
||||
return manager.areDataFlavorsAvailable(DataFlavor.stringFlavor) ? manager.getContents() : null;
|
||||
}
|
||||
else {
|
||||
return producer.produce();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getStringContent(@NotNull Transferable content) {
|
||||
RawText raw = RawText.fromTransferable(content);
|
||||
|
||||
+6
-2
@@ -23,6 +23,10 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Base class for {@link EditorActionHandler} instances, which need to modify the document.
|
||||
* Implementations should override {@link #executeWriteAction(Editor, Caret, DataContext)}.
|
||||
*/
|
||||
public abstract class EditorWriteActionHandler extends EditorActionHandler {
|
||||
private boolean inExecution;
|
||||
|
||||
@@ -34,7 +38,7 @@ public abstract class EditorWriteActionHandler extends EditorActionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void doExecute(final Editor editor, @Nullable final Caret caret, final DataContext dataContext) {
|
||||
public void doExecute(final Editor editor, @Nullable final Caret caret, final DataContext dataContext) {
|
||||
if (editor.isViewer()) return;
|
||||
|
||||
if (dataContext != null) {
|
||||
@@ -63,7 +67,7 @@ public abstract class EditorWriteActionHandler extends EditorActionHandler {
|
||||
|
||||
/**
|
||||
* @deprecated Use/override
|
||||
* {@link #executeWriteAction(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)}
|
||||
* {@link #executeWriteAction(Editor, Caret, DataContext)}
|
||||
* instead.
|
||||
*/
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorCopyPasteHelper;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.util.Producer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
||||
public abstract class BasePasteHandler extends EditorWriteActionHandler {
|
||||
protected Transferable myTransferable;
|
||||
|
||||
@Override
|
||||
public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
|
||||
// We capture the contents to paste here, so it that it won't be affected by possible clipboard operations later (e.g. during unlocking
|
||||
// of current file for writing)
|
||||
myTransferable = getContentsToPaste(editor, dataContext);
|
||||
try {
|
||||
super.doExecute(editor, caret, dataContext);
|
||||
}
|
||||
finally {
|
||||
myTransferable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, @Nullable Caret caret, DataContext dataContext) {
|
||||
if (myTransferable != null) {
|
||||
EditorCopyPasteHelper.getInstance().pasteTransferable(editor, myTransferable);
|
||||
}
|
||||
}
|
||||
|
||||
protected Transferable getContentsToPaste(Editor editor, DataContext dataContext) {
|
||||
Producer<Transferable> producer = PasteAction.TRANSFERABLE_PROVIDER.getData(dataContext);
|
||||
return EditorModificationUtil.getContentsToPasteToEditor(producer);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-5
@@ -19,10 +19,9 @@ import com.intellij.ide.CopyPasteManagerEx;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.ui.UIBundle;
|
||||
|
||||
@@ -100,9 +99,6 @@ public class MultiplePasteAction extends AnAction implements DumbAware {
|
||||
|
||||
if (editor != null) {
|
||||
if (editor.isViewer()) return;
|
||||
if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){
|
||||
return;
|
||||
}
|
||||
|
||||
final AnAction pasteAction = ActionManager.getInstance().getAction(IdeActions.ACTION_PASTE);
|
||||
AnActionEvent newEvent = new AnActionEvent(e.getInputEvent(),
|
||||
|
||||
@@ -17,10 +17,10 @@ package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.EditorCopyPasteHelper;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.Producer;
|
||||
@@ -38,17 +38,17 @@ public class PasteAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends EditorWriteActionHandler {
|
||||
private static class Handler extends BasePasteHandler {
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
Producer<Transferable> producer = TRANSFERABLE_PROVIDER.getData(dataContext);
|
||||
if (!editor.getCaretModel().supportsMultipleCarets() && editor.isColumnMode()) {
|
||||
EditorModificationUtil.pasteTransferableAsBlock(editor, producer);
|
||||
}
|
||||
else {
|
||||
TextRange range = EditorModificationUtil.pasteTransferable(editor, producer);
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, range);
|
||||
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
|
||||
TextRange range = null;
|
||||
if (myTransferable != null) {
|
||||
TextRange[] ranges = EditorCopyPasteHelper.getInstance().pasteTransferable(editor, myTransferable);
|
||||
if (ranges != null && ranges.length == 1) {
|
||||
range = ranges[0];
|
||||
}
|
||||
}
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-22
@@ -21,15 +21,9 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.openapi.editor.event.EditorMouseEventArea;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.Producer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -71,30 +65,19 @@ public class PasteFromX11Action extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler extends EditorWriteActionHandler {
|
||||
public static class Handler extends BasePasteHandler {
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
protected Transferable getContentsToPaste(Editor editor, DataContext dataContext) {
|
||||
Clipboard clip = editor.getComponent().getToolkit().getSystemSelection();
|
||||
if (clip == null) return;
|
||||
if (clip == null) return null;
|
||||
|
||||
final Transferable content;
|
||||
try {
|
||||
content = clip.getContents(null);
|
||||
return clip.getContents(null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.info(e);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (content == null) return;
|
||||
|
||||
TextRange range = EditorModificationUtil.pasteTransferable(editor, new Producer<Transferable>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Transferable produce() {
|
||||
return content;
|
||||
}
|
||||
});
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-21
@@ -19,15 +19,10 @@ import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.Producer;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -47,21 +42,9 @@ public class SimplePasteAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Handler extends EditorWriteActionHandler {
|
||||
private static class Handler extends BasePasteHandler {
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
Producer<Transferable> producer = PasteAction.TRANSFERABLE_PROVIDER.getData(dataContext);
|
||||
if (!editor.getCaretModel().supportsMultipleCarets() && editor.isColumnMode()) {
|
||||
EditorModificationUtil.pasteTransferableAsBlock(editor, producer);
|
||||
}
|
||||
else {
|
||||
TextRange range = EditorModificationUtil.pasteTransferable(editor, producer);
|
||||
editor.putUserData(EditorEx.LAST_PASTED_REGION, range);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Editor editor, DataContext dataContext) {
|
||||
public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
|
||||
return !editor.isViewer();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-12
@@ -26,12 +26,12 @@ import com.intellij.openapi.util.text.LineTokenizer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class EditorCopyPasteHelperImpl extends EditorCopyPasteHelper {
|
||||
private static final Logger LOG = Logger.getInstance(EditorCopyPasteHelperImpl.class);
|
||||
@@ -72,14 +72,8 @@ public class EditorCopyPasteHelperImpl extends EditorCopyPasteHelper {
|
||||
@Nullable
|
||||
@Override
|
||||
public TextRange[] pasteFromClipboard(@NotNull Editor editor) {
|
||||
CopyPasteManager manager = CopyPasteManager.getInstance();
|
||||
if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) {
|
||||
Transferable clipboardContents = manager.getContents();
|
||||
if (clipboardContents != null) {
|
||||
return pasteTransferable(editor, clipboardContents);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
Transferable transferable = EditorModificationUtil.getContentsToPasteToEditor(null);
|
||||
return transferable == null ? null : pasteTransferable(editor, transferable);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.mac.MacMainFrameDecorator;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.ui.Animator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -221,6 +222,7 @@ public class SheetMessage {
|
||||
staticImage = null;
|
||||
myWindow.setContentPane(myController.getPanel(myWindow));
|
||||
|
||||
IJSwingUtilities.moveMousePointerOn(myWindow.getRootPane().getDefaultButton());
|
||||
myController.requestFocus();
|
||||
} else {
|
||||
if (restoreFullScreenButton) {
|
||||
|
||||
@@ -100,7 +100,7 @@ inspection.empty.method.delete.quickfix=Delete unnecessary method(s)
|
||||
inspection.empty.method.problem.descriptor=Method only calls its super
|
||||
inspection.empty.method.problem.descriptor1=Empty method overrides empty method
|
||||
inspection.empty.method.problem.descriptor2=The method is empty
|
||||
inspection.empty.method.problem.descriptor3=The method and all it's derivables are empty
|
||||
inspection.empty.method.problem.descriptor3=The method and all its derivables are empty
|
||||
inspection.empty.method.problem.descriptor4=All implementations of this method are empty
|
||||
|
||||
#redundant cast
|
||||
|
||||
@@ -716,9 +716,6 @@
|
||||
<action id="IntroduceParameter">
|
||||
<keyboard-shortcut first-keystroke="control alt P"/>
|
||||
</action>
|
||||
<action id="IntroduceFunctionalParameter">
|
||||
<keyboard-shortcut first-keystroke="control alt shift P"/>
|
||||
</action>
|
||||
<action id="NextOccurence">
|
||||
<keyboard-shortcut first-keystroke="control alt DOWN"/>
|
||||
</action>
|
||||
|
||||
@@ -215,6 +215,7 @@ public class AllIcons {
|
||||
public static final Icon Class_filter = IconLoader.getIcon("/debugger/class_filter.png"); // 16x16
|
||||
public static final Icon CommandLine = IconLoader.getIcon("/debugger/commandLine.png"); // 16x16
|
||||
public static final Icon Console = IconLoader.getIcon("/debugger/console.png"); // 16x16
|
||||
public static final Icon Console_log = IconLoader.getIcon("/debugger/console_log.png"); // 16x16
|
||||
public static final Icon Db_array = IconLoader.getIcon("/debugger/db_array.png"); // 16x16
|
||||
public static final Icon Db_db_object = IconLoader.getIcon("/debugger/db_db_object.png"); // 16x16
|
||||
public static final Icon Db_dep_exception_breakpoint = IconLoader.getIcon("/debugger/db_dep_exception_breakpoint.png"); // 12x12
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -229,15 +229,17 @@ public class InjectorUtils {
|
||||
public static BaseInjection findCommentInjection(@NotNull PsiElement context, @NotNull String supportId, @Nullable Ref<PsiElement> causeRef) {
|
||||
PsiElement target = CompletionUtil.getOriginalOrSelf(context);
|
||||
PsiFile file = target.getContainingFile();
|
||||
if (file == null || file.getFileType().isBinary()) return null;
|
||||
TreeMap<TextRange, BaseInjection> map = getInjectionMap(file);
|
||||
Map.Entry<TextRange, BaseInjection> entry = map == null ? null : map.lowerEntry(target.getTextRange());
|
||||
if (map == null) return null;
|
||||
Map.Entry<TextRange, BaseInjection> entry = map.lowerEntry(target.getTextRange());
|
||||
if (entry == null) return null;
|
||||
|
||||
PsiComment psiComment = PsiTreeUtil.findElementOfClassAtOffset(file, entry.getKey().getStartOffset(), PsiComment.class, false);
|
||||
if (psiComment == null) return null;
|
||||
TextRange r0 = psiComment.getTextRange();
|
||||
|
||||
// calulate topmost siblings & heights
|
||||
// calculate topmost siblings & heights
|
||||
PsiElement commonParent = PsiTreeUtil.findCommonParent(psiComment, target);
|
||||
int h1 = 0, h2 = 0;
|
||||
PsiElement e1 = psiComment, e2 = target;
|
||||
@@ -269,8 +271,7 @@ public class InjectorUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static TreeMap<TextRange, BaseInjection> getInjectionMap(@Nullable final PsiFile file) {
|
||||
if (file == null) return null; // e.g. null for synthetic groovy variables
|
||||
private static TreeMap<TextRange, BaseInjection> getInjectionMap(@NotNull final PsiFile file) {
|
||||
return CachedValuesManager.getCachedValue(file, new CachedValueProvider<TreeMap<TextRange, BaseInjection>>() {
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
+14
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.groovy.dsl;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import gnu.trove.THashMap;
|
||||
@@ -49,11 +50,16 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
|
||||
@Nullable
|
||||
public synchronized String getInactivityReason(VirtualFile file) {
|
||||
String status = myStatus.get(file);
|
||||
return status == null || status == ENABLED ? null : status;
|
||||
return ENABLED.equals(status) ? null : status;
|
||||
}
|
||||
|
||||
public synchronized boolean isActivated(VirtualFile file) {
|
||||
return myStatus.get(file) == ENABLED;
|
||||
final String status = myStatus.get(file);
|
||||
if (status == null) {
|
||||
myStatus.put(file, ENABLED);
|
||||
return true;
|
||||
}
|
||||
return ENABLED.equals(status);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -66,7 +72,9 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
|
||||
Element element = new Element("file");
|
||||
root.addContent(element);
|
||||
element.setAttribute("url", file.getUrl());
|
||||
element.setAttribute("status", (status == ENABLED ? "" : status));
|
||||
if (!ENABLED.equals(status)) {
|
||||
element.setAttribute("status", status);
|
||||
}
|
||||
}
|
||||
return root;
|
||||
}
|
||||
@@ -76,10 +84,10 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
|
||||
List<Element> children = state.getChildren("file");
|
||||
for (Element element : children) {
|
||||
String url = element.getAttributeValue("url", "");
|
||||
String status = element.getAttributeValue("status", ENABLED);
|
||||
String status = element.getAttributeValue("status");
|
||||
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (file != null) {
|
||||
myStatus.put(file, status);
|
||||
myStatus.put(file, StringUtil.isNotEmpty(status) ? status : ENABLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -74,7 +74,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
private static final Key<Pair<GroovyDslExecutor, Long>> CACHED_EXECUTOR = Key.create("CachedGdslExecutor");
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.dsl.GroovyDslFileIndex");
|
||||
private static final Logger LOG = Logger.getInstance(GroovyDslFileIndex.class);
|
||||
|
||||
@NonNls public static final ID<String, Void> NAME = ID.create("GroovyDslFileIndex");
|
||||
@NonNls private static final String OUR_KEY = "ourKey";
|
||||
@@ -412,7 +412,10 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
if (!vfile.isValid()) {
|
||||
continue;
|
||||
}
|
||||
if (!fileIndex.isInLibraryClasses(vfile) && !fileIndex.isInLibrarySource(vfile)) {
|
||||
if (fileIndex.isInLibrarySource(vfile)) {
|
||||
continue;
|
||||
}
|
||||
if (!fileIndex.isInLibraryClasses(vfile)) {
|
||||
if (!fileIndex.isInSourceContent(vfile) || !isActivated(vfile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -183,8 +183,9 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light {
|
||||
}
|
||||
decompiler.decompileContext();
|
||||
|
||||
file.putUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY,
|
||||
new ExactMatchLineNumbersMapping(saver.myMapping));
|
||||
if (saver.myMapping != null) {
|
||||
file.putUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY, new ExactMatchLineNumbersMapping(saver.myMapping));
|
||||
}
|
||||
|
||||
return saver.myResult;
|
||||
}
|
||||
@@ -344,7 +345,7 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light {
|
||||
private static class ExactMatchLineNumbersMapping implements LineNumbersMapping {
|
||||
private int[] myMapping;
|
||||
|
||||
private ExactMatchLineNumbersMapping(int[] mapping) {
|
||||
private ExactMatchLineNumbersMapping(@NotNull int[] mapping) {
|
||||
myMapping = mapping;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
|
||||
private boolean myDisposed;
|
||||
private VirtualFileListener myVfsListener;
|
||||
private Editor mySelectedEditor;
|
||||
private String myPropertyToSelectWhenVisible;
|
||||
|
||||
public ResourceBundleEditor(@NotNull ResourceBundle resourceBundle) {
|
||||
myProject = resourceBundle.getProject();
|
||||
@@ -208,6 +209,9 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
|
||||
if (newEditor == this) {
|
||||
if (oldEditor instanceof TextEditor) {
|
||||
setStructureViewSelectionFromPropertiesFile(((TextEditor)oldEditor).getEditor());
|
||||
} else if (myPropertyToSelectWhenVisible != null) {
|
||||
setStructureViewSelection(myPropertyToSelectWhenVisible);
|
||||
myPropertyToSelectWhenVisible = null;
|
||||
}
|
||||
}
|
||||
else if (newEditor instanceof TextEditor) {
|
||||
@@ -239,6 +243,17 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
|
||||
|
||||
Object root = tree.getModel().getRoot();
|
||||
if (AbstractTreeUi.isLoadingChildrenFor(root)) {
|
||||
boolean isEditorVisible = false;
|
||||
for (FileEditor editor : FileEditorManager.getInstance(myProject).getSelectedEditors()) {
|
||||
if (editor == this) {
|
||||
isEditorVisible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isEditorVisible) {
|
||||
myPropertyToSelectWhenVisible = propertyName;
|
||||
return;
|
||||
}
|
||||
mySelectionChangeAlarm.cancelAllRequests();
|
||||
mySelectionChangeAlarm.addRequest(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -49,11 +49,15 @@ public class PyProjectStructureDetector extends ProjectStructureDetector {
|
||||
@NotNull List<DetectedProjectRoot> result) {
|
||||
LOG.info("Detecting roots under " + dir);
|
||||
for (File child : children) {
|
||||
if (FileUtilRt.extensionEquals(child.getName(), "py")) {
|
||||
final String name = child.getName();
|
||||
if (FileUtilRt.extensionEquals(name, "py")) {
|
||||
LOG.info("Found Python file " + child.getPath());
|
||||
result.add(new DetectedContentRoot(dir, "Python", PythonModuleTypeBase.getInstance(), WebModuleType.getInstance()));
|
||||
return DirectoryProcessingResult.SKIP_CHILDREN;
|
||||
}
|
||||
if ("node_modules".equals(name)) {
|
||||
return DirectoryProcessingResult.SKIP_CHILDREN;
|
||||
}
|
||||
}
|
||||
return DirectoryProcessingResult.PROCESS_CHILDREN;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
|
||||
<action id="IntroduceFunctionalParameter" class="com.intellij.refactoring.actions.IntroduceFunctionalParameterAction">
|
||||
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="IntroduceParameter"/>
|
||||
<keyboard-shortcut first-keystroke="control shift alt P" keymap="$default"/>
|
||||
</action>
|
||||
|
||||
<action id="IntroduceParameterObject" class="com.intellij.refactoring.actions.IntroduceParameterObjectAction">
|
||||
|
||||
Reference in New Issue
Block a user