Merge branch 'master' of git@git.labs.intellij.net:idea/community

This commit is contained in:
Kirill Kalishev
2010-11-24 20:32:11 +03:00
28 changed files with 218 additions and 206 deletions
@@ -65,6 +65,7 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
final boolean needLeftParenth = isToInsertParenth(context, item);
final boolean hasParams = needLeftParenth && hasParams(context, item);
final boolean annotation = insertingAnnotation(context, item);
if (CompletionUtil.isOverwrite(item, completionChar)) {
removeEndOfIdentifier(needLeftParenth && hasParams, context);
@@ -114,7 +115,7 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
});
}
if (insertingAnnotation(context, item)) {
if (annotation) {
// Check if someone inserts annotation class that require @
PsiElement elementAt = file.findElementAt(context.getStartOffset());
final PsiElement parentElement = elementAt != null ? elementAt.getParent():null;
@@ -59,12 +59,12 @@ public class ReferenceRange {
public static boolean containsOffsetInElement(PsiReference ref, int offset) {
if (ref instanceof MultiRangeReference) {
for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
if (range.contains(offset)) return true;
if (range.containsOffset(offset)) return true;
}
return false;
}
return ref.getRangeInElement().contains(offset);
return ref.getRangeInElement().containsOffset(offset);
}
public static boolean containsRangeInElement(PsiReference ref, TextRange rangeInElement) {
@@ -402,7 +402,9 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
LOG.assertTrue(fileCopy.findElementAt(offset) == insertedElement, "wrong offset");
final TextRange range = insertedElement.getTextRange();
LOG.assertTrue(range.substring(fileCopy.getText()).equals(insertedElement.getText()), "wrong text");
if (!range.substring(fileCopy.getText()).equals(insertedElement.getText())) {
LOG.error("wrong text: copy='" + fileCopy.getText() + "'; element='" + insertedElement.getText() + "'");
}
return new CompletionParameters(insertedElement, fileCopy.getOriginalFile(), myCompletionType, offset, invocationCount);
}
@@ -273,7 +273,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
private boolean isOutdated() {
if (!myDisposed) {
LOG.assertTrue(this == CompletionServiceImpl.getCompletionService().getCurrentCompletion());
CompletionProgressIndicator current = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
LOG.assertTrue(this == current, current);
}
return myDisposed || myEditor.isDisposed() || getProject().isDisposed();
}
@@ -391,10 +392,14 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
}
myLookup.show();
//todo remove these assertions before X release
if (!ApplicationManager.getApplication().isUnitTestMode()) {
LOG.assertTrue(myLookup.isVisible());
}
}
myLookup.refreshUi();
if (!ApplicationManager.getApplication().isUnitTestMode()) {
LOG.assertTrue(myLookup.isVisible());
LOG.assertTrue(myLookup.isVisible(), "really?");
}
hideAutopopupIfMeaningless();
}
@@ -1,42 +0,0 @@
/*
* Copyright 2000-2009 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.folding.impl.actions;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ex.FoldingModelEx;
import com.intellij.openapi.project.DumbAware;
public class FoldingActionGroup extends DefaultActionGroup implements DumbAware {
public FoldingActionGroup() {
super();
}
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
DataContext dataContext = event.getDataContext();
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
if (editor == null){
presentation.setVisible(false);
return;
}
FoldingModelEx foldingModel = (FoldingModelEx)editor.getFoldingModel();
presentation.setVisible(foldingModel.isFoldingEnabled());
}
}
@@ -476,7 +476,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
JComponent internalComponent = myEditor.getContentComponent();
final JRootPane rootPane = editorComponent.getRootPane();
if (rootPane == null) {
LOG.error(myArranger);
LOG.error(myArranger + "; " + myEditor.isDisposed());
}
JLayeredPane layeredPane = rootPane.getLayeredPane();
Point layeredPanePoint=SwingUtilities.convertPoint(internalComponent,location, layeredPane);
@@ -712,6 +712,9 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
public Rectangle getCurrentItemBounds(){
int index = myList.getSelectedIndex();
if (index < 0) {
LOG.error("No selected element, size=" + myList.getModel().getSize() + "; items" + getItems());
}
Rectangle itmBounds = myList.getCellBounds(index, index);
if (itmBounds == null){
LOG.error("No bounds for " + index + "; size=" + myList.getModel().getSize());
@@ -369,14 +369,19 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
//offset can be changed after text trimming after insert due to buffer constraints
appendToHistoryDocument(history, text);
int offset = history.getTextLength() - text.length();
final HighlighterIterator iterator = consoleEditor.getHighlighter().createIterator(0);
final int localStartOffset = textRange.getStartOffset();
final HighlighterIterator iterator = consoleEditor.getHighlighter().createIterator(localStartOffset);
final int localEndOffset = textRange.getEndOffset();
while (!iterator.atEnd()) {
final int localOffset = textRange.getStartOffset();
final int start = Math.max(iterator.getStart(), localOffset) - localOffset;
final int end = Math.min(iterator.getEnd(), textRange.getEndOffset()) - localOffset;
markupModel.addRangeHighlighter(start + offset, end + offset, HighlighterLayer.SYNTAX, iterator.getTextAttributes(),
HighlighterTargetArea.EXACT_RANGE);
final int itStart = iterator.getStart();
if (itStart > localEndOffset) break;
final int itEnd = iterator.getEnd();
if (itEnd >= localStartOffset) {
final int start = Math.max(itStart, localStartOffset) - localStartOffset + offset;
final int end = Math.min(itEnd, localEndOffset) - localStartOffset + offset;
markupModel.addRangeHighlighter(start, end, HighlighterLayer.SYNTAX, iterator.getTextAttributes(),
HighlighterTargetArea.EXACT_RANGE);
}
iterator.advance();
}
if (myDoSaveErrorsToHistory) {
@@ -1,43 +0,0 @@
/*
* Copyright 2000-2009 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.ide.projectView.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
public final class ProjectViewActionGroup extends DefaultActionGroup {
public ProjectViewActionGroup() {
super();
}
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
Project project = PlatformDataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
presentation.setVisible(false);
return;
}
String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
boolean isProjectViewActive = ToolWindowId.PROJECT_VIEW.equals(id);
presentation.setVisible(isProjectViewActive);
}
}
@@ -27,6 +27,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.impl.light.LightElement;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.psi.impl.source.PsiFileWithStubSupport;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.stubs.StubTree;
@@ -65,7 +66,7 @@ public abstract class PsiAnchor {
final StubBasedPsiElement elt = (StubBasedPsiElement)element;
if (elt.getStub() != null || elt.getElementType().shouldCreateStub(element.getNode())) {
int index = calcStubIndex((StubBasedPsiElement)element);
if (index != -1) return new StubIndexReference(file, index);
if (index != -1) return new StubIndexReference(file, index, elt.getElementType());
}
}
@@ -220,8 +221,10 @@ public abstract class PsiAnchor {
private final VirtualFile myVirtualFile;
private final Project myProject;
private final int myIndex;
private final IStubElementType myElementType;
public StubIndexReference(@NotNull PsiFile file, final int index) {
public StubIndexReference(@NotNull PsiFile file, final int index, IStubElementType elementType) {
myElementType = elementType;
myVirtualFile = file.getVirtualFile();
myProject = file.getProject();
myIndex = index;
@@ -253,6 +256,8 @@ public abstract class PsiAnchor {
if (myIndex >= list.size()) return null;
StubElement stub = list.get(myIndex);
if (stub.getStubType() != myElementType) return null;
if (foreign) {
final PsiElement cachedPsi = ((StubBase)stub).getCachedPsi();
if (cachedPsi != null) return cachedPsi;
@@ -274,12 +279,12 @@ public abstract class PsiAnchor {
final StubIndexReference that = (StubIndexReference)o;
return myIndex == that.myIndex && myVirtualFile.equals(that.myVirtualFile);
return myIndex == that.myIndex && myVirtualFile.equals(that.myVirtualFile) && myElementType.equals(that.myElementType);
}
@Override
public int hashCode() {
return 31 * myVirtualFile.hashCode() + myIndex;
return (31 * myVirtualFile.hashCode() + myIndex) * 31 + myElementType.hashCode();
}
public int getStartOffset() {
@@ -68,7 +68,7 @@ public class SharedPsiElementImplUtil {
LOG.error(element);
}
for (TextRange range : ReferenceRange.getRanges(reference)) {
if (range.getStartOffset() <= offset && offset <= range.getEndOffset()) {
if (range.containsOffset(offset)) {
outReferences.add(reference);
}
}
@@ -91,6 +91,11 @@ public class RenameDialog extends RefactoringDialog {
myHelpID = RenamePsiElementProcessor.forElement(psiElement).getHelpID(psiElement);
}
@Override
protected boolean hasPreviewButton() {
return RenamePsiElementProcessor.forElement(myPsiElement).showRenamePreviewButton(myPsiElement);
}
protected void dispose() {
myNameSuggestionsField.removeDataChangedListener(myNameChangedListener);
super.dispose();
@@ -139,6 +139,10 @@ public abstract class RenamePsiElementProcessor {
}
}
public boolean showRenamePreviewButton(final PsiElement psiElement){
return true;
}
/**
* Returns the element to be renamed instead of the element on which the rename refactoring was invoked (for example, a super method
* of an inherited method).
@@ -37,6 +37,21 @@ public abstract class FileEditorManager {
*/
@NotNull public abstract FileEditor[] openFile(@NotNull VirtualFile file, boolean focusEditor);
/**
* Opens a file
*
* @param file file to open
* @param focusEditor <code>true</code> if need to focus
* @param useActiveSplitter if <code>false</code> then manager will search
* the file through all splitters
*
* @return array of opened editors
*/
@NotNull public FileEditor[] openFile(@NotNull VirtualFile file, boolean focusEditor, boolean useActiveSplitter) {
throw new UnsupportedOperationException("Not implemented");
}
/**
* Closes all editors opened for the file.
*
@@ -1,41 +0,0 @@
/*
* Copyright 2000-2009 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.ide.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindowManager;
public class CodeEditorActionGroup extends DefaultActionGroup implements DumbAware {
public CodeEditorActionGroup() {
super();
}
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
Project project = PlatformDataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
presentation.setVisible(false);
return;
}
boolean active = ToolWindowManager.getInstance(project).isEditorComponentActive();
presentation.setVisible(active);
}
}
@@ -21,8 +21,11 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.fileEditor.impl.EditorHistoryManager;
import com.intellij.openapi.fileEditor.impl.EditorWindow;
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
@@ -102,11 +105,13 @@ public class Switcher extends AnAction implements DumbAware {
public void actionPerformed(AnActionEvent e) {
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
if (project == null) return;
boolean selectFirstItem = false;
if (SWITCHER == null) {
synchronized (Switcher.class) {
if (SWITCHER == null) {
SWITCHER = new SwitcherPanel(project);
FeatureUsageTracker.getInstance().triggerFeatureUsed(SWITCHER_FEATURE_ID);
selectFirstItem = !FileEditorManagerEx.getInstanceEx(project).hasOpenedFile();
}
}
}
@@ -114,7 +119,11 @@ public class Switcher extends AnAction implements DumbAware {
if (e.getInputEvent().isShiftDown()) {
SWITCHER.goBack();
} else {
SWITCHER.goForward();
if (selectFirstItem) {
SWITCHER.files.setSelectedIndex(0);
} else {
SWITCHER.goForward();
}
}
}
@@ -128,6 +137,7 @@ public class Switcher extends AnAction implements DumbAware {
final JLabel pathLabel = new JLabel(" ");
final JPanel descriptions;
final Project project;
final Map<VirtualFile, FileEditor> files2editors;
SwitcherPanel(Project project) {
super(new BorderLayout(0, 0));
@@ -212,11 +222,20 @@ public class Switcher extends AnAction implements DumbAware {
separator.setBackground(Color.WHITE);
final FileEditorManager editorManager = FileEditorManager.getInstance(project);
final VirtualFile[] openFiles = editorManager.getOpenFiles();
try {
Arrays.sort(openFiles, new RecentFilesComparator(project));
} catch (Exception e) {// IndexNotReadyException
final FileEditor[] allEditors = editorManager.getAllEditors();
files2editors = new HashMap<VirtualFile, FileEditor>();
for (FileEditor editor : allEditors) {
files2editors.put(((FileEditorManagerImpl)editorManager).getFile(editor), editor);
}
final VirtualFile[] recentFiles = EditorHistoryManager.getInstance(project).getFiles();
final ArrayList<VirtualFile> openFiles = new ArrayList<VirtualFile>();
for (VirtualFile recentFile : recentFiles) {
openFiles.add(0, recentFile);
}
final ArrayList<VirtualFile> tmp = new ArrayList<VirtualFile>(files2editors.keySet());
tmp.removeAll(openFiles);
for (VirtualFile virtualFile : tmp) {
openFiles.add(0, virtualFile);
}
final DefaultListModel filesModel = new DefaultListModel();
@@ -315,7 +334,15 @@ public class Switcher extends AnAction implements DumbAware {
return true;
}
}).createPopup();
myPopup.showInCenterOf(ideFrame.getContentPane());
Component comp = null;
final EditorWindow result = FileEditorManagerEx.getInstanceEx(project).getActiveWindow().getResult();
if (result != null) {
comp = result.getOwner();
}
if (comp == null) {
comp = ideFrame.getContentPane();
}
myPopup.showInCenterOf(comp);
}
private int getModifiers(ShortcutSet shortcutSet) {
@@ -494,7 +521,8 @@ public class Switcher extends AnAction implements DumbAware {
((ToolWindow)value).activate(null, true, true);
}
else if (value instanceof VirtualFile) {
FileEditorManager.getInstance(project).openFile((VirtualFile)value, true);
final VirtualFile file = (VirtualFile)value;
FileEditorManager.getInstance(project).openFile(file, true, true);
}
}
@@ -123,10 +123,18 @@ public abstract class FileEditorManagerEx extends FileEditorManager {
@NotNull
public FileEditor[] openFile(@NotNull final VirtualFile file, final boolean focusEditor) {
return openFileWithProviders(file, focusEditor).getFirst ();
return openFileWithProviders(file, focusEditor, false).getFirst ();
}
@NotNull public abstract Pair<FileEditor[],FileEditorProvider[]> openFileWithProviders(@NotNull VirtualFile file, boolean focusEditor);
@NotNull
@Override
public FileEditor[] openFile(@NotNull VirtualFile file, boolean focusEditor, boolean useActiveSplitter) {
return openFileWithProviders(file, focusEditor, useActiveSplitter).getFirst();
}
@NotNull public abstract Pair<FileEditor[],FileEditorProvider[]> openFileWithProviders(@NotNull VirtualFile file,
boolean focusEditor,
boolean useActiveSplitter);
public abstract boolean isChanged(@NotNull EditorComposite editor);
@@ -547,18 +547,34 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
//-------------------------------------- Open File ----------------------------------------
@NotNull public Pair<FileEditor[], FileEditorProvider[]> openFileWithProviders(@NotNull final VirtualFile file, final boolean focusEditor) {
@NotNull public Pair<FileEditor[], FileEditorProvider[]> openFileWithProviders(@NotNull final VirtualFile file,
final boolean focusEditor,
boolean useActiveSplitter) {
if (!file.isValid()) {
throw new IllegalArgumentException("file is not valid: " + file);
}
assertDispatchThread();
EditorsSplitters splitters = getSplitters();
EditorWindow wndToOpenIn = splitters.getCurrentWindow();
EditorWindow wndToOpenIn = null;
if (useActiveSplitter) {
for (EditorsSplitters splitters : getAllSplitters()) {
final EditorWindow window = splitters.getCurrentWindow();
if (window == null) continue;
if (window.isFileOpen(file)) {
wndToOpenIn = window;
if (wndToOpenIn != getActiveWindow().getResult()) {
System.out.println("Not active");
}
break;
}
}
} else {
wndToOpenIn = getSplitters().getCurrentWindow();
}
if (wndToOpenIn == null) {
wndToOpenIn = splitters.getOrCreateCurrentWindow(file);
wndToOpenIn = getSplitters().getOrCreateCurrentWindow(file);
}
return openFileImpl2(wndToOpenIn, file, focusEditor);
}
@@ -728,7 +744,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
if (!ApplicationManagerEx.getApplicationEx().isUnitTestMode()) {
if (focusEditor) {
//myFirstIsActive = myTabbedContainer1.equals(tabbedContainer);
window.setAsCurrentWindow(false);
window.setAsCurrentWindow(true);
ToolWindowManager.getInstance(myProject).activateEditorComponent();
}
}
@@ -1018,10 +1034,13 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
public FileEditor[] getAllEditors() {
assertReadAccess();
final ArrayList<FileEditor> result = new ArrayList<FileEditor>();
final EditorWithProviderComposite[] editorsComposites = getSplitters().getEditorsComposites();
for (EditorWithProviderComposite editorsComposite : editorsComposites) {
final FileEditor[] editors = editorsComposite.getEditors();
ContainerUtil.addAll(result, editors);
final Set<EditorsSplitters> allSplitters = getAllSplitters();
for (EditorsSplitters splitter : allSplitters) {
final EditorWithProviderComposite[] editorsComposites = splitter.getEditorsComposites();
for (EditorWithProviderComposite editorsComposite : editorsComposites) {
final FileEditor[] editors = editorsComposite.getEditors();
ContainerUtil.addAll(result, editors);
}
}
return result.toArray(new FileEditor[result.size()]);
}
@@ -1168,15 +1187,17 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
private EditorWithProviderComposite getEditorComposite(@NotNull final FileEditor editor) {
final EditorWithProviderComposite[] editorsComposites = getSplitters().getEditorsComposites();
for (int i = editorsComposites.length - 1; i >= 0; i--) {
final EditorWithProviderComposite composite = editorsComposites[i];
final FileEditor[] editors = composite.getEditors();
for (int j = editors.length - 1; j >= 0; j--) {
final FileEditor _editor = editors[j];
LOG.assertTrue(_editor != null);
if (editor.equals(_editor)) {
return composite;
for (EditorsSplitters splitters : getAllSplitters()) {
final EditorWithProviderComposite[] editorsComposites = splitters.getEditorsComposites();
for (int i = editorsComposites.length - 1; i >= 0; i--) {
final EditorWithProviderComposite composite = editorsComposites[i];
final FileEditor[] editors = composite.getEditors();
for (int j = editors.length - 1; j >= 0; j--) {
final FileEditor _editor = editors[j];
LOG.assertTrue(_editor != null);
if (editor.equals(_editor)) {
return composite;
}
}
}
}
@@ -443,7 +443,7 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Projec
private void gotoPlaceInfo(@NotNull PlaceInfo info) { // TODO: Msk
final boolean wasActive = myToolWindowManager.isEditorComponentActive();
final Pair<FileEditor[],FileEditorProvider[]> editorsWithProviders = myEditorManager.openFileWithProviders(info.getFile(), wasActive);
final Pair<FileEditor[],FileEditorProvider[]> editorsWithProviders = myEditorManager.openFileWithProviders(info.getFile(), wasActive, false);
final FileEditor [] editors = editorsWithProviders.getFirst();
final FileEditorProvider[] providers = editorsWithProviders.getSecond();
for (int i = 0; i < editors.length; i++) {
@@ -134,7 +134,7 @@
<group id="CodeEditorBaseGroup">
<separator/>
<group id="CodeEditorViewGroup" class="com.intellij.ide.actions.CodeEditorActionGroup">
<group id="CodeEditorViewGroup">
<action id="FileStructurePopup" class="com.intellij.ide.actions.ViewStructureAction"/>
<action id="QuickJavaDoc" class="com.intellij.codeInsight.documentation.actions.ShowJavaDocInfoAction"/>
<action id="ExternalJavaDoc" class="com.intellij.ide.actions.ExternalJavaDocAction"/>
@@ -146,7 +146,7 @@
</group>
<separator/>
<group id="ProjectViewGroup" class="com.intellij.ide.projectView.actions.ProjectViewActionGroup">
<group id="ProjectViewGroup">
<action id="ProjectViewChangeView" class="com.intellij.ide.projectView.actions.ChangeProjectViewAction"/>
</group>
<separator/>
@@ -156,7 +156,7 @@
<add-to-group group-id="ViewMenu" relative-to-action="QuickChangeScheme" anchor="after"/>
</group>
<group id="FoldingGroup" class="com.intellij.codeInsight.folding.impl.actions.FoldingActionGroup" popup="true">
<group id="FoldingGroup" popup="true">
<action id="ExpandRegion" class="com.intellij.codeInsight.folding.impl.actions.ExpandRegionAction"/>
<action id="CollapseRegion" class="com.intellij.codeInsight.folding.impl.actions.CollapseRegionAction"/>
<separator/>
@@ -66,7 +66,9 @@ import java.util.Map;
@Override
@NotNull
public Pair<FileEditor[], FileEditorProvider[]> openFileWithProviders(@NotNull VirtualFile file, boolean focusEditor) {
public Pair<FileEditor[], FileEditorProvider[]> openFileWithProviders(@NotNull VirtualFile file,
boolean focusEditor,
boolean useActiveSplitter) {
Editor editor = openTextEditor(new OpenFileDescriptor(myProject, file), focusEditor);
final FileEditor fileEditor = TextEditorProvider.getInstance().getTextEditor(editor);
return Pair.create (new FileEditor[] {fileEditor}, new FileEditorProvider[] {getProvider (fileEditor)});
@@ -31,6 +31,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
* Date: Aug 24, 2010
*/
public class LowMemoryWatcher {
private static final long MEM_THRESHOLD = 5 /*MB*/ * 1024 * 1024;
public static abstract class ForceableAdapter implements Forceable {
public boolean isDirty() {
@@ -49,6 +50,7 @@ public class LowMemoryWatcher {
static {
final Thread thread = new Thread("LowMemoryWatcher") {
boolean shouldCleanup = false;
public void run() {
updateRef();
final Set<WeakReference<LowMemoryWatcher>> toRemove = new HashSet<WeakReference<LowMemoryWatcher>>();
@@ -57,18 +59,25 @@ public class LowMemoryWatcher {
try {
ourRefQueue.remove();
updateRef();
if (!shouldCleanup) {
final Runtime runtime = Runtime.getRuntime();
shouldCleanup = (runtime.maxMemory() - runtime.totalMemory()) <= MEM_THRESHOLD;
}
for (WeakReference<LowMemoryWatcher> instanceRef : ourInstances) {
final LowMemoryWatcher watcher = instanceRef.get();
if (watcher == null) {
toRemove.add(instanceRef);
}
else {
try {
watcher.doCleanup();
}
catch (Throwable e) {
LOG.info(e);
if (shouldCleanup) {
try {
watcher.doCleanup();
}
catch (Throwable e) {
LOG.info(e);
}
}
}
}
@@ -57,6 +57,10 @@ public class TextRange {
return myStartOffset <= startOffset && myEndOffset >= endOffset;
}
public boolean containsOffset(int offset) {
return myStartOffset <= offset && offset <= myEndOffset;
}
public String toString() {
return "(" + myStartOffset + "," + myEndOffset + ")";
}
@@ -131,16 +131,7 @@ public class GrabDependencies implements IntentionAction {
return grAnnotation.getText();
}
};
String common = StringUtil.join(excludes, mapper, ",");
if (!resolvers.isEmpty()) {
if (!common.isEmpty()) {
common += ",";
}
common += StringUtil.join(resolvers, mapper, ",");
}
if (!common.isEmpty()) {
common = "," + common;
}
String common = StringUtil.join(excludes, mapper, " ") + " " + StringUtil.join(resolvers, mapper, " ");
final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
assert sdk != null;
@@ -151,7 +142,7 @@ public class GrabDependencies implements IntentionAction {
final Map<String, GeneralCommandLine> lines = new HashMap<String, GeneralCommandLine>();
for (GrAnnotation grab : grabs) {
String grabText = grab.getText();
String query = "@Grapes([" + grabText + common + "])";
String query = grabText + " " + common;
final JavaParameters javaParameters = GroovyScriptRunConfiguration.createJavaParametersWithSdk(module);
//debug
@@ -71,7 +71,7 @@ public class GroovyClassNameInsertHandler implements InsertHandler<JavaPsiClassR
}
AllClassesGetter.TRY_SHORTENING.handleInsert(context, item);
if (inNew && !JavaCompletionUtil.hasAccessibleInnerClass(psiClass, position)) {
if (inNew && !JavaCompletionUtil.hasAccessibleInnerClass(psiClass, file)) {
JavaCompletionUtil.insertParentheses(context, item, false, GroovyCompletionUtil.hasConstructorParameters(psiClass));
}
@@ -259,6 +259,7 @@ public class GroovyCompletionUtil {
}
public static LookupElement createClassLookupItem(PsiClass psiClass) {
assert psiClass.isValid();
return AllClassesGetter.createLookupItem(psiClass, new GroovyClassNameInsertHandler());
}
@@ -20,6 +20,8 @@ import com.intellij.execution.JavaExecutionUtil;
import com.intellij.execution.junit.JUnitConfiguration;
import com.intellij.execution.junit.JUnitUtil;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
@@ -84,12 +86,20 @@ public class JUnitConfigurationModel {
final String className = getJUnitTextValue(CLASS);
data.TEST_OBJECT = testObject;
if (testObject != JUnitConfiguration.TEST_PACKAGE && testObject != JUnitConfiguration.TEST_PATTERN) {
final PsiClass testClass = JUnitUtil.findPsiClass(className, module, myProject);
data.METHOD_NAME = getJUnitTextValue(METHOD);
if (testClass != null && testClass.isValid()) {
data.setMainClass(testClass);
try {
data.METHOD_NAME = getJUnitTextValue(METHOD);
final PsiClass testClass = JUnitUtil.findPsiClass(className, module, myProject);
if (testClass != null && testClass.isValid()) {
data.setMainClass(testClass);
}
else {
data.MAIN_CLASS_NAME = className;
}
}
else {
catch (ProcessCanceledException e) {
data.MAIN_CLASS_NAME = className;
}
catch (IndexNotReadyException e) {
data.MAIN_CLASS_NAME = className;
}
}
@@ -169,7 +169,7 @@ public class DomElementProblemDescriptorImpl implements DomElementProblemDescrip
private static Pair<TextRange, PsiElement> createTagNameRange(final XmlTag tag) {
final PsiElement startToken = XmlTagUtil.getStartTagNameElement(tag);
assert startToken != null;
assert startToken != null : tag.getText();
return Pair.create(startToken.getTextRange().shiftRight(-tag.getTextRange().getStartOffset()), (PsiElement)tag);
}
@@ -15,6 +15,7 @@
*/
package com.intellij.util.xml.impl;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlEntityRef;
@@ -82,10 +83,28 @@ public class PhysicalDomParentStrategy implements DomParentStrategy {
final XmlElement thatElement = ((PhysicalDomParentStrategy)o).myElement;
if (xmlElementsEqual(myElement, thatElement)) {
if (myElement != thatElement) {
//todo remove this assertion before X release
if (ApplicationManagerEx.getApplicationEx().isInternal()) {
PsiElement cur = myElement;
while (cur != null && !cur.isPhysical()) {
cur = cur.getParent();
}
throw new AssertionError(myElement.getText() + "; including=" + (cur == null ? null : cur.getText()));
}
final PsiElement nav1 = myElement.getNavigationElement();
final PsiElement nav2 = thatElement.getNavigationElement();
assert nav1 == nav2 : nav1.getContainingFile() + ":" + nav1.getTextRange().getStartOffset() + "!=" + nav2.getContainingFile() + ":" + nav2.getTextRange().getStartOffset() +
"; " + (nav1==myElement) + ";" + (nav2==thatElement);
assert nav1 == nav2 : nav1.getContainingFile() +
":" +
nav1.getTextRange().getStartOffset() +
"!=" +
nav2.getContainingFile() +
":" +
nav2.getTextRange().getStartOffset() +
"; " +
(nav1 == myElement) +
";" +
(nav2 == thatElement);
}
return true;
}
@@ -95,7 +114,7 @@ public class PhysicalDomParentStrategy implements DomParentStrategy {
private static boolean xmlElementsEqual(@NotNull final PsiElement fst, @NotNull final PsiElement snd) {
if (fst.equals(snd)) return true;
if (fst.isPhysical() || snd.isPhysical()) return false;
if (fst.isValid() && fst.isPhysical() || snd.isValid() && snd.isPhysical()) return false;
if (fst.getTextLength() != snd.getTextLength()) return false;
if (fst.getStartOffsetInParent() != snd.getStartOffsetInParent()) return false;