mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Generated
+5
-5
@@ -46,8 +46,8 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/dvcs/dvcs.iml" filepath="$PROJECT_DIR$/platform/dvcs/dvcs.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/eclipse/eclipse.iml" filepath="$PROJECT_DIR$/plugins/eclipse/eclipse.iml" group="plugins" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/eclipse/jps-plugin/eclipse-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/eclipse/jps-plugin/eclipse-jps-plugin.iml" group="plugins" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/editor-ui-api/editor-ui-api.iml" filepath="$PROJECT_DIR$/platform/editor-ui-api/editor-ui-api.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/editor-ui-ex/editor-ui-ex.iml" filepath="$PROJECT_DIR$/platform/editor-ui-ex/editor-ui-ex.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/editor-ui-api/editor-ui-api.iml" filepath="$PROJECT_DIR$/platform/editor-ui-api/editor-ui-api.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/editor-ui-ex/editor-ui-ex.iml" filepath="$PROJECT_DIR$/platform/editor-ui-ex/editor-ui-ex.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/execution/impl/execution-impl.iml" filepath="$PROJECT_DIR$/java/execution/impl/execution-impl.iml" group="java" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/execution/openapi/execution-openapi.iml" filepath="$PROJECT_DIR$/java/execution/openapi/execution-openapi.iml" group="java" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/extensions/extensions.iml" filepath="$PROJECT_DIR$/platform/extensions/extensions.iml" group="platform" />
|
||||
@@ -106,10 +106,10 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/python/main_idea_python_plugin.iml" filepath="$PROJECT_DIR$/python/main_idea_python_plugin.iml" group="python" />
|
||||
<module fileurl="file://$PROJECT_DIR$/python/main_pycharm_ce.iml" filepath="$PROJECT_DIR$/python/main_pycharm_ce.iml" group="python" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/manifest/manifest.iml" filepath="$PROJECT_DIR$/java/manifest/manifest.iml" group="java" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/artifact-resolver-m31/maven-artifact-resolver-m31.iml" filepath="$PROJECT_DIR$/plugins/maven/artifact-resolver-m31/maven-artifact-resolver-m31.iml" group="plugins/maven" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven.iml" filepath="$PROJECT_DIR$/plugins/maven/maven.iml" group="plugins/maven" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/artifact-resolver-m2/maven-artifact-resolver-m2.iml" filepath="$PROJECT_DIR$/plugins/maven/artifact-resolver-m2/maven-artifact-resolver-m2.iml" group="plugins/maven" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/artifact-resolver-m3/maven-artifact-resolver-m3.iml" filepath="$PROJECT_DIR$/plugins/maven/artifact-resolver-m3/maven-artifact-resolver-m3.iml" group="plugins/maven" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/artifact-resolver-m31/maven-artifact-resolver-m31.iml" filepath="$PROJECT_DIR$/plugins/maven/artifact-resolver-m31/maven-artifact-resolver-m31.iml" group="plugins/maven" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/jps-plugin/maven-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/maven/jps-plugin/maven-jps-plugin.iml" group="plugins/maven" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven-server-api/maven-server-api.iml" filepath="$PROJECT_DIR$/plugins/maven/maven-server-api/maven-server-api.iml" group="plugins/maven" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven2-server-impl/maven2-server-impl.iml" filepath="$PROJECT_DIR$/plugins/maven/maven2-server-impl/maven2-server-impl.iml" group="plugins/maven" />
|
||||
@@ -136,9 +136,9 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/python/python-pydev.iml" filepath="$PROJECT_DIR$/python/python-pydev.iml" group="python" />
|
||||
<module fileurl="file://$PROJECT_DIR$/python/python-rest/python-rest.iml" filepath="$PROJECT_DIR$/python/python-rest/python-rest.iml" group="python" />
|
||||
<module fileurl="file://$PROJECT_DIR$/xml/relaxng/relaxng.iml" filepath="$PROJECT_DIR$/xml/relaxng/relaxng.iml" group="plugins" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/remote-servers/agent-rt/remote-servers-agent-rt.iml" filepath="$PROJECT_DIR$/platform/remote-servers/agent-rt/remote-servers-agent-rt.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/remote-servers/agent-rt/remote-servers-agent-rt.iml" filepath="$PROJECT_DIR$/platform/remote-servers/agent-rt/remote-servers-agent-rt.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/remote-servers/api/remote-servers-api.iml" filepath="$PROJECT_DIR$/platform/remote-servers/api/remote-servers-api.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/git4idea/remote-servers-git/remote-servers-git.iml" filepath="$PROJECT_DIR$/plugins/git4idea/remote-servers-git/remote-servers-git.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/git4idea/remote-servers-git/remote-servers-git.iml" filepath="$PROJECT_DIR$/plugins/git4idea/remote-servers-git/remote-servers-git.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/remote-servers/impl/remote-servers-impl.iml" filepath="$PROJECT_DIR$/platform/remote-servers/impl/remote-servers-impl.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/remote-servers/api/remote-servers-java-api.iml" filepath="$PROJECT_DIR$/java/remote-servers/api/remote-servers-java-api.iml" group="java" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/remote-servers/impl/remote-servers-java-impl.iml" filepath="$PROJECT_DIR$/java/remote-servers/impl/remote-servers-java-impl.iml" group="java" />
|
||||
|
||||
+7
-7
@@ -24,7 +24,7 @@ echo "Updating $WORK_IDEA_HOME from compiled classes in $DEV_IDEA_HOME"
|
||||
ANT_HOME="$DEV_IDEA_HOME/lib/ant"
|
||||
ANT_CLASSPATH="$DEV_IDEA_HOME/build/lib/gant/lib/jps.jar"
|
||||
java -Xms64m -Xmx512m -Dant.home="$ANT_HOME" -classpath "$ANT_HOME/lib/ant-launcher.jar" org.apache.tools.ant.launch.Launcher \
|
||||
-lib "$ANT_CLASSPATH" -f $DEV_IDEA_HOME/build/update.xml $TARGET
|
||||
-lib "$ANT_CLASSPATH" -f "$DEV_IDEA_HOME/build/update.xml" $TARGET
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Update failed; work IDEA build not modified."
|
||||
@@ -32,17 +32,17 @@ if [ "$?" != "0" ]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
rm -rf $WORK_IDEA_HOME/lib
|
||||
rm -rf $WORK_IDEA_HOME/plugins
|
||||
rm -rf "$WORK_IDEA_HOME/lib"
|
||||
rm -rf "$WORK_IDEA_HOME/plugins"
|
||||
|
||||
cp -R $DEV_IDEA_HOME/out/deploy/* $WORK_IDEA_HOME
|
||||
cp -R "$DEV_IDEA_HOME/out/deploy/"* "$WORK_IDEA_HOME"
|
||||
|
||||
OS_TYPE=`uname -s`
|
||||
if [ "$OS_TYPE" = "Linux" ]; then
|
||||
cp -a $DEV_IDEA_HOME/bin/linux/*.so $WORK_IDEA_HOME/bin
|
||||
cp -a $DEV_IDEA_HOME/bin/linux/fsnotifier* $WORK_IDEA_HOME/bin
|
||||
elif [ "$OS_TYPE" = "Darwin" ]; then
|
||||
cp -a $DEV_IDEA_HOME/bin/mac/*.jnilib $WORK_IDEA_HOME/bin
|
||||
cp -a $DEV_IDEA_HOME/bin/mac/fsnotifier $WORK_IDEA_HOME/bin
|
||||
cp -a $DEV_IDEA_HOME/bin/mac/restarter $WORK_IDEA_HOME/bin
|
||||
cp -a "$DEV_IDEA_HOME/bin/mac/"*.jnilib "$WORK_IDEA_HOME/bin"
|
||||
cp -a "$DEV_IDEA_HOME/bin/mac/fsnotifier" "$WORK_IDEA_HOME/bin"
|
||||
cp -a "$DEV_IDEA_HOME/bin/mac/restarter" "$WORK_IDEA_HOME/bin"
|
||||
fi
|
||||
|
||||
@@ -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 ImagesBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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.
|
||||
@@ -66,7 +66,7 @@ public final class IfsUtil {
|
||||
private static boolean refresh(@NotNull VirtualFile file) throws IOException {
|
||||
Long loadedTimeStamp = file.getUserData(TIMESTAMP_KEY);
|
||||
SoftReference<BufferedImage> imageRef = file.getUserData(BUFFERED_IMAGE_REF_KEY);
|
||||
if (loadedTimeStamp == null || loadedTimeStamp.longValue() != file.getTimeStamp() || imageRef == null || imageRef.get() == null) {
|
||||
if (loadedTimeStamp == null || loadedTimeStamp.longValue() != file.getTimeStamp() || SoftReference.dereference(imageRef) == null) {
|
||||
try {
|
||||
final byte[] content = file.contentsToByteArray();
|
||||
|
||||
@@ -113,7 +113,7 @@ public final class IfsUtil {
|
||||
public static BufferedImage getImage(@NotNull VirtualFile file) throws IOException {
|
||||
refresh(file);
|
||||
SoftReference<BufferedImage> imageRef = file.getUserData(BUFFERED_IMAGE_REF_KEY);
|
||||
return imageRef != null ? imageRef.get() : null;
|
||||
return SoftReference.dereference(imageRef);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -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.
|
||||
@@ -45,8 +45,7 @@ public class CompilerBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -19,14 +19,10 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.impl.DocumentImpl;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.xdebugger.impl.ui.TextViewer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -36,6 +32,7 @@ import java.awt.*;
|
||||
* @author Jeka
|
||||
*/
|
||||
public class ViewTextAction extends BaseValueAction {
|
||||
@Override
|
||||
protected void processText(final Project project, final String text, DebuggerTreeNodeImpl node, DebuggerContextImpl debuggerContext) {
|
||||
final NodeDescriptorImpl descriptor = node.getDescriptor();
|
||||
final String labelText = descriptor instanceof ValueDescriptorImpl? ((ValueDescriptorImpl)descriptor).getValueLabel() : null;
|
||||
@@ -46,8 +43,7 @@ public class ViewTextAction extends BaseValueAction {
|
||||
}
|
||||
|
||||
private static class MyDialog extends DialogWrapper {
|
||||
|
||||
private EditorTextField myTextViewer;
|
||||
private final EditorTextField myTextViewer;
|
||||
|
||||
private MyDialog(Project project) {
|
||||
super(project, false);
|
||||
@@ -55,7 +51,7 @@ public class ViewTextAction extends BaseValueAction {
|
||||
setCancelButtonText("Close");
|
||||
setCrossClosesWindow(true);
|
||||
|
||||
myTextViewer = new TextViewer(project);
|
||||
myTextViewer = new TextViewer(project, true, true);
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -63,48 +59,23 @@ public class ViewTextAction extends BaseValueAction {
|
||||
myTextViewer.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected Action[] createActions() {
|
||||
return new Action[] {getCancelAction()};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDimensionServiceKey() {
|
||||
return "#com.intellij.debugger.actions.ViewTextAction";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(myTextViewer, BorderLayout.CENTER);
|
||||
panel.setPreferredSize(new Dimension(300, 200));
|
||||
return panel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class TextViewer extends EditorTextField {
|
||||
|
||||
private TextViewer(Project project) {
|
||||
super(createDocument(), project, FileTypes.PLAIN_TEXT, true, false);
|
||||
}
|
||||
|
||||
private static Document createDocument() {
|
||||
final Document document = EditorFactory.getInstance().createDocument("");
|
||||
if (document instanceof DocumentImpl) {
|
||||
((DocumentImpl)document).setAcceptSlashR(true);
|
||||
}
|
||||
return document;
|
||||
}
|
||||
|
||||
protected EditorEx createEditor() {
|
||||
final EditorEx editor = super.createEditor();
|
||||
editor.setHorizontalScrollbarVisible(true);
|
||||
editor.setVerticalScrollbarVisible(true);
|
||||
editor.setEmbeddedIntoDialogWrapper(true);
|
||||
editor.getComponent().setPreferredSize(null);
|
||||
editor.getSettings().setUseSoftWraps(true);
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -41,6 +41,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiDocumentManagerBase;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.ui.ClickListener;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -112,7 +113,7 @@ public abstract class DebuggerEditorImpl extends CompletionEditor{
|
||||
new ClickListener() {
|
||||
@Override
|
||||
public boolean onClick(MouseEvent e, int clickCount) {
|
||||
ListPopup oldPopup = myPopup != null ? myPopup.get() : null;
|
||||
ListPopup oldPopup = SoftReference.dereference(myPopup);
|
||||
if (oldPopup != null && !oldPopup.isDisposed()) {
|
||||
oldPopup.cancel();
|
||||
myPopup = null;
|
||||
|
||||
@@ -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.
|
||||
@@ -45,8 +45,7 @@ public class DebuggerBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.util.descriptors.impl;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -71,8 +86,7 @@ public class ConfigFileImpl implements ConfigFile {
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiFile getPsiFile() {
|
||||
Reference<PsiFile> ref = myPsiFile;
|
||||
PsiFile psiFile = ref == null ? null : ref.get();
|
||||
PsiFile psiFile = com.intellij.reference.SoftReference.dereference(myPsiFile);
|
||||
|
||||
if (psiFile != null && psiFile.isValid()) {
|
||||
return psiFile;
|
||||
|
||||
+6
@@ -20,6 +20,12 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Base java local inspection which provides batch suppress actions, i.e. actions which don't need UI components to run (e.g. Editor).
|
||||
* Please use this class if your inspection and its fixes
|
||||
* - work with PSI or document only and
|
||||
* - don't provide {@link com.intellij.codeInsight.intention.IntentionAction} for quick fixes/suppression, making do with {@link LocalQuickFix} only.
|
||||
*/
|
||||
public abstract class BaseJavaBatchLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool implements BatchSuppressableTool {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -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.
|
||||
@@ -77,7 +77,7 @@ public class RefCountHolder {
|
||||
|
||||
private static RefCountHolder getInstance(@NotNull PsiFile file, @NotNull ProgressIndicator indicator, boolean acquire) {
|
||||
HolderReference ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
|
||||
RefCountHolder holder = ref == null ? null : ref.get();
|
||||
RefCountHolder holder = com.intellij.reference.SoftReference.dereference(ref);
|
||||
if (holder == null && acquire) {
|
||||
holder = new RefCountHolder(file);
|
||||
HolderReference newRef = new HolderReference(holder);
|
||||
@@ -88,7 +88,7 @@ public class RefCountHolder {
|
||||
break;
|
||||
}
|
||||
ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
|
||||
RefCountHolder newHolder = ref == null ? null : ref.get();
|
||||
RefCountHolder newHolder = com.intellij.reference.SoftReference.dereference(ref);
|
||||
if (newHolder != null) {
|
||||
holder = newHolder;
|
||||
break;
|
||||
|
||||
+2
-2
@@ -85,8 +85,8 @@ public class Java15APIUsageInspectionBase extends BaseJavaBatchLocalInspectionTo
|
||||
private static Set<String> getForbiddenApi(@NotNull LanguageLevel languageLevel) {
|
||||
if (!ourPresentableShortMessage.containsKey(languageLevel)) return null;
|
||||
Reference<Set<String>> ref = ourForbiddenAPI.get(languageLevel);
|
||||
Set<String> result;
|
||||
if (ref == null || (result = ref.get()) == null) {
|
||||
Set<String> result = SoftReference.dereference(ref);
|
||||
if (result == null) {
|
||||
result = new THashSet<String>(1000);
|
||||
loadForbiddenApi("api" + getShortName(languageLevel) + ".txt", result);
|
||||
ourForbiddenAPI.put(languageLevel, new SoftReference<Set<String>>(result));
|
||||
|
||||
+9
-3
@@ -77,14 +77,20 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
|
||||
if (!AnnotationUtil.isAnnotatingApplicable(field, anno)) {
|
||||
final PsiAnnotation notNull = AnnotationUtil.findAnnotation(field, manager.getNotNulls());
|
||||
final PsiAnnotation nullable = AnnotationUtil.findAnnotation(field, manager.getNullables());
|
||||
String message = "";
|
||||
final PsiAnnotation annotation;
|
||||
String message = "Not \'";
|
||||
if (annotated.isDeclaredNullable) {
|
||||
message += nullable.getQualifiedName();
|
||||
annotation = nullable;
|
||||
} else {
|
||||
message += notNull.getQualifiedName();
|
||||
annotation = notNull;
|
||||
}
|
||||
message += " contradicts to configured defaults";
|
||||
holder.registerProblem(field.getNameIdentifier(), message,
|
||||
message += "\' but \'" + anno + "\' would be used for code generation.";
|
||||
final PsiJavaCodeReferenceElement annotationNameReferenceElement = annotation.getNameReferenceElement();
|
||||
holder.registerProblem(annotationNameReferenceElement != null ? annotationNameReferenceElement : field.getNameIdentifier(),
|
||||
message,
|
||||
ProblemHighlightType.WEAK_WARNING,
|
||||
new ChangeNullableDefaultsFix(notNull, nullable, manager));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,6 +268,10 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass {
|
||||
for (PsiMethod psiMethod : psiMethods) {
|
||||
getRefManager().getReference(psiMethod);
|
||||
}
|
||||
|
||||
RefJavaUtil.getInstance().addReferences(psiClass, this, psiClass.getExtendsList());
|
||||
RefJavaUtil.getInstance().addReferences(psiClass, this, psiClass.getImplementsList());
|
||||
|
||||
getRefManager().fireBuildReferences(this);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -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.
|
||||
@@ -38,6 +38,17 @@ public class RefJavaUtilImpl extends RefJavaUtil{
|
||||
findIn.accept(
|
||||
new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
final PsiElement target = reference.resolve();
|
||||
|
||||
if (target instanceof PsiClass) {
|
||||
final PsiClass aClass = (PsiClass)target;
|
||||
final RefClassImpl refClass = (RefClassImpl)refFrom.getRefManager().getReference(aClass);
|
||||
refFrom.addReference(refClass, aClass, psiFrom, false, true, null);
|
||||
}
|
||||
|
||||
if (target instanceof PsiModifierListOwner && isDeprecated(target)) {
|
||||
refFrom.setUsesDeprecatedApi(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
|
||||
@@ -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 CompletionBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
+5
-7
@@ -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.
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -85,12 +86,9 @@ public class JavaPsiClassReferenceElement extends LookupItem<Object> {
|
||||
@Override
|
||||
public PsiClass getObject() {
|
||||
if (myClass instanceof PsiAnchor) {
|
||||
Reference<PsiClass> cache = myCache;
|
||||
if (cache != null) {
|
||||
PsiClass psiClass = cache.get();
|
||||
if (psiClass != null) {
|
||||
return psiClass;
|
||||
}
|
||||
PsiClass psiClass = SoftReference.dereference(myCache);
|
||||
if (psiClass != null) {
|
||||
return psiClass;
|
||||
}
|
||||
|
||||
final PsiClass retrieve = (PsiClass)((PsiAnchor)myClass).retrieve();
|
||||
|
||||
@@ -246,7 +246,10 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
|
||||
|
||||
public static void annotateOnOverrideImplement(PsiMethod method, PsiClass targetClass, PsiMethod overridden, boolean insertOverride) {
|
||||
if (insertOverride && canInsertOverride(overridden, targetClass)) {
|
||||
AddAnnotationPsiFix.addPhysicalAnnotation(Override.class.getName(), PsiNameValuePair.EMPTY_ARRAY, method.getModifierList());
|
||||
final String overrideAnnotationName = Override.class.getName();
|
||||
if (!AnnotationUtil.isAnnotated(method, overrideAnnotationName, false, true)) {
|
||||
AddAnnotationPsiFix.addPhysicalAnnotation(overrideAnnotationName, PsiNameValuePair.EMPTY_ARRAY, method.getModifierList());
|
||||
}
|
||||
}
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(targetClass);
|
||||
final GlobalSearchScope moduleScope = module != null ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module) : null;
|
||||
|
||||
@@ -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 JavadocBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -56,9 +56,7 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -230,36 +228,7 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl
|
||||
|
||||
parameters.addParametersString(OTHER_OPTIONS);
|
||||
|
||||
final Set<Module> modules = new HashSet<Module>();
|
||||
myGenerationOptions.accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitFile(PsiFile file) {
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
|
||||
if (module != null) {
|
||||
modules.add(module);
|
||||
}
|
||||
}
|
||||
});
|
||||
final PathsList classPath;
|
||||
final OrderEnumerator orderEnumerator = ProjectRootManager.getInstance(myProject).orderEntries(modules);
|
||||
if (jdk.getSdkType() instanceof JavaSdk) {
|
||||
classPath = orderEnumerator.withoutSdk().withoutModuleSourceEntries().getPathsList();
|
||||
}
|
||||
else {
|
||||
//libraries are included into jdk
|
||||
classPath = orderEnumerator.withoutModuleSourceEntries().getPathsList();
|
||||
}
|
||||
final String classPathString = classPath.getPathsString();
|
||||
if (classPathString.length() > 0) {
|
||||
parameters.add("-classpath");
|
||||
parameters.add(classPathString);
|
||||
}
|
||||
|
||||
if (OUTPUT_DIRECTORY != null) {
|
||||
parameters.add("-d");
|
||||
parameters.add(OUTPUT_DIRECTORY.replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
final Set<Module> modules = new LinkedHashSet<Module>();
|
||||
try {
|
||||
final File sourcePathTempFile = FileUtil.createTempFile("javadoc", "args.txt", true);
|
||||
parameters.add("@" + sourcePathTempFile.getCanonicalPath());
|
||||
@@ -274,10 +243,10 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl
|
||||
scopeType == AnalysisScope.MODULES ||
|
||||
scopeType == AnalysisScope.PROJECT ||
|
||||
scopeType == AnalysisScope.DIRECTORY;
|
||||
myGenerationOptions.accept(new MyContentIterator(myProject, packages, sources, usePackageNotation));
|
||||
myGenerationOptions.accept(new MyContentIterator(myProject, packages, sources, modules, usePackageNotation));
|
||||
}
|
||||
};
|
||||
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(findRunnable, "Search for sources to generate javadoc in...", false, myProject)) {
|
||||
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(findRunnable, "Search for sources to generate javadoc in...", true, myProject)) {
|
||||
return;
|
||||
}
|
||||
if (packages.size() + sources.size() == 0) {
|
||||
@@ -319,6 +288,27 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl
|
||||
catch (IOException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
|
||||
final PathsList classPath;
|
||||
final OrderEnumerator orderEnumerator = ProjectRootManager.getInstance(myProject).orderEntries(modules);
|
||||
if (jdk.getSdkType() instanceof JavaSdk) {
|
||||
classPath = orderEnumerator.withoutSdk().withoutModuleSourceEntries().getPathsList();
|
||||
}
|
||||
else {
|
||||
//libraries are included into jdk
|
||||
classPath = orderEnumerator.withoutModuleSourceEntries().getPathsList();
|
||||
}
|
||||
final String classPathString = classPath.getPathsString();
|
||||
if (classPathString.length() > 0) {
|
||||
parameters.add("-classpath");
|
||||
parameters.add(classPathString);
|
||||
}
|
||||
|
||||
if (OUTPUT_DIRECTORY != null) {
|
||||
parameters.add("-d");
|
||||
parameters.add(OUTPUT_DIRECTORY.replace('/', File.separatorChar));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -343,9 +333,15 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl
|
||||
private final PsiManager myPsiManager;
|
||||
private final Collection<String> myPackages;
|
||||
private final Collection<String> mySourceFiles;
|
||||
private final Set<Module> myModules;
|
||||
private final boolean myUsePackageNotation;
|
||||
|
||||
public MyContentIterator(Project project, Collection<String> packages, Collection<String> sources, boolean canUsePackageNotation) {
|
||||
public MyContentIterator(Project project,
|
||||
Collection<String> packages,
|
||||
Collection<String> sources,
|
||||
Set<Module> modules,
|
||||
boolean canUsePackageNotation) {
|
||||
myModules = modules;
|
||||
myUsePackageNotation = canUsePackageNotation;
|
||||
myPsiManager = PsiManager.getInstance(project);
|
||||
myPackages = packages;
|
||||
@@ -357,7 +353,10 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl
|
||||
final VirtualFile fileOrDir = file.getVirtualFile();
|
||||
if (fileOrDir == null) return;
|
||||
if (!fileOrDir.isInLocalFileSystem()) return;
|
||||
final Module module = ModuleUtil.findModuleForFile(fileOrDir, myPsiManager.getProject());
|
||||
final Module module = ModuleUtilCore.findModuleForFile(fileOrDir, myPsiManager.getProject());
|
||||
if (module != null) {
|
||||
myModules.add(module);
|
||||
}
|
||||
if (file instanceof PsiJavaFile) {
|
||||
final PsiJavaFile javaFile = (PsiJavaFile)file;
|
||||
final String packageName = javaFile.getPackageName();
|
||||
|
||||
@@ -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.
|
||||
@@ -39,8 +39,7 @@ public class JavaCoreBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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.
|
||||
@@ -159,7 +159,7 @@ public class ControlFlowFactory {
|
||||
@NotNull
|
||||
private CopyOnWriteArrayList<ControlFlowContext> getOrCreateCachedFlowsForElement(@NotNull PsiElement element) {
|
||||
Reference<CopyOnWriteArrayList<ControlFlowContext>> cachedRef = cachedFlows.get(element);
|
||||
CopyOnWriteArrayList<ControlFlowContext> cached = cachedRef == null ? null : cachedRef.get();
|
||||
CopyOnWriteArrayList<ControlFlowContext> cached = com.intellij.reference.SoftReference.dereference(cachedRef);
|
||||
if (cached == null) {
|
||||
cached = ContainerUtil.createEmptyCOWList();
|
||||
cachedFlows.put(element, new SoftReference<CopyOnWriteArrayList<ControlFlowContext>>(cached));
|
||||
|
||||
@@ -179,8 +179,7 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx {
|
||||
|
||||
@Override
|
||||
public PsiPackage findPackage(@NotNull String qualifiedName) {
|
||||
SoftReference<ConcurrentMap<String, PsiPackage>> ref = myPackageCache;
|
||||
ConcurrentMap<String, PsiPackage> cache = ref == null ? null : ref.get();
|
||||
ConcurrentMap<String, PsiPackage> cache = SoftReference.dereference(myPackageCache);
|
||||
if (cache == null) {
|
||||
myPackageCache = new SoftReference<ConcurrentMap<String, PsiPackage>>(cache = new ConcurrentHashMap<String, PsiPackage>());
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -49,7 +50,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
|
||||
private volatile CachedValue<PsiModifierList> myAnnotationList;
|
||||
private volatile CachedValue<Collection<PsiDirectory>> myDirectories;
|
||||
private volatile CachedValue<Collection<PsiDirectory>> myDirectoriesWithLibSources;
|
||||
private volatile SoftReference<Set<String>> myPublicClassNamesCache;
|
||||
private volatile Reference<Set<String>> myPublicClassNamesCache;
|
||||
|
||||
public PsiPackageImpl(PsiManager manager, String qualifiedName) {
|
||||
super(manager, qualifiedName);
|
||||
@@ -176,8 +177,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
|
||||
}
|
||||
|
||||
private Set<String> getClassNamesCache() {
|
||||
SoftReference<Set<String>> ref = myPublicClassNamesCache;
|
||||
Set<String> cache = ref == null ? null : ref.get();
|
||||
Set<String> cache = SoftReference.dereference(myPublicClassNamesCache);
|
||||
if (cache == null) {
|
||||
GlobalSearchScope scope = allScope();
|
||||
|
||||
|
||||
+4
-6
@@ -57,17 +57,15 @@ public class PsiAnnotationStubImpl extends StubBase<PsiAnnotation> implements Ps
|
||||
|
||||
@Override
|
||||
public PsiAnnotation getPsiElement() {
|
||||
if (myParsedFromRepository != null) {
|
||||
PsiAnnotation annotation = myParsedFromRepository.get();
|
||||
if (annotation != null) {
|
||||
return annotation;
|
||||
}
|
||||
PsiAnnotation annotation = SoftReference.dereference(myParsedFromRepository);
|
||||
if (annotation != null) {
|
||||
return annotation;
|
||||
}
|
||||
|
||||
final String text = getText();
|
||||
try {
|
||||
PsiJavaParserFacade facade = JavaPsiFacade.getInstance(getProject()).getParserFacade();
|
||||
PsiAnnotation annotation = facade.createAnnotationFromText(text, getPsi());
|
||||
annotation = facade.createAnnotationFromText(text, getPsi());
|
||||
myParsedFromRepository = new SoftReference<PsiAnnotation>(annotation);
|
||||
return annotation;
|
||||
}
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class PsiImportStatementStubImpl extends StubBase<PsiImportStatementBase>
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiJavaCodeReferenceElement getReference() {
|
||||
PsiJavaCodeReferenceElement ref = myReference != null ? myReference.get() : null;
|
||||
PsiJavaCodeReferenceElement ref = SoftReference.dereference(myReference);
|
||||
if (ref == null) {
|
||||
ref = isStatic() ? getStaticReference() : getRegularReference();
|
||||
myReference = new SoftReference<PsiJavaCodeReferenceElement>(ref);
|
||||
|
||||
@@ -35,8 +35,7 @@ public abstract class TypePointerBase<T extends PsiType> implements SmartTypePoi
|
||||
|
||||
@Override
|
||||
public T getType() {
|
||||
Reference<T> typeRef = myTypeRef;
|
||||
T myType = typeRef == null ? null : typeRef.get();
|
||||
T myType = SoftReference.dereference(myTypeRef);
|
||||
if (myType != null && myType.isValid()) return myType;
|
||||
|
||||
myType = calcType();
|
||||
|
||||
@@ -57,17 +57,15 @@ public class PsiAnnotationMethodImpl extends PsiMethodImpl implements PsiAnnotat
|
||||
final String text = stub.getDefaultValueText();
|
||||
if (StringUtil.isEmpty(text)) return null;
|
||||
|
||||
if (myCachedDefaultValue != null) {
|
||||
final PsiAnnotationMemberValue value = myCachedDefaultValue.get();
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
PsiAnnotationMemberValue value = SoftReference.dereference(myCachedDefaultValue);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@NonNls final String annoText = "@interface _Dummy_ { Class foo() default " + text + "; }";
|
||||
final PsiFileFactory factory = PsiFileFactory.getInstance(getProject());
|
||||
final PsiJavaFile file = (PsiJavaFile)factory.createFileFromText("a.java", JavaFileType.INSTANCE, annoText);
|
||||
final PsiAnnotationMemberValue value = ((PsiAnnotationMethod)file.getClasses()[0].getMethods()[0]).getDefaultValue();
|
||||
value = ((PsiAnnotationMethod)file.getClasses()[0].getMethods()[0]).getDefaultValue();
|
||||
myCachedDefaultValue = new SoftReference<PsiAnnotationMemberValue>(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -72,19 +72,17 @@ public class PsiAnonymousClassImpl extends PsiClassImpl implements PsiAnonymousC
|
||||
return getTypeByTree();
|
||||
}
|
||||
|
||||
PsiClassType type = null;
|
||||
if (myCachedBaseType != null) type = myCachedBaseType.get();
|
||||
PsiClassType type = SoftReference.dereference(myCachedBaseType);
|
||||
if (type != null) return type;
|
||||
|
||||
if (!isInQualifiedNew()) {
|
||||
final PsiJavaCodeReferenceElement ref;
|
||||
final String refText = stub.getBaseClassReferenceText();
|
||||
assert refText != null : stub;
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
|
||||
|
||||
final PsiElement context = calcBasesResolveContext(PsiNameHelper.getShortClassName(refText), getExtendsList());
|
||||
try {
|
||||
ref = factory.createReferenceFromText(refText, context);
|
||||
final PsiJavaCodeReferenceElement ref = factory.createReferenceFromText(refText, context);
|
||||
((PsiJavaCodeReferenceElementImpl)ref).setKindWhenDummy(PsiJavaCodeReferenceElementImpl.CLASS_NAME_KIND);
|
||||
type = factory.createType(ref);
|
||||
}
|
||||
|
||||
@@ -128,15 +128,12 @@ public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements Ps
|
||||
public PsiType getType() {
|
||||
final PsiFieldStub stub = getStub();
|
||||
if (stub != null) {
|
||||
SoftReference<PsiType> cachedType = myCachedType;
|
||||
if (cachedType != null) {
|
||||
PsiType type = cachedType.get();
|
||||
if (type != null) return type;
|
||||
}
|
||||
PsiType type = SoftReference.dereference(myCachedType);
|
||||
if (type != null) return type;
|
||||
|
||||
String typeText = TypeInfo.createTypeText(stub.getType(true));
|
||||
try {
|
||||
final PsiType type = JavaPsiFacade.getInstance(getProject()).getParserFacade().createTypeFromText(typeText, this);
|
||||
type = JavaPsiFacade.getInstance(getProject()).getParserFacade().createTypeFromText(typeText, this);
|
||||
myCachedType = new SoftReference<PsiType>(type);
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -195,14 +195,11 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
|
||||
final String typeText = TypeInfo.createTypeText(stub.getReturnTypeText(true));
|
||||
if (typeText == null) return null;
|
||||
|
||||
SoftReference<PsiType> cachedType = myCachedType;
|
||||
if (cachedType != null) {
|
||||
PsiType type = cachedType.get();
|
||||
if (type != null) return type;
|
||||
}
|
||||
PsiType type = SoftReference.dereference(myCachedType);
|
||||
if (type != null) return type;
|
||||
|
||||
try {
|
||||
final PsiType type = JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(typeText, this);
|
||||
type = JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(typeText, this);
|
||||
myCachedType = new SoftReference<PsiType>(type);
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -39,12 +39,13 @@ import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PsiParameterImpl extends JavaStubPsiElement<PsiParameterStub> implements PsiParameter {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiParameterImpl");
|
||||
|
||||
private volatile SoftReference<PsiType> myCachedType = null;
|
||||
private volatile Reference<PsiType> myCachedType = null;
|
||||
|
||||
public PsiParameterImpl(@NotNull PsiParameterStub stub) {
|
||||
this(stub, JavaStubElementTypes.PARAMETER);
|
||||
@@ -116,16 +117,13 @@ public class PsiParameterImpl extends JavaStubPsiElement<PsiParameterStub> imple
|
||||
public PsiType getType() {
|
||||
PsiParameterStub stub = getStub();
|
||||
if (stub != null) {
|
||||
SoftReference<PsiType> cachedType = myCachedType;
|
||||
if (cachedType != null) {
|
||||
PsiType type = cachedType.get();
|
||||
if (type != null) return type;
|
||||
}
|
||||
PsiType type = SoftReference.dereference(myCachedType);
|
||||
if (type != null) return type;
|
||||
|
||||
String typeText = TypeInfo.createTypeText(stub.getType(true));
|
||||
assert typeText != null : stub;
|
||||
try {
|
||||
PsiType type = JavaPsiFacade.getInstance(getProject()).getParserFacade().createTypeFromText(typeText, this);
|
||||
type = JavaPsiFacade.getInstance(getProject()).getParserFacade().createTypeFromText(typeText, this);
|
||||
myCachedType = new SoftReference<PsiType>(type);
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -124,7 +124,7 @@ public class JavaResolveCache {
|
||||
|
||||
private <T extends PsiExpression> PsiType getCachedType(T expr) {
|
||||
Reference<PsiType> reference = myCalculatedTypes.get(expr);
|
||||
return reference == null ? null : reference.get();
|
||||
return SoftReference.dereference(reference);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
// ca<caret>
|
||||
+5
@@ -37,6 +37,11 @@ public class CustomFileTypeCompletionTest extends LightCompletionTestCase {
|
||||
testByCount(2, "case", "catch");
|
||||
}
|
||||
|
||||
public void testComment() throws Throwable {
|
||||
configureByFile(BASE_PATH + "foo.cs");
|
||||
testByCount(0, new String[] { null });
|
||||
}
|
||||
|
||||
public void testPlainTextSubstitution() throws IOException {
|
||||
FileTypeManagerEx.getInstanceEx().registerFileType(MockLanguageFileType.INSTANCE, "xxx");
|
||||
try {
|
||||
|
||||
+19
-2
@@ -36,16 +36,29 @@ $some_long_variable_name<caret>
|
||||
|
||||
public void testFromAnotherFile() {
|
||||
myFixture.configureByText "b.txt", '''
|
||||
$some_long_variable_name = Obj::instance();
|
||||
$some_local = 1;
|
||||
'''
|
||||
myFixture.configureByText "a.txt", '''
|
||||
$some_lon<caret>
|
||||
$some_long_variable_name = Obj::instance();
|
||||
$some_lo<caret>
|
||||
'''
|
||||
|
||||
complete()
|
||||
myFixture.checkResult '''
|
||||
$some_long_variable_name = Obj::instance();
|
||||
$some_long_variable_name<caret>
|
||||
'''
|
||||
complete()
|
||||
myFixture.checkResult '''
|
||||
$some_long_variable_name = Obj::instance();
|
||||
$some_local<caret>
|
||||
'''
|
||||
backComplete()
|
||||
myFixture.checkResult '''
|
||||
$some_long_variable_name = Obj::instance();
|
||||
$some_long_variable_name<caret>
|
||||
'''
|
||||
|
||||
}
|
||||
|
||||
public void "test no middle matching"() {
|
||||
@@ -144,4 +157,8 @@ class Xoo {
|
||||
private void complete() {
|
||||
myFixture.performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION)
|
||||
}
|
||||
|
||||
private void backComplete() {
|
||||
myFixture.performEditorAction(IdeActions.ACTION_HIPPIE_BACKWARD_COMPLETION)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -27,11 +27,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
* lie under corresponding first parameter of one method.
|
||||
*
|
||||
* @see GlobalInspectionTool
|
||||
*
|
||||
* Please note that if your inspection/fixes/suppressions don't need UI components (e.g. Editor) to run, consider using
|
||||
* {@link BaseJavaBatchLocalInspectionTool} instead.
|
||||
*/
|
||||
public abstract class BaseJavaLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool implements CustomSuppressableInspectionTool {
|
||||
@Override
|
||||
public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
|
||||
return SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(getShortName()));
|
||||
String shortName = getShortName();
|
||||
HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
|
||||
if (key == null) {
|
||||
throw new AssertionError("HighlightDisplayKey.find(" + shortName + ") is null. Inspection: "+getClass());
|
||||
}
|
||||
return SuppressManager.getInstance().createSuppressActions(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
@@ -19,6 +19,7 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointer;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -38,4 +39,7 @@ public abstract class JavaDeploymentSourceUtil {
|
||||
@NotNull
|
||||
public abstract List<DeploymentSource> createArtifactDeploymentSources(@NotNull Project project,
|
||||
@NotNull Collection<? extends Artifact> artifacts);
|
||||
|
||||
@NotNull
|
||||
public abstract List<DeploymentSource> createArtifactDeploymentSources(Project project, ArtifactType... artifactTypes);
|
||||
}
|
||||
|
||||
+18
-6
@@ -16,17 +16,14 @@
|
||||
package com.intellij.remoteServer.impl.configuration.deployment;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointer;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointerManager;
|
||||
import com.intellij.packaging.artifacts.*;
|
||||
import com.intellij.remoteServer.configuration.deployment.ArtifactDeploymentSource;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import com.intellij.remoteServer.configuration.deployment.JavaDeploymentSourceUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -49,4 +46,19 @@ public class JavaDeploymentSourceUtilImpl extends JavaDeploymentSourceUtil {
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<DeploymentSource> createArtifactDeploymentSources(Project project, ArtifactType... artifactTypes) {
|
||||
if (project.isDefault()) return Collections.emptyList();
|
||||
Artifact[] artifacts = ArtifactManager.getInstance(project).getArtifacts();
|
||||
List<Artifact> supportedArtifacts = new ArrayList<Artifact>();
|
||||
Set<ArtifactType> typeSet = ContainerUtil.set(artifactTypes);
|
||||
for (Artifact artifact : artifacts) {
|
||||
if (typeSet.contains(artifact.getArtifactType())) {
|
||||
supportedArtifacts.add(artifact);
|
||||
}
|
||||
}
|
||||
return createArtifactDeploymentSources(project, supportedArtifacts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 AnalysisScopeBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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 DaemonBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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 InspectionsBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
+3
-1
@@ -81,7 +81,9 @@ public class FilePatternPackageSet extends PatternBasedPackageSet {
|
||||
|
||||
private boolean fileMatcher(VirtualFile virtualFile, ProjectFileIndex fileIndex, VirtualFile projectBaseDir){
|
||||
final String relativePath = getRelativePath(virtualFile, fileIndex, true, projectBaseDir);
|
||||
LOG.assertTrue(relativePath != null, "vFile: " + virtualFile + "; projectBaseDir: " + projectBaseDir + "; content File: "+fileIndex.getContentRootForFile(virtualFile));
|
||||
if (relativePath == null) {
|
||||
LOG.error("vFile: " + virtualFile + "; projectBaseDir: " + projectBaseDir + "; content File: "+fileIndex.getContentRootForFile(virtualFile));
|
||||
}
|
||||
return myFilePattern.matcher(relativePath).matches();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 QuickFixBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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 CodeInsightBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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.
|
||||
@@ -39,8 +39,7 @@ public class CoreBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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 IdeBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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 EditorBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.patterns;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -63,6 +64,15 @@ public class PsiFilePattern<T extends PsiFile, Self extends PsiFilePattern<T, Se
|
||||
});
|
||||
}
|
||||
|
||||
public Self withFileType(final ElementPattern<? extends FileType> fileTypePattern) {
|
||||
return with(new PatternCondition<T>("withFileType") {
|
||||
@Override
|
||||
public boolean accepts(@NotNull T file, ProcessingContext context) {
|
||||
return fileTypePattern.accepts(file.getFileType(), context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class Capture<T extends PsiFile> extends PsiFilePattern<T,Capture<T>> {
|
||||
|
||||
protected Capture(final Class<T> aClass) {
|
||||
|
||||
@@ -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 PsiBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ public class PsiCacheKey<T,H extends PsiElement> extends Key<SoftReference<Pair<
|
||||
@Nullable
|
||||
public final T getCachedValueOrNull(@NotNull H h) {
|
||||
SoftReference<Pair<Long, T>> ref = h.getUserData(this);
|
||||
Pair<Long, T> data = ref == null ? null : ref.get();
|
||||
Pair<Long, T> data = SoftReference.dereference(ref);
|
||||
if (data == null || data.getFirst() != h.getManager().getModificationTracker().getJavaStructureModificationCount()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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 LangBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.mock;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -8,6 +23,7 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.WeakFactoryMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -51,7 +67,7 @@ public class MockFileDocumentManagerImpl extends FileDocumentManager {
|
||||
public Document getCachedDocument(@NotNull VirtualFile file) {
|
||||
if (myCachedDocumentKey != null) {
|
||||
Reference<Document> reference = file.getUserData(myCachedDocumentKey);
|
||||
return reference != null ? reference.get() : null;
|
||||
return SoftReference.dereference(reference);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -188,7 +188,7 @@ abstract class CharArray implements CharSequenceBackedByArray, Dumpable {
|
||||
}
|
||||
CharSequence originalSequence = myOriginalSequence;
|
||||
int origLen = originalSequence == null ? -1 : originalSequence.length();
|
||||
String string = myStringRef == null ? null : myStringRef.get();
|
||||
String string = com.intellij.reference.SoftReference.dereference(myStringRef);
|
||||
int stringLen = string == null ? -1 : string.length();
|
||||
assert origLen == stringLen || origLen==-1 || stringLen==-1;
|
||||
|
||||
@@ -219,7 +219,7 @@ abstract class CharArray implements CharSequenceBackedByArray, Dumpable {
|
||||
|
||||
myDebugArray.assertConsistency();
|
||||
|
||||
CharSequence str = myStringRef == null ? null : myStringRef.get();
|
||||
CharSequence str = com.intellij.reference.SoftReference.dereference(myStringRef);
|
||||
if (str == null) {
|
||||
if (myHasDeferredChanges) {
|
||||
str = doSubString(0, myCount + myDeferredShift).toString();
|
||||
@@ -388,7 +388,7 @@ abstract class CharArray implements CharSequenceBackedByArray, Dumpable {
|
||||
@NotNull
|
||||
public String toString() {
|
||||
assertConsistency();
|
||||
String str = myStringRef == null ? null : myStringRef.get();
|
||||
String str = com.intellij.reference.SoftReference.dereference(myStringRef);
|
||||
if (str == null) {
|
||||
if (myHasDeferredChanges) {
|
||||
str = substring(0, length()).toString();
|
||||
|
||||
@@ -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 FileTypesBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -355,14 +355,14 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
|
||||
@Nullable
|
||||
private Document getCachedDocument() {
|
||||
final Document document = myDocument != null ? myDocument.get() : null;
|
||||
final Document document = com.intellij.reference.SoftReference.dereference(myDocument);
|
||||
if (document != null) return document;
|
||||
return FileDocumentManager.getInstance().getCachedDocument(getVirtualFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Document getDocument() {
|
||||
Document document = myDocument != null ? myDocument.get() : null;
|
||||
Document document = com.intellij.reference.SoftReference.dereference(myDocument);
|
||||
if (document == null/* TODO[ik] make this change && isEventSystemEnabled()*/) {
|
||||
document = FileDocumentManager.getInstance().getDocument(getVirtualFile());
|
||||
myDocument = new SoftReference<Document>(document);
|
||||
@@ -535,7 +535,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
|
||||
@Override
|
||||
public long getModificationStamp() {
|
||||
Document document = myDocument == null ? null : myDocument.get();
|
||||
Document document = com.intellij.reference.SoftReference.dereference(myDocument);
|
||||
if (document != null) return document.getModificationStamp();
|
||||
return myVirtualFile.getModificationStamp();
|
||||
}
|
||||
|
||||
@@ -193,8 +193,7 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
}
|
||||
|
||||
private RangeMarker getMarker() {
|
||||
Reference<RangeMarker> ref = myMarkerRef;
|
||||
return ref == null ? null : ref.get();
|
||||
return com.intellij.reference.SoftReference.dereference(myMarkerRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
|
||||
private static <E extends PsiElement> SmartPointerEx<E> getCachedPointer(@NotNull E element) {
|
||||
Reference<SmartPointerEx> data = element.getUserData(CACHED_SMART_POINTER_KEY);
|
||||
SmartPointerEx cachedPointer = data == null ? null : data.get();
|
||||
SmartPointerEx cachedPointer = SoftReference.dereference(data);
|
||||
if (cachedPointer != null) {
|
||||
PsiElement cachedElement = cachedPointer.getCachedElement();
|
||||
if (cachedElement != null && cachedElement != element) {
|
||||
|
||||
+2
-3
@@ -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.
|
||||
@@ -93,8 +93,7 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
|
||||
|
||||
@Override
|
||||
public E getCachedElement() {
|
||||
Reference<E> ref = myElement;
|
||||
return ref == null ? null : ref.get();
|
||||
return com.intellij.reference.SoftReference.dereference(myElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -393,8 +393,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
}
|
||||
|
||||
private void clearStub(@NotNull String reason) {
|
||||
SoftReference<StubTree> stubRef = myStub;
|
||||
StubTree stubHolder = stubRef == null ? null : stubRef.get();
|
||||
StubTree stubHolder = SoftReference.dereference(myStub);
|
||||
if (stubHolder != null) {
|
||||
((PsiFileStubImpl<?>)stubHolder.getRoot()).clearPsi(reason);
|
||||
}
|
||||
@@ -730,7 +729,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
if (myStub == null) return null;
|
||||
|
||||
synchronized (PsiLock.LOCK) {
|
||||
return myStub != null ? myStub.get() : null;
|
||||
return SoftReference.dereference(myStub);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -993,7 +992,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
FileElement fileElement = calcTreeElement();
|
||||
synchronized (myStubFromTreeLock) {
|
||||
SoftReference<StubTree> ref = fileElement.getUserData(STUB_TREE_IN_PARSED_TREE);
|
||||
StubTree tree = ref == null ? null : ref.get();
|
||||
StubTree tree = SoftReference.dereference(ref);
|
||||
|
||||
if (tree == null) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
|
||||
@@ -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.
|
||||
@@ -96,8 +96,7 @@ public abstract class CachedValueBase<T> {
|
||||
|
||||
@Nullable
|
||||
private Data<T> getData() {
|
||||
final SoftReference<Data<T>> ref = myData;
|
||||
return ref == null ? null : ref.get();
|
||||
return SoftReference.dereference(myData);
|
||||
}
|
||||
|
||||
protected boolean isUpToDate(@NotNull Data data) {
|
||||
|
||||
@@ -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.
|
||||
@@ -52,7 +52,7 @@ public class CompressionUtil {
|
||||
public static int writeCompressed(DataOutput out, byte[] bytes, int length) throws IOException {
|
||||
if (length > COMPRESSION_THRESHOLD && ourCanUseSnappy) {
|
||||
SoftReference<byte[]> reference = spareBufferLocal.get();
|
||||
byte[] compressedOutputBuffer = reference != null ? reference.get():null;
|
||||
byte[] compressedOutputBuffer = com.intellij.reference.SoftReference.dereference(reference);
|
||||
int maxCompressedSize = 32 + length + length / 6; // snappy.cc#MaxCompressedLength
|
||||
if (compressedOutputBuffer == null || compressedOutputBuffer.length < maxCompressedSize) {
|
||||
compressedOutputBuffer = new byte[maxCompressedSize];
|
||||
|
||||
@@ -40,8 +40,7 @@ public class DvcsBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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.
|
||||
@@ -81,8 +81,7 @@ public class RefactoringBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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.
|
||||
@@ -55,8 +55,7 @@ public class UsageViewBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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 CodeEditorBundle {
|
||||
}
|
||||
|
||||
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<ResourceBundle>(bundle);
|
||||
|
||||
+1
-1
@@ -781,7 +781,7 @@ public class CodeCompletionHandlerBase {
|
||||
final Document document = cached.second;
|
||||
assert document != null;
|
||||
file.putUserData(FILE_COPY_KEY, new SoftReference<Trinity<PsiFile,Document, Long>>(Trinity.create(copy, document, combinedOffsets)));
|
||||
document.setText(file.getText());
|
||||
document.setText(file.getViewProvider().getContents());
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.ide.highlighter.custom.SyntaxTable;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.psi.CustomHighlighterTokenType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.patterns.PlatformPatterns.psiElement;
|
||||
import static com.intellij.patterns.PlatformPatterns.psiFile;
|
||||
import static com.intellij.patterns.StandardPatterns.instanceOf;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class CustomFileTypeCompletionContributor extends CompletionContributor {
|
||||
public CustomFileTypeCompletionContributor() {
|
||||
extend(CompletionType.BASIC, psiElement().inFile(psiFile().withFileType(instanceOf(CustomSyntaxTableFileType.class))),
|
||||
new CompletionProvider<CompletionParameters>() {
|
||||
@Override
|
||||
protected void addCompletions(@NotNull CompletionParameters parameters,
|
||||
ProcessingContext context,
|
||||
@NotNull CompletionResultSet result) {
|
||||
if (inCommentOrLiteral(parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomSyntaxTableFileType fileType = (CustomSyntaxTableFileType)parameters.getOriginalFile().getFileType();
|
||||
SyntaxTable syntaxTable = fileType.getSyntaxTable();
|
||||
String prefix = findPrefix(parameters.getPosition(), parameters.getOffset());
|
||||
CompletionResultSet resultSetWithPrefix = result.withPrefixMatcher(prefix);
|
||||
|
||||
addVariants(resultSetWithPrefix, syntaxTable.getKeywords1());
|
||||
addVariants(resultSetWithPrefix, syntaxTable.getKeywords2());
|
||||
addVariants(resultSetWithPrefix, syntaxTable.getKeywords3());
|
||||
addVariants(resultSetWithPrefix, syntaxTable.getKeywords4());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean inCommentOrLiteral(CompletionParameters parameters) {
|
||||
HighlighterIterator iterator = ((EditorEx)parameters.getEditor()).getHighlighter().createIterator(parameters.getOffset());
|
||||
IElementType elementType = iterator.getTokenType();
|
||||
if (elementType == CustomHighlighterTokenType.WHITESPACE) {
|
||||
iterator.retreat();
|
||||
elementType = iterator.getTokenType();
|
||||
}
|
||||
return elementType == CustomHighlighterTokenType.LINE_COMMENT ||
|
||||
elementType == CustomHighlighterTokenType.MULTI_LINE_COMMENT ||
|
||||
elementType == CustomHighlighterTokenType.STRING ||
|
||||
elementType == CustomHighlighterTokenType.SINGLE_QUOTED_STRING;
|
||||
}
|
||||
|
||||
private static void addVariants(CompletionResultSet resultSet, Set<String> keywords) {
|
||||
for (String keyword : keywords) {
|
||||
resultSet.addElement(LookupElementBuilder.create(keyword));
|
||||
}
|
||||
}
|
||||
|
||||
private static String findPrefix(PsiElement insertedElement, int offset) {
|
||||
String text = insertedElement.getText();
|
||||
int offsetInElement = offset - insertedElement.getTextOffset();
|
||||
int start = offsetInElement - 1;
|
||||
while(start >=0 ) {
|
||||
if(!Character.isJavaIdentifierStart(text.charAt(start))) break;
|
||||
--start;
|
||||
}
|
||||
return text.substring(start+1, offsetInElement).trim();
|
||||
}
|
||||
|
||||
}
|
||||
-58
@@ -1,58 +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.completion;
|
||||
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.ide.highlighter.custom.SyntaxTable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.filters.TrueFilter;
|
||||
|
||||
/**
|
||||
* @author Maxim.Mossienko
|
||||
*/
|
||||
public class SyntaxTableCompletionData extends CompletionData{
|
||||
private final SyntaxTable mySyntaxTable;
|
||||
|
||||
public SyntaxTableCompletionData(SyntaxTable _syntaxTable) {
|
||||
mySyntaxTable = _syntaxTable;
|
||||
mySyntaxTable.getKeywords1();
|
||||
|
||||
final CompletionVariant variant = new CompletionVariant(TrueFilter.INSTANCE);
|
||||
variant.includeScopeClass(PsiElement.class, true);
|
||||
variant.addCompletionFilter(TrueFilter.INSTANCE);
|
||||
final String[] empty = {};
|
||||
|
||||
variant.addCompletion(mySyntaxTable.getKeywords1().toArray(empty), TailType.NONE);
|
||||
variant.addCompletion(mySyntaxTable.getKeywords2().toArray(empty), TailType.NONE);
|
||||
variant.addCompletion(mySyntaxTable.getKeywords3().toArray(empty), TailType.NONE);
|
||||
variant.addCompletion(mySyntaxTable.getKeywords4().toArray(empty), TailType.NONE);
|
||||
|
||||
registerVariant(variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findPrefix(PsiElement insertedElement, int offset) {
|
||||
String text = insertedElement.getText();
|
||||
int offsetInElement = offset - insertedElement.getTextOffset();
|
||||
int start = offsetInElement - 1;
|
||||
while(start >=0 ) {
|
||||
if(!Character.isJavaIdentifierStart(text.charAt(start))) break;
|
||||
--start;
|
||||
}
|
||||
return text.substring(start+1, offsetInElement).trim();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -138,7 +138,7 @@ public class WordCompletionContributor extends CompletionContributor implements
|
||||
|
||||
final PsiFile file = insertedElement.getContainingFile();
|
||||
final CompletionData data = CompletionUtil.getCompletionDataByElement(insertedElement, file);
|
||||
if (data != null && !(data instanceof SyntaxTableCompletionData)) {
|
||||
if (data != null) {
|
||||
Set<CompletionVariant> toAdd = new HashSet<CompletionVariant>();
|
||||
data.addKeywordVariants(toAdd, insertedElement, file);
|
||||
for (CompletionVariant completionVariant : toAdd) {
|
||||
|
||||
+36
-20
@@ -65,6 +65,7 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
|
||||
String oldPrefix = completionState.oldPrefix;
|
||||
CompletionVariant lastProposedVariant = completionState.lastProposedVariant;
|
||||
boolean fromOtherFiles = completionState.fromOtherFiles;
|
||||
|
||||
if (lastProposedVariant == null || oldPrefix == null || !new CamelHumpMatcher(oldPrefix).isStartMatch(currentPrefix) ||
|
||||
!currentPrefix.equals(lastProposedVariant.variant)) {
|
||||
@@ -72,15 +73,17 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
oldPrefix = currentPrefix;
|
||||
completionState.oldPrefix = oldPrefix;
|
||||
lastProposedVariant = null;
|
||||
fromOtherFiles = false;
|
||||
}
|
||||
|
||||
CompletionVariant nextVariant = computeNextVariant(editor, oldPrefix, lastProposedVariant, data, file);
|
||||
CompletionVariant nextVariant = computeNextVariant(editor, oldPrefix, lastProposedVariant, data, file, fromOtherFiles);
|
||||
if (nextVariant == null) return;
|
||||
|
||||
int replacementEnd = data.startOffset + data.myWordUnderCursor.length();
|
||||
editor.getDocument().replaceString(data.startOffset, replacementEnd, nextVariant.variant);
|
||||
editor.getCaretModel().moveToOffset(data.startOffset + nextVariant.variant.length());
|
||||
completionState.lastProposedVariant = nextVariant;
|
||||
completionState.fromOtherFiles = nextVariant.editor != editor;
|
||||
highlightWord(nextVariant, project, data);
|
||||
}
|
||||
|
||||
@@ -105,12 +108,15 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
private CompletionVariant computeNextVariant(final Editor editor,
|
||||
@Nullable final String prefix,
|
||||
@Nullable CompletionVariant lastProposedVariant,
|
||||
final CompletionData data, PsiFile file) {
|
||||
final List<CompletionVariant> variants = computeVariants(editor, new CamelHumpMatcher(StringUtil.notNullize(prefix)), file);
|
||||
final CompletionData data,
|
||||
PsiFile file,
|
||||
boolean includeWordsFromOtherFiles
|
||||
) {
|
||||
final List<CompletionVariant> variants = computeVariants(editor, new CamelHumpMatcher(StringUtil.notNullize(prefix)), file, includeWordsFromOtherFiles);
|
||||
if (variants.isEmpty()) return null;
|
||||
|
||||
for (CompletionVariant variant : variants) {
|
||||
if (lastProposedVariant != null) {
|
||||
if (lastProposedVariant != null) {
|
||||
for (CompletionVariant variant : variants) {
|
||||
if (variant.variant.equals(lastProposedVariant.variant)) {
|
||||
if (lastProposedVariant.offset > data.startOffset && variant.offset > data.startOffset) lastProposedVariant = variant;
|
||||
if (lastProposedVariant.offset < data.startOffset && variant.offset < data.startOffset) lastProposedVariant = variant;
|
||||
@@ -135,7 +141,9 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
}
|
||||
else {
|
||||
for (CompletionVariant variant : variants) {
|
||||
if (variant.offset > data.startOffset) return variant;
|
||||
if (variant.offset > data.startOffset) {
|
||||
return variant;
|
||||
}
|
||||
}
|
||||
|
||||
return variants.iterator().next();
|
||||
@@ -149,7 +157,9 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
CompletionVariant result = null;
|
||||
for (CompletionVariant variant : variants) {
|
||||
if (variant == lastProposedVariant) {
|
||||
if (result == null) return variants.get(variants.size() - 1);
|
||||
if (result == null) {
|
||||
return computeNextVariant(editor, prefix, null, data, file, !includeWordsFromOtherFiles);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
result = variant;
|
||||
@@ -165,7 +175,7 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
return i.next();
|
||||
}
|
||||
else {
|
||||
return variants.iterator().next();
|
||||
return computeNextVariant(editor, prefix, null, data, file, !includeWordsFromOtherFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,7 +196,7 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
this.offset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static boolean containsLetters(CharSequence seq, int start, int end) {
|
||||
for (int i = start; i < end; i++) {
|
||||
if (Character.isLetter(seq.charAt(i))) {
|
||||
@@ -196,7 +206,10 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<CompletionVariant> computeVariants(@NotNull final Editor editor, CamelHumpMatcher matcher, PsiFile file) {
|
||||
private static List<CompletionVariant> computeVariants(@NotNull final Editor editor,
|
||||
CamelHumpMatcher matcher,
|
||||
PsiFile file,
|
||||
boolean includeWordsFromOtherFiles) {
|
||||
|
||||
final CharSequence chars = editor.getDocument().getCharsSequence();
|
||||
|
||||
@@ -205,15 +218,17 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
|
||||
final int caretOffset = editor.getCaretModel().getOffset();
|
||||
|
||||
addWordsForEditor((EditorEx)editor, matcher, chars, words, afterWords, caretOffset);
|
||||
|
||||
for(FileEditor fileEditor: FileEditorManager.getInstance(file.getProject()).getAllEditors()) {
|
||||
if (fileEditor instanceof TextEditor) {
|
||||
Editor anotherEditor = ((TextEditor)fileEditor).getEditor();
|
||||
if (anotherEditor != editor) {
|
||||
addWordsForEditor((EditorEx)anotherEditor, matcher, anotherEditor.getDocument().getCharsSequence(), words, afterWords, 0);
|
||||
if (includeWordsFromOtherFiles) {
|
||||
for(FileEditor fileEditor: FileEditorManager.getInstance(file.getProject()).getAllEditors()) {
|
||||
if (fileEditor instanceof TextEditor) {
|
||||
Editor anotherEditor = ((TextEditor)fileEditor).getEditor();
|
||||
if (anotherEditor != editor) {
|
||||
addWordsForEditor((EditorEx)anotherEditor, matcher, anotherEditor.getDocument().getCharsSequence(), words, afterWords, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addWordsForEditor((EditorEx)editor, matcher, chars, words, afterWords, caretOffset);
|
||||
}
|
||||
|
||||
Set<String> allWords = new HashSet<String>();
|
||||
@@ -240,10 +255,10 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private interface TokenProcessor {
|
||||
boolean processToken(int start, int end);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addWordsForEditor(final EditorEx editor,
|
||||
final CamelHumpMatcher matcher,
|
||||
@@ -304,7 +319,7 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
final int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
final CompletionData data = new CompletionData();
|
||||
|
||||
|
||||
processWords(editor, Math.max(offset - 1, 0), new TokenProcessor() {
|
||||
@Override
|
||||
public boolean processToken(int start, int end) {
|
||||
@@ -347,5 +362,6 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
private static class CompletionState {
|
||||
public String oldPrefix;
|
||||
public CompletionVariant lastProposedVariant;
|
||||
public boolean fromOtherFiles;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-15
@@ -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<DocumentationManager> 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<DocumentationManager> 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 {
|
||||
|
||||
+3
-1
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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<LightweightHint> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-17
@@ -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> usageView = new Ref<UsageView>();
|
||||
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> 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
|
||||
|
||||
+4
-11
@@ -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<PsiElement/* doc anchor */, PsiElement /* original element */> getDocInfo() {
|
||||
WeakReference<PsiElement> docAnchorRef = myDocAnchor;
|
||||
if (docAnchorRef == null) {
|
||||
return null;
|
||||
}
|
||||
PsiElement docAnchor = docAnchorRef.get();
|
||||
PsiElement docAnchor = SoftReference.dereference(myDocAnchor);
|
||||
if (docAnchor == null) {
|
||||
return null;
|
||||
}
|
||||
WeakReference<PsiElement> originalElementRef = myOriginalElement;
|
||||
if (originalElementRef == null) {
|
||||
return null;
|
||||
}
|
||||
PsiElement originalElement = originalElementRef.get();
|
||||
PsiElement originalElement = SoftReference.dereference(myOriginalElement);
|
||||
if (originalElement == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+13
-10
@@ -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()) {
|
||||
|
||||
@@ -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<BufferedImage> 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<BufferedImage> 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) {
|
||||
|
||||
@@ -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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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.
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.util.MinimizeButton;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
@@ -52,8 +53,10 @@ public class RegExHelpPopup extends JPanel {
|
||||
" summary=\"Regular expression constructs, and what they match\"> \n" +
|
||||
" \n" +
|
||||
" <tr align=\"left\"> \n" +
|
||||
" <th bgcolor=\"#CCCCFF\" align=\"left\" id=\"construct\">Construct</th> \n" +
|
||||
" <th bgcolor=\"#CCCCFF\" align=\"left\" id=\"matches\">Matches</th> \n" +
|
||||
" <th bgcolor=\"" + toHTMLColor(UIUtil.getLabelBackground()) +
|
||||
"\" align=\"left\" id=\"construct\">Construct</th> \n" +
|
||||
" <th bgcolor=\"" + toHTMLColor(UIUtil.getLabelBackground()) +
|
||||
"\" align=\"left\" id=\"matches\">Matches</th> \n" +
|
||||
" </tr> \n" +
|
||||
" \n" +
|
||||
" <tr><th> </th></tr> \n" +
|
||||
@@ -340,4 +343,7 @@ public class RegExHelpPopup extends JPanel {
|
||||
.setTitle("Regular expressions syntax").setDimensionServiceKey(null, "RegExHelpPopup", true).createPopup();
|
||||
}
|
||||
|
||||
private static String toHTMLColor(Color color) {
|
||||
return "#" + Integer.toHexString(color.getRGB() & 0xffffff);
|
||||
}
|
||||
}
|
||||
|
||||
+100
@@ -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<FoldingDescriptor> 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<FoldingDescriptor> 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<Trinity<Integer, Integer, IElementType>> stack = new LinkedList<Trinity<Integer, Integer, IElementType>>();
|
||||
String editorText = document.getText();
|
||||
while (!iterator.atEnd() && iterator.getStart() < totalRange.getEndOffset()) {
|
||||
final Trinity<Integer, Integer, IElementType> 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;
|
||||
}
|
||||
}
|
||||
+30
@@ -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;
|
||||
}
|
||||
}
|
||||
-3
@@ -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())) {
|
||||
|
||||
@@ -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
|
||||
|
||||
+5
-6
@@ -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<WhiteSpaceFormattingStrategy> getAllStrategies() {
|
||||
final WeakReference<Collection<WhiteSpaceFormattingStrategy>> reference = myCachedStrategies.get();
|
||||
if (reference != null) {
|
||||
final Collection<WhiteSpaceFormattingStrategy> strategies = reference.get();
|
||||
if (strategies != null) {
|
||||
return strategies;
|
||||
}
|
||||
final Collection<WhiteSpaceFormattingStrategy> strategies = SoftReference.dereference(reference);
|
||||
if (strategies != null) {
|
||||
return strategies;
|
||||
}
|
||||
final Collection<Language> languages = Language.getRegisteredLanguages();
|
||||
if (languages == null) {
|
||||
|
||||
@@ -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<SemCacheChunk> ref = myCache.get(root);
|
||||
return ref == null ? null : ref.get();
|
||||
return com.intellij.reference.SoftReference.dereference(ref);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -1095,13 +1095,13 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
if (myProjectsBeingUpdated.contains(project)) return null;
|
||||
|
||||
SoftReference<ProjectIndexableFilesFilter> 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<FileContentImpl> 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;
|
||||
|
||||
@@ -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<ResourceBundle>(bundle);
|
||||
|
||||
+1
-2
@@ -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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<ActionCallback> ref = (WeakReference<ActionCallback>)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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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<Balloon> 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) {
|
||||
|
||||
@@ -71,6 +71,7 @@ public interface IdeActions {
|
||||
@NonNls String ACTION_SMART_TYPE_COMPLETION = "SmartTypeCompletion";
|
||||
@Deprecated @NonNls String ACTION_CLASS_NAME_COMPLETION = "ClassNameCompletion";
|
||||
@NonNls String ACTION_HIPPIE_COMPLETION = "HippieCompletion";
|
||||
@NonNls String ACTION_HIPPIE_BACKWARD_COMPLETION = "HippieBackwardCompletion";
|
||||
@NonNls String ACTION_CHOOSE_LOOKUP_ITEM = "EditorChooseLookupItem";
|
||||
@NonNls String ACTION_CHOOSE_LOOKUP_ITEM_ALWAYS = "EditorChooseLookupItemAlways";
|
||||
@NonNls String ACTION_CHOOSE_LOOKUP_ITEM_REPLACE = "EditorChooseLookupItemReplace";
|
||||
|
||||
@@ -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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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<ResourceBundle>(bundle);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ResourceBundle>(bundle);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user