diff --git a/.idea/libraries/jna.xml b/.idea/libraries/jna.xml
index 7a9e4319d055..d9fed3852d8f 100644
--- a/.idea/libraries/jna.xml
+++ b/.idea/libraries/jna.xml
@@ -3,7 +3,6 @@
-
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java b/java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java
index 9ff1b2bec9fd..d8d8dd469c43 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * 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.
@@ -130,13 +130,8 @@ class ReloadClassesWorker {
continue;
}
redefineProcessor.processClass(qualifiedName, content);
- if (myProgress.isCancelled()) {
- break;
- }
- }
- if (!myProgress.isCancelled()) {
- redefineProcessor.processPending();
}
+ redefineProcessor.processPending();
myProgress.setFraction(1);
final int partiallyRedefinedClassesCount = redefineProcessor.getPartiallyRedefinedClassesCount();
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
index 12af14a61b5c..15bb4fe3bd4c 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
@@ -288,9 +288,48 @@ public class HighlightUtil extends HighlightUtilBase {
}
+ @Nullable
+ static HighlightInfo checkIntersectionInTypeCast(@NotNull PsiTypeCastExpression expression) {
+ final PsiTypeElement castTypeElement = expression.getCastType();
+ if (castTypeElement == null) return null;
+ PsiType castType = castTypeElement.getType();
+ if (isIntersection(castTypeElement, castType)) {
+ if (PsiUtil.isLanguageLevel8OrHigher(expression)) {
+ final PsiTypeElement[] conjuncts = PsiTreeUtil.getChildrenOfType(castTypeElement, PsiTypeElement.class);
+ if (conjuncts != null) {
+ final List conjList = new ArrayList(Arrays.asList(conjuncts));
+ for (int i = 1; i < conjuncts.length; i++) {
+ final PsiTypeElement conjunct = conjuncts[i];
+ final PsiType conjType = conjunct.getType();
+ if (conjType instanceof PsiClassType) {
+ final PsiClass aClass = ((PsiClassType)conjType).resolve();
+ if (aClass != null && !aClass.isInterface()) {
+ final HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
+ .range(conjunct)
+ .descriptionAndTooltip(JavaErrorMessages.message("interface.expected")).create();
+ QuickFixAction.registerQuickFixAction(errorResult, new FlipIntersectionSidesFix(aClass.getName(), conjList, conjunct, castTypeElement), null);
+ return errorResult;
+ }
+ }
+ }
+ }
+ } else {
+ return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
+ .range(expression)
+ .descriptionAndTooltip("Intersection types in cast are not supported at this language level").create();
+ }
+ }
+ return null;
+ }
+
+ static boolean isIntersection(PsiTypeElement castTypeElement, PsiType castType) {
+ if (castType instanceof PsiIntersectionType) return true;
+ return PsiTreeUtil.getChildrenOfType(castTypeElement, PsiTypeElement.class) != null;
+ }
+
@Nullable
static HighlightInfo checkInconvertibleTypeCast(@NotNull PsiTypeCastExpression expression) {
- PsiTypeElement castTypeElement = expression.getCastType();
+ final PsiTypeElement castTypeElement = expression.getCastType();
if (castTypeElement == null) return null;
PsiType castType = castTypeElement.getType();
@@ -306,6 +345,7 @@ public class HighlightUtil extends HighlightUtilBase {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
+
return null;
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
index d24c311e4a53..f552a66c25ab 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
@@ -1336,6 +1336,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
public void visitTypeCastExpression(PsiTypeCastExpression typeCast) {
super.visitTypeCastExpression(typeCast);
try {
+ if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkIntersectionInTypeCast(typeCast));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkInconvertibleTypeCast(typeCast));
}
catch (IndexNotReadyException ignore) {
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FlipIntersectionSidesFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FlipIntersectionSidesFix.java
new file mode 100644
index 000000000000..8eed99632fda
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FlipIntersectionSidesFix.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.daemon.impl.quickfix;
+
+import com.intellij.codeInsight.FileModificationService;
+import com.intellij.codeInsight.intention.IntentionAction;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.util.Function;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+/**
+* User: anna
+* Date: 10/31/13
+*/
+public class FlipIntersectionSidesFix implements IntentionAction {
+ private static final Logger LOG = Logger.getInstance("#" + FlipIntersectionSidesFix.class.getName());
+ private final String myClassName;
+ private final List myConjuncts;
+ private final PsiTypeElement myConjunct;
+ private final PsiTypeElement myCastTypeElement;
+
+ public FlipIntersectionSidesFix(String className,
+ @NotNull List conjList,
+ PsiTypeElement conjunct,
+ PsiTypeElement castTypeElement) {
+ myClassName = className;
+ myConjuncts = conjList;
+ LOG.assertTrue(!conjList.isEmpty());
+ myConjunct = conjunct;
+ myCastTypeElement = castTypeElement;
+ }
+
+ @NotNull
+ @Override
+ public String getText() {
+ return "Move '" + myClassName + "' to the beginning";
+ }
+
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return "Move to front";
+ }
+
+ @Override
+ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+ for (PsiTypeElement typeElement : myConjuncts) {
+ if (!typeElement.isValid()) return false;
+ }
+ return !Comparing.strEqual(myConjunct.getText(), myConjuncts.get(0).getText());
+ }
+
+ @Override
+ public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+ if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
+ myConjuncts.remove(myConjunct);
+ myConjuncts.add(0, myConjunct);
+
+ final String intersectionTypeText = StringUtil.join(myConjuncts, new Function() {
+ @Override
+ public String fun(PsiTypeElement element) {
+ return element.getText();
+ }
+ }, " & ");
+ final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
+ final PsiTypeCastExpression fixedCast =
+ (PsiTypeCastExpression)elementFactory.createExpressionFromText("(" + intersectionTypeText + ") a", myCastTypeElement);
+ final PsiTypeElement fixedCastCastType = fixedCast.getCastType();
+ LOG.assertTrue(fixedCastCastType != null);
+ final PsiElement flippedTypeElement = myCastTypeElement.replace(fixedCastCastType);
+ CodeStyleManager.getInstance(project).reformat(flippedTypeElement);
+ }
+
+ @Override
+ public boolean startInWriteAction() {
+ return true;
+ }
+}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyWithThisFix.java
similarity index 88%
rename from java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java
rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyWithThisFix.java
index cebb50c019ea..beb210744589 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyWithThisFix.java
@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.codeInsight.daemon.impl.analysis;
+package com.intellij.codeInsight.daemon.impl.quickfix;
+import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -26,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
/**
* User: anna
*/
-class QualifyWithThisFix implements IntentionAction {
+public class QualifyWithThisFix implements IntentionAction {
private final PsiClass myContainingClass;
private final PsiElement myExpression;
@@ -54,6 +55,7 @@ class QualifyWithThisFix implements IntentionAction {
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+ if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
final PsiThisExpression thisExpression =
RefactoringChangeUtil.createThisExpression(PsiManager.getInstance(project), myContainingClass);
((PsiReferenceExpression)myExpression).setQualifierExpression(thisExpression);
diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
index 51e2fdf0341f..115b646768c8 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
@@ -179,7 +179,15 @@ public class TypeConversionUtil {
}
return false;
}
- else if (toType instanceof PsiIntersectionType) return false;
+ else if (toType instanceof PsiIntersectionType) {
+ if (fromType instanceof PsiClassType && ((PsiClassType)fromType).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_8)) {
+ for (PsiType conjunct : ((PsiIntersectionType)toType).getConjuncts()) {
+ if (!isNarrowingReferenceConversionAllowed(fromType, conjunct)) return false;
+ }
+ return true;
+ }
+ return false;
+ }
if (fromType instanceof PsiDisjunctionType) {
return isNarrowingReferenceConversionAllowed(((PsiDisjunctionType)fromType).getLeastUpperBound(), toType);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
index 50df51eaa7a4..de5d470e8e69 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
@@ -445,14 +445,18 @@ public class InferenceSession {
}
else if (acceptObject || upperBounds.size() > 1 || !upperBounds.get(0).equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
PsiType glb = null;
- for (PsiType upperBound : upperBounds) {
- upperBound = acceptBoundsWithRecursiveDependencies(typeParameter, upperBound, substitutor);
- if (isProperType(upperBound, false)) {
- if (glb == null) {
- glb = upperBound;
- }
- else {
- glb = GenericsUtil.getGreatestLowerBound(glb, upperBound);
+ if (isThrowable(upperBounds)) {
+ glb = PsiType.getJavaLangRuntimeException(myManager, GlobalSearchScope.allScope(myManager.getProject()));
+ } else {
+ for (PsiType upperBound : upperBounds) {
+ upperBound = acceptBoundsWithRecursiveDependencies(typeParameter, upperBound, substitutor);
+ if (isProperType(upperBound, false)) {
+ if (glb == null) {
+ glb = upperBound;
+ }
+ else {
+ glb = GenericsUtil.getGreatestLowerBound(glb, upperBound);
+ }
}
}
}
@@ -473,6 +477,20 @@ public class InferenceSession {
return substitutor;
}
+ private static boolean isThrowable(List upperBounds) {
+ boolean commonThrowable = false;
+ for (PsiType upperBound : upperBounds) {
+ if (upperBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) continue;
+ if (upperBound.equalsToText(CommonClassNames.JAVA_LANG_EXCEPTION) ||
+ upperBound.equalsToText(CommonClassNames.JAVA_LANG_THROWABLE)) {
+ commonThrowable = true;
+ } else {
+ return false;
+ }
+ }
+ return commonThrowable;
+ }
+
private PsiType acceptBoundsWithRecursiveDependencies(PsiTypeParameter typeParameter, PsiType bound, PsiSubstitutor substitutor) {
if (!isProperType(bound)) {
final PsiSubstitutor subst = PsiUtil.resolveClassInType(bound) != typeParameter ? substitutor.put(typeParameter, null) : substitutor;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersection.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersection.java
new file mode 100644
index 000000000000..66affa9cde79
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersection.java
@@ -0,0 +1,11 @@
+import java.io.Serializable;
+
+public class FooBar1 {
+ {
+ Object x = null;
+ Object y = (CharSequence & Serializable) x;
+ Object y2 = (CharSequence & Integer) x;
+ Object y3 = (Integer & CharSequence) x;
+ int y1 = (CharSequence & Serializable) x;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/after1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/after1.java
new file mode 100644
index 000000000000..f07cf3847bda
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/after1.java
@@ -0,0 +1,7 @@
+// "Move 'Number' to the beginning" "true"
+class C {
+ {
+ Object x = null;
+ Object y2 = (Number & CharSequence) x;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/before1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/before1.java
new file mode 100644
index 000000000000..38380bc0c315
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/before1.java
@@ -0,0 +1,7 @@
+// "Move 'Number' to the beginning" "true"
+class C {
+ {
+ Object x = null;
+ Object y2 = (CharSequence & Number) x;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/before2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/before2.java
new file mode 100644
index 000000000000..34f28f2733f3
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection/before2.java
@@ -0,0 +1,7 @@
+// "Move 'Number' to the beginning" "false"
+class C {
+ {
+ Object x = null;
+ Object y2 = (Number & Number) x;
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceIntroduceConstantPanel.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FlipIntersectionTypesTest.java
similarity index 56%
rename from plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceIntroduceConstantPanel.java
rename to java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FlipIntersectionTypesTest.java
index 5bd7e5bf48df..ddd8ce49bc9a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceIntroduceConstantPanel.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FlipIntersectionTypesTest.java
@@ -13,24 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.refactoring.introduce.constant;
+package com.intellij.codeInsight.daemon.quickFix;
-import com.intellij.ui.components.JBCheckBox;
-
-import javax.swing.*;
-
-/**
- * Created by Max Medvedev on 8/29/13
- */
-public class GrInplaceIntroduceConstantPanel {
- private JBCheckBox myMoveToAnotherClassJBCheckBox;
- private JPanel myRootPane;
-
- public boolean isMoveToAnotherClass() {
- return myMoveToAnotherClassJBCheckBox.isSelected();
+public class FlipIntersectionTypesTest extends LightQuickFixTestCase {
+ public void test() throws Exception {
+ doAllTests();
}
- public JComponent getRootPane() {
- return myRootPane;
+ @Override
+ protected String getBasePath() {
+ return "/codeInsight/daemonCodeAnalyzer/quickFix/flipIntersection";
}
}
+
diff --git a/lib/jna-platform.jar b/lib/jna-platform.jar
deleted file mode 100644
index 4b3d567c6209..000000000000
Binary files a/lib/jna-platform.jar and /dev/null differ
diff --git a/lib/required_for_dist.txt b/lib/required_for_dist.txt
index f7e7e48ef0b0..5f749bcff7f8 100644
--- a/lib/required_for_dist.txt
+++ b/lib/required_for_dist.txt
@@ -21,7 +21,6 @@ jgoodies-forms.jar
jgoodies-looks-2.4.2.jar
jh.jar
jna-utils.jar
-jna-platform.jar
jna.jar
jsch-0.1.50.jar
jsr166e.jar
diff --git a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java
index 69c2b0cdf326..207b819fff23 100644
--- a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java
+++ b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java
@@ -163,40 +163,39 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
}
else {
final String decoded = decode(text);
- if (decoded != null) {
- if (context instanceof PackagePrefixFileSystemItem) {
- context = ((PackagePrefixFileSystemItem)context).getDirectory();
+ if (context instanceof PackagePrefixFileSystemItem) {
+ context = ((PackagePrefixFileSystemItem)context).getDirectory();
+ }
+
+ if (context instanceof PsiDirectory && caseSensitivityApplies((PsiDirectory)context, caseSensitive)) {
+ // optimization: do not load all children into VFS
+ PsiDirectory directory = (PsiDirectory)context;
+ PsiFileSystemItem child = directory.findFile(decoded);
+ if (child == null) child = directory.findSubdirectory(decoded);
+ if (child != null) {
+ result.add(new PsiElementResolveResult(getOriginalFile(child)));
}
-
- if (context instanceof PsiDirectory && caseSensitivityApplies((PsiDirectory)context, caseSensitive)) {
- // optimization: do not load all children into VFS
- PsiDirectory directory = (PsiDirectory)context;
- PsiFileSystemItem child = directory.findFile(decoded);
- if (child == null) child = directory.findSubdirectory(decoded);
- if (child != null) {
- result.add(new PsiElementResolveResult(getOriginalFile(child)));
+ }
+ else {
+ processVariants(context, new PsiFileSystemItemProcessor() {
+ @Override
+ public boolean acceptItem(String name, boolean isDirectory) {
+ return caseSensitive ? decoded.equals(name) : decoded.compareToIgnoreCase(name) == 0;
}
- }
- else {
- processVariants(context, new PsiFileSystemItemProcessor() {
- @Override
- public boolean acceptItem(String name, boolean isDirectory) {
- return caseSensitive ? decoded.equals(name) : decoded.compareToIgnoreCase(name) == 0;
- }
- @Override
- public boolean execute(@NotNull PsiFileSystemItem element) {
- result.add(new PsiElementResolveResult(getOriginalFile(element)));
- return true;
- }
- });
- }
+ @Override
+ public boolean execute(@NotNull PsiFileSystemItem element) {
+ result.add(new PsiElementResolveResult(getOriginalFile(element)));
+ return true;
+ }
+ });
}
}
}
}
+ @NotNull
public String getFileNameToCreate() {
return decode(getCanonicalText());
}
@@ -218,8 +217,8 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
!myFileReferenceSet.isEndingSlashNotAllowed() && myIndex > 0);
}
- @Nullable
- public String decode(final String text) {
+ @NotNull
+ public String decode(@NotNull final String text) {
// strip http get parameters
String _text = text;
if (text.indexOf('?') >= 0) {
@@ -228,7 +227,7 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
if (myFileReferenceSet.isUrlEncoded()) {
try {
- return new URI(_text).getPath();
+ return StringUtil.notNullize(new URI(_text).getPath(), text);
}
catch (Exception e) {
return text;
@@ -504,7 +503,7 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
public String getUnresolvedMessagePattern() {
return LangBundle.message("error.cannot.resolve")
+ " " + (isLast() ? LangBundle.message("terms.file") : LangBundle.message("terms.directory"))
- + " '" + StringUtil.escapePattern(StringUtil.notNullize(decode(getCanonicalText()))) + "'";
+ + " '" + StringUtil.escapePattern(decode(getCanonicalText())) + "'";
}
public final boolean isLast() {
diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java
index 04a67b29b829..444bc492aa81 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java
@@ -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.
@@ -44,7 +44,7 @@ import java.util.List;
// This prevents languages with polyadic expressions or sequences
// from reusing it, use simpleChooser instead.
public abstract class OccurrencesChooser {
- public static enum ReplaceChoice {
+ public enum ReplaceChoice {
NO("Replace this occurrence only"), NO_WRITE("Replace all occurrences but write"), ALL("Replace all {0} occurrences");
private final String myDescription;
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
index 33f23494b341..fc7335595a10 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import com.intellij.lang.refactoring.NamesValidator;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.command.impl.FinishMarkAction;
@@ -327,7 +328,7 @@ public abstract class InplaceRefactoring {
new WriteCommandAction(myProject, getCommandName()) {
@Override
- protected void run(com.intellij.openapi.application.Result result) throws Throwable {
+ protected void run(Result result) throws Throwable {
startTemplate(builder);
}
}.execute();
diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java
index 501fd0457aaf..2f2418b2ca35 100644
--- a/platform/util/src/com/intellij/openapi/application/PathManager.java
+++ b/platform/util/src/com/intellij/openapi/application/PathManager.java
@@ -416,9 +416,7 @@ public class PathManager {
// helpers
private static String getAbsolutePath(String path) {
- if (path.startsWith("~/") || path.startsWith("~\\")) {
- path = getUserHome() + path.substring(1);
- }
+ path = FileUtil.expandUserHome(path);
return new File(path).getAbsolutePath();
}
diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
index cd3668c73250..677587c19876 100644
--- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
@@ -1213,6 +1213,13 @@ public class FileUtil extends FileUtilRt {
return path;
}
+ public static String expandUserHome(String path) {
+ if (path.startsWith("~/") || path.startsWith("~\\")) {
+ path = SystemProperties.getUserHome() + path.substring(1);
+ }
+ return path;
+ }
+
@NotNull
public static File[] notNullize(@Nullable File[] files) {
return notNullize(files, ArrayUtil.EMPTY_FILE_ARRAY);
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/ContentRevisionFactory.java b/platform/vcs-log/api/src/com/intellij/vcs/log/ContentRevisionFactory.java
new file mode 100644
index 000000000000..dcf81e7b18c6
--- /dev/null
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/ContentRevisionFactory.java
@@ -0,0 +1,35 @@
+/*
+ * 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.vcs.log;
+
+import com.intellij.openapi.vcs.changes.ContentRevision;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ *
This factory is used to create a particular {@link ContentRevision} instance which corresponds to the file and the commit hash.
+ *
Different VCS plugins may use different {@link ContentRevision} implementation, therefore we need to be able
+ * to retrieve a correct instance for a commit.
Full details of a commit: all metadata (commit message, author, committer, etc.) and the changes.
*
These details will be shown in dedicated panels displayed near the log.
*
An instance of this object can be obtained via
- * {@link VcsLogObjectsFactory#createFullDetails(
- * Hash, List, long, VirtualFile, String, String, String, String, String, String, long, List) VcsLogObjectsFactory#createFullDetails}