diff --git a/.idea/libraries/xpp3_1_1_4_min.xml b/.idea/libraries/xpp3_1_1_4_min.xml
index eacf2fbe430a..8c36562b134d 100644
--- a/.idea/libraries/xpp3_1_1_4_min.xml
+++ b/.idea/libraries/xpp3_1_1_4_min.xml
@@ -8,4 +8,4 @@
-
+
\ No newline at end of file
diff --git a/.idea/scopes/IDEA_Test_Sources.xml b/.idea/scopes/IDEA_Test_Sources.xml
new file mode 100644
index 000000000000..235c39035fe0
--- /dev/null
+++ b/.idea/scopes/IDEA_Test_Sources.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
new file mode 100644
index 000000000000..922003b8433b
--- /dev/null
+++ b/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
index 4eff6bc5adcf..ec0e60455f43 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.debugger.settings.DebuggerSettings;
import com.intellij.debugger.ui.CompletionEditor;
import com.intellij.debugger.ui.DebuggerExpressionComboBox;
import com.intellij.debugger.ui.DebuggerStatementEditor;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.ide.util.ClassFilter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
@@ -190,7 +191,7 @@ public abstract class BreakpointPropertiesPanel {
final JComboBox baseBreakpointCombo = new ComboBox();
myBreakpointComboboxHandler = new BreakpointComboboxHandler(myProject, baseBreakpointCombo);
- baseBreakpointCombo.setRenderer(new BreakpointComboRenderer());
+ baseBreakpointCombo.setRenderer(new BreakpointComboRenderer(baseBreakpointCombo.getRenderer()));
baseBreakpointCombo.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
ComboboxItem item = (ComboboxItem)baseBreakpointCombo.getSelectedItem();
@@ -674,29 +675,29 @@ public abstract class BreakpointPropertiesPanel {
}
}
- private static class BreakpointComboRenderer extends DefaultListCellRenderer {
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
- super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- setPreferredSize(new Dimension(MAX_COMBO_WIDTH, getPreferredSize().height));
+ private static class BreakpointComboRenderer extends ListCellRendererWrapper {
+ public BreakpointComboRenderer(final ListCellRenderer listCellRenderer) {
+ super(listCellRenderer);
+ }
+
+ @Override
+ public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
Breakpoint breakpoint = ((ComboboxItem)value).getBreakpoint();
final String text = breakpoint != null ? breakpoint.getDisplayName() : DebuggerBundle.message("value.none");
setText(text);
+
final Icon icon;
if (breakpoint != null) {
- icon = breakpoint instanceof BreakpointWithHighlighter ?
- breakpoint.ENABLED? ((BreakpointWithHighlighter)breakpoint).getSetIcon(false) : ((BreakpointWithHighlighter)breakpoint)
- .getDisabledIcon(false) : breakpoint.getIcon();
+ icon = breakpoint instanceof BreakpointWithHighlighter
+ ? breakpoint.ENABLED
+ ? ((BreakpointWithHighlighter)breakpoint).getSetIcon(false)
+ : ((BreakpointWithHighlighter)breakpoint).getDisabledIcon(false)
+ : breakpoint.getIcon();
}
else {
icon = null;
}
setIcon(icon);
- setDisabledIcon(icon);
- return this;
}
}
diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryNameAndLevelPanel.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryNameAndLevelPanel.java
index 8cfc93655f3b..6898b9456c60 100644
--- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryNameAndLevelPanel.java
+++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryNameAndLevelPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -15,13 +15,13 @@
*/
package com.intellij.facet.impl.ui.libraries;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.ui.EnumComboBoxModel;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.awt.*;
import java.util.HashMap;
import java.util.Map;
@@ -40,15 +40,13 @@ class LibraryNameAndLevelPanel {
levels.put(LibrariesContainer.LibraryLevel.GLOBAL, ProjectBundle.message("combobox.item.global.library"));
levels.put(LibrariesContainer.LibraryLevel.PROJECT, ProjectBundle.message("combobox.item.project.library"));
levels.put(LibrariesContainer.LibraryLevel.MODULE, ProjectBundle.message("combobox.item.module.library"));
- myLevelComboBox.setRenderer(new DefaultListCellRenderer() {
+ myLevelComboBox.setRenderer(new ListCellRendererWrapper(myLevelComboBox.getRenderer()) {
@Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof LibrariesContainer.LibraryLevel) {
final LibrariesContainer.LibraryLevel level = (LibrariesContainer.LibraryLevel)value;
setText(levels.get(level));
}
- return component;
}
});
myLevelComboBox.setModel(new EnumComboBoxModel(LibrariesContainer.LibraryLevel.class));
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java
index e085da3d4450..7cd65f35618b 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.roots.ui.configuration.libraryEditor;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
@@ -26,7 +27,6 @@ import com.intellij.util.ui.FormBuilder;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import java.awt.*;
import java.util.List;
/**
@@ -48,14 +48,12 @@ public class CreateNewLibraryDialog extends LibraryEditorDialogBase {
}
myLibraryLevelCombobox = new ComboBox(model);
myLibraryLevelCombobox.setSelectedIndex(selectedTable);
- myLibraryLevelCombobox.setRenderer(new DefaultListCellRenderer() {
+ myLibraryLevelCombobox.setRenderer(new ListCellRendererWrapper(myLibraryLevelCombobox.getRenderer()) {
@Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof LibraryTable) {
setText(((LibraryTable)value).getPresentation().getDisplayName(false));
}
- return component;
}
});
init();
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
index 6bca3124730d..b1afd83a6068 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
@@ -26,6 +26,7 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.RedundantCastUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.IncorrectOperationException;
@@ -34,6 +35,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Set;
import java.util.Stack;
class ControlFlowAnalyzer extends JavaElementVisitor {
@@ -525,13 +527,20 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
startElement(switchStmt);
PsiElementFactory psiFactory = JavaPsiFacade.getInstance(switchStmt.getProject()).getElementFactory();
PsiExpression caseExpression = switchStmt.getExpression();
-
+ Set enumVals = null;
if (caseExpression != null /*&& !(caseExpression instanceof PsiReferenceExpression)*/) {
caseExpression.accept(this);
generateBoxingUnboxingInstructionFor(caseExpression, PsiType.INT);
- if (TypeConversionUtil.isEnumType(caseExpression.getType())) {
+ final PsiClass psiClass = PsiUtil.resolveClassInType(caseExpression.getType());
+ if (psiClass != null && psiClass.isEnum()) {
addInstruction(new FieldReferenceInstruction(caseExpression, "switch statement expression"));
+ enumVals = new HashSet();
+ for (PsiField f : psiClass.getFields()) {
+ if (f instanceof PsiEnumConstant) {
+ enumVals.add((PsiEnumConstant)f);
+ }
+ }
} else {
addInstruction(new PopInstruction());
}
@@ -567,6 +576,12 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
}
addInstruction(new ConditionalGotoInstruction(offset, false, statement));
+
+ if (enumVals != null) {
+ if (caseValue instanceof PsiReferenceExpression) {
+ enumVals.remove(((PsiReferenceExpression)caseValue).resolve());
+ }
+ }
}
catch (IncorrectOperationException e) {
LOG.error(e);
@@ -575,8 +590,10 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
}
}
- int offset = defaultLabel != null ? getStartOffset(defaultLabel) : getEndOffset(body);
- addInstruction(new GotoInstruction(offset));
+ if (enumVals == null || !enumVals.isEmpty()) {
+ int offset = defaultLabel != null ? getStartOffset(defaultLabel) : getEndOffset(body);
+ addInstruction(new GotoInstruction(offset));
+ }
body.accept(this);
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/internal/GtkPreferredJComboBoxRendererInspection.java b/java/java-impl/src/com/intellij/codeInspection/internal/GtkPreferredJComboBoxRendererInspection.java
index 8b8f7f571e17..5e1567cd9086 100644
--- a/java/java-impl/src/com/intellij/codeInspection/internal/GtkPreferredJComboBoxRendererInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/internal/GtkPreferredJComboBoxRendererInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -16,15 +16,24 @@
package com.intellij.codeInspection.internal;
import com.intellij.codeInspection.ProblemsHolder;
+import com.intellij.ide.ui.ListCellRendererWrapper;
+import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.util.InheritanceUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class GtkPreferredJComboBoxRendererInspection extends InternalInspection {
- private static final String RENDERER_CLASS_NAME = DefaultListCellRenderer.class.getName();
- private static final String MESSAGE = "Please use ListCellRendererWrapper instead to prevent artifacts under GTK+ Look and Feel.";
+ private static final String COMBO_BOX_CLASS_NAME = JComboBox.class.getName();
+ private static final String RIGHT_RENDERER_CLASS_NAME = ListCellRendererWrapper.class.getName();
+ private static final String SETTER_METHOD_NAME = "setRenderer";
+
+ private static final String MESSAGE =
+ "Default ListCellRenderer implementations are known to cause UI artifacts under GTK+ Look and Feel," +
+ "so please use ListCellRendererWrapper instead.";
@Nls
@NotNull
@@ -40,26 +49,32 @@ public class GtkPreferredJComboBoxRendererInspection extends InternalInspection
}
@NotNull
- public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
+ public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override
- public void visitReferenceExpression(PsiReferenceExpression expression) {
- }
+ public void visitMethodCallExpression(final PsiMethodCallExpression expression) {
+ super.visitMethodCallExpression(expression);
- @Override
- public void visitClass(final PsiClass aClass) {
- final PsiClass superClass = aClass.getSuperClass();
- if (superClass != null && RENDERER_CLASS_NAME.equals(superClass.getQualifiedName())){
- final PsiIdentifier nameIdentifier = aClass.getNameIdentifier();
- holder.registerProblem(nameIdentifier != null ? nameIdentifier : aClass, MESSAGE);
- }
- }
+ final Project project = expression.getProject();
+ final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
- @Override
- public void visitAnonymousClass(final PsiAnonymousClass aClass) {
- if (RENDERER_CLASS_NAME.equals(aClass.getBaseClassReference().getQualifiedName())){
- holder.registerProblem(aClass.getBaseClassReference(), MESSAGE);
- }
+ final PsiElement target = expression.getMethodExpression().resolve();
+ if (!(target instanceof PsiMethod)) return;
+ final PsiMethod method = (PsiMethod)target;
+ if (!SETTER_METHOD_NAME.equals(method.getName())) return;
+ final PsiClass aClass = ((PsiMethod)target).getContainingClass();
+ final PsiClass comboClass = facade.findClass(COMBO_BOX_CLASS_NAME, GlobalSearchScope.allScope(project));
+ if (!InheritanceUtil.isInheritorOrSelf(aClass, comboClass, true)) return;
+
+ final PsiExpression[] arguments = expression.getArgumentList().getExpressions();
+ if (arguments.length != 1) return;
+ final PsiType type = arguments[0].getType();
+ if (!(type instanceof PsiClassType)) return;
+ final PsiClass rendererClass = ((PsiClassType)type).resolve();
+ final PsiClass rightClass = facade.findClass(RIGHT_RENDERER_CLASS_NAME, GlobalSearchScope.allScope(project));
+ if (InheritanceUtil.isInheritorOrSelf(rendererClass, rightClass, true)) return;
+
+ holder.registerProblem(expression, MESSAGE);
}
};
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java b/java/java-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java
index 0c13c7792b11..242599ad167c 100644
--- a/java/java-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import com.intellij.ExtensionPoints;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInspection.*;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.LanguageLevelUtil;
@@ -39,6 +40,7 @@ import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@@ -71,6 +73,7 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
loadForbiddenApi("ignore16List.txt", ourIgnored16ClassesAPI);
}
+ @Nullable
private static Set getForbiddenApi(@NotNull LanguageLevel languageLevel) {
if (!ourPresentableShortMessage.containsKey(languageLevel)) return null;
Reference> ref = ourForbiddenAPI.get(languageLevel);
@@ -84,34 +87,22 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
}
private static void loadForbiddenApi(@NonNls String fileName, Set set) {
- BufferedReader reader = null;
try {
final InputStream stream = Java15APIUsageInspection.class.getResourceAsStream(fileName);
- reader = new BufferedReader(new InputStreamReader(stream, CharsetToolkit.UTF8_CHARSET));
-
- do {
- String line = reader.readLine();
- if (line == null) break;
-
- set.add(line);
- } while(true);
- }
- catch (UnsupportedEncodingException e) {
- // can't be.
- }
- catch (IOException e) {
- // can't be
- }
- finally {
- if (reader != null) {
- try {
- reader.close();
- }
- catch (IOException e) {
- // Will not happen
- }
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, CharsetToolkit.UTF8_CHARSET));
+ try {
+ do {
+ String line = reader.readLine();
+ if (line == null) break;
+ set.add(line);
+ } while(true);
+ }
+ finally {
+ reader.close();
}
}
+ catch (UnsupportedEncodingException ignored) { }
+ catch (IOException ignored) { }
}
@NotNull
@@ -186,13 +177,12 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
cModel.addElement(level);
}
llCombo.setSelectedItem(myEffectiveLanguageLevel != null ? myEffectiveLanguageLevel : LanguageLevel.JDK_1_3);
- llCombo.setRenderer(new DefaultListCellRenderer(){
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ llCombo.setRenderer(new ListCellRendererWrapper(llCombo.getRenderer()) {
+ @Override
+ public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof LanguageLevel) {
setText(((LanguageLevel)value).getPresentableText());
}
- return rendererComponent;
}
});
llCombo.addActionListener(new ActionListener() {
@@ -348,7 +338,8 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
private static boolean isForbiddenSignature(@NotNull PsiMember member, @NotNull LanguageLevel languageLevel) {
Set forbiddenApi = getForbiddenApi(languageLevel);
- return forbiddenApi != null && isForbiddenSignature(getSignature(member), languageLevel, forbiddenApi);
+ String signature = getSignature(member);
+ return forbiddenApi != null && signature != null && isForbiddenSignature(signature, languageLevel, forbiddenApi);
}
private static boolean isForbiddenSignature(@NotNull String signature, @NotNull LanguageLevel languageLevel, @NotNull Set forbiddenApi) {
@@ -363,6 +354,7 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
return nextForbiddenApi != null && isForbiddenSignature(signature, nextLanguageLevel, nextForbiddenApi);
}
+ @Nullable
public static String getSignature(PsiMember member) {
if (member instanceof PsiClass) {
return ((PsiClass)member).getQualifiedName();
@@ -388,5 +380,4 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
assert false;
return null;
}
-
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java
index 1da7c451ab43..ed356580d7f5 100644
--- a/java/java-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java
+++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java
@@ -123,9 +123,12 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass {
setServlet(servlet != null && psiClass.isInheritor(servlet, true));
}
if (!isApplet() && !isServlet()) {
- setTestCase(TestUtil.isTestClass(psiClass));
- for (RefClass refBase : getBaseClasses()) {
- ((RefClassImpl)refBase).setTestCase(true);
+ final boolean isTestClass = TestUtil.isTestClass(psiClass);
+ setTestCase(isTestClass);
+ if (isTestClass) {
+ for (RefClass refBase : getBaseClasses()) {
+ ((RefClassImpl)refBase).setTestCase(true);
+ }
}
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
index c60d11f38076..56785d336eaa 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
@@ -406,7 +406,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
Pair substitution = null;
if (owner instanceof PsiMethod && parent instanceof PsiCallExpression) {
PsiCallExpression methodCall = (PsiCallExpression)parent;
- substitution = inferMethodTypeParameterFromParent(methodCall.getParent(), methodCall, typeParameter, substitutor, forCompletion);
+ substitution = inferMethodTypeParameterFromParent(skipParenthesizedExprUp(methodCall.getParent()), methodCall, typeParameter, substitutor, forCompletion);
}
return substitution;
}
@@ -612,11 +612,15 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
Pair constraint = null;
PsiType expectedType = null;
- if (parent instanceof PsiVariable && methodCall.equals(((PsiVariable)parent).getInitializer())) {
- expectedType = ((PsiVariable)parent).getType();
+ if (parent instanceof PsiVariable) {
+ if (methodCall.equals(skipParenthesizedExprDown(((PsiVariable)parent).getInitializer()))) {
+ expectedType = ((PsiVariable)parent).getType();
+ }
}
- else if (parent instanceof PsiAssignmentExpression && methodCall.equals(((PsiAssignmentExpression)parent).getRExpression())) {
- expectedType = ((PsiAssignmentExpression)parent).getLExpression().getType();
+ else if (parent instanceof PsiAssignmentExpression) {
+ if (methodCall.equals(skipParenthesizedExprDown(((PsiAssignmentExpression)parent).getRExpression()))) {
+ expectedType = ((PsiAssignmentExpression)parent).getLExpression().getType();
+ }
}
else if (parent instanceof PsiReturnStatement) {
PsiMethod method = PsiTreeUtil.getParentOfType(parent, PsiMethod.class);
@@ -702,6 +706,21 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
return result;
}
+ @Nullable
+ private static PsiExpression skipParenthesizedExprDown(PsiExpression initializer) {
+ while (initializer instanceof PsiParenthesizedExpression) {
+ initializer = ((PsiParenthesizedExpression)initializer).getExpression();
+ }
+ return initializer;
+ }
+
+ private static PsiElement skipParenthesizedExprUp(PsiElement parent) {
+ while (parent instanceof PsiParenthesizedExpression) {
+ parent = parent.getParent();
+ }
+ return parent;
+ }
+
@Nullable
private static Pair inferTypeForCompletionFromCallContext(final PsiCallExpression innerMethodCall,
final PsiExpressionList expressionList,
diff --git a/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java b/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java
index bcc50ca04e75..7f50bdd404de 100644
--- a/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -36,6 +36,7 @@ import com.intellij.refactoring.util.classMembers.MemberInfo;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@@ -47,7 +48,6 @@ import java.util.Collections;
public class InheritanceToDelegationDialog extends RefactoringDialog {
private final PsiClass[] mySuperClasses;
-
private final PsiClass myClass;
private final HashMap> myBasesToMemberInfos;
@@ -91,6 +91,7 @@ public class InheritanceToDelegationDialog extends RefactoringDialog {
return myFieldNameField.getEnteredName();
}
+ @Nullable
public String getInnerClassName() {
if (myInnerClassNameField != null) {
return myInnerClassNameField.getEnteredName();
@@ -168,7 +169,7 @@ public class InheritanceToDelegationDialog extends RefactoringDialog {
gbc.insets = new Insets(4, 8, 0, 8);
myClassCombo = new JComboBox(mySuperClasses);
- myClassCombo.setRenderer(new ClassCellRenderer());
+ myClassCombo.setRenderer(new ClassCellRenderer(myClassCombo.getRenderer()));
gbc.gridwidth = 2;
final JLabel classComboLabel = new JLabel();
panel.add(classComboLabel, gbc);
diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java
index 77bc209ba764..7b6f1602ab2b 100644
--- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -13,15 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * Created by IntelliJ IDEA.
- * User: dsl
- * Date: 18.06.2002
- * Time: 13:16:29
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
package com.intellij.refactoring.memberPullUp;
import com.intellij.openapi.help.HelpManager;
@@ -44,6 +35,7 @@ import com.intellij.refactoring.util.classMembers.UsesAndInterfacesDependencyMem
import com.intellij.ui.IdeBorderFactory;
import com.intellij.usageView.UsageViewUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@@ -52,6 +44,10 @@ import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
+/**
+ * @author dsl
+ * Date: 18.06.2002
+ */
public class PullUpDialog extends RefactoringDialog {
private final Callback myCallback;
private MemberSelectionPanel myMemberSelectionPanel;
@@ -61,16 +57,13 @@ public class PullUpDialog extends RefactoringDialog {
private final MemberInfoStorage myMemberInfoStorage;
private List myMemberInfos;
private DocCommentPanel myJavaDocPanel;
-
private JComboBox myClassCombo;
- public static interface Callback {
+ public interface Callback {
boolean checkConflicts(PullUpDialog dialog);
}
-
- public PullUpDialog(Project project, PsiClass aClass, List superClasses,
- MemberInfoStorage memberInfoStorage, Callback callback) {
+ public PullUpDialog(Project project, PsiClass aClass, List superClasses, MemberInfoStorage memberInfoStorage, Callback callback) {
super(project, true);
myClass = aClass;
mySuperClasses = superClasses;
@@ -83,6 +76,7 @@ public class PullUpDialog extends RefactoringDialog {
init();
}
+ @Nullable
public PsiClass getSuperClass() {
if (myClassCombo != null) {
return (PsiClass) myClassCombo.getSelectedItem();
@@ -133,10 +127,9 @@ public class PullUpDialog extends RefactoringDialog {
panel.add(classComboLabel, gbConstraints);
myClassCombo = new JComboBox(mySuperClasses.toArray());
- myClassCombo.setRenderer(new ClassCellRenderer());
+ myClassCombo.setRenderer(new ClassCellRenderer(myClassCombo.getRenderer()));
classComboLabel.setText(RefactoringBundle.message("pull.up.members.to", UsageViewUtil.getLongName(myClass)));
classComboLabel.setLabelFor(myClassCombo);
-// myClassCombo.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
PsiClass nearestBase = RefactoringHierarchyUtil.getNearestBaseClass(myClass, false);
int indexToSelect = 0;
@@ -210,7 +203,6 @@ public class PullUpDialog extends RefactoringDialog {
super(myClass, getSuperClass(), false, myInterfaceContainmentVerifier);
}
-
public boolean isMemberEnabled(MemberInfo member) {
PsiClass currentSuperClass = getSuperClass();
if(currentSuperClass == null) return true;
diff --git a/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperDialog.java b/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperDialog.java
index 0c404004ea14..89857dea18c3 100644
--- a/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -13,15 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * Created by IntelliJ IDEA.
- * User: dsl
- * Date: 06.06.2002
- * Time: 11:30:13
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
package com.intellij.refactoring.turnRefsToSuper;
import com.intellij.openapi.help.HelpManager;
@@ -37,11 +28,16 @@ import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.JBList;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.List;
+/**
+ * @author dsl
+ * Date: 06.06.2002
+ */
public class TurnRefsToSuperDialog extends RefactoringDialog {
@NotNull private final PsiClass mySubClass;
private final List mySuperClasses;
@@ -59,6 +55,7 @@ public class TurnRefsToSuperDialog extends RefactoringDialog {
init();
}
+ @Nullable
public PsiClass getSuperClass() {
if(mySuperClassesList != null) {
return (PsiClass) mySuperClassesList.getSelectedValue();
@@ -99,7 +96,7 @@ public class TurnRefsToSuperDialog extends RefactoringDialog {
panel.add(classListLabel, gbConstraints);
mySuperClassesList = new JBList(mySuperClasses.toArray());
- mySuperClassesList.setCellRenderer(new ClassCellRenderer());
+ mySuperClassesList.setCellRenderer(new ClassCellRenderer(mySuperClassesList.getCellRenderer()));
mySuperClassesList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
classListLabel.setText(RefactoringBundle.message("turnRefsToSuper.change.usages.to", mySubClass.getQualifiedName()));
@@ -127,9 +124,10 @@ public class TurnRefsToSuperDialog extends RefactoringDialog {
protected void doAction() {
JavaRefactoringSettings.getInstance().TURN_REFS_TO_SUPER_PREVIEW_USAGES = isPreviewUsages();
- final TurnRefsToSuperProcessor processor = new TurnRefsToSuperProcessor(
- getProject(), mySubClass, getSuperClass(), isUseInInstanceOf());
- invokeRefactoring(processor);
+ final PsiClass superClass = getSuperClass();
+ if (superClass != null) {
+ invokeRefactoring(new TurnRefsToSuperProcessor(getProject(), mySubClass, superClass, isUseInInstanceOf()));
+ }
}
protected JComponent createCenterPanel() {
diff --git a/java/java-impl/src/com/intellij/refactoring/ui/ClassCellRenderer.java b/java/java-impl/src/com/intellij/refactoring/ui/ClassCellRenderer.java
index d085a934d6b1..0da54a47add1 100644
--- a/java/java-impl/src/com/intellij/refactoring/ui/ClassCellRenderer.java
+++ b/java/java-impl/src/com/intellij/refactoring/ui/ClassCellRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -13,66 +13,44 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * Created by IntelliJ IDEA.
- * User: dsl
- * Date: 18.06.2002
- * Time: 13:47:11
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
package com.intellij.refactoring.ui;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.util.Iconable;
import com.intellij.psi.PsiClass;
import com.intellij.refactoring.RefactoringBundle;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import java.awt.*;
/**
- * Renders a list cell which contains a class
+ * Renders a list cell which contains a class.
+ *
+ * @author dsl
+ * Date: 18.06.2002
*/
-public class ClassCellRenderer extends DefaultListCellRenderer {
+public class ClassCellRenderer extends ListCellRendererWrapper {
private final boolean myShowReadOnly;
- public ClassCellRenderer() {
- setOpaque(true);
+
+ public ClassCellRenderer(ListCellRenderer original) {
+ super(original);
myShowReadOnly = true;
}
- public ClassCellRenderer(boolean showReadOnly) {
- setOpaque(true);
- myShowReadOnly = showReadOnly;
- }
+ @Override
+ public void customize(JList list, PsiClass aClass, int index, boolean selected, boolean hasFocus) {
+ if (aClass != null) {
+ setText(getClassText(aClass));
- public Component getListCellRendererComponent(
- JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
- final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- if (value != null) {
- return customizeRenderer(this, value, myShowReadOnly);
+ int flags = Iconable.ICON_FLAG_VISIBILITY;
+ if (myShowReadOnly) {
+ flags |= Iconable.ICON_FLAG_READ_STATUS;
+ }
+ Icon icon = aClass.getIcon(flags);
+ if (icon != null) {
+ setIcon(icon);
+ }
}
- return rendererComponent;
- }
-
- public static JLabel customizeRenderer(final JLabel cellRendererComponent, @NotNull final Object value, final boolean showReadOnly) {
- PsiClass aClass = (PsiClass) value;
- cellRendererComponent.setText(getClassText(aClass));
-
- int flags = Iconable.ICON_FLAG_VISIBILITY;
- if (showReadOnly) {
- flags |= Iconable.ICON_FLAG_READ_STATUS;
- }
- Icon icon = aClass.getIcon(flags);
- if(icon != null) {
- cellRendererComponent.setIcon(icon);
- }
- return cellRendererComponent;
}
private static String getClassText(@NotNull PsiClass aClass) {
diff --git a/java/java-impl/src/com/intellij/refactoring/util/ParameterTablePanel.java b/java/java-impl/src/com/intellij/refactoring/util/ParameterTablePanel.java
index 6ab2bcf8c6f4..0bc5241b5d76 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/ParameterTablePanel.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/ParameterTablePanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.refactoring.util;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.refactoring.ui.TypeSelector;
@@ -24,9 +25,10 @@ import com.intellij.ui.BooleanTableCellRenderer;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.TableUtil;
import com.intellij.ui.UIBundle;
+import com.intellij.ui.table.JBTable;
import com.intellij.util.ui.AbstractTableCellEditor;
-import com.intellij.util.ui.Table;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -45,7 +47,7 @@ public abstract class ParameterTablePanel extends JPanel {
private final VariableData[] myVariableData;
private final TypeSelector[] myParameterTypeSelectors;
- private final Table myTable;
+ private final JBTable myTable;
private final MyTableModel myTableModel;
private final JButton myUpButton;
private final JButton myDownButton;
@@ -88,7 +90,7 @@ public abstract class ParameterTablePanel extends JPanel {
myVariableData = variableData;
myTableModel = new MyTableModel();
- myTable = new Table(myTableModel);
+ myTable = new JBTable(myTableModel);
DefaultCellEditor defaultEditor = (DefaultCellEditor)myTable.getDefaultEditor(Object.class);
defaultEditor.setClickCountToStart(1);
@@ -122,28 +124,24 @@ public abstract class ParameterTablePanel extends JPanel {
myTypeRendererCombo = new JComboBox(getVariableData());
myTypeRendererCombo.setOpaque(true);
myTypeRendererCombo.setBorder(null);
-
- myTypeRendererCombo.setRenderer(new DefaultListCellRenderer() {
-
- public Component getListCellRendererComponent(final JList list,
- final Object value,
- final int index, final boolean isSelected, final boolean cellHasFocus) {
- setText(((VariableData)value).type.getPresentableText());
- return this;
+ myTypeRendererCombo.setRenderer(new ListCellRendererWrapper(myTypeRendererCombo.getRenderer()) {
+ @Override
+ public void customize(JList list, VariableData value, int index, boolean selected, boolean hasFocus) {
+ if (value != null) {
+ setText(value.type.getPresentableText());
+ }
}
});
myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN).setCellEditor(new AbstractTableCellEditor() {
TypeSelector myCurrentSelector;
+
+ @Nullable
public Object getCellEditorValue() {
return myCurrentSelector.getSelectedType();
}
- public Component getTableCellEditorComponent(final JTable table,
- final Object value,
- final boolean isSelected,
- final int row,
- final int column) {
+ public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
myCurrentSelector = myParameterTypeSelectors[row];
return myCurrentSelector.getComponent();
}
diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java
index d6235e877486..281acc42c674 100644
--- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.refactoring.wrapreturnvalue;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.ide.util.TreeClassChooser;
import com.intellij.ide.util.TreeClassChooserFactory;
import com.intellij.openapi.help.HelpManager;
@@ -39,7 +40,6 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
-import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -107,7 +107,10 @@ class WrapReturnValueDialog extends RefactoringDialog {
if (myCreateInnerClassButton.isSelected()) {
final String innerClassName = getInnerClassName().trim();
if (!nameHelper.isIdentifier(innerClassName)) throw new ConfigurationException("\'" + innerClassName + "\' is invalid inner class name");
- if (sourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null) throw new ConfigurationException("Inner class with name \'" + innerClassName + "\' already exist");
+ final PsiClass containingClass = sourceMethod.getContainingClass();
+ if (containingClass != null && containingClass.findInnerClassByName(innerClassName, false) != null) {
+ throw new ConfigurationException("Inner class with name \'" + innerClassName + "\' already exist");
+ }
} else if (useExistingClassButton.isSelected()) {
final String className = existingClassField.getText().trim();
if (className.length() == 0 || !nameHelper.isQualifiedName(className)) {
@@ -168,7 +171,10 @@ class WrapReturnValueDialog extends RefactoringDialog {
}
final PsiClass containingClass = sourceMethod.getContainingClass();
- final String containingClassName = containingClass instanceof PsiAnonymousClass ? "Anonymous " + ((PsiAnonymousClass)containingClass).getBaseClassType().getClassName() : containingClass.getName();
+ assert containingClass != null : sourceMethod;
+ final String containingClassName = containingClass instanceof PsiAnonymousClass
+ ? "Anonymous " + ((PsiAnonymousClass)containingClass).getBaseClassType().getClassName()
+ : containingClass.getName();
final String sourceMethodName = sourceMethod.getName();
sourceMethodTextField.setText(containingClassName + '.' + sourceMethodName);
final ButtonGroup buttonGroup = new ButtonGroup();
@@ -188,26 +194,21 @@ class WrapReturnValueDialog extends RefactoringDialog {
final DefaultComboBoxModel model = new DefaultComboBoxModel();
myFieldsCombo.setModel(model);
- myFieldsCombo.setRenderer(new DefaultListCellRenderer(){
+ myFieldsCombo.setRenderer(new ListCellRendererWrapper(myFieldsCombo.getRenderer()) {
@Override
- public Component getListCellRendererComponent(final JList list,
- final Object value,
- final int index,
- final boolean isSelected,
- final boolean cellHasFocus) {
- final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof PsiField) {
final PsiField field = (PsiField)value;
setText(field.getName());
setIcon(field.getIcon(Iconable.ICON_FLAG_VISIBILITY));
}
- return rendererComponent;
}
});
existingClassField.getChildComponent().getDocument().addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
@Override
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
- final PsiClass currentClass = JavaPsiFacade.getInstance(myProject).findClass(existingClassField.getText(), GlobalSearchScope.allScope(myProject));
+ final JavaPsiFacade facade = JavaPsiFacade.getInstance(myProject);
+ final PsiClass currentClass = facade.findClass(existingClassField.getText(), GlobalSearchScope.allScope(myProject));
if (currentClass != null) {
model.removeAllElements();
for (PsiField field : currentClass.getFields()) {
diff --git a/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java b/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java
index 9187f3b7f5be..f4e5971cc61f 100644
--- a/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java
+++ b/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -13,14 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * @author cdr
- */
package com.intellij.unscramble;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.ide.IdeBundle;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.extensions.Extensions;
@@ -50,7 +47,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-public class UnscrambleDialog extends DialogWrapper{
+/**
+ * @author cdr
+ */
+public class UnscrambleDialog extends DialogWrapper {
@NonNls private static final String PROPERTY_LOG_FILE_HISTORY_URLS = "UNSCRAMBLE_LOG_FILE_URL";
@NonNls private static final String PROPERTY_LOG_FILE_LAST_URL = "UNSCRAMBLE_LOG_FILE_LAST_URL";
@NonNls private static final String PROPERTY_UNSCRAMBLER_NAME_USED = "UNSCRAMBLER_NAME_USED";
@@ -204,17 +204,13 @@ public class UnscrambleDialog extends DialogWrapper{
private void populateRegisteredUnscramblerList() {
List unscrambleComponents = getRegisteredUnscramblers();
-
- //myUnscrambleChooser.addItem(null);
for (final UnscrambleSupport unscrambleSupport : unscrambleComponents) {
myUnscrambleChooser.addItem(unscrambleSupport);
}
- myUnscrambleChooser.setRenderer(new DefaultListCellRenderer() {
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- UnscrambleSupport unscrambleSupport = (UnscrambleSupport)value;
+ myUnscrambleChooser.setRenderer(new ListCellRendererWrapper(myUnscrambleChooser.getRenderer()) {
+ @Override
+ public void customize(JList list, UnscrambleSupport unscrambleSupport, int index, boolean selected, boolean hasFocus) {
setText(unscrambleSupport == null ? IdeBundle.message("unscramble.no.unscrambler.item") : unscrambleSupport.getPresentableName());
- return this;
}
});
}
@@ -291,7 +287,7 @@ public class UnscrambleDialog extends DialogWrapper{
}
if (!first && mustHaveNewLineBefore(line)) {
builder.append("\n");
- if (line.startsWith("\"")) builder.append("\n"); // Additional linebreak for thread names
+ if (line.startsWith("\"")) builder.append("\n"); // Additional line break for thread names
}
first = false;
int i = builder.lastIndexOf("\n");
@@ -312,12 +308,12 @@ public class UnscrambleDialog extends DialogWrapper{
}
private static boolean mustHaveNewLineBefore(String line) {
- final int nonws = CharArrayUtil.shiftForward(line, 0, " \t");
- if (nonws < line.length()) {
- line = line.substring(nonws);
+ final int nonWs = CharArrayUtil.shiftForward(line, 0, " \t");
+ if (nonWs < line.length()) {
+ line = line.substring(nonWs);
}
- if (line.startsWith("at")) return true; // Start of the new stackframe entry
+ if (line.startsWith("at")) return true; // Start of the new stack frame entry
if (line.startsWith("Caused")) return true; // Caused by message
if (line.startsWith("- locked")) return true; // "Locked a monitor" logging
if (line.startsWith("- waiting")) return true; // "Waiting for monitor" logging
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondMisc.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondMisc.java
index 9e04fbaf9ca8..414e6116ea24 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondMisc.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondMisc.java
@@ -135,3 +135,21 @@ class TestLocal {
class QualifiedTest {
java.util.Map s = new java.util.HashMap<>();
}
+
+
+class TZ {
+
+}
+
+class ParenthTest {
+ public ParenthTest(T x) {
+
+ }
+
+ public T z = null;
+
+ public int a() {
+ ParenthTest x = (new ParenthTest<>(null)); //red code is here
+ return 1;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/SwitchEnumCases/expected.xml b/java/java-tests/testData/inspection/dataFlow/SwitchEnumCases/expected.xml
new file mode 100644
index 000000000000..1592ccd0f50f
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/SwitchEnumCases/expected.xml
@@ -0,0 +1,8 @@
+
+
+
+ Test.java
+ 72
+ Method invocation <code>foo.length()</code> may produce <code>java.lang.NullPointerException</code>
+
+
diff --git a/java/java-tests/testData/inspection/dataFlow/SwitchEnumCases/src/Test.java b/java/java-tests/testData/inspection/dataFlow/SwitchEnumCases/src/Test.java
new file mode 100644
index 000000000000..db2b055df957
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/SwitchEnumCases/src/Test.java
@@ -0,0 +1,78 @@
+public class Test {
+ void withDefaultWithoutBreak(MyEnum e) {
+ String foo = null;
+ switch (e) {
+ case FOO:
+ foo = "foo";
+ case BAR:
+ foo = "bar";
+ default:
+ foo = "default";
+ }
+ int l = foo.length();
+ }
+
+ void withDefaultWithBreak(MyEnum e) {
+ String foo = null;
+ switch (e) {
+ case FOO:
+ foo = "foo";
+ break;
+ case BAR:
+ foo = "bar";
+ break;
+ default:
+ foo = "default";
+ }
+ int l = foo.length();
+ }
+
+ void withDefaultWithoutBar(MyEnum e) {
+ String foo = null;
+ switch (e) {
+ case FOO:
+ foo = "foo";
+ break;
+ default:
+ foo = "default";
+ }
+ int l = foo.length();
+ }
+
+ void withoutDefaultWithBreak(MyEnum e) {
+ String foo = null;
+ switch (e) {
+ case FOO:
+ foo = "foo";
+ break;
+ case BAR:
+ foo = "bar";
+ break;
+ }
+ int l = foo.length();
+ }
+
+ void withoutDefaultWithoutBreak(MyEnum e) {
+ String foo = null;
+ switch (e) {
+ case FOO:
+ foo = "foo";
+ case BAR:
+ foo = "bar";
+ }
+ int l = foo.length();
+ }
+
+ void withoutDefaultWithoutBar(MyEnum e) {
+ String foo = null;
+ switch (e) {
+ case FOO:
+ foo = "foo";
+ }
+ int l = foo.length();
+ }
+}
+
+enum MyEnum {
+ FOO, BAR;
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index 34e3591c9fcf..4fec9c5a40cc 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -140,4 +140,5 @@ public class DataFlowInspectionTest extends InspectionTestCase {
public void testIDEADEV13156() throws Exception { doTest15(); }
//public void testIDEADEV11033() throws Exception { doTest15(); }
+ public void testSwitchEnumCases() throws Exception { doTest15(); }
}
diff --git a/java/openapi/src/com/intellij/psi/util/InheritanceUtil.java b/java/openapi/src/com/intellij/psi/util/InheritanceUtil.java
index 8aff7e38b7ee..aac2fcbc77c7 100644
--- a/java/openapi/src/com/intellij/psi/util/InheritanceUtil.java
+++ b/java/openapi/src/com/intellij/psi/util/InheritanceUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.Set;
public class InheritanceUtil {
+ private InheritanceUtil() { }
+
/**
* @deprecated Use {@link PsiClass#isInheritor(com.intellij.psi.PsiClass, boolean)} instead.
*/
@@ -33,16 +35,19 @@ public class InheritanceUtil {
}
/**
+ * @param aClass a class to check.
+ * @param baseClass supposed base class.
+ * @param checkDeep true to check deeper than aClass.super (see {@linkplain PsiClass#isInheritor(com.intellij.psi.PsiClass, boolean)}).
* @return true if aClass is the baseClass or baseClass inheritor
*/
- public static boolean isInheritorOrSelf(@Nullable PsiClass aClass, @Nullable PsiClass baseClass, boolean checkDeep) { //TODO: remove this method!!
+ public static boolean isInheritorOrSelf(@Nullable PsiClass aClass, @Nullable PsiClass baseClass, boolean checkDeep) {
if (aClass == null || baseClass == null) return false;
PsiManager manager = aClass.getManager();
return manager.areElementsEquivalent(baseClass, aClass) || aClass.isInheritor(baseClass, checkDeep);
}
/**
- * @return true if aClass is the baseClass or baseClass inheritor
+ * @deprecated use {@linkplain #isInheritorOrSelf(com.intellij.psi.PsiClass, com.intellij.psi.PsiClass, boolean)}.
*/
public static boolean isCorrectDescendant(@Nullable PsiClass aClass, @Nullable PsiClass baseClass, boolean checkDeep) {
return isInheritorOrSelf(aClass, baseClass, checkDeep);
diff --git a/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurableBase.java b/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurableBase.java
index 3a3b52155387..628cf283de15 100644
--- a/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurableBase.java
+++ b/platform/lang-api/src/com/intellij/ide/util/frameworkSupport/FrameworkSupportConfigurableBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package com.intellij.ide.util.frameworkSupport;
import com.intellij.facet.ui.libraries.LibraryInfo;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
@@ -44,7 +45,8 @@ public class FrameworkSupportConfigurableBase extends FrameworkSupportConfigurab
this(frameworkSupportProvider, model, Collections.emptyList(), null);
}
- public FrameworkSupportConfigurableBase(final FrameworkSupportProviderBase frameworkSupportProvider, FrameworkSupportModel model, List versions, String versionLabelText) {
+ public FrameworkSupportConfigurableBase(FrameworkSupportProviderBase frameworkSupportProvider, FrameworkSupportModel model,
+ List versions, @Nullable String versionLabelText) {
myFrameworkSupportProvider = frameworkSupportProvider;
myFrameworkSupportModel = model;
if (versions.size() > 0) {
@@ -62,14 +64,12 @@ public class FrameworkSupportConfigurableBase extends FrameworkSupportConfigurab
}
}
myVersionComboBox.setPrototypeDisplayValue(maxValue + "_");
- myVersionComboBox.setRenderer(new DefaultListCellRenderer() {
+ myVersionComboBox.setRenderer(new ListCellRendererWrapper(myVersionComboBox.getRenderer()) {
@Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof FrameworkVersion) {
setText(((FrameworkVersion)value).getVersionName());
}
- return component;
}
});
myVersionComboBox.setSelectedItem(defaultVersion);
@@ -101,5 +101,4 @@ public class FrameworkSupportConfigurableBase extends FrameworkSupportConfigurab
public FrameworkVersion getSelectedVersion() {
return (FrameworkVersion)myVersionComboBox.getSelectedItem();
}
-
}
diff --git a/platform/lang-api/src/com/intellij/openapi/editor/PsiAwareDefaultLineWrapPositionStrategy.java b/platform/lang-api/src/com/intellij/openapi/editor/PsiAwareDefaultLineWrapPositionStrategy.java
index f10ddc670f76..47462ad878c7 100644
--- a/platform/lang-api/src/com/intellij/openapi/editor/PsiAwareDefaultLineWrapPositionStrategy.java
+++ b/platform/lang-api/src/com/intellij/openapi/editor/PsiAwareDefaultLineWrapPositionStrategy.java
@@ -23,15 +23,15 @@ import org.jetbrains.annotations.Nullable;
/**
* {@link LineWrapPositionStrategy} implementation that uses
* {@link LanguageLineWrapPositionStrategy#getDefaultImplementation() default line wrap strategy} but restricts its scope
- * by {@link #PsiAwareDefaultLineWrapPositionStrategy(IElementType...) target tokens/elements}.
+ * by {@link #PsiAwareDefaultLineWrapPositionStrategy(boolean, IElementType...) target tokens/elements}.
*
* @author Denis Zhdanov
* @since 5/12/11 12:50 PM
*/
public class PsiAwareDefaultLineWrapPositionStrategy extends PsiAwareLineWrapPositionStrategy {
- public PsiAwareDefaultLineWrapPositionStrategy(@NotNull IElementType ... enabledTypes) {
- super(enabledTypes);
+ public PsiAwareDefaultLineWrapPositionStrategy(boolean nonVirtualOnly, @NotNull IElementType ... enabledTypes) {
+ super(nonVirtualOnly, enabledTypes);
}
@Override
@@ -40,10 +40,11 @@ public class PsiAwareDefaultLineWrapPositionStrategy extends PsiAwareLineWrapPos
int startOffset,
int endOffset,
int maxPreferredOffset,
- boolean allowToBeyondMaxPreferredOffset)
+ boolean allowToBeyondMaxPreferredOffset,
+ boolean virtual)
{
LineWrapPositionStrategy implementation = LanguageLineWrapPositionStrategy.INSTANCE.getDefaultImplementation();
return implementation.calculateWrapPosition(document, project, startOffset, endOffset, maxPreferredOffset,
- allowToBeyondMaxPreferredOffset);
+ allowToBeyondMaxPreferredOffset, virtual);
}
}
diff --git a/platform/lang-api/src/com/intellij/openapi/editor/PsiAwareLineWrapPositionStrategy.java b/platform/lang-api/src/com/intellij/openapi/editor/PsiAwareLineWrapPositionStrategy.java
index 72dba9b8199d..a59da3c70e69 100644
--- a/platform/lang-api/src/com/intellij/openapi/editor/PsiAwareLineWrapPositionStrategy.java
+++ b/platform/lang-api/src/com/intellij/openapi/editor/PsiAwareLineWrapPositionStrategy.java
@@ -39,14 +39,17 @@ public abstract class PsiAwareLineWrapPositionStrategy implements LineWrapPositi
private static final Logger LOG = Logger.getInstance("#" + PsiAwareLineWrapPositionStrategy.class.getName());
private final TokenSet myEnabledTypes;
+ private final boolean myNonVirtualOnly;
/**
* Creates new PsiAwareLineWrapPositionStrategy object.
*
+ * @param nonVirtualOnly defines if current PSI-aware logic should be exploited only for 'real wrap' position requests
* @param enabledTypes target element/token types where line wrapping is allowed
*/
- public PsiAwareLineWrapPositionStrategy(@NotNull IElementType ... enabledTypes) {
+ public PsiAwareLineWrapPositionStrategy(boolean nonVirtualOnly, @NotNull IElementType ... enabledTypes) {
myEnabledTypes = TokenSet.create(enabledTypes);
+ myNonVirtualOnly = nonVirtualOnly;
if (enabledTypes.length <= 0) {
LOG.warn(String.format("%s instance is created with empty token/element types. That will lead to inability to perform line wrap",
getClass().getName()));
@@ -59,11 +62,19 @@ public abstract class PsiAwareLineWrapPositionStrategy implements LineWrapPositi
int startOffset,
int endOffset,
int maxPreferredOffset,
- boolean allowToBeyondMaxPreferredOffset) {
+ boolean allowToBeyondMaxPreferredOffset,
+ boolean virtual) {
+ if (virtual && myNonVirtualOnly) {
+ LineWrapPositionStrategy implementation = LanguageLineWrapPositionStrategy.INSTANCE.getDefaultImplementation();
+ return implementation.calculateWrapPosition(
+ document, project, startOffset, endOffset, maxPreferredOffset, allowToBeyondMaxPreferredOffset, virtual
+ );
+ }
+
if (project == null) {
return -1;
}
-
+
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
if (documentManager == null) {
return -1;
@@ -84,7 +95,7 @@ public abstract class PsiAwareLineWrapPositionStrategy implements LineWrapPositi
TextRange textRange = element.getTextRange();
int start = Math.max(textRange.getStartOffset(), startOffset);
int end = Math.min(textRange.getEndOffset(), endOffset);
- int result = doCalculateWrapPosition(document, project, start, end, end, false);
+ int result = doCalculateWrapPosition(document, project, start, end, end, false, virtual);
if (result >= 0) {
return result;
}
@@ -96,15 +107,15 @@ public abstract class PsiAwareLineWrapPositionStrategy implements LineWrapPositi
if (start > startOffset) {
return start;
- }
+ }
}
}
return -1;
}
/**
- * Serves for the same purposes as {@link #calculateWrapPosition(Document, Project, int, int, int, boolean)} but ensures that given
- * offsets target {@link #PsiAwareLineWrapPositionStrategy(IElementType...) enabled token/element types}.
+ * Serves for the same purposes as {@link #calculateWrapPosition(Document, Project, int, int, int, boolean, boolean)} but ensures
+ * that given offsets target {@link #PsiAwareLineWrapPositionStrategy(boolean, IElementType...) enabled token/element types}.
*
* @param document target document which text is being processed
* @param project target project
@@ -117,12 +128,13 @@ public abstract class PsiAwareLineWrapPositionStrategy implements LineWrapPositi
* @param allowToBeyondMaxPreferredOffset indicates if it's allowed to return value from
* (maxPreferredOffset; endOffset] interval in case of inability to
* find appropriate offset from (startOffset; maxPreferredOffset] interval
+ * @param virtual identifies if current request is for virtual wrap (soft wrap) position
* @return offset from (startOffset; endOffset] interval where
* target line should be wrapped OR -1 if no wrapping should be performed
*/
protected abstract int doCalculateWrapPosition(
@NotNull Document document, @Nullable Project project, int startOffset, int endOffset, int maxPreferredOffset,
- boolean allowToBeyondMaxPreferredOffset
+ boolean allowToBeyondMaxPreferredOffset, boolean virtual
);
/**
@@ -134,7 +146,10 @@ public abstract class PsiAwareLineWrapPositionStrategy implements LineWrapPositi
*/
private boolean allowToWrapInside(@NotNull PsiElement element) {
TextRange textRange = element.getTextRange();
- for (PsiElement parent = element; parent != null && parent.getTextRange().equals(textRange); parent = parent.getParent()) {
+ if (textRange == null) {
+ return false;
+ }
+ for (PsiElement parent = element; parent != null && textRange.equals(parent.getTextRange()); parent = parent.getParent()) {
ASTNode parentNode = parent.getNode();
if (parentNode != null && myEnabledTypes.contains(parentNode.getElementType())) {
return true;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java
index 656992640479..6fe03bbcde46 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java
@@ -150,7 +150,7 @@ public class AutoHardWrapHandler {
new VisualPosition(caretModel.getVisualPosition().line, margin - FormatConstants.RESERVED_LINE_WRAP_WIDTH_IN_COLUMNS)
));
- int wrapOffset = strategy.calculateWrapPosition(document, project, startOffset, endOffset, maxPreferredOffset, true);
+ int wrapOffset = strategy.calculateWrapPosition(document, project, startOffset, endOffset, maxPreferredOffset, true, false);
if (wrapOffset < 0) {
return;
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java
index 8cadef5cb45b..a5f8f949d049 100644
--- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -356,7 +356,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable
public RecognizedFileTypes() {
super(new BorderLayout());
add(myWholePanel, BorderLayout.CENTER);
- myFileTypesList.setCellRenderer(new FileTypeRenderer(new FileTypeRenderer.FileTypeListProvider(){
+ myFileTypesList.setCellRenderer(new FileTypeRenderer(myFileTypesList.getCellRenderer(), new FileTypeRenderer.FileTypeListProvider() {
public Iterable getCurrentFileTypeList() {
ArrayList result = new ArrayList();
for (int i = 0; i < myFileTypesList.getModel().getSize(); i++) {
diff --git a/platform/lang-impl/src/com/intellij/openapi/module/ModuleNavigatable.java b/platform/lang-impl/src/com/intellij/openapi/module/ModuleNavigatable.java
new file mode 100644
index 000000000000..76b4a3a53743
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/openapi/module/ModuleNavigatable.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2011 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.openapi.module;
+
+import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
+import com.intellij.pom.Navigatable;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public class ModuleNavigatable implements Navigatable {
+ private final Module module;
+
+ public ModuleNavigatable(@NotNull Module module) {
+ this.module = module;
+ }
+
+ @Override
+ public void navigate(boolean requestFocus) {
+ ProjectSettingsService.getInstance(module.getProject()).openContentEntriesSettings(module);
+ }
+
+ @Override
+ public boolean canNavigate() {
+ return !module.isDisposed();
+ }
+
+ @Override
+ public boolean canNavigateToSource() {
+ return false;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryNavigatable.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryNavigatable.java
new file mode 100644
index 000000000000..80d00c99ba9b
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryNavigatable.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2011 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.openapi.roots.libraries;
+
+import com.intellij.ide.projectView.impl.nodes.NamedLibraryElement;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.roots.LibraryOrderEntry;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.OrderEntry;
+import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
+import com.intellij.pom.Navigatable;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public class LibraryNavigatable implements Navigatable {
+ private final Module module;
+ private NamedLibraryElement element;
+
+ public LibraryNavigatable(@NotNull Library library, @NotNull Module module) {
+ this.module = module;
+ for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
+ if (entry instanceof LibraryOrderEntry) {
+ if (((LibraryOrderEntry)entry).getLibrary() == library) {
+ element = new NamedLibraryElement(module, entry);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void navigate(boolean requestFocus) {
+ ProjectSettingsService.getInstance(module.getProject()).openProjectLibrarySettings(element);
+ }
+
+ @Override
+ public boolean canNavigate() {
+ return !module.isDisposed() && element != null;
+ }
+
+ @Override
+ public boolean canNavigateToSource() {
+ return false;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
index 4841db5a70c1..8b99608be6de 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
@@ -381,7 +381,7 @@ public class CodeFormatterFacade {
// We know that current line exceeds right margin if control flow reaches this place, so, wrap it.
int wrapOffset = strategy.calculateWrapPosition(
document, editor.getProject(), Math.max(startLineOffset, startOffsetToUse), Math.min(endLineOffset, endOffsetToUse),
- preferredWrapPosition, false
+ preferredWrapPosition, false, false
);
if (wrapOffset < 0) {
continue;
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java b/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java
index 21757e3af59f..d39cad7af87c 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java
@@ -104,7 +104,9 @@ public interface EditorSettings {
void setUseSoftWraps(boolean use);
boolean isAllSoftWrapsShown();
boolean isUseCustomSoftWrapIndent();
+ void setUseCustomSoftWrapIndent(boolean useCustomSoftWrapIndent);
int getCustomSoftWrapIndent();
+ void setCustomSoftWrapIndent(int indent);
boolean isAllowSingleLogicalLineFolding();
void setAllowSingleLogicalLineFolding(boolean allow);
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/GenericLineWrapPositionStrategy.java b/platform/platform-api/src/com/intellij/openapi/editor/GenericLineWrapPositionStrategy.java
index 93289b0caddd..a3d5988effc3 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/GenericLineWrapPositionStrategy.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/GenericLineWrapPositionStrategy.java
@@ -48,7 +48,8 @@ public class GenericLineWrapPositionStrategy implements LineWrapPositionStrategy
int startOffset,
int endOffset,
int maxPreferredOffset,
- boolean allowToBeyondMaxPreferredOffset)
+ boolean allowToBeyondMaxPreferredOffset,
+ boolean virtual)
{
if (endOffset <= startOffset) {
return endOffset;
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java b/platform/platform-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java
index 958db895b793..2e13a3fb8f09 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java
@@ -45,11 +45,12 @@ public interface LineWrapPositionStrategy {
* @param allowToBeyondMaxPreferredOffset indicates if it's allowed to return value from
* (maxPreferredOffset; endOffset] interval in case of inability to
* find appropriate offset from (startOffset; maxPreferredOffset] interval
+ * @param virtual identifies if current request is for virtual wrap (soft wrap) position
* @return offset from (startOffset; endOffset] interval where
* target line should be wrapped OR -1 if no wrapping should be performed
*/
int calculateWrapPosition(
@NotNull Document document, @Nullable Project project, int startOffset, int endOffset, int maxPreferredOffset,
- boolean allowToBeyondMaxPreferredOffset
+ boolean allowToBeyondMaxPreferredOffset, boolean virtual
);
}
diff --git a/platform/platform-api/testSrc/com/intellij/openapi/editor/DefaultLineWrapPositionStrategyTest.java b/platform/platform-api/testSrc/com/intellij/openapi/editor/DefaultLineWrapPositionStrategyTest.java
index 8d5ba9fa4e19..a4b8ddf29bab 100644
--- a/platform/platform-api/testSrc/com/intellij/openapi/editor/DefaultLineWrapPositionStrategyTest.java
+++ b/platform/platform-api/testSrc/com/intellij/openapi/editor/DefaultLineWrapPositionStrategyTest.java
@@ -85,7 +85,8 @@ public class DefaultLineWrapPositionStrategyTest {
final Context context = new Context(document);
context.init();
int actual = myStrategy.calculateWrapPosition(
- createMockDocument(context.document), myProject, 0, context.document.length(), context.edgeIndex, allowToBeyondMaxPreferredOffset
+ createMockDocument(context.document), myProject, 0, context.document.length(), context.edgeIndex,
+ allowToBeyondMaxPreferredOffset, true
);
assertSame(context.wrapIndex, actual);
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java
index e00b6928ebaf..ae5672dd1f95 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java
@@ -77,6 +77,8 @@ public class SettingsImpl implements EditorSettings {
private Boolean myIsRefrainFromScrolling = null;
private Boolean myUseSoftWraps = null;
private Boolean myIsAllSoftWrapsShown = null;
+ private Boolean myUseCustomSoftWrapIndent = null;
+ private Integer myCustomSoftWrapIndent = null;
public boolean isRightMarginShown() {
return myIsRightMarginShown != null
@@ -206,8 +208,6 @@ public class SettingsImpl implements EditorSettings {
public void reinitSettings() {
myCachedTabSize = null;
- //TODO den check
- //myUseSoftWraps = null;
}
public int getTabSize(Project project) {
@@ -419,12 +419,23 @@ public class SettingsImpl implements EditorSettings {
@Override
public boolean isUseCustomSoftWrapIndent() {
- return EditorSettingsExternalizable.getInstance().isUseCustomSoftWrapIndent();
+ return myUseCustomSoftWrapIndent == null ? EditorSettingsExternalizable.getInstance().isUseCustomSoftWrapIndent()
+ : myUseCustomSoftWrapIndent;
+ }
+
+ @Override
+ public void setUseCustomSoftWrapIndent(boolean useCustomSoftWrapIndent) {
+ myUseCustomSoftWrapIndent = useCustomSoftWrapIndent;
}
@Override
public int getCustomSoftWrapIndent() {
- return EditorSettingsExternalizable.getInstance().getCustomSoftWrapIndent();
+ return myCustomSoftWrapIndent == null ? EditorSettingsExternalizable.getInstance().getCustomSoftWrapIndent() : myCustomSoftWrapIndent;
+ }
+
+ @Override
+ public void setCustomSoftWrapIndent(int indent) {
+ myCustomSoftWrapIndent = indent;
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
index 1a27b73d43de..083c0f47f817 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
@@ -517,10 +517,14 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
myLineWrapPositionStrategy = LanguageLineWrapPositionStrategy.INSTANCE.forEditor(myEditor);
}
- softWrapOffset = myLineWrapPositionStrategy.calculateWrapPosition(document, myEditor.getProject(), minOffset, maxOffset, preferredOffset, true);
+ softWrapOffset = myLineWrapPositionStrategy.calculateWrapPosition(
+ document, myEditor.getProject(), minOffset, maxOffset, preferredOffset, true, true
+ );
}
- if (softWrapOffset >= lineData.endLineOffset || softWrapOffset < 0) {
+ if (softWrapOffset >= lineData.endLineOffset || softWrapOffset < 0
+ || (myCustomIndentUsedLastTime && softWrapOffset == lineData.nonWhiteSpaceSymbolOffset))
+ {
return null;
}
@@ -787,8 +791,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
public int indentInColumns;
public int indentInPixels;
public int endLineOffset;
-
- private int myNonWhiteSpaceSymbolOffset;
+ public int nonWhiteSpaceSymbolOffset;
public void update(int logicalLine, int spaceWidth, Editor editor) {
Document document = myEditor.getDocument();
@@ -803,7 +806,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
CharSequence text = document.getCharsSequence();
indentInColumns = 0;
indentInPixels = 0;
- myNonWhiteSpaceSymbolOffset = -1;
+ nonWhiteSpaceSymbolOffset = -1;
for (int i = startLineOffset; i < endLineOffset; i++) {
char c = text.charAt(i);
@@ -814,7 +817,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
indentInColumns += calculateWidthInColumns(c, x - indentInPixels, spaceWidth);
indentInPixels = x;
break;
- default: myNonWhiteSpaceSymbolOffset = i; return;
+ default: nonWhiteSpaceSymbolOffset = i; return;
}
}
}
@@ -828,7 +831,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
* @param softWrapOffset offset of the soft wrap that occurred on document line which data is stored at the current object
*/
public void update(int softWrapOffset) {
- if (myNonWhiteSpaceSymbolOffset >= 0 && softWrapOffset > myNonWhiteSpaceSymbolOffset) {
+ if (nonWhiteSpaceSymbolOffset >= 0 && softWrapOffset > nonWhiteSpaceSymbolOffset) {
return;
}
indentInColumns = 0;
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java
index 25eec3e66c5e..06fd4db48cc8 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ListScrollingUtil;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -33,8 +34,7 @@ import java.awt.event.MouseEvent;
import java.util.Arrays;
import java.util.Comparator;
-public class FileTypeChooser extends DialogWrapper{
- private final DefaultListModel myModel = new DefaultListModel();
+public class FileTypeChooser extends DialogWrapper {
private JList myList;
private JLabel myTitleLabel;
private JTextField myPattern;
@@ -62,13 +62,13 @@ public class FileTypeChooser extends DialogWrapper{
}
});
+ final DefaultListModel model = new DefaultListModel();
for (FileType type : fileTypes) {
if (!type.isReadOnly() && type != FileTypes.UNKNOWN && !(type instanceof NativeFileType)) {
- myModel.addElement(type);
+ model.addElement(type);
}
}
-
- myList.setModel(myModel);
+ myList.setModel(model);
myPattern.setText(pattern);
setTitle(FileTypesBundle.message("filetype.chooser.title"));
@@ -79,7 +79,7 @@ public class FileTypeChooser extends DialogWrapper{
myTitleLabel.setText(FileTypesBundle.message("filetype.chooser.prompt", myFileName));
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- myList.setCellRenderer(new FileTypeRenderer());
+ myList.setCellRenderer(new FileTypeRenderer(myList.getCellRenderer()));
myList.addMouseListener(
new MouseAdapter() {
@@ -125,22 +125,27 @@ public class FileTypeChooser extends DialogWrapper{
* Otherwise asks user to select file type and associates it with fileName extension if any selected.
* @return Known file type or null. Never returns {@link com.intellij.openapi.fileTypes.FileTypes#UNKNOWN}.
*/
+ @Nullable
public static FileType getKnownFileTypeOrAssociate(VirtualFile file) {
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
FileType type = fileTypeManager.getFileTypeByFile(file);
- if (type == FileTypes.UNKNOWN)
+ if (type == FileTypes.UNKNOWN) {
type = getKnownFileTypeOrAssociate(file.getName());
+ }
return type;
}
+ @Nullable
public static FileType getKnownFileTypeOrAssociate(String fileName) {
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
FileType type = fileTypeManager.getFileTypeByFileName(fileName);
- if (type == FileTypes.UNKNOWN)
+ if (type == FileTypes.UNKNOWN) {
type = associateFileType(fileName);
+ }
return type;
}
+ @Nullable
public static FileType associateFileType(String fileName) {
final FileTypeChooser chooser = new FileTypeChooser(suggestPatternText(fileName), fileName);
chooser.show();
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeRenderer.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeRenderer.java
index e513445d0552..faceb61eb5cd 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeRenderer.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -15,35 +15,36 @@
*/
package com.intellij.openapi.fileTypes.impl;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.ui.LayeredIcon;
import com.intellij.util.ui.EmptyIcon;
import javax.swing.*;
-import java.awt.*;
-import java.util.*;
+import java.util.Arrays;
+import java.util.List;
-public class FileTypeRenderer extends DefaultListCellRenderer {
+public class FileTypeRenderer extends ListCellRendererWrapper {
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
- private final FileTypeListProvider myFileTypeListProvider;
-
- public FileTypeRenderer(final FileTypeListProvider fileTypeListProvider) {
- myFileTypeListProvider = fileTypeListProvider;
- }
-
- public FileTypeRenderer() {
- this(new DefaultFileTypeListProvider());
- }
-
- public static interface FileTypeListProvider {
+ public interface FileTypeListProvider {
Iterable getCurrentFileTypeList();
}
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- FileType type = (FileType)value;
+ private final FileTypeListProvider myFileTypeListProvider;
+
+ public FileTypeRenderer(final ListCellRenderer renderer) {
+ this(renderer, new DefaultFileTypeListProvider());
+ }
+
+ public FileTypeRenderer(final ListCellRenderer renderer, final FileTypeListProvider fileTypeListProvider) {
+ super(renderer);
+ myFileTypeListProvider = fileTypeListProvider;
+ }
+
+ @Override
+ public void customize(JList list, FileType type, int index, boolean selected, boolean hasFocus) {
LayeredIcon layeredIcon = new LayeredIcon(2);
layeredIcon.setIcon(EMPTY_ICON, 0);
final Icon icon = type.getIcon();
@@ -60,7 +61,6 @@ public class FileTypeRenderer extends DefaultListCellRenderer {
else {
setText(type.getDescription());
}
- return this;
}
private boolean isDuplicated(final String description) {
@@ -79,12 +79,12 @@ public class FileTypeRenderer extends DefaultListCellRenderer {
return false;
}
- public Dimension getPreferredSize() {
- return new Dimension(0, 20);
- }
+ //public Dimension getPreferredSize() {
+ // return new Dimension(0, 20);
+ //}
private static class DefaultFileTypeListProvider implements FileTypeListProvider {
- private final java.util.List myFileTypes;
+ private final List myFileTypes;
public DefaultFileTypeListProvider() {
myFileTypes = Arrays.asList(FileTypeManager.getInstance().getRegisteredFileTypes());
diff --git a/platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java b/platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java
index ff8f09b3ee29..26ab633d80ca 100644
--- a/platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java
+++ b/platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.impl.softwrap.mapping;
import com.intellij.codeInsight.folding.CodeFoldingManager;
import com.intellij.openapi.editor.*;
+import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.SoftWrapModelEx;
import com.intellij.openapi.editor.impl.AbstractEditorProcessingOnDocumentModificationTest;
import com.intellij.openapi.editor.impl.SoftWrapModelImpl;
@@ -793,6 +794,21 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorP
assertEquals(new VisualPosition(1, 8), getEditor().offsetToVisualPosition(getEditor().getDocument().getTextLength() - 1));
}
+ public void testNoWrapAtFirstNonWsSymbolWithCustomIndent() throws IOException {
+ String text =
+ " 1111111111111111111111111111111";
+ init(70, text);
+ getEditor().getSettings().setCustomSoftWrapIndent(0);
+ getEditor().getSettings().setUseCustomSoftWrapIndent(true);
+ int textLength = getEditor().getDocument().getTextLength();
+ //Trigger soft wraps recalculation.
+ assertEquals(new LogicalPosition(0, textLength), myEditor.offsetToLogicalPosition(textLength));
+
+ // Don't expect soft wraps to be registered as there is no point in wrapping at the first non-white space symbol position
+ // in all cases when soft wrap is located at the left screen edge.
+ assertEmpty(getSoftWrapModel().getRegisteredSoftWraps());
+ }
+
public void testXmlWithLongCdata() throws IOException {
String text =
"\n" +
diff --git a/platform/platform-resources-en/src/messages/PsiBundle.properties b/platform/platform-resources-en/src/messages/PsiBundle.properties
index 508794100df1..6a870242fa45 100644
--- a/platform/platform-resources-en/src/messages/PsiBundle.properties
+++ b/platform/platform-resources-en/src/messages/PsiBundle.properties
@@ -75,7 +75,7 @@ jdk.1.3.language.level.description=1.3 - Plain old Java
jdk.1.4.language.level.description=1.4 - 'assert' keyword
jdk.1.5.language.level.description=5.0 - 'enum' keyword, autoboxing, etc.
jdk.1.6.language.level.description=6.0 - @Override in interfaces
-jdk.1.7.language.level.description=7.0 - "Diamonds", strings in switch, etc.
+jdk.1.7.language.level.description=7.0 - Diamonds, ARM, multi-catch, etc.
jdk.1.8.language.level.description=8.0 - Type annotations
#access levels
diff --git a/platform/testFramework/src/com/intellij/testFramework/TeamCityLogger.java b/platform/testFramework/src/com/intellij/testFramework/TeamCityLogger.java
index 1a35b91c28de..5b178ca68fbb 100644
--- a/platform/testFramework/src/com/intellij/testFramework/TeamCityLogger.java
+++ b/platform/testFramework/src/com/intellij/testFramework/TeamCityLogger.java
@@ -53,8 +53,9 @@ public class TeamCityLogger {
public static void warning(String message, @Nullable Throwable throwable) {
if (isUnderTC) {
tcLog(message, "WARNING");
+ } else {
+ LOG.warn(message, throwable);
}
- LOG.warn(message, throwable);
}
public static void error(String message) {
@@ -63,8 +64,9 @@ public class TeamCityLogger {
public static void error(String message, @Nullable Throwable throwable) {
if (isUnderTC) {
tcLog(message, "ERROR");
+ } else {
+ LOG.error(message, throwable);
}
- LOG.error(message, throwable);
}
private static void tcLog(String message, String level) {
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java
index 2aca0f99ad7e..b7c58bde02be 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java
@@ -24,8 +24,8 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
-import com.intellij.ui.ColoredListCellRenderer;
import com.intellij.ui.EditorTextField;
+import com.intellij.ui.HtmlListCellRenderer;
import com.intellij.ui.ShiftTabAction;
import com.intellij.ui.SimpleTextAttributes;
import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
@@ -42,9 +42,7 @@ import java.util.HashSet;
import java.util.Set;
public class LanguagePanel extends AbstractInjectionPanel {
-
private JPanel myRoot;
-
private ComboBox myLanguage;
private EditorTextField myPrefix;
private EditorTextField mySuffix;
@@ -57,12 +55,11 @@ public class LanguagePanel extends AbstractInjectionPanel {
Arrays.sort(languageIDs);
myLanguage.setModel(new DefaultComboBoxModel(languageIDs));
- myLanguage.setRenderer(new ColoredListCellRenderer() {
+ myLanguage.setRenderer(new HtmlListCellRenderer(myLanguage.getRenderer()) {
final Set IDs = new HashSet(Arrays.asList(languageIDs));
- protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
- final String s = String.valueOf(value);
-
+ @Override
+ protected void doCustomize(JList list, String s, int index, boolean selected, boolean hasFocus) {
final SimpleTextAttributes attributes =
IDs.contains(s) ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.ERROR_ATTRIBUTES;
append(s, attributes);
@@ -74,11 +71,6 @@ public class LanguagePanel extends AbstractInjectionPanel {
setIcon(fileType.getIcon());
append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
append("(" + fileType.getDescription() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
-// } else if (language == StdLanguages.EL) {
-// // IDEA-10012
-// setIcon(StdFileTypes.JSP.getIcon());
-// append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
-// append("(Expression Language)", SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
}
}
diff --git a/plugins/devkit/src/projectRoots/IdeaJdkConfigurable.java b/plugins/devkit/src/projectRoots/IdeaJdkConfigurable.java
index a0491c94c4ce..9b3b8f2fd679 100644
--- a/plugins/devkit/src/projectRoots/IdeaJdkConfigurable.java
+++ b/plugins/devkit/src/projectRoots/IdeaJdkConfigurable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.devkit.projectRoots;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
@@ -44,7 +45,7 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
- * User: anna
+ * @author anna
* Date: Nov 22, 2004
*/
public class IdeaJdkConfigurable implements AdditionalDataConfigurable {
@@ -110,15 +111,12 @@ public class IdeaJdkConfigurable implements AdditionalDataConfigurable {
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
wholePanel.add(myInternalJres, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.EAST,
GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 0), 0, 0));
- myInternalJres.setRenderer(new DefaultListCellRenderer(){
- public Component getListCellRendererComponent(final JList list,
- final Object value,
- final int index, final boolean isSelected, final boolean cellHasFocus) {
- final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ myInternalJres.setRenderer(new ListCellRendererWrapper(myInternalJres.getRenderer()) {
+ @Override
+ public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof Sdk) {
setText(((Sdk)value).getName());
}
- return rendererComponent;
}
});
diff --git a/plugins/devkit/src/run/PluginRunConfigurationEditor.java b/plugins/devkit/src/run/PluginRunConfigurationEditor.java
index 0473e7edb4dd..bb227b0c9a28 100644
--- a/plugins/devkit/src/run/PluginRunConfigurationEditor.java
+++ b/plugins/devkit/src/run/PluginRunConfigurationEditor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -16,7 +16,7 @@
package org.jetbrains.idea.devkit.run;
import com.intellij.execution.configurations.LogFileOptions;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.ConfigurationException;
@@ -24,7 +24,6 @@ import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.ui.LabeledComponent;
-import com.intellij.openapi.util.Computable;
import com.intellij.ui.RawCommandLineEditor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -122,18 +121,13 @@ public class PluginRunConfigurationEditor extends SettingsEditor() {
- public String compute() {
- return ((Module)value).getName();
- }
- }));
- setIcon(((Module)value).getModuleType().getNodeIcon(true));
+ myModules.setRenderer(new ListCellRendererWrapper(myModules.getRenderer()) {
+ @Override
+ public void customize(JList list, final Module module, int index, boolean selected, boolean hasFocus) {
+ if (module != null) {
+ setText(module.getName());
+ setIcon(module.getModuleType().getNodeIcon(true));
}
- return this;
}
});
JPanel wholePanel = new JPanel(new GridBagLayout());
diff --git a/plugins/git4idea/src/git4idea/changes/GitChangeProvider.java b/plugins/git4idea/src/git4idea/changes/GitChangeProvider.java
index c7b29bb66145..2427e4477c9b 100644
--- a/plugins/git4idea/src/git4idea/changes/GitChangeProvider.java
+++ b/plugins/git4idea/src/git4idea/changes/GitChangeProvider.java
@@ -150,7 +150,7 @@ public class GitChangeProvider implements ChangeProvider {
for (FilePath filePath : myDirty) {
final VirtualFile vf = filePath.getVirtualFile();
if (vf != null) {
- if ((! FileStatus.ADDED.equals(myAddGate.getStatus(vf))) && myFileDocumentManager.isFileModified(vf)) {
+ if ((myAddGate.getStatus(vf) == null) && myFileDocumentManager.isFileModified(vf)) {
final VirtualFile root = myVcsManager.getVcsRootFor(vf);
if (root != null) {
final GitRevisionNumber beforeRevisionNumber = GitChangeUtils.loadRevision(myProject, root, "HEAD");
diff --git a/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java b/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java
index d7964f60a0bb..36cd25776048 100644
--- a/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java
+++ b/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java
@@ -253,7 +253,7 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider<
return new Pair(commit, filePath);
}
}
- final List history = GitHistoryUtils.history(myProject, filePath, null, number.asString() + "^..");
+ final List history = GitHistoryUtils.history(myProject, filePath, null, number.asString() + "..");
return new Pair(commit, ((GitFileRevision) history.get(history.size() - 1)).getPath());
}
diff --git a/plugins/git4idea/src/git4idea/commands/GitTask.java b/plugins/git4idea/src/git4idea/commands/GitTask.java
index aeee1251d300..491066a0769e 100644
--- a/plugins/git4idea/src/git4idea/commands/GitTask.java
+++ b/plugins/git4idea/src/git4idea/commands/GitTask.java
@@ -373,7 +373,9 @@ public class GitTask {
}
public void dispose() {
- myTimer.cancel();
+ if (myTimer != null) {
+ myTimer.cancel();
+ }
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/actions/GroovyStatementMover.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/actions/GroovyStatementMover.java
index 0274611c4990..ba224e31dce8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/actions/GroovyStatementMover.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/actions/GroovyStatementMover.java
@@ -72,7 +72,8 @@ public class GroovyStatementMover extends StatementUpDownMover {
final GroovyPsiElement pivot = getElementToMove((GroovyFileBase)file, offset);
if (pivot == null) return false;
- range = getLineRange(pivot);
+ final LineRange pivotRange = getLineRange(pivot);
+ range = new LineRange(Math.min(range.startLine, pivotRange.startLine), Math.max(range.endLine, pivotRange.endLine));
final GroovyPsiElement scope = PsiTreeUtil.getParentOfType(pivot, GrMethod.class, GrTypeDefinitionBody.class, GroovyFileBase.class);
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/updown/GroovyMoveStatementTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/updown/GroovyMoveStatementTest.java
index 284f2020651e..17ddf990b3ac 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/updown/GroovyMoveStatementTest.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/updown/GroovyMoveStatementTest.java
@@ -92,6 +92,8 @@ public class GroovyMoveStatementTest extends LightCodeInsightFixtureTestCase {
public void testInSwitchCaseUp4() throws Throwable { bothTest(); }
public void testInSwitchCaseUp5() throws Throwable { bothTest(); }
+ public void testTwoStatements() throws Throwable { bothTest(); }
+
private void bothTest() {
final List data = TestUtils.readInput(getTestDataPath() + getTestName(true) + ".test");
final String initial = data.get(0);
diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/twoStatements.test b/plugins/groovy/testdata/groovy/actions/moveStatement/twoStatements.test
new file mode 100644
index 000000000000..ff729284e08a
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/actions/moveStatement/twoStatements.test
@@ -0,0 +1,13 @@
+public static void main(String[] args) {
+ for (String s : args) {
+ }
+ println("a")
+ println("b")
+}
+-----
+public static void main(String[] args) {
+ for (String s : args) {
+ println("a")
+ println("b")
+ }
+}
\ No newline at end of file
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java
index 2e3934c149ab..3381e9345776 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java
@@ -109,12 +109,12 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
SvnUtil.checkRepositoryVersion15(myVcs, url);
final SVNRevision svnRevision = ((SvnRevisionNumber)revision.getRevisionNumber()).getRevision();
- final MySteppedLogGetter logGetter = new MySteppedLogGetter(myVcs, ioFile, progress, client, endRevision, result, url);
+ final MySteppedLogGetter logGetter = new MySteppedLogGetter(myVcs, ioFile, progress, client, endRevision, result, url, calculateMergeinfo);
logGetter.go();
final LinkedList rp = logGetter.getRevisionPoints();
for (int i = 0; i < rp.size() - 1; i++) {
- client.doAnnotate(ioFile, SVNRevision.UNDEFINED, rp.get(i + 1), rp.get(i), true, calculateMergeinfo, annotateHandler, null);
+ client.doAnnotate(ioFile, svnRevision, rp.get(i + 1), rp.get(i), true, calculateMergeinfo, annotateHandler, null);
}
if (rp.get(1).getNumber() > 0) {
@@ -189,7 +189,10 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
@Override
public VcsAnnotation createCacheable(FileAnnotation fileAnnotation) {
final SvnFileAnnotation svnFileAnnotation = (SvnFileAnnotation)fileAnnotation;
- svnFileAnnotation.getAnnotationSourceSwitcher().switchTo(AnnotationSource.LOCAL);
+ final AnnotationSourceSwitcher annotationSourceSwitcher = svnFileAnnotation.getAnnotationSourceSwitcher();
+ if (annotationSourceSwitcher != null) {
+ annotationSourceSwitcher.switchTo(AnnotationSource.LOCAL);
+ }
final int size = svnFileAnnotation.getNumLines();
final VcsUsualLineAnnotationData lineAnnotationData = new VcsUsualLineAnnotationData(size);
@@ -198,24 +201,28 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
lineAnnotationData.put(i, revisionNumber);
}
- final VcsRareLineAnnotationData merged = new VcsRareLineAnnotationData(size);
- final Map addMap = new HashMap();
- svnFileAnnotation.getAnnotationSourceSwitcher().switchTo(AnnotationSource.MERGE);
- for (int i = 0; i < size; i++) {
- if (svnFileAnnotation.getAnnotationSourceSwitcher().mergeSourceAvailable(i)) {
- final VcsRevisionNumber number = svnFileAnnotation.getLineRevisionNumber(i);
- if (number == null) continue;
- merged.put(i, number);
- addMap.put(number, svnFileAnnotation.getRevision(((SvnRevisionNumber) number).getRevision().getNumber()));
+ final VcsAnnotation vcsAnnotation = new VcsAnnotation(new FilePathImpl(svnFileAnnotation.getFile()), lineAnnotationData,
+ svnFileAnnotation.getFirstRevisionNumber());
+
+ if (annotationSourceSwitcher != null) {
+ final VcsRareLineAnnotationData merged = new VcsRareLineAnnotationData(size);
+ final Map addMap = new HashMap();
+
+ annotationSourceSwitcher.switchTo(AnnotationSource.MERGE);
+ for (int i = 0; i < size; i++) {
+ if (annotationSourceSwitcher.mergeSourceAvailable(i)) {
+ final VcsRevisionNumber number = svnFileAnnotation.getLineRevisionNumber(i);
+ if (number == null) continue;
+ merged.put(i, number);
+ addMap.put(number, svnFileAnnotation.getRevision(((SvnRevisionNumber) number).getRevision().getNumber()));
+ }
+ }
+ if (! merged.isEmpty()) {
+ vcsAnnotation.addAnnotation(MERGED_KEY, merged);
+ vcsAnnotation.addCachedOtherRevisions(addMap);
}
}
- final VcsAnnotation vcsAnnotation = new VcsAnnotation(new FilePathImpl(svnFileAnnotation.getFile()), lineAnnotationData,
- svnFileAnnotation.getFirstRevisionNumber());
- if (! merged.isEmpty()) {
- vcsAnnotation.addAnnotation(MERGED_KEY, merged);
- vcsAnnotation.addCachedOtherRevisions(addMap);
- }
return vcsAnnotation;
}
@@ -264,18 +271,18 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
private final ProgressIndicator myProgress;
private final SVNLogClient myClient;
private final SVNRevision myEndRevision;
- private final boolean mySupportsMergeinfo;
+ private final boolean myCalculateMergeinfo;
private final SvnFileAnnotation myResult;
private final String myUrl;
private MySteppedLogGetter(final SvnVcs vcs, final File ioFile, final ProgressIndicator progress, final SVNLogClient client,
- final SVNRevision endRevision, final SvnFileAnnotation result, final String url) {
+ final SVNRevision endRevision, final SvnFileAnnotation result, final String url, final boolean calculateMergeinfo) {
myVcs = vcs;
myIoFile = ioFile;
myProgress = progress;
myClient = client;
myEndRevision = endRevision;
- mySupportsMergeinfo = SvnUtil.checkRepositoryVersion15(myVcs, url);
+ myCalculateMergeinfo = calculateMergeinfo;
myResult = result;
myUrl = url;
myRevisionPoints = new LinkedList();
@@ -293,14 +300,14 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
}
if (! longHistory) {
- doLog(mySupportsMergeinfo, null, 0);
+ doLog(myCalculateMergeinfo, null, 0);
putDefaultBounds();
} else {
doLog(false, null, 0);
final List fileRevisionList = myResult.getRevisions();
if (fileRevisionList.size() < maxAnnotateRevisions) {
putDefaultBounds();
- if (mySupportsMergeinfo) {
+ if (myCalculateMergeinfo) {
doLog(true, null, 0);
}
return;
@@ -311,8 +318,8 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
((SvnRevisionNumber)fileRevisionList.get(maxAnnotateRevisions - 1).getRevisionNumber()).getRevision();
myRevisionPoints.add(truncateTo);
- myResult.clearRevisions();
- if (mySupportsMergeinfo) {
+ // todo file history can be asked in parallel
+ if (myCalculateMergeinfo) {
doLog(true, truncateTo, maxAnnotateRevisions);
}
}
@@ -322,13 +329,15 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
myRevisionPoints.add(myEndRevision);
myRevisionPoints.add(SVNRevision.create(0));
}
-
+
private void doLog(final boolean includeMerged, final SVNRevision truncateTo, final int max) throws SVNException {
myClient.doLog(new File[]{myIoFile}, myEndRevision, truncateTo == null ? SVNRevision.create(1L) : truncateTo,
SVNRevision.UNDEFINED, false, false, includeMerged, max, null,
new ISVNLogEntryHandler() {
public void handleLogEntry(SVNLogEntry logEntry) {
- if (SVNRevision.UNDEFINED.getNumber() == logEntry.getRevision()) return;
+ if (SVNRevision.UNDEFINED.getNumber() == logEntry.getRevision()) {
+ return;
+ }
if (myProgress != null) {
myProgress.checkCanceled();
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnFileAnnotation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnFileAnnotation.java
index 4ca27cc8c0ef..d2f89e47af21 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnFileAnnotation.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnFileAnnotation.java
@@ -239,9 +239,9 @@ public class SvnFileAnnotation implements FileAnnotation {
}
final LineInfo info = myInfos.get(lineNumber);
if (info == null) return null;
- SvnFileRevision svnRevision = myRevisionMap.get(info.getRevision());
- if (svnRevision != null) {
- return svnRevision.getRevisionNumber();
+ final long revision = info.getRevision();
+ if (revision >= 0) {
+ return new SvnRevisionNumber(SVNRevision.create(revision));
}
return null;
}
@@ -310,9 +310,10 @@ public class SvnFileAnnotation implements FileAnnotation {
@Override
protected void showAffectedPaths(int lineNum) {
if (lineNum >= 0 && lineNum < myInfos.size()) {
- SvnFileRevision svnRevision = myRevisionMap.get(getRevision(lineNum));
- if (svnRevision != null) {
- ShowAllAffectedGenericAction.showSubmittedFiles(myVcs.getProject(), svnRevision.getRevisionNumber(), myFile, myVcs.getKeyInstanceMethod());
+ final long revision = getRevision(lineNum);
+ if (revision >= 0) {
+ ShowAllAffectedGenericAction.showSubmittedFiles(myVcs.getProject(), new SvnRevisionNumber(SVNRevision.create(revision)),
+ myFile, myVcs.getKeyInstanceMethod());
}
}
}
diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java
index 38791d5d602d..c1d96ecc6d30 100644
--- a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java
+++ b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java
@@ -332,14 +332,15 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
}
public void start() {
- start = System.currentTimeMillis();
+ if (start == 0) {
+ start = System.currentTimeMillis();
+ }
tree.getSelectionModel().setSelectionPath(new TreePath(treeBuilder.getNodeForElement(rootNode)));
rootNode.setInProgress(true);
rootNode.setStarted(true);
}
public void finish() {
- if (end > 0) return;
if (start > 0) {
end = System.currentTimeMillis();
}
diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/completion/CompletionLists.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/completion/CompletionLists.java
index 51c491ddefe8..43272690e95e 100644
--- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/completion/CompletionLists.java
+++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/completion/CompletionLists.java
@@ -322,15 +322,17 @@ public class CompletionLists {
XmlElement context,
boolean allowDefault) {
if (namespaceContext == null) return true;
- if (uri == null) return true;
final String namespaceURI;
if (prefixedName.getPrefix() != null) {
+ if (uri == null || uri.length() == 0) return false;
+
namespaceURI = namespaceContext.getNamespaceURI(prefixedName.getPrefix(), context);
} else {
- if (!allowDefault) return false;
+ if (!allowDefault) return (uri == null || uri.length() == 0);
+
if ((namespaceURI = namespaceContext.getDefaultNamespace(context)) == null) {
- return false;
+ return (uri == null || uri.length() == 0);
}
}
return uri.equals(namespaceURI);
diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java
index d321c7435e6b..36774b20d7e8 100644
--- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java
+++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/validation/inspections/CheckNodeTest.java
@@ -23,7 +23,6 @@ import com.intellij.psi.xml.XmlElement;
import org.intellij.lang.xpath.XPathFileType;
import org.intellij.lang.xpath.context.ContextProvider;
import org.intellij.lang.xpath.context.NamespaceContext;
-import org.intellij.lang.xpath.context.XPathVersion;
import org.intellij.lang.xpath.psi.PrefixedName;
import org.intellij.lang.xpath.psi.XPathNodeTest;
import org.jetbrains.annotations.NonNls;
@@ -141,15 +140,18 @@ public class CheckNodeTest extends XPathInspection {
boolean b = prefixedName.getLocalName().equals(element.getLocalPart()) || "*".equals(element.getLocalPart());
final String prefix = prefixedName.getPrefix();
- if (prefix != null || allowDefaultNamespace) {
+ if (prefix != null) {
if (!"*".equals(prefix)) {
- final String namespaceURI = prefix != null ? namespaceContext.getNamespaceURI(prefix, context) : namespaceContext.getDefaultNamespace(context);
+ final String namespaceURI = namespaceContext.getNamespaceURI(prefix, context);
b = b && element.getNamespaceURI().equals(namespaceURI);
}
+ } else if (allowDefaultNamespace) {
+ final String namespaceURI = namespaceContext.getDefaultNamespace(context);
+ b = b && (element.getNamespaceURI().equals(namespaceURI) || (element.getNamespaceURI().length() == 0 && namespaceURI == null));
} else {
b = b && element.getNamespaceURI().length() == 0;
}
- return b;
+ return b;
}
}
}
diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java
index ec00f72fdfb6..4b02edbf74fb 100644
--- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java
+++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java
@@ -234,16 +234,17 @@ class XsltRunSettingsEditor extends SettingsEditor {
myClasspathAndJDKPanel.setVisible(ALLOW_CHOOSING_SDK);
updateOutputState();
- myFileType.setRenderer(new FileTypeRenderer() {
- public Component getListCellRendererComponent(JList jList, Object object, int i, boolean b, boolean b1) {
- if (object == null) {
- super.getListCellRendererComponent(jList, StdFileTypes.ARCHIVE, i, b, b1);
- setIcon(IconLoader.getIcon("/actions/cancel.png"));
- setText("Disabled");
- return this;
- }
- return super.getListCellRendererComponent(jList, object, i, b, b1);
+ myFileType.setRenderer(new FileTypeRenderer(myFileType.getRenderer()) {
+ @Override
+ public void customize(JList list, FileType type, int index, boolean selected, boolean hasFocus) {
+ if (type == null) {
+ setIcon(IconLoader.getIcon("/actions/cancel.png"));
+ setText("Disabled");
}
+ else {
+ super.customize(list, type, index, selected, hasFocus);
+ }
+ }
});
myFileType.setModel(new DefaultComboBoxModel(getFileTypes(project)));
diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml
index e6376569f96f..95749b72564f 100644
--- a/resources/src/META-INF/IdeaPlugin.xml
+++ b/resources/src/META-INF/IdeaPlugin.xml
@@ -7,6 +7,8 @@
+
+
com.intellij.util.xml.impl.JavaDomApplicationComponent
@@ -651,8 +653,6 @@
-
-
@@ -688,8 +688,11 @@
+
+
+
@@ -883,6 +886,13 @@
serviceImplementation="com.intellij.profile.codeInspection.JavaAwareInspectionProfileManager"/>
+
+
+
+
+
+
+
diff --git a/resources/src/componentSets/IdeaComponents.xml b/resources/src/componentSets/IdeaComponents.xml
index 6c285554c078..300d134326ad 100644
--- a/resources/src/componentSets/IdeaComponents.xml
+++ b/resources/src/componentSets/IdeaComponents.xml
@@ -35,7 +35,6 @@
-
diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml
index f97d93819572..5d39ce44262a 100644
--- a/resources/src/idea/RichPlatformPlugin.xml
+++ b/resources/src/idea/RichPlatformPlugin.xml
@@ -234,12 +234,6 @@
-
-
-
-
-
-
@@ -283,10 +277,6 @@
-
-
-
-
@@ -365,12 +355,11 @@
+
+
-
-
-
diff --git a/xml/impl/src/com/intellij/psi/formatter/MarkupLineWrapPositionStrategy.java b/xml/impl/src/com/intellij/psi/formatter/MarkupLineWrapPositionStrategy.java
index 1f3c21bc9960..7fb5d9a9f821 100644
--- a/xml/impl/src/com/intellij/psi/formatter/MarkupLineWrapPositionStrategy.java
+++ b/xml/impl/src/com/intellij/psi/formatter/MarkupLineWrapPositionStrategy.java
@@ -30,6 +30,6 @@ import com.intellij.psi.xml.XmlTokenType;
public class MarkupLineWrapPositionStrategy extends PsiAwareDefaultLineWrapPositionStrategy {
public MarkupLineWrapPositionStrategy() {
- super(XmlElementType.XML_TEXT, TokenType.WHITE_SPACE);
+ super(true, XmlElementType.XML_TEXT, TokenType.WHITE_SPACE);
}
}