();
data.addKeywordVariants(toAdd, insertedElement, file);
for (CompletionVariant completionVariant : toAdd) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java
index c37adbf42774..4451797b3b26 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java
@@ -24,6 +24,7 @@ import com.intellij.codeInsight.daemon.impl.actions.ShowErrorDescriptionAction;
import com.intellij.codeInsight.hint.LineTooltipRenderer;
import com.intellij.codeInsight.hint.TooltipLinkHandlerEP;
import com.intellij.codeInsight.hint.TooltipRenderer;
+import com.intellij.codeInspection.ui.DefaultInspectionToolPresentation;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ex.ErrorStripTooltipRendererProvider;
import com.intellij.openapi.editor.impl.TrafficTooltipRenderer;
@@ -42,8 +43,6 @@ import javax.swing.*;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererProvider {
@NonNls private static final String END_MARKER = "";
@@ -143,20 +142,7 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP
if (ref != null) {
String description = TooltipLinkHandlerEP.getDescription(ref, editor);
if (description != null) {
- description = UIUtil.getHtmlBody(description);
- final int descriptionEnd = description.indexOf("");
- if (descriptionEnd < 0) {
- final Pattern pattern = Pattern.compile(".*Use.*(the (panel|checkbox|checkboxes|field|button|controls).*below).*", Pattern.DOTALL);
- final Matcher matcher = pattern.matcher(description);
- int startFindIdx = 0;
- while (matcher.find(startFindIdx)) {
- final int end = matcher.end(1);
- startFindIdx = end;
- description = description.substring(0, matcher.start(1)) + " inspection settings " + description.substring(end);
- }
- } else {
- description = description.substring(0, descriptionEnd);
- }
+ description = DefaultInspectionToolPresentation.stripUIRefsFromInspectionDescription(UIUtil.getHtmlBody(description));
text += UIUtil.getHtmlBody(problem).replace(DaemonBundle.message("inspection.extended.description"),
DaemonBundle.message("inspection.collapse.description")) +
END_MARKER + "" + description + BORDER_LINE;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java
index ec2b0f7b2f1d..0d1f3590699c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java
@@ -221,7 +221,7 @@ public class InjectedGeneralHighlightingPass extends GeneralHighlightingPass imp
if (textRange.isEmpty()) continue;
String desc = injectedPsi.getLanguage().getDisplayName() + ": " + injectedPsi.getText();
HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_BACKGROUND).range(textRange);
- if (injectedAttributes != null && !InjectedLanguageUtil.suppressInjectionBackground(host)) {
+ if (injectedAttributes != null && InjectedLanguageUtil.isHighlightInjectionBackground(host)) {
builder.textAttributes(injectedAttributes);
}
builder.unescapedToolTip(desc);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java
index 7c237915a1fa..89e8b55f9b4c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java
@@ -32,6 +32,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiWhiteSpace;
+import com.intellij.reference.SoftReference;
import com.intellij.ui.popup.PopupFactoryImpl;
import com.intellij.util.Alarm;
import com.intellij.util.containers.WeakHashMap;
@@ -169,11 +170,7 @@ public class QuickDocOnMouseOverManager {
if (hint != null) {
// Skip the event if the control is shown because of explicit 'show quick doc' action call.
- WeakReference ref = myDocumentationManager;
- if (ref == null) {
- return;
- }
- DocumentationManager manager = ref.get();
+ DocumentationManager manager = SoftReference.dereference(myDocumentationManager);
if (manager == null || !manager.isCloseOnSneeze()) {
return;
}
@@ -257,16 +254,7 @@ public class QuickDocOnMouseOverManager {
@Nullable
private DocumentationManager getDocManager() {
- WeakReference ref = myDocumentationManager;
- if (ref == null) {
- return null;
- }
-
- DocumentationManager docManager = ref.get();
- if (docManager == null) {
- return null;
- }
- return docManager;
+ return SoftReference.dereference(myDocumentationManager);
}
private static class DelayedQuickDocInfo {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java
index a574ce0c5465..528187a0e6b2 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.editorActions.wordSelection;
import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
@@ -38,7 +39,8 @@ public class NaturalLanguageTextSelectioner extends ExtendWordSelectionHandlerBa
@Override
public boolean canSelect(PsiElement e) {
- return e instanceof PsiPlainText || e instanceof PsiComment;
+ return (e instanceof PsiPlainText || e instanceof PsiComment) &&
+ !(e.getContainingFile().getFileType() instanceof CustomSyntaxTableFileType);
}
private static TextRange findParagraphRange(String text, int start, int end) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java
index 6b94a3f6a61e..0576f1d09a76 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java
@@ -82,7 +82,7 @@ public class HighlightUsagesHandler extends HighlightHandlerBase {
if (usageTargets == null) {
PsiElement targetElement = getTargetElement(editor, file);
- if (targetElement != null) {
+ if (targetElement != null && targetElement != file) {
if (!(targetElement instanceof NavigationItem)) {
targetElement = targetElement.getNavigationElement();
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java
index b0e1e6c38265..5ccd71b866c7 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java
@@ -29,6 +29,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
+import com.intellij.reference.SoftReference;
import com.intellij.ui.LightweightHint;
import org.jetbrains.annotations.NotNull;
@@ -45,14 +46,12 @@ public class ShowContainerInfoHandler implements CodeInsightActionHandler {
PsiElement container = null;
WeakReference ref = editor.getUserData(MY_LAST_HINT_KEY);
- if (ref != null){
- LightweightHint hint = ref.get();
- if (hint != null && hint.isVisible()){
- hint.hide();
- container = hint.getUserData(CONTAINER_KEY);
- if (container != null && !container.isValid()){
- container = null;
- }
+ LightweightHint hint = SoftReference.dereference(ref);
+ if (hint != null && hint.isVisible()){
+ hint.hide();
+ container = hint.getUserData(CONTAINER_KEY);
+ if (container != null && !container.isValid()){
+ container = null;
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java
index f9f37713e138..2af811074a54 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java
@@ -44,6 +44,7 @@ import com.intellij.psi.*;
import com.intellij.psi.presentation.java.SymbolPresentationUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.reference.SoftReference;
import com.intellij.ui.popup.AbstractPopup;
import com.intellij.ui.popup.NotLookupOrSearchCondition;
import com.intellij.ui.popup.PopupPositionManager;
@@ -226,18 +227,16 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
final Ref usageView = new Ref();
final String title = CodeInsightBundle.message("implementation.view.title", text);
- if (myPopupRef != null) {
- final JBPopup popup = myPopupRef.get();
- if (popup != null && popup.isVisible() && popup instanceof AbstractPopup) {
- final ImplementationViewComponent component = (ImplementationViewComponent) ((AbstractPopup)popup).getComponent();
- ((AbstractPopup)popup).setCaption(title);
- component.update(impls, index);
- updateInBackground(editor, element, component, title, (AbstractPopup)popup, usageView);
- if (invokedByShortcut) {
- ((AbstractPopup)popup).focusPreferredComponent();
- }
- return;
+ JBPopup popup = SoftReference.dereference(myPopupRef);
+ if (popup != null && popup.isVisible() && popup instanceof AbstractPopup) {
+ final ImplementationViewComponent component = (ImplementationViewComponent) ((AbstractPopup)popup).getComponent();
+ ((AbstractPopup)popup).setCaption(title);
+ component.update(impls, index);
+ updateInBackground(editor, element, component, title, (AbstractPopup)popup, usageView);
+ if (invokedByShortcut) {
+ ((AbstractPopup)popup).focusPreferredComponent();
}
+ return;
}
final ImplementationViewComponent component = new ImplementationViewComponent(impls, index);
@@ -250,7 +249,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
}
};
- final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component.getPreferredFocusableComponent())
+ popup = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component.getPreferredFocusableComponent())
.setRequestFocusCondition(project, NotLookupOrSearchCondition.INSTANCE)
.setProject(project)
.addListener(updateProcessor)
@@ -284,11 +283,9 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
ImplementationViewComponent component,
String title,
AbstractPopup popup, Ref usageView) {
- if (myTaskRef != null) {
- final BackgroundUpdaterTask updaterTask = myTaskRef.get();
- if (updaterTask != null) {
- updaterTask.setCanceled();
- }
+ final BackgroundUpdaterTask updaterTask = SoftReference.dereference(myTaskRef);
+ if (updaterTask != null) {
+ updaterTask.setCanceled();
}
if (element == null) return; //already found
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/AbstractDocumentationTooltipAction.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/AbstractDocumentationTooltipAction.java
index 713b434cb395..c0a4780a24cc 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/AbstractDocumentationTooltipAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/AbstractDocumentationTooltipAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement;
+import com.intellij.reference.SoftReference;
import com.intellij.util.PatchedWeakReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -64,19 +65,11 @@ public abstract class AbstractDocumentationTooltipAction extends AnAction {
@Nullable
private Pair getDocInfo() {
- WeakReference docAnchorRef = myDocAnchor;
- if (docAnchorRef == null) {
- return null;
- }
- PsiElement docAnchor = docAnchorRef.get();
+ PsiElement docAnchor = SoftReference.dereference(myDocAnchor);
if (docAnchor == null) {
return null;
}
- WeakReference originalElementRef = myOriginalElement;
- if (originalElementRef == null) {
- return null;
- }
- PsiElement originalElement = originalElementRef.get();
+ PsiElement originalElement = SoftReference.dereference(myOriginalElement);
if (originalElement == null) {
return null;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewManager.java b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewManager.java
index 2336a9c19196..b96666b00e1c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewManager.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewManager.java
@@ -33,6 +33,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
+import com.intellij.reference.SoftReference;
import com.intellij.util.Alarm;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -160,15 +161,17 @@ public class ImageOrColorPreviewManager implements Disposable, EditorMouseMotion
if (elementRef == null && event.getMouseEvent().isShiftDown()) {
alarm.addRequest(new PreviewRequest(point, editor, false), 100);
}
- else if (elementRef != null && elementRef.get() != getPsiElementAt(point, editor)) {
- PsiElement element = elementRef.get();
- elementRef = null;
- for (ElementPreviewProvider provider : Extensions.getExtensions(ElementPreviewProvider.EP_NAME)) {
- try {
- provider.hide(element, editor);
- }
- catch (Exception e) {
- LOG.error(e);
+ else {
+ PsiElement element = SoftReference.dereference(elementRef);
+ if (element != getPsiElementAt(point, editor)) {
+ elementRef = null;
+ for (ElementPreviewProvider provider : Extensions.getExtensions(ElementPreviewProvider.EP_NAME)) {
+ try {
+ provider.hide(element, editor);
+ }
+ catch (Exception e) {
+ LOG.error(e);
+ }
}
}
}
@@ -193,7 +196,7 @@ public class ImageOrColorPreviewManager implements Disposable, EditorMouseMotion
@Override
public void run() {
PsiElement element = getPsiElementAt(point, editor);
- if (element == null || !element.isValid() || (elementRef != null && elementRef.get() == element)) {
+ if (element == null || !element.isValid() || SoftReference.dereference(elementRef) == element) {
return;
}
if (PsiDocumentManager.getInstance(element.getProject()).isUncommited(editor.getDocument()) || DumbService.getInstance(element.getProject()).isDumb()) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImagePreviewComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImagePreviewComponent.java
index 3baa777939ce..ca3e581dfd73 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImagePreviewComponent.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImagePreviewComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,7 +103,7 @@ public class ImagePreviewComponent extends JPanel implements PreviewHintComponen
private static boolean refresh(@NotNull VirtualFile file) throws IOException {
Long loadedTimeStamp = file.getUserData(TIMESTAMP_KEY);
SoftReference imageRef = file.getUserData(BUFFERED_IMAGE_REF_KEY);
- if (loadedTimeStamp == null || loadedTimeStamp < file.getTimeStamp() || imageRef == null || imageRef.get() == null) {
+ if (loadedTimeStamp == null || loadedTimeStamp < file.getTimeStamp() || SoftReference.dereference(imageRef) == null) {
try {
final byte[] content = file.contentsToByteArray();
InputStream inputStream = new ByteArrayInputStream(content, 0, content.length);
@@ -153,11 +153,9 @@ public class ImagePreviewComponent extends JPanel implements PreviewHintComponen
try {
refresh(file);
SoftReference imageRef = file.getUserData(BUFFERED_IMAGE_REF_KEY);
- if (imageRef != null) {
- final BufferedImage image = imageRef.get();
- if (image != null) {
- return new ImagePreviewComponent(image, file.getLength());
- }
+ final BufferedImage image = SoftReference.dereference(imageRef);
+ if (image != null) {
+ return new ImagePreviewComponent(image, file.getLength());
}
}
catch (IOException ignored) {
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java
index 2dc1cf0b1b4c..9db2d9e1afdf 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java
@@ -450,7 +450,7 @@ class Browser extends JPanel {
if (description == null) {
description = underConstruction;
}
- page.append(UIUtil.getHtmlBody(description));
+ page.append(DefaultInspectionToolPresentation.stripUIRefsFromInspectionDescription(UIUtil.getHtmlBody(description)));
page.append("");
myHTMLViewer.setText(XmlStringUtil.wrapInHtml(page));
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java
index 212489bda65f..fe7c3ab22b81 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java
@@ -51,6 +51,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.tree.DefaultTreeModel;
import java.io.*;
import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class DefaultInspectionToolPresentation implements ProblemDescriptionsProcessor, InspectionToolPresentation {
@NotNull private final InspectionToolWrapper myToolWrapper;
@@ -91,6 +93,23 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
return FileStatus.NOT_CHANGED;
}
+ public static String stripUIRefsFromInspectionDescription(String description) {
+ final int descriptionEnd = description.indexOf("");
+ if (descriptionEnd < 0) {
+ final Pattern pattern = Pattern.compile(".*Use.*(the (panel|checkbox|checkboxes|field|button|controls).*below).*", Pattern.DOTALL);
+ final Matcher matcher = pattern.matcher(description);
+ int startFindIdx = 0;
+ while (matcher.find(startFindIdx)) {
+ final int end = matcher.end(1);
+ startFindIdx = end;
+ description = description.substring(0, matcher.start(1)) + " inspection settings " + description.substring(end);
+ }
+ } else {
+ description = description.substring(0, descriptionEnd);
+ }
+ return description;
+ }
+
protected HighlightSeverity getSeverity(@NotNull RefElement element) {
final PsiElement psiElement = element.getPointer().getContainingFile();
if (psiElement != null) {
diff --git a/platform/lang-impl/src/com/intellij/find/FindBundle.java b/platform/lang-impl/src/com/intellij/find/FindBundle.java
index 129858ae9ce8..e4c431bf9bf3 100644
--- a/platform/lang-impl/src/com/intellij/find/FindBundle.java
+++ b/platform/lang-impl/src/com/intellij/find/FindBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,8 +40,7 @@ public class FindBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeFoldingBuilder.java b/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeFoldingBuilder.java
new file mode 100644
index 000000000000..9dca9c5b7f60
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeFoldingBuilder.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.highlighter.custom.impl;
+
+import com.intellij.codeInsight.highlighting.BraceMatcher;
+import com.intellij.codeInsight.highlighting.BraceMatchingUtil;
+import com.intellij.ide.highlighter.custom.CustomFileHighlighter;
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.folding.CustomFoldingBuilder;
+import com.intellij.lang.folding.FoldingDescriptor;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter;
+import com.intellij.openapi.editor.highlighter.HighlighterIterator;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.fileTypes.SyntaxHighlighter;
+import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.Trinity;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author yole
+ */
+public class CustomFileTypeFoldingBuilder extends CustomFoldingBuilder {
+
+ @Override
+ protected void buildLanguageFoldRegions(@NotNull List descriptors,
+ @NotNull PsiElement root,
+ @NotNull Document document,
+ boolean quick) {
+ FileType fileType = root.getContainingFile().getFileType();
+ if (!(fileType instanceof CustomSyntaxTableFileType)) {
+ return;
+ }
+ CustomFileHighlighter highlighter = new CustomFileHighlighter(((CustomSyntaxTableFileType) fileType).getSyntaxTable());
+ buildBraceMatcherBasedFolding(descriptors, root, document, highlighter);
+ }
+
+ public static void buildBraceMatcherBasedFolding(List descriptors,
+ PsiElement root,
+ Document document,
+ SyntaxHighlighter highlighter) {
+ LexerEditorHighlighter editorHighlighter = new LexerEditorHighlighter(highlighter, EditorColorsManager.getInstance().getGlobalScheme());
+ editorHighlighter.setText(document.getText());
+ FileType fileType = root.getContainingFile().getFileType();
+ BraceMatcher braceMatcher = BraceMatchingUtil.getBraceMatcher(fileType, root.getLanguage());
+ TextRange totalRange = root.getTextRange();
+ final HighlighterIterator iterator = editorHighlighter.createIterator(totalRange.getStartOffset());
+
+ final LinkedList> stack = new LinkedList>();
+ String editorText = document.getText();
+ while (!iterator.atEnd() && iterator.getStart() < totalRange.getEndOffset()) {
+ final Trinity last;
+ if (braceMatcher.isLBraceToken(iterator, editorText, fileType) &&
+ braceMatcher.isStructuralBrace(iterator, editorText, fileType)) {
+ stack.addLast(Trinity.create(iterator.getStart(), iterator.getEnd(), iterator.getTokenType()));
+ }
+ else if (braceMatcher.isRBraceToken(iterator, editorText, fileType) &&
+ braceMatcher.isStructuralBrace(iterator, editorText, fileType)
+ && !stack.isEmpty() && braceMatcher.isPairBraces((last = stack.getLast()).third, iterator.getTokenType())) {
+ stack.removeLast();
+ TextRange range = new TextRange(last.first, iterator.getEnd());
+ if (StringUtil.countChars(document.getText(range), '\n') >= 3) {
+ descriptors.add(new FoldingDescriptor(root, range));
+ }
+ }
+ iterator.advance();
+ }
+ }
+
+ @Override
+ protected String getLanguagePlaceholderText(@NotNull ASTNode node, @NotNull TextRange range) {
+ return "{...}";
+ }
+
+ @Override
+ protected boolean isRegionCollapsedByDefault(@NotNull ASTNode node) {
+ return false;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeSelectWordHandler.java b/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeSelectWordHandler.java
new file mode 100644
index 000000000000..cc1b3108d4c6
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeSelectWordHandler.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.highlighter.custom.impl;
+
+import com.intellij.codeInsight.editorActions.BraceMatcherBasedSelectioner;
+import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
+import com.intellij.psi.PsiElement;
+
+/**
+ * @author yole
+ */
+public class CustomFileTypeSelectWordHandler extends BraceMatcherBasedSelectioner {
+ @Override
+ public boolean canSelect(PsiElement e) {
+ return e.getContainingFile().getFileType() instanceof CustomSyntaxTableFileType;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/StandardFileTypeRegistrator.java b/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/StandardFileTypeRegistrator.java
index 772adf695ea5..07b5bb58edd7 100644
--- a/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/StandardFileTypeRegistrator.java
+++ b/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/StandardFileTypeRegistrator.java
@@ -16,8 +16,6 @@
package com.intellij.ide.highlighter.custom.impl;
-import com.intellij.codeInsight.completion.CompletionUtil;
-import com.intellij.codeInsight.completion.SyntaxTableCompletionData;
import com.intellij.codeInsight.editorActions.TypedHandler;
import com.intellij.codeInsight.highlighting.BraceMatchingUtil;
import com.intellij.ide.highlighter.FileTypeRegistrator;
@@ -37,7 +35,6 @@ public class StandardFileTypeRegistrator implements FileTypeRegistrator {
private static void init(final AbstractFileType abstractFileType) {
SyntaxTable table = abstractFileType.getSyntaxTable();
- CompletionUtil.registerCompletionData(abstractFileType,new SyntaxTableCompletionData(table));
if (!isEmpty(table.getStartComment()) && !isEmpty(table.getEndComment()) ||
!isEmpty(table.getLineComment())) {
diff --git a/platform/lang-impl/src/com/intellij/indentation/AbstractIndentParser.java b/platform/lang-impl/src/com/intellij/indentation/AbstractIndentParser.java
index 310f3f025f17..a298b73fda23 100644
--- a/platform/lang-impl/src/com/intellij/indentation/AbstractIndentParser.java
+++ b/platform/lang-impl/src/com/intellij/indentation/AbstractIndentParser.java
@@ -1,9 +1,23 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.indentation;
import com.intellij.lang.ASTNode;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.PsiParser;
-import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.util.containers.HashMap;
@@ -114,7 +128,7 @@ public abstract class AbstractIndentParser implements PsiParser {
}
protected static boolean tokenIn(@Nullable final IElementType elementType, @NotNull final TokenSet tokenSet) {
- return tokenIn(elementType, tokenSet.getTypes());
+ return tokenSet.contains(elementType);
}
@NotNull
diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/WhiteSpaceFormattingStrategyFactory.java b/platform/lang-impl/src/com/intellij/psi/formatter/WhiteSpaceFormattingStrategyFactory.java
index 77acdd406810..4d268f8da1d6 100644
--- a/platform/lang-impl/src/com/intellij/psi/formatter/WhiteSpaceFormattingStrategyFactory.java
+++ b/platform/lang-impl/src/com/intellij/psi/formatter/WhiteSpaceFormattingStrategyFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 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.
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
+import com.intellij.reference.SoftReference;
import com.intellij.util.PatchedWeakReference;
import org.jetbrains.annotations.NotNull;
@@ -74,11 +75,9 @@ public class WhiteSpaceFormattingStrategyFactory {
@NotNull
public static Collection getAllStrategies() {
final WeakReference> reference = myCachedStrategies.get();
- if (reference != null) {
- final Collection strategies = reference.get();
- if (strategies != null) {
- return strategies;
- }
+ final Collection strategies = SoftReference.dereference(reference);
+ if (strategies != null) {
+ return strategies;
}
final Collection languages = Language.getRegisteredLanguages();
if (languages == null) {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
index ef2c75d2c960..b70c3adad85f 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
@@ -497,7 +497,7 @@ public class InjectedLanguageUtil {
return LanguageUtil.isInjectableLanguage(language);
}
- public static boolean suppressInjectionBackground(@Nullable PsiLanguageInjectionHost host) {
- return host instanceof InjectionBackgroundSuppressor;
+ public static boolean isHighlightInjectionBackground(@Nullable PsiLanguageInjectionHost host) {
+ return !(host instanceof InjectionBackgroundSuppressor);
}
}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionBackgroundSuppressor.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionBackgroundSuppressor.java
index d2626123cebf..a98d65303984 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionBackgroundSuppressor.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionBackgroundSuppressor.java
@@ -16,6 +16,8 @@
package com.intellij.psi.impl.source.tree.injected;
/**
+ * Marker interface that suppresses injection background.
+ *
* @author ignatov
*/
public interface InjectionBackgroundSuppressor {
diff --git a/platform/lang-impl/src/com/intellij/semantic/SemServiceImpl.java b/platform/lang-impl/src/com/intellij/semantic/SemServiceImpl.java
index 7d2329aa88fe..ebc286a2dfb0 100644
--- a/platform/lang-impl/src/com/intellij/semantic/SemServiceImpl.java
+++ b/platform/lang-impl/src/com/intellij/semantic/SemServiceImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -282,7 +282,7 @@ public class SemServiceImpl extends SemService{
@Nullable
private SemCacheChunk obtainChunk(@Nullable PsiElement root) {
final SoftReference ref = myCache.get(root);
- return ref == null ? null : ref.get();
+ return com.intellij.reference.SoftReference.dereference(ref);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/tools/ToolsBundle.java b/platform/lang-impl/src/com/intellij/tools/ToolsBundle.java
index f2ec53652e85..997da889eb9c 100644
--- a/platform/lang-impl/src/com/intellij/tools/ToolsBundle.java
+++ b/platform/lang-impl/src/com/intellij/tools/ToolsBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,8 +40,7 @@ public class ToolsBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
index feba37c8888a..57c917b44219 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
@@ -1095,13 +1095,13 @@ public class FileBasedIndexImpl extends FileBasedIndex {
if (myProjectsBeingUpdated.contains(project)) return null;
SoftReference reference = project.getUserData(ourProjectFilesSetKey);
- ProjectIndexableFilesFilter data = reference != null ? reference.get() : null;
+ ProjectIndexableFilesFilter data = com.intellij.reference.SoftReference.dereference(reference);
if (data != null && data.myModificationCount == myFilesModCount) return data;
if (myCalcIndexableFilesLock.tryLock()) { // make best effort for calculating filter
try {
reference = project.getUserData(ourProjectFilesSetKey);
- data = reference != null ? reference.get() : null;
+ data = com.intellij.reference.SoftReference.dereference(reference);
if (data != null && data.myModificationCount == myFilesModCount) {
return data;
}
@@ -1557,7 +1557,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
getInputFilter(requestedIndexId).acceptInput(vFile)) {
// Reasonably attempt to use same file content when calculating indices as we can evaluate them several at once and store in file content
WeakReference previousContentRef = document.getUserData(ourFileContentKey);
- FileContentImpl previousContent = previousContentRef != null ? previousContentRef.get() : null;
+ FileContentImpl previousContent = com.intellij.reference.SoftReference.dereference(previousContentRef);
final FileContentImpl newFc;
if (previousContent != null && previousContent.getStamp() == currentDocStamp) {
newFc = previousContent;
diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/LocalHistoryBundle.java b/platform/lvcs-impl/src/com/intellij/history/integration/LocalHistoryBundle.java
index df58d44c4743..6ff6d8d21fec 100644
--- a/platform/lvcs-impl/src/com/intellij/history/integration/LocalHistoryBundle.java
+++ b/platform/lvcs-impl/src/com/intellij/history/integration/LocalHistoryBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,8 +32,7 @@ public class LocalHistoryBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-api/src/com/intellij/featureStatistics/FeatureStatisticsBundle.java b/platform/platform-api/src/com/intellij/featureStatistics/FeatureStatisticsBundle.java
index b4d2bf408c85..22136335e239 100644
--- a/platform/platform-api/src/com/intellij/featureStatistics/FeatureStatisticsBundle.java
+++ b/platform/platform-api/src/com/intellij/featureStatistics/FeatureStatisticsBundle.java
@@ -54,8 +54,7 @@ public class FeatureStatisticsBundle {
}
}
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeBuilder.java b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeBuilder.java
index 2917ad27b80c..5f4417c920f6 100644
--- a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeBuilder.java
+++ b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import com.intellij.openapi.progress.Progressive;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.Condition;
+import com.intellij.reference.SoftReference;
import com.intellij.util.Processor;
import com.intellij.util.containers.TransferToEDTQueue;
import com.intellij.util.ui.UIUtil;
@@ -634,7 +635,7 @@ public class AbstractTreeBuilder implements Disposable {
@Nullable
public static AbstractTreeBuilder getBuilderFor(@NotNull JTree tree) {
final WeakReference ref = (WeakReference)tree.getClientProperty(TREE_BUILDER);
- return ref != null ? (AbstractTreeBuilder)ref.get() : null;
+ return (AbstractTreeBuilder)SoftReference.dereference(ref);
}
@Nullable
diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeState.java b/platform/platform-api/src/com/intellij/ide/util/treeView/TreeState.java
index 61fda59ac4f6..94277aed0277 100644
--- a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeState.java
+++ b/platform/platform-api/src/com/intellij/ide/util/treeView/TreeState.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Progressive;
import com.intellij.openapi.util.*;
+import com.intellij.reference.SoftReference;
import com.intellij.util.ui.tree.TreeUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -442,10 +443,8 @@ public class TreeState implements JDOMExternalizable {
@Override
public ActionCallback getInitialized() {
final WeakReference ref = (WeakReference)myTree.getClientProperty(CALLBACK);
- if (ref != null) {
- final ActionCallback callback = ref.get();
- if (callback != null) return callback;
- }
+ final ActionCallback callback = SoftReference.dereference(ref);
+ if (callback != null) return callback;
return new ActionCallback.Done();
}
diff --git a/platform/platform-api/src/com/intellij/idea/ActionsBundle.java b/platform/platform-api/src/com/intellij/idea/ActionsBundle.java
index 43318d00108b..68fb85a3f501 100644
--- a/platform/platform-api/src/com/intellij/idea/ActionsBundle.java
+++ b/platform/platform-api/src/com/intellij/idea/ActionsBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,8 +52,7 @@ public class ActionsBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(IDEA_ACTIONS_BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-api/src/com/intellij/notification/Notification.java b/platform/platform-api/src/com/intellij/notification/Notification.java
index 5a538dcbfba2..674e20282334 100644
--- a/platform/platform-api/src/com/intellij/notification/Notification.java
+++ b/platform/platform-api/src/com/intellij/notification/Notification.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupAdapter;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
+import com.intellij.reference.SoftReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -129,8 +130,7 @@ public class Notification {
balloon.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
- WeakReference ref = myBalloonRef;
- if (ref != null && ref.get() == balloon) {
+ if (SoftReference.dereference(myBalloonRef) == balloon) {
myBalloonRef = null;
}
}
@@ -139,7 +139,7 @@ public class Notification {
@Nullable
public Balloon getBalloon() {
- return myBalloonRef == null ? null : myBalloonRef.get();
+ return SoftReference.dereference(myBalloonRef);
}
public void notify(@Nullable Project project) {
diff --git a/platform/platform-api/src/com/intellij/openapi/application/ApplicationBundle.java b/platform/platform-api/src/com/intellij/openapi/application/ApplicationBundle.java
index c64536b8775f..2f42278c3ee2 100644
--- a/platform/platform-api/src/com/intellij/openapi/application/ApplicationBundle.java
+++ b/platform/platform-api/src/com/intellij/openapi/application/ApplicationBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@ public class ApplicationBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-api/src/com/intellij/openapi/diff/DiffBundle.java b/platform/platform-api/src/com/intellij/openapi/diff/DiffBundle.java
index 42fda764171e..35ad6170213e 100644
--- a/platform/platform-api/src/com/intellij/openapi/diff/DiffBundle.java
+++ b/platform/platform-api/src/com/intellij/openapi/diff/DiffBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@ public class DiffBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/OpenFileDescriptor.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/OpenFileDescriptor.java
index 3acfb0df70aa..d8f6572042e9 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileEditor/OpenFileDescriptor.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/OpenFileDescriptor.java
@@ -118,12 +118,12 @@ public class OpenFileDescriptor implements Navigatable {
throw new IllegalStateException("Navigation is not possible with null project");
}
- if (!myFile.isDirectory() && navigateInEditor(myProject, requestFocus)) return;
+ if (!myFile.isDirectory() && navigateInEditorOrNativeApp(myProject, requestFocus)) return;
navigateInProjectView(requestFocus);
}
- private boolean navigateInEditor(@NotNull Project project, boolean requestFocus) {
+ private boolean navigateInEditorOrNativeApp(@NotNull Project project, boolean requestFocus) {
FileType type = FileTypeManager.getInstance().getKnownFileTypeOrAssociate(myFile,project);
if (type == null || !myFile.isValid()) return false;
@@ -131,6 +131,10 @@ public class OpenFileDescriptor implements Navigatable {
return ((INativeFileType) type).openFileInAssociatedApplication(project, myFile);
}
+ return navigateInEditor(project, requestFocus);
+ }
+
+ public boolean navigateInEditor(@NotNull Project project, boolean requestFocus) {
return navigateInRequestedEditor() || navigateInAnyFileEditor(project, requestFocus);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/keymap/KeyMapBundle.java b/platform/platform-api/src/com/intellij/openapi/keymap/KeyMapBundle.java
index 2e6d14fb2cf5..efd081cc53d9 100644
--- a/platform/platform-api/src/com/intellij/openapi/keymap/KeyMapBundle.java
+++ b/platform/platform-api/src/com/intellij/openapi/keymap/KeyMapBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +44,7 @@ public class KeyMapBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-api/src/com/intellij/openapi/options/OptionsBundle.java b/platform/platform-api/src/com/intellij/openapi/options/OptionsBundle.java
index d80d5704d80d..e86d07d7a133 100644
--- a/platform/platform-api/src/com/intellij/openapi/options/OptionsBundle.java
+++ b/platform/platform-api/src/com/intellij/openapi/options/OptionsBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@ public class OptionsBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/VcsBundle.java b/platform/platform-api/src/com/intellij/openapi/vcs/VcsBundle.java
index 54dac0ecee93..536db1ebd279 100644
--- a/platform/platform-api/src/com/intellij/openapi/vcs/VcsBundle.java
+++ b/platform/platform-api/src/com/intellij/openapi/vcs/VcsBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,8 +43,7 @@ public class VcsBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
index 1fc5939e0396..3d8c4ff9cd3c 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
@@ -19,6 +19,8 @@ import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.ActiveRunnable;
import com.intellij.openapi.util.Expirable;
+import com.intellij.openapi.util.registry.Registry;
+import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -149,8 +151,26 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable {
@NotNull
public final ActionCallback run() {
if (myToFocus != null) {
- if (!myToFocus.requestFocusInWindow()) {
- myToFocus.requestFocus();
+ if (Registry.is("actionSystem.doNotStealFocus")) {
+ Window topWindow = SwingUtilities.windowForComponent(myToFocus);
+ UIUtil.setAutoRequestFocus(topWindow, topWindow.isActive());
+ while (topWindow.getOwner() != null) {
+ topWindow = SwingUtilities.windowForComponent(topWindow);
+ UIUtil.setAutoRequestFocus(topWindow, topWindow.isActive());
+ }
+
+ if (topWindow.isActive()) {
+ if (!myToFocus.requestFocusInWindow()) {
+ myToFocus.requestFocus();
+ }
+ } else {
+ myToFocus.requestFocusInWindow();
+ }
+
+ } else {
+ if (!myToFocus.requestFocusInWindow()) {
+ myToFocus.requestFocus();
+ }
}
}
clear();
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/TabInfo.java b/platform/platform-api/src/com/intellij/ui/tabs/TabInfo.java
index 40cbb9a94307..302ad819cd7f 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/TabInfo.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/TabInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package com.intellij.ui.tabs;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.ui.Queryable;
+import com.intellij.reference.SoftReference;
import com.intellij.ui.PlaceProvider;
import com.intellij.ui.SimpleColoredText;
import com.intellij.ui.SimpleTextAttributes;
@@ -237,7 +238,7 @@ public final class TabInfo implements Queryable, PlaceProvider {
@Nullable
public JComponent getLastFocusOwner() {
- return myLastFocusOwner != null ? myLastFocusOwner.get() : null;
+ return SoftReference.dereference(myLastFocusOwner);
}
public TabInfo setAlertIcon(final AlertIcon alertIcon) {
diff --git a/platform/platform-impl/src/com/intellij/diagnostic/DiagnosticBundle.java b/platform/platform-impl/src/com/intellij/diagnostic/DiagnosticBundle.java
index 3e0b118e953e..6ecd54988fab 100644
--- a/platform/platform-impl/src/com/intellij/diagnostic/DiagnosticBundle.java
+++ b/platform/platform-impl/src/com/intellij/diagnostic/DiagnosticBundle.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@ public class DiagnosticBundle {
}
private static ResourceBundle getBundle() {
- ResourceBundle bundle = null;
- if (ourBundle != null) bundle = ourBundle.get();
+ ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference(bundle);
diff --git a/platform/platform-impl/src/com/intellij/execution/process/KillableColoredProcessHandler.java b/platform/platform-impl/src/com/intellij/execution/process/KillableColoredProcessHandler.java
index 6b47c0a053c2..267e386ac45c 100644
--- a/platform/platform-impl/src/com/intellij/execution/process/KillableColoredProcessHandler.java
+++ b/platform/platform-impl/src/com/intellij/execution/process/KillableColoredProcessHandler.java
@@ -106,16 +106,7 @@ public class KillableColoredProcessHandler extends ColoredProcessHandler impleme
protected void doDestroyProcess() {
boolean gracefulTerminationAttempted = false;
if (canKillProcessSoftly() && shouldKillProcessSoftly()) {
- if (SystemInfo.isWindows) {
- if (myProcess instanceof RunnerWinProcess) {
- RunnerWinProcess runnerWinProcess = (RunnerWinProcess) myProcess;
- runnerWinProcess.destroyGracefully(true);
- gracefulTerminationAttempted = true;
- }
- }
- else if (SystemInfo.isUnix) {
- gracefulTerminationAttempted = UnixProcessManager.sendSigIntToProcessTree(myProcess);
- }
+ gracefulTerminationAttempted = gracefulProcessTermination();
}
if (!gracefulTerminationAttempted) {
// execute default process destroy
@@ -123,6 +114,20 @@ public class KillableColoredProcessHandler extends ColoredProcessHandler impleme
}
}
+ protected boolean gracefulProcessTermination() {
+ if (SystemInfo.isWindows) {
+ if (myProcess instanceof RunnerWinProcess) {
+ RunnerWinProcess runnerWinProcess = (RunnerWinProcess) myProcess;
+ runnerWinProcess.destroyGracefully(true);
+ return true;
+ }
+ }
+ else if (SystemInfo.isUnix) {
+ return UnixProcessManager.sendSigIntToProcessTree(myProcess);
+ }
+ return false;
+ }
+
/**
* @return true, if graceful process termination should be attempted first
*/
diff --git a/platform/platform-impl/src/com/intellij/ide/IdeRepaintManager.java b/platform/platform-impl/src/com/intellij/ide/IdeRepaintManager.java
index bb2cf498987c..8aa0e38c0d0d 100644
--- a/platform/platform-impl/src/com/intellij/ide/IdeRepaintManager.java
+++ b/platform/platform-impl/src/com/intellij/ide/IdeRepaintManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
package com.intellij.ide;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.reference.SoftReference;
import org.jetbrains.annotations.NonNls;
import javax.swing.*;
@@ -160,7 +161,7 @@ public class IdeRepaintManager extends RepaintManager {
return;
}
//ignore the last processed component
- if (myLastComponent != null && c == myLastComponent.get()) {
+ if (SoftReference.dereference(myLastComponent) == c) {
return;
}
myLastComponent = new WeakReference(c);
diff --git a/platform/platform-impl/src/com/intellij/ide/dnd/DnDManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/dnd/DnDManagerImpl.java
index 84d516265588..621ff0d2346d 100644
--- a/platform/platform-impl/src/com/intellij/ide/dnd/DnDManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/ide/dnd/DnDManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.Application;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
+import com.intellij.reference.SoftReference;
import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.util.ui.GeometryUtil;
import com.intellij.util.ui.UIUtil;
@@ -741,6 +742,6 @@ public class DnDManagerImpl extends DnDManager implements Disposable {
@Nullable
public Component getLastDropHandler() {
- return myLastDropHandler != null ? myLastDropHandler.get() : null;
+ return SoftReference.dereference(myLastDropHandler);
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryContentHandler.java b/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryContentHandler.java
index d36731d87858..6092139d3e0f 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryContentHandler.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryContentHandler.java
@@ -53,7 +53,7 @@ class RepositoryContentHandler extends DefaultHandler {
@NonNls private static final String DATE = "date";
private PluginNode currentPlugin;
- private String currentValue;
+ private final StringBuilder currentValue = new StringBuilder();
private ArrayList plugins;
private Stack categoriesStack;
@@ -86,45 +86,47 @@ class RepositoryContentHandler extends DefaultHandler {
currentPlugin.setVendorEmail(atts.getValue(EMAIL));
currentPlugin.setVendorUrl(atts.getValue(URL));
}
- currentValue = "";
+ currentValue.setLength(0);
}
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
+ String currentValueString = currentValue.toString();
+ currentValue.setLength(0);
+
if (qName.equals(ID)) {
- currentPlugin.setId(currentValue);
+ currentPlugin.setId(currentValueString);
}
else if (qName.equals(NAME)) {
- currentPlugin.setName(currentValue);
+ currentPlugin.setName(currentValueString);
}
else if (qName.equals(DESCRIPTION)) {
- currentPlugin.setDescription(currentValue);
+ currentPlugin.setDescription(currentValueString);
}
else if (qName.equals(VERSION)) {
- currentPlugin.setVersion(currentValue);
+ currentPlugin.setVersion(currentValueString);
}
else if (qName.equals(VENDOR)) {
- currentPlugin.setVendor(currentValue);
+ currentPlugin.setVendor(currentValueString);
}
else if (qName.equals(DEPENDS)) {
- currentPlugin.addDepends(PluginId.getId(currentValue));
+ currentPlugin.addDepends(PluginId.getId(currentValueString));
}
else if (qName.equals(CHNAGE_NOTES)) {
- currentPlugin.setChangeNotes(currentValue);
+ currentPlugin.setChangeNotes(currentValueString);
}
else if (qName.equals(CATEGORY)) {
categoriesStack.pop();
}
else if (qName.equals(RATING)) {
- currentPlugin.setRating(currentValue);
+ currentPlugin.setRating(currentValueString);
}
else if (qName.equals(DOWNLOAD_URL)) {
- currentPlugin.setDownloadUrl(currentValue);
+ currentPlugin.setDownloadUrl(currentValueString);
}
- currentValue = "";
}
public void characters(char[] ch, int start, int length) throws SAXException {
- currentValue += new String(ch, start, length);
+ currentValue.append(ch, start, length);
}
public ArrayList getPluginsList() {
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHighlighterCache.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHighlighterCache.java
index a90d575f9e3c..c1499a71a71b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHighlighterCache.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHighlighterCache.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 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.
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter;
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
import com.intellij.openapi.util.Key;
+import com.intellij.reference.SoftReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -43,7 +44,7 @@ public class EditorHighlighterCache {
return null;
}
final WeakReference editorHighlighterWeakReference = document.getUserData(ourSomeEditorSyntaxHighlighter);
- final EditorHighlighter someEditorHighlighter = editorHighlighterWeakReference != null ? editorHighlighterWeakReference.get() : null;
+ final EditorHighlighter someEditorHighlighter = SoftReference.dereference(editorHighlighterWeakReference);
if (someEditorHighlighter instanceof LexerEditorHighlighter &&
((LexerEditorHighlighter)someEditorHighlighter).isValid()
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/BaseRemoteFileEditor.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/BaseRemoteFileEditor.java
index b3dde8163544..fc12a045783a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/BaseRemoteFileEditor.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/BaseRemoteFileEditor.java
@@ -13,6 +13,7 @@ import com.intellij.openapi.fileEditor.impl.text.TextEditorState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.UserDataHolderBase;
+import com.intellij.pom.Navigatable;
import com.intellij.util.EventDispatcher;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -22,6 +23,7 @@ import java.beans.PropertyChangeListener;
public abstract class BaseRemoteFileEditor implements TextEditor, PropertyChangeListener {
protected Editor myMockTextEditor;
+ protected volatile Navigatable myPendingNavigatable;
protected final Project myProject;
private final UserDataHolderBase myUserDataHolder = new UserDataHolderBase();
@@ -129,4 +131,31 @@ public abstract class BaseRemoteFileEditor implements TextEditor, PropertyChange
public void propertyChange(PropertyChangeEvent evt) {
myDispatcher.getMulticaster().propertyChange(evt);
}
+
+ @Override
+ public boolean canNavigateTo(@NotNull Navigatable navigatable) {
+ TextEditor editor = getTextEditor();
+ return editor == null ? isValid() : editor.canNavigateTo(navigatable);
+ }
+
+ @Override
+ public void navigateTo(@NotNull Navigatable navigatable) {
+ TextEditor editor = getTextEditor();
+ if (editor != null) {
+ editor.navigateTo(navigatable);
+ }
+ else if (isValid()) {
+ myPendingNavigatable = navigatable;
+ }
+ }
+
+ protected void checkPendingNavigable() {
+ Navigatable navigatable = myPendingNavigatable;
+ if (navigatable != null) {
+ myPendingNavigatable = null;
+ TextEditor editor = getTextEditor();
+ assert editor != null;
+ editor.navigateTo(navigatable);
+ }
+ }
}
\ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
index 354e0c774a51..5c34d2eb2523 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
@@ -792,7 +792,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
for (int i = 0; i < providers.length; i++) {
try {
final FileEditorProvider provider = providers[i];
- LOG.assertTrue(provider != null);
+ LOG.assertTrue(provider != null, "Provider for file "+file+" is null. All providers: "+Arrays.asList(providers));
LOG.assertTrue(provider.accept(myProject, file), "Provider " + provider + " doesn't accept file " + file);
final FileEditor editor = provider.createEditor(myProject, file);
LOG.assertTrue(editor != null);
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java
index 57e37184e364..fd7c5710ab5d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java
@@ -15,11 +15,11 @@
*/
package com.intellij.openapi.fileEditor.impl.http;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.fileEditor.impl.BaseRemoteFileEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.impl.http.HttpVirtualFile;
-import com.intellij.pom.Navigatable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -35,6 +35,22 @@ public class HttpFileEditor extends BaseRemoteFileEditor {
super(project);
myPanel = new RemoteFilePanel(project, virtualFile, this);
+ virtualFile.getFileInfo().download().doWhenDone(new Runnable() {
+ @Override
+ public void run() {
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ checkPendingNavigable();
+ }
+ });
+ }
+ }).doWhenRejected(new Runnable() {
+ @Override
+ public void run() {
+ myPendingNavigatable = null;
+ }
+ });
}
@Override
@@ -68,20 +84,6 @@ public class HttpFileEditor extends BaseRemoteFileEditor {
myPanel.deselectNotify();
}
- @Override
- public boolean canNavigateTo(@NotNull Navigatable navigatable) {
- TextEditor textEditor = getTextEditor();
- return textEditor != null && textEditor.canNavigateTo(navigatable);
- }
-
- @Override
- public void navigateTo(@NotNull Navigatable navigatable) {
- final TextEditor textEditor = myPanel.getFileEditor();
- if (textEditor != null) {
- textEditor.navigateTo(navigatable);
- }
- }
-
@Override
@Nullable
protected TextEditor getTextEditor() {
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeyProcessorContext.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeyProcessorContext.java
index d01bc8e1a068..e832caae4775 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeyProcessorContext.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeyProcessorContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package com.intellij.openapi.keymap.impl;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.reference.SoftReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -44,7 +45,7 @@ public class KeyProcessorContext {
@Nullable
public JComponent getFoundComponent() {
- return myFoundComponent != null ? myFoundComponent.get() : null;
+ return SoftReference.dereference(myFoundComponent);
}
public void setFoundComponent(final JComponent foundComponent) {
@@ -77,7 +78,7 @@ public class KeyProcessorContext {
@Nullable
public Component getFocusOwner() {
- return myFocusOwner != null ? myFocusOwner.get() : null;
+ return SoftReference.dereference(myFocusOwner);
}
public void setFocusOwner(final Component focusOwner) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
index b58811c930fb..dc9821ec9836 100644
--- a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
@@ -43,6 +43,7 @@ import com.intellij.openapi.wm.ex.LayoutFocusTraversalPolicyExt;
import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.openapi.wm.impl.IdeGlassPaneImpl;
+import com.intellij.reference.SoftReference;
import com.intellij.ui.*;
import com.intellij.ui.components.JBLayeredPane;
import com.intellij.ui.mac.foundation.Foundation;
@@ -788,7 +789,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
@Nullable
private Project getProject() {
- return myProject != null ? myProject.get() : null;
+ return SoftReference.dereference(myProject);
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java
index f21d2c06bb21..aef53edeb096 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java
@@ -44,8 +44,7 @@ class Win32FsCache {
@NotNull
private Map getMap() {
- Reference