Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-09-11 17:37:25 +02:00
18 changed files with 183 additions and 94 deletions
@@ -51,11 +51,12 @@ import java.util.*;
*/
public class GenericsHighlightUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil");
private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
private GenericsHighlightUtil() {
}
private GenericsHighlightUtil() { }
@Nullable
public static HighlightInfo checkInferredTypeArguments(PsiMethod genericMethod,
PsiMethodCallExpression call,
PsiSubstitutor substitutor) {
@@ -67,7 +68,8 @@ public class GenericsHighlightUtil {
PsiClassType[] extendsTypes = typeParameter.getExtendsListTypes();
for (PsiClassType type : extendsTypes) {
PsiType extendsType = substitutor.substitute(type);
if (substituted instanceof PsiWildcardType && TypeConversionUtil.erasure(extendsType).equals(TypeConversionUtil.erasure(((PsiWildcardType)substituted).getExtendsBound()))) {
if (substituted instanceof PsiWildcardType &&
TypeConversionUtil.erasure(extendsType).equals(TypeConversionUtil.erasure(((PsiWildcardType)substituted).getExtendsBound()))) {
PsiType extendsBound = ((PsiWildcardType)substituted).getExtendsBound();
if (extendsBound instanceof PsiClassType) {
PsiType[] parameters = ((PsiClassType)extendsBound).getParameters();
@@ -103,7 +105,7 @@ public class GenericsHighlightUtil {
}
@Nullable
public static HighlightInfo checkParameterizedReferenceTypeArguments(PsiElement resolved,
public static HighlightInfo checkParameterizedReferenceTypeArguments(final PsiElement resolved,
final PsiJavaCodeReferenceElement referenceElement,
final PsiSubstitutor substitutor) {
if (!(resolved instanceof PsiTypeParameterListOwner)) return null;
@@ -116,18 +118,14 @@ public class GenericsHighlightUtil {
final PsiReferenceParameterList referenceParameterList,
final PsiSubstitutor substitutor,
boolean registerIntentions) {
if (referenceParameterList != null) {
HighlightInfo info = HighlightUtil.checkGenericsFeature(referenceParameterList, referenceParameterList.getTypeParameterElements().length);
if (info != null) return info;
}
PsiDiamondType.DiamondInferenceResult inferenceResult = null;
PsiTypeElement[] referenceElements = null;
if (referenceParameterList != null) {
referenceElements = referenceParameterList.getTypeParameterElements();
if (referenceElements.length == 1 && referenceElements[0].getType() instanceof PsiDiamondType) {
if (!typeParameterListOwner.hasTypeParameters()) {
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceElements[0], "Diamond operator is not applicable for non-parameterized types");
final String description = JavaErrorMessages.message("generics.diamond.not.applicable");
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceElements[0], description);
}
inferenceResult = ((PsiDiamondType)referenceElements[0].getType()).resolveInferredTypes();
final String errorMessage = inferenceResult.getErrorMessage();
@@ -165,9 +163,9 @@ public class GenericsHighlightUtil {
if (description != null) {
final HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceParameterList, description);
if (registerIntentions) {
PsiElement pparent = referenceParameterList.getParent().getParent();
if (pparent instanceof PsiTypeElement) {
PsiElement variable = pparent.getParent();
PsiElement grandParent = referenceParameterList.getParent().getParent();
if (grandParent instanceof PsiTypeElement) {
PsiElement variable = grandParent.getParent();
if (variable instanceof PsiVariable) {
if (targetParametersNum == 0) {
QuickFixAction.registerQuickFixAction(highlightInfo, new RemoveTypeArgumentsFix(variable));
@@ -1029,7 +1027,7 @@ public class GenericsHighlightUtil {
MethodSignatureBackedByPsiMethod superMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
if (superMethod == null) {
HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, overrideAnnotation,
JavaErrorMessages.message("method.doesnot.override.super"));
JavaErrorMessages.message("method.does.not.override.super"));
PullAsAbstractUpFix.registerQuickFix(highlightInfo, method);
return highlightInfo;
}
@@ -1245,6 +1243,26 @@ public class GenericsHighlightUtil {
return list;
}
@Nullable
public static HighlightInfo checkParametersAllowed(PsiReferenceParameterList refParamList) {
HighlightInfo info = HighlightUtil.checkGenericsFeature(refParamList, refParamList.getTypeParameterElements().length);
if (info != null) return info;
if (refParamList.getTextLength() != 0) {
final PsiElement parent = refParamList.getParent();
if (parent instanceof PsiReferenceExpression) {
final PsiElement grandParent = parent.getParent();
if (!(grandParent instanceof PsiMethodCallExpression)) {
final String message = JavaErrorMessages.message("generics.reference.parameters.not.allowed");
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, refParamList, message);
}
}
}
return null;
}
@Nullable
public static HighlightInfo checkParametersOnRaw(PsiReferenceParameterList refParamList) {
if (refParamList.getTypeArguments().length == 0) return null;
JavaResolveResult resolveResult = null;
@@ -982,16 +982,17 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
}
}
@Override public void visitReferenceParameterList(PsiReferenceParameterList list) {
myHolder.add(GenericsHighlightUtil.checkParametersOnRaw(list));
@Override
public void visitReferenceParameterList(PsiReferenceParameterList list) {
myHolder.add(GenericsHighlightUtil.checkParametersAllowed(list));
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkParametersOnRaw(list));
}
@Override public void visitReturnStatement(PsiReturnStatement statement) {
try {
myHolder.add(HighlightUtil.checkReturnStatementType(statement));
}
catch (IndexNotReadyException ignore) {
}
catch (IndexNotReadyException ignore) { }
}
@Override public void visitStatement(PsiStatement statement) {
@@ -167,7 +167,7 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
}
if (enclosingContext instanceof PsiMethod && methodName.equals(enclosingContext.getName()) &&
PsiTreeUtil.isAncestor(targetClass, parentClass, true)) {
PsiTreeUtil.isAncestor(targetClass, parentClass, true) && !ref.isQualified()) {
FieldConflictsResolver.qualifyReference(ref, method, null);
}
@@ -17,21 +17,26 @@ package com.intellij.openapi.projectRoots;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
/**
* User: anna
* Date: 3/28/12
* @author anna
* @since 3/28/12
*/
public class JavaVersionServiceImpl extends JavaVersionService {
private JavaSdkVersion myTestVersion = null;
public void setTestVersion(JavaSdkVersion testVersion) {
@TestOnly
public void setTestVersion(@Nullable JavaSdkVersion testVersion) {
myTestVersion = testVersion;
}
@Override
public boolean isAtLeast(PsiElement element, JavaSdkVersion version) {
if (ApplicationManager.getApplication().isUnitTestMode()) return myTestVersion != null && myTestVersion.isAtLeast(version);
if (ApplicationManager.getApplication().isUnitTestMode()) {
return myTestVersion != null && myTestVersion.isAtLeast(version);
}
return JavaSdkVersionUtil.isAtLeast(element, version);
}
}
@@ -62,6 +62,8 @@ generics.type.argument.cannot.be.of.primitive.type=Type argument cannot be of pr
generics.unchecked.assignment=Unchecked assignment: ''{0}'' to ''{1}''
generics.unchecked.cast=Unchecked cast: ''{0}'' to ''{1}''
generics.unchecked.call.to.member.of.raw.type=Unchecked call to ''{0}'' as a member of raw type ''{1}''
generics.diamond.not.applicable=Diamond operator is not applicable for non-parameterized types
generics.reference.parameters.not.allowed=Reference parameters are not allowed here
foreach.not.applicable=foreach not applicable to type ''{0}''.
illegal.to.access.static.member.from.enum.constructor.or.instance.initializer=It is illegal to access static member ''{0}'' from enum constructor or instance initializer
enum.types.cannot.be.instantiated=Enum types cannot be instantiated
@@ -74,7 +76,7 @@ generics.cannot.catch.type.parameters=Cannot catch type parameters
generics.cannot.instanceof.type.parameters=Class or array expected
illegal.generic.type.for.instanceof=Illegal generic type for instanceof
cannot.select.dot.class.from.type.variable=Cannot select from a type variable
method.doesnot.override.super=Method does not override method from its superclass
method.does.not.override.super=Method does not override method from its superclass
call.to.super.is.not.allowed.in.enum.constructor=Call to super is not allowed in enum constructor
vararg.not.last.parameter=Vararg parameter must be the last in the list
modifiers.for.enum.constants=No modifiers allowed for enum constants
@@ -0,0 +1,10 @@
import java.util.*;
class C {
static final List EMPTY = new ArrayList(0);
void m() {
List<String> list = C.<error descr="Reference parameters are not allowed here"><String></error>EMPTY;
System.out.println(list);
}
}
@@ -0,0 +1,20 @@
// "Create Method 'run'" "true"
class Bug {
interface Foo<X> {
void run(X x);
}
public static void main(String[] args) {
new Foo<Bug>() {
@Override
public void run(Bug o) {
o.run();
}
};
}
private void run() {
<selection>//To change body of created methods use File | Settings | File Templates.</selection>
}
}
@@ -0,0 +1,16 @@
// "Create Method 'run'" "true"
class Bug {
interface Foo<X> {
void run(X x);
}
public static void main(String[] args) {
new Foo<Bug>() {
@Override
public void run(Bug o) {
o.ru<caret>n();
}
};
}
}
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 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;
import com.intellij.codeInspection.LocalInspectionTool;
@@ -62,33 +77,30 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testExceptions() throws Exception { doTest(false); }
public void testExplicitMethodParameters() throws Exception { doTest(false); }
public void testExplicitMethodParameters1() throws Exception { doTest(false); }
public void testInferenceWithBounds() throws Exception {doTest(false);}
public void testInferenceWithSuperBounds() throws Exception {doTest(false);}
public void testInferenceWithUpperBoundPromotion() throws Exception {doTest(false);}
public void testVariance() throws Exception {doTest(false);}
public void testForeachTypes() throws Exception {doTest(false);}
public void testRawOverridingMethods() throws Exception {doTest(false);}
public void testAutoboxing() throws Exception {doTest(false);}
public void testAutoboxingMethods() throws Exception {doTest(false);}
public void testAutoboxingConstructors() throws Exception {doTest(false);}
public void testInferenceWithBounds() throws Exception { doTest(false); }
public void testInferenceWithSuperBounds() throws Exception { doTest(false); }
public void testInferenceWithUpperBoundPromotion() throws Exception { doTest(false); }
public void testVariance() throws Exception { doTest(false); }
public void testForeachTypes() throws Exception { doTest(false); }
public void testRawOverridingMethods() throws Exception { doTest(false); }
public void testAutoboxing() throws Exception { doTest(false); }
public void testAutoboxingMethods() throws Exception { doTest(false); }
public void testAutoboxingConstructors() throws Exception { doTest(false); }
public void testEnumWithAbstractMethods() throws Exception { doTest(false); }
public void testEnum() throws Exception { doTest(false); }
public void testSameErasure() throws Exception { doTest(false); }
public void testMethods() throws Exception { doTest(false); }
public void testFields() throws Exception { doTest(false); }
public void testStaticImports() throws Exception { doTest(true); }
public void testUncheckedCasts() throws Exception { doTest(true); }
public void testUncheckedOverriding() throws Exception { doTest(true); }
public void testWildcardTypes() throws Exception { doTest(true); }
public void testConvertibleTypes() throws Exception { doTest(true); }
public void testIntersectionTypes() throws Exception { doTest(true); }
public void testVarargs() throws Exception { doTest(true); }
public void testTypeArgsOnRaw() throws Exception { doTest(false); }
public void testConditionalExpression() throws Exception { doTest(false); }
public void testUnused() throws Exception { doTest(true); }
public void testIDEADEV7337() throws Exception { doTest(true); }
public void testIDEADEV10459() throws Exception { doTest(true); }
public void testIDEADEV12951() throws Exception { doTest(true); }
@@ -101,7 +113,6 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEADEV25778() throws Exception { doTest(true); }
public void testIDEADEV57343() throws Exception { doTest(false); }
public void testSOE() throws Exception { doTest(true); }
public void testGenericExtendException() throws Exception { doTest(false); }
public void testSameErasureDifferentReturnTypes() throws Exception { doTest17Incompatibility(); }
public void testSameErasureDifferentReturnTypesJdk14() throws Exception { doTest(false); }
@@ -118,27 +129,25 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testInnerClassRef() throws Exception { doTest(false); }
public void testPrivateInnerClassRef() throws Exception { doTest(false); }
public void testWideningCastToTypeParam() throws Exception { doTest(false); }
public void testCapturedWildcardAssignments() throws Exception { doTest(false);}
public void testCapturedWildcardAssignments() throws Exception { doTest(false); }
public void testTypeParameterBoundVisibility() throws Exception { doTest17Incompatibility(); }
public void testTypeParameterBoundVisibilityJdk14() throws Exception { doTest(false);}
public void testUncheckedWarningsLevel6() throws Exception { doTest(true);}
public void testIDEA77991() throws Exception { doTest(false);}
public void testIDEA80386() throws Exception { doTest(false);}
public void testIDEA66311() throws Exception { doTest17Incompatibility();}
public void testIDEA88895() throws Exception { doTest17Incompatibility();}
public void testIDEA66311_16() throws Exception { doTest(false);}
public void testIDEA76283() throws Exception {doTest(false);}
public void testIDEA74899() throws Exception {doTest(false);}
public void testIDEA63291() throws Exception {doTest(false);}
public void testIDEA72912() throws Exception {doTest(false);}
public void testIllegalGenericTypeInInstanceof() throws Exception {doTest(false);}
public void testIDEA57339() throws Exception {doTest(false);}
public void testIDEA57340() throws Exception {doTest(false);}
public void testIDEA89771() throws Exception {doTest(false);}
public void testIDEA89801() throws Exception {doTest(false);}
public void testInconvertibleTypes() throws Exception {doTest(false);}
public void testTypeParameterBoundVisibilityJdk14() throws Exception { doTest(false); }
public void testUncheckedWarningsLevel6() throws Exception { doTest(true); }
public void testIDEA77991() throws Exception { doTest(false); }
public void testIDEA80386() throws Exception { doTest(false); }
public void testIDEA66311() throws Exception { doTest17Incompatibility(); }
public void testIDEA88895() throws Exception { doTest17Incompatibility(); }
public void testIDEA66311_16() throws Exception { doTest(false); }
public void testIDEA76283() throws Exception { doTest(false); }
public void testIDEA74899() throws Exception { doTest(false); }
public void testIDEA63291() throws Exception { doTest(false); }
public void testIDEA72912() throws Exception { doTest(false); }
public void testIllegalGenericTypeInInstanceof() throws Exception { doTest(false); }
public void testIDEA57339() throws Exception { doTest(false); }
public void testIDEA57340() throws Exception { doTest(false); }
public void testIDEA89771() throws Exception { doTest(false); }
public void testIDEA89801() throws Exception { doTest(false); }
public void testInconvertibleTypes() throws Exception { doTest(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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,14 +25,13 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Manages virtual file systems
* Manages virtual file systems.
*
* @see VirtualFileSystem
* @see LocalFileSystem
* @see JarFileSystem
*/
public abstract class VirtualFileManager implements ModificationTracker{
public static final Topic<BulkFileListener> VFS_CHANGES = new Topic<BulkFileListener>("NewVirtualFileSystem changes", BulkFileListener.class);
public abstract class VirtualFileManager implements ModificationTracker {
public static final Topic<BulkFileListener> VFS_CHANGES =
new Topic<BulkFileListener>("NewVirtualFileSystem changes", BulkFileListener.class);
/**
* Gets the instance of <code>VirtualFileManager</code>.
@@ -40,7 +39,7 @@ public abstract class VirtualFileManager implements ModificationTracker{
* @return <code>VirtualFileManager</code>
*/
@NotNull
public static VirtualFileManager getInstance(){
public static VirtualFileManager getInstance() {
return ApplicationManager.getApplication().getComponent(VirtualFileManager.class);
}
@@ -55,12 +54,12 @@ public abstract class VirtualFileManager implements ModificationTracker{
/**
* Refreshes the cached file system information from the physical file system.
* <p>
* <p/>
* This method should be only called within write-action.
* See {@link com.intellij.openapi.application.Application#runWriteAction}.
*
* @param asynchronous if <code>true</code> then the operation will be performed in a separate thread,
* otherwise will be performed immediately
* otherwise will be performed immediately
*/
public abstract void refresh(boolean asynchronous);
@@ -88,14 +87,14 @@ public abstract class VirtualFileManager implements ModificationTracker{
/**
* Refreshes only the part of the file system needed for searching the file by the given URL and finds file
* by the given URL.<br>
*
* <p/>
* This method is useful when the file was created externally and you need to find <code>{@link VirtualFile}</code>
* corresponding to it.<p>
*
* <p/>
* This method should be only called within write-action.
* See {@link com.intellij.openapi.application.Application#runWriteAction}.
*
* @param url the URL
* @param url the URL
* @return <code>{@link VirtualFile}</code> if the file was found, <code>null</code> otherwise
* @see VirtualFileSystem#findFileByPath
* @see VirtualFileSystem#refreshAndFindFileByPath
@@ -106,7 +105,7 @@ public abstract class VirtualFileManager implements ModificationTracker{
/**
* Adds listener to the file system.
*
* @param listener the listener
* @param listener the listener
* @see VirtualFileListener
*/
public abstract void addVirtualFileListener(@NotNull VirtualFileListener listener);
@@ -116,7 +115,7 @@ public abstract class VirtualFileManager implements ModificationTracker{
/**
* Removes listener form the file system.
*
* @param listener the listener
* @param listener the listener
*/
public abstract void removeVirtualFileListener(@NotNull VirtualFileListener listener);
@@ -125,11 +124,11 @@ public abstract class VirtualFileManager implements ModificationTracker{
* file systems.
*
* @param protocol the protocol
* @param path the path
* @param path the path
* @return URL
*/
@NotNull
public static String constructUrl(@NotNull String protocol, @NotNull String path){
public static String constructUrl(@NotNull String protocol, @NotNull String path) {
return protocol + "://" + path;
}
@@ -141,7 +140,7 @@ public abstract class VirtualFileManager implements ModificationTracker{
* @see VirtualFileSystem#getProtocol
*/
@Nullable
public static String extractProtocol(@NotNull String url){
public static String extractProtocol(@NotNull String url) {
int index = url.indexOf("://");
if (index < 0) return null;
return url.substring(0, index);
@@ -155,13 +154,14 @@ public abstract class VirtualFileManager implements ModificationTracker{
* @return path
*/
@NotNull
public static String extractPath(@NotNull String url){
public static String extractPath(@NotNull String url) {
int index = url.indexOf("://");
if (index < 0) return url;
return url.substring(index + "://".length());
}
public abstract void addVirtualFileManagerListener(@NotNull VirtualFileManagerListener listener);
public abstract void addVirtualFileManagerListener(@NotNull VirtualFileManagerListener listener, @NotNull Disposable parentDisposable);
public abstract void removeVirtualFileManagerListener(@NotNull VirtualFileManagerListener listener);
@@ -32,6 +32,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.openapi.ui.Splitter;
@@ -417,7 +418,11 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
public void run() {
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
myTodoTreeBuilder.rebuildCache();
try {
myTodoTreeBuilder.rebuildCache();
}
catch (IndexNotReadyException ignore) {
}
}
});
final Runnable runnable = new Runnable() {
@@ -130,7 +130,6 @@ public abstract class LocalFileSystem extends NewVirtualFileSystem {
/** @deprecated implementation details (to remove in IDEA 13) */
@SuppressWarnings({"UnusedDeclaration"})
@NotNull
String getFileSystemRootPath();
/** @deprecated implementation details (to remove in IDEA 13) */
@@ -163,9 +163,6 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
if (document != null) {
loadState(result, document.getRootElement());
}
else {
LOG.info("Document was not loaded for " + myFileSpec);
}
if (!myIsProjectSettings && useProvidersData) {
for (RoamingType roamingType : RoamingType.values()) {
@@ -173,11 +170,9 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
try {
if (myStreamProvider.isEnabled()) {
final Document sharedDocument = StorageUtil.loadDocument(myStreamProvider.loadContent(myFileSpec, roamingType));
if (sharedDocument != null) {
filterComponentsDisabledForRoaming(sharedDocument.getRootElement(), roamingType);
filterOutOfDateComponents(sharedDocument.getRootElement());
loadState(result, sharedDocument.getRootElement());
}
}
@@ -186,11 +181,9 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
LOG.warn(e);
}
}
}
}
return result;
}
@@ -151,11 +151,11 @@ public class EditorsSplitters extends JPanel {
if (showEmptyText()) {
UIUtil.applyRenderingHints(g);
g.setColor(Gray._100);
g.setColor(UIUtil.isUnderDarcula() ? Gray._200: Gray._100);
g.setFont(UIUtil.getLabelFont().deriveFont(18f));
final UIUtil.TextPainter painter = new UIUtil.TextPainter().withShadow(true).withLineSpacing(1.4f);
painter.appendLine("No files are open").underlined(Gray._150);
painter.appendLine("No files are open").underlined(UIUtil.isUnderDarcula() ? Gray._220 : Gray._150);
if (!isProjectViewVisible()) {
painter.appendLine("Open Project View with " + KeymapUtil.getShortcutText(new KeyboardShortcut(
@@ -83,7 +83,6 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
/** @deprecated implementation details (to remove in IDEA 13) */
@Override
@NotNull
public String getFileSystemRootPath() {
return myFSRootPath;
}
@@ -2160,7 +2160,7 @@ public class UIUtil {
public TextPainter() {
myDrawShadow = isUnderAquaLookAndFeel();
myShadowColor = Gray._220;
myShadowColor = isUnderDarcula() ? Gray._0 : Gray._220;
myLineSpacing = 1.0f;
}
@@ -2287,14 +2287,16 @@ public class UIUtil {
}
if (myDrawShadow) {
int xOff = isUnderDarcula() ? 1 : 0;
int yOff = 1;
final Color oldColor = g.getColor();
g.setColor(myShadowColor);
if (info.withBullet) {
g.drawString(info.bulletChar + " ", x - fm.stringWidth(" " + info.bulletChar), yOffset[0] + 1);
g.drawString(info.bulletChar + " ", x - fm.stringWidth(" " + info.bulletChar) + xOff, yOffset[0] + yOff);
}
g.drawString(pair.getFirst(), xOffset, yOffset[0] + 1);
g.drawString(pair.getFirst(), xOffset + xOff, yOffset[0] + yOff);
g.setColor(oldColor);
}
@@ -17,10 +17,12 @@
package com.intellij.tasks.actions;
import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.popup.*;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.LocalChangeList;
@@ -52,11 +54,11 @@ public class SwitchTaskAction extends BaseTaskAction {
DataContext dataContext = e.getDataContext();
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
assert project != null;
final ListPopupImpl popup = createPopup(dataContext, true);
final ListPopupImpl popup = createPopup(dataContext, null, true);
popup.showCenteredInCurrentWindow(project);
}
public static ListPopupImpl createPopup(final DataContext dataContext, boolean withTitle) {
public static ListPopupImpl createPopup(final DataContext dataContext, @Nullable final Runnable onDispose, boolean withTitle) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final Ref<Boolean> shiftPressed = Ref.create(false);
final Ref<JComponent> componentRef = Ref.create();
@@ -98,6 +100,14 @@ public class SwitchTaskAction extends BaseTaskAction {
};
final ListPopupImpl popup = (ListPopupImpl)JBPopupFactory.getInstance().createListPopup(step);
if (onDispose != null) {
Disposer.register(popup, new Disposable() {
@Override
public void dispose() {
onDispose.run();
}
});
}
componentRef.set(popup.getComponent());
if (items.size() <= 2) {
return popup;
@@ -66,7 +66,7 @@ public class SwitchTaskCombo extends ComboBoxAction implements DumbAware {
@Override
protected JBPopup createPopup(Runnable onDispose) {
return SwitchTaskAction.createPopup(DataManager.getInstance().getDataContext(this), false);
return SwitchTaskAction.createPopup(DataManager.getInstance().getDataContext(this), onDispose, false);
}
};
}