Merge remote-tracking branch 'origin/master'

This commit is contained in:
Maxim.Mossienko
2012-04-19 19:47:59 +04:00
98 changed files with 522 additions and 588 deletions
@@ -29,10 +29,6 @@ import java.awt.event.KeyEvent;
super(IdeBundle.message("button.add"));
}
public void setButton(AbstractButton button) {
super.setButton(button);
}
public void setPanel(BreakpointPanel panel) {
super.setPanel(panel);
getPanel().getTable().registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
@@ -16,13 +16,12 @@
package com.intellij.debugger.ui.breakpoints.actions;
import com.intellij.debugger.ui.breakpoints.BreakpointPanel;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.ide.IdeBundle;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
@@ -47,9 +46,6 @@ public class GotoSourceAction extends BreakpointPanelAction {
FileEditorManager.getInstance(myProject).openTextEditor(editSourceDescriptor, true);
}
}
public void setButton(AbstractButton button) {
super.setButton(button);
}
public void setPanel(BreakpointPanel panel) {
super.setPanel(panel);
@@ -15,8 +15,8 @@
*/
package com.intellij.debugger.ui.breakpoints.actions;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.ui.breakpoints.AnyExceptionBreakpoint;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointManager;
@@ -39,9 +39,6 @@ public class RemoveAction extends BreakpointPanelAction {
myProject = project;
}
public void setButton(AbstractButton button) {
super.setButton(button);
}
public void setPanel(BreakpointPanel panel) {
super.setPanel(panel);
@@ -15,8 +15,8 @@
*/
package com.intellij.debugger.ui.breakpoints.actions;
import com.intellij.debugger.ui.breakpoints.BreakpointPanel;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.ui.breakpoints.BreakpointPanel;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -30,9 +30,6 @@ public class SwitchViewAction extends BreakpointPanelAction {
super(DebuggerBundle.message("button.switch.view"));
}
public void setButton(AbstractButton button) {
super.setButton(button);
}
public void actionPerformed(ActionEvent e) {
getPanel().switchViews();
@@ -15,12 +15,11 @@
*/
package com.intellij.debugger.ui.breakpoints.actions;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.ide.IdeBundle;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
@@ -35,9 +34,6 @@ public class ViewSourceAction extends BreakpointPanelAction {
myProject = project;
}
public void setButton(AbstractButton button) {
super.setButton(button);
}
public void actionPerformed(ActionEvent e) {
OpenFileDescriptor editSourceDescriptor = getPanel().createEditSourceDescriptor(myProject);
@@ -1,82 +0,0 @@
/*
* 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.framework.addSupport;
import com.intellij.facet.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.roots.ModifiableModelsProvider;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ui.configuration.FacetsProvider;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author nik
*/
public abstract class FacetBasedFrameworkSupportInModuleProvider<F extends Facet> extends FrameworkSupportInModuleProvider {
private static final Logger LOG = Logger.getInstance("#com.intellij.framework.addSupport.FacetBasedFrameworkSupportInModuleProvider");
private final FacetType<F, ?> myFacetType;
protected FacetBasedFrameworkSupportInModuleProvider(FacetType<F, ?> facetType) {
myFacetType = facetType;
}
public boolean isEnabledForModuleType(@NotNull final ModuleType moduleType) {
return myFacetType.isSuitableModuleType(moduleType);
}
@Override
public boolean isSupportAlreadyAdded(@NotNull Module module, @NotNull FacetsProvider facetsProvider) {
return !FacetManager.getInstance(module).getFacetsByType(myFacetType.getId()).isEmpty();
}
protected class FacetBasedFrameworkSupportInModuleConfigurable extends FrameworkSupportInModuleConfigurable {
@Override
public JComponent createComponent() {
return null;
}
@Override
public void addSupport(@NotNull Module module,
@NotNull ModifiableRootModel rootModel,
@NotNull ModifiableModelsProvider modifiableModelsProvider) {
FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel model = facetManager.createModifiableModel();
Facet underlyingFacet = null;
FacetTypeId<?> underlyingFacetType = myFacetType.getUnderlyingFacetType();
if (underlyingFacetType != null) {
underlyingFacet = model.getFacetByType(underlyingFacetType);
LOG.assertTrue(underlyingFacet != null, underlyingFacetType);
}
F facet = facetManager.createFacet(myFacetType, myFacetType.getDefaultFacetName(), underlyingFacet);
setupConfiguration(facet, rootModel);
model.addFacet(facet);
model.commit();
onFacetCreated(facet, rootModel);
}
protected void setupConfiguration(final F facet, final ModifiableRootModel rootModel) {
}
protected void onFacetCreated(final F facet, final ModifiableRootModel rootModel) {
}
}
}
@@ -393,10 +393,6 @@ public class ProjectNameWithTypeStep extends ProjectNameStep {
return !myWizardContext.isCreatingNewProject() || super.validate();
}
public void disposeUIResources() {
super.disposeUIResources();
}
private static class PermanentSingleSelectionModel extends DefaultListSelectionModel {
public PermanentSingleSelectionModel() {
super.setSelectionMode(SINGLE_SELECTION);
@@ -429,4 +425,4 @@ public class ProjectNameWithTypeStep extends ProjectNameStep {
myInternalPanel.add(component, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(10, 0, 0, 0), 0, 0));
}
}
}
@@ -397,13 +397,7 @@ public class ConfigurationErrorsComponent extends JPanel implements Disposable,
myList = list;
myText = new JTextPane() {
@Override
public void setCursor(Cursor cursor) {
super.setCursor(cursor);
//onCursorChanged(cursor);
}
};
myText = new JTextPane();
myButtonsPanel = new JPanel(new BorderLayout());
myButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 3, 5, 3));
@@ -1075,7 +1075,8 @@ public class GenericsHighlightUtil {
}
}
public static boolean isUncheckedWarning(PsiJavaCodeReferenceElement expression, PsiElement resolve) {
public static boolean isUncheckedWarning(PsiJavaCodeReferenceElement expression, JavaResolveResult resolveResult) {
final PsiElement resolve = resolveResult.getElement();
if (resolve instanceof PsiMethod) {
final PsiMethod psiMethod = (PsiMethod)resolve;
@@ -1087,7 +1088,7 @@ public class GenericsHighlightUtil {
final PsiParameter varargParameter =
psiMethod.getParameterList().getParameters()[parametersCount - 1];
final PsiType componentType = ((PsiEllipsisType)varargParameter.getType()).getComponentType();
if (!isReifiableType(componentType)) {
if (!isReifiableType(resolveResult.getSubstitutor().substitute(componentType))) {
final PsiElement parent = expression.getParent();
if (parent instanceof PsiCall) {
final PsiExpressionList argumentList = ((PsiCall)parent).getArgumentList();
@@ -1109,7 +1110,7 @@ public class GenericsHighlightUtil {
}
}
for (int i = parametersCount - 1; i < args.length; i++) {
if (!isReifiableType(args[i].getType())){
if (!isReifiableType(resolveResult.getSubstitutor().substitute(args[i].getType()))){
return true;
}
}
@@ -60,10 +60,6 @@ public class ExplicitTypeCanBeDiamondInspection extends BaseJavaLocalInspectionT
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override
public void visitNewExpression(PsiNewExpression expression) {
if (PsiDiamondTypeUtil.canCollapseToDiamond(expression, expression, null)) {
@@ -170,9 +170,5 @@ public class PossibleHeapPollutionVarargsInspection extends BaseJavaLocalInspect
}
protected abstract void registerProblem(PsiMethod method, PsiIdentifier nameIdentifier);
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
}
}
}
@@ -70,9 +70,6 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {}
@Override public void visitField(PsiField field) {
if (isNullLiteralExpression(field.getInitializer()) && NullableNotNullManager.isNotNull(field)) {
holder.registerProblem(field.getInitializer(), InspectionsBundle.message("dataflow.message.initializing.field.with.null"));
@@ -29,7 +29,6 @@ import com.intellij.codeInspection.dataFlow.DfaInstructionState;
import com.intellij.codeInspection.dataFlow.DfaMemoryState;
import com.intellij.codeInspection.dataFlow.InstructionVisitor;
import com.intellij.openapi.progress.ProgressManager;
import org.jetbrains.annotations.NonNls;
import java.util.ArrayList;
@@ -71,9 +70,4 @@ public abstract class Instruction {
public int getIndex() {
return myIndex;
}
@NonNls
public String toString() {
return super.toString();
}
}
@@ -62,8 +62,6 @@ public class DefUseInspection extends BaseLocalInspectionTool {
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {}
@Override public void visitMethod(PsiMethod method) {
checkCodeBlock(method.getBody(), holder, isOnTheFly);
}
@@ -44,9 +44,6 @@ public class DuplicateThrowsInspection extends BaseLocalInspectionTool {
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override public void visitMethod(PsiMethod method) {
PsiReferenceList throwsList = method.getThrowsList();
PsiJavaCodeReferenceElement[] refs = throwsList.getReferenceElements();
@@ -95,10 +95,6 @@ public class EqualsAndHashcode extends BaseJavaLocalInspectionTool {
(LocalQuickFix[])null);
}
}
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
//do nothing
}
};
}
@@ -60,10 +60,6 @@ public class UndesirableClassUsageInspection extends InternalInspection {
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
if (!ApplicationManagerEx.getApplicationEx().isInternal()) return new JavaElementVisitor() {};
return new JavaElementVisitor() {
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override
public void visitNewExpression(PsiNewExpression expression) {
PsiJavaCodeReferenceElement ref = expression.getClassReference();
@@ -67,9 +67,6 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override public void visitMethod(PsiMethod method) {
if (!PsiUtil.isLanguageLevel5OrHigher(method)) return;
checkNullableStuffForMethod(method, holder);
@@ -117,10 +117,6 @@ public class SuspiciousNameCombinationInspection extends BaseLocalInspectionTool
public MyVisitor(final ProblemsHolder problemsHolder) {
myProblemsHolder = problemsHolder;
}
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override public void visitVariable(PsiVariable variable) {
if (variable.hasInitializer()) {
PsiExpression expr = variable.getInitializer();
@@ -50,9 +50,6 @@ public class TestOnlyInspection extends BaseJavaLocalInspectionTool {
@Override public void visitCallExpression(PsiCallExpression e) {
validate(e, h);
}
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
}
};
}
@@ -108,4 +105,4 @@ public class TestOnlyInspection extends BaseJavaLocalInspectionTool {
String message = InspectionsBundle.message("inspection.test.only.problems.test.only.method.call");
h.registerProblem(e, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
}
@@ -188,7 +188,8 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
public void visitReferenceExpression(PsiReferenceExpression expression) {
if (IGNORE_UNCHECKED_GENERICS_ARRAY_CREATION) return;
if (!PsiUtil.isLanguageLevel5OrHigher(expression)) return;
if (GenericsHighlightUtil.isUncheckedWarning(expression, expression.resolve())) {
final JavaResolveResult result = expression.advancedResolve(false);
if (GenericsHighlightUtil.isUncheckedWarning(expression, result)) {
registerProblem("Unchecked generics array creation for varargs parameter", expression, LocalQuickFix.EMPTY_ARRAY);
}
}
@@ -199,7 +200,7 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool
if (IGNORE_UNCHECKED_GENERICS_ARRAY_CREATION) return;
if (!PsiUtil.isLanguageLevel5OrHigher(expression)) return;
final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
if (GenericsHighlightUtil.isUncheckedWarning(classReference, expression.resolveConstructor())) {
if (GenericsHighlightUtil.isUncheckedWarning(classReference, expression.resolveMethodGenerics())) {
registerProblem("Unchecked generics array creation for varargs parameter", classReference, LocalQuickFix.EMPTY_ARRAY);
}
}
@@ -17,12 +17,7 @@ package com.intellij.cyclicDependencies.ui;
import com.intellij.analysis.AnalysisScopeBundle;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.packageDependencies.ui.PackageDependenciesNode;
import com.intellij.psi.PsiFile;
import javax.swing.*;
import java.util.Set;
/**
* User: anna
@@ -33,26 +28,6 @@ public class CycleNode extends PackageDependenciesNode{
super(project);
}
public void fillFiles(Set<PsiFile> set, boolean recursively) {
super.fillFiles(set, recursively);
}
public void addFile(VirtualFile file, boolean isMarked) {
super.addFile(file, isMarked);
}
public Icon getOpenIcon() {
return super.getOpenIcon();
}
public Icon getClosedIcon() {
return super.getClosedIcon();
}
public int getWeight() {
return super.getWeight();
}
public String toString() {
return AnalysisScopeBundle.message("cyclic.dependencies.tree.cycle.node.text");
}
@@ -94,10 +94,6 @@ public class ClassesScopeTreeStructureExpander implements ScopeTreeStructureExpa
@Override public void visitField(PsiField field) {
classNode.add(new FieldNode(field));
}
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
}
});
}
}
@@ -961,14 +961,6 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
myInstanceVisitor = instanceScanner;
}
@Override public void visitTypeElement(PsiTypeElement type) {
super.visitTypeElement (type);
}
@Override public void visitReferenceElement(PsiJavaCodeReferenceElement element) {
super.visitReferenceElement (element);
}
protected void visitClassMemberReferenceElement(PsiMember classMember, PsiJavaCodeReferenceElement classMemberReference) {
if ("super".equals(classMemberReference.getText()) && classMemberReference.getParent() instanceof PsiMethodCallExpression) {
return;
@@ -75,9 +75,6 @@ public class InlineParameterExpressionProcessor extends BaseRefactoringProcessor
return InlineParameterHandler.REFACTORING_NAME;
}
@Override
protected void refreshElements(PsiElement[] elements) {
}
@NotNull
@Override
@@ -945,7 +945,7 @@ public class RefactoringUtil {
return false;
}
public static interface ImplicitConstructorUsageVisitor {
public interface ImplicitConstructorUsageVisitor {
void visitConstructor(PsiMethod constructor, PsiMethod baseConstructor);
void visitClassWithoutConstructors(PsiClass aClass);
@@ -40,7 +40,8 @@ public class TypesDistinctProver {
}
if (type2 instanceof PsiCapturedWildcardType) {
return provablyDistinct((PsiWildcardType)type1, ((PsiCapturedWildcardType)type2).getWildcard());
return ((PsiWildcardType)type1).isExtends() ||
provablyDistinct((PsiWildcardType)type1, ((PsiCapturedWildcardType)type2).getWildcard());
}
if (type2 instanceof PsiClassType) {
@@ -156,6 +156,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
if (wildcardType.isExtends() != wildcard.isExtends()) {
return wildcard.isBounded() ? PsiWildcardType.createUnbounded(wildcardType.getManager()) : newBound;
}
if (!wildcard.isBounded()) return PsiWildcardType.createUnbounded(wildcardType.getManager());
}
return PsiWildcardType.changeBound(wildcardType, newBound);
@@ -200,8 +200,9 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements
Map<PsiTypeParameter, PsiType> map = new HashMap<PsiTypeParameter, PsiType>();
map.put(javaLangClass.getTypeParameters()[0], PsiWildcardType.createExtends(manager, qualifierType));
PsiSubstitutor substitutor = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createSubstitutor(map);
return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory()
final PsiClassType classType = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory()
.createType(javaLangClass, substitutor, languageLevel);
return PsiUtil.captureToplevelWildcards(classType, methodExpression);
}
}
}
@@ -44,10 +44,6 @@ public class SegmentedOutputStream extends OutputStream implements PacketProcess
flush();
}
public synchronized void write(byte[] b, int off, int len) throws IOException {
super.write(b, off, len);
}
public synchronized void flush() throws IOException {
myPrintStream.flush();
}
@@ -0,0 +1,10 @@
public class Util {
public Util(String a) {
this.a = a;
}
public Util() {
su<caret>this("2");
}
}
@@ -0,0 +1,10 @@
public class Util {
public Util(String a) {
this.a = a;
}
public Util() {
super(<caret>"2");
}
}
@@ -0,0 +1,8 @@
import java.lang.reflect.*;
class Example {
private void demo() {
<error descr="Incompatible types. Found: 'java.lang.reflect.TypeVariable<java.lang.Class<capture<? extends Example>>>[]', required: 'java.lang.reflect.TypeVariable<java.lang.Class<? extends Example>>[]'">TypeVariable<Class<? extends Example>>[] typeParameters = getClass().getTypeParameters();</error>
Object typeParameters1 = <error descr="Inconvertible types; cannot cast 'java.lang.reflect.TypeVariable<java.lang.Class<capture<? extends Example>>>[]' to 'java.lang.reflect.TypeVariable<java.lang.Class<? extends Example>>[]'">(TypeVariable<Class<? extends Example>>[]) getClass().getTypeParameters()</error>;
}
}
@@ -60,8 +60,8 @@ abstract class C {
try { g(); }
catch (IE1 | IE2 e) {
Class<? extends E> clazz1 = e.getClass();
<error descr="Incompatible types. Found: 'java.lang.Class<? extends C.E>', required: 'java.lang.Class<? extends C.IE1>'">Class<? extends IE1> clazz2 = e.getClass();</error>
<error descr="Incompatible types. Found: 'java.lang.Class<? extends C.E>', required: 'java.lang.Class<? extends C.I>'">Class<? extends I> clazz3 = e.getClass();</error>
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends C.E>>', required: 'java.lang.Class<? extends C.IE1>'">Class<? extends IE1> clazz2 = e.getClass();</error>
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends C.E>>', required: 'java.lang.Class<? extends C.I>'">Class<? extends I> clazz3 = e.getClass();</error>
}
}
}
@@ -119,3 +119,13 @@ class OCM<T> {
this(s, false, c);
}
}
class TPSubstitution<T> {
public void f(T... args) {
System.out.println(args);
}
public void g() {
new TPSubstitution<String>().f();
}
}
@@ -45,7 +45,7 @@ class AllPredicate<T>
}
public static void foo(SortedMap<?, ?> sourceSortedMap) {
new TreeMap<Object, Object>(<warning descr="Unchecked cast: 'java.util.Comparator<capture<? super capture<?>>>' to 'java.util.Comparator<? super java.lang.Object>'">(Comparator<? super Object>) sourceSortedMap.comparator()</warning>);
new TreeMap<Object, Object>(<warning descr="Unchecked cast: 'java.util.Comparator<capture<?>>' to 'java.util.Comparator<? super java.lang.Object>'">(Comparator<? super Object>) sourceSortedMap.comparator()</warning>);
}
}
@@ -22,11 +22,6 @@ import com.intellij.JavaTestUtil;
*/
public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/reflection/";
@@ -3,26 +3,30 @@ package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
public class TabCompletionTest extends LightCompletionTestCase {
public class TabCompletionTest extends LightFixtureCompletionTestCase {
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/normal";
}
public void testMethodCallCompletionWithTab() throws Exception {
configureByFile("/codeInsight/completion/normal/MethodLookup3.java");
checkResultByFile("/codeInsight/completion/normal/MethodLookup3_After.java");
configureByFile("MethodLookup3.java");
checkResultByFile("MethodLookup3_After.java");
}
public void testReplaceThisWithSuper() throws Throwable {
configureByFile("ReplaceThisWithSuper.java");
checkResultByFile("ReplaceThisWithSuper_After.java");
}
public void testTabInXml() throws Throwable {
configureByFile("/codeInsight/completion/normal/TabInXml.xml");
checkResultByFile("/codeInsight/completion/normal/TabInXml_After.xml");
configureByFile("TabInXml.xml");
checkResultByFile("TabInXml_After.xml");
}
public void testTabInXml2() throws Throwable {
configureByFile("/codeInsight/completion/normal/TabInXml2.xml");
checkResultByFile("/codeInsight/completion/normal/TabInXml2_After.xml");
configureByFile("TabInXml2.xml");
checkResultByFile("TabInXml2_After.xml");
}
@Override
@@ -47,12 +47,6 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos);
}
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
return new LocalInspectionTool[]{
@@ -304,5 +298,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
}
public void testIDEA84533() throws Exception { doTest(false, false); }
public void testClassLiteral() throws Exception { doTest(false, false);}
}
@@ -8,7 +8,6 @@ import com.intellij.codeInspection.defUse.DefUseInspection;
import com.intellij.psi.JavaElementVisitor;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiLiteralExpression;
import com.intellij.psi.PsiReferenceExpression;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -53,9 +52,6 @@ public class EmptyIntentionInspectionQuickFixTest extends LightQuickFixTestCase{
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override public void visitLiteralExpression(PsiLiteralExpression expression) {
final String s = (String)expression.getValue();
if (s.contains("a")) holder.registerProblem(expression, "Look ma! This String contains 'a'");
@@ -67,10 +67,6 @@ public class RemoveRedundantUncheckedSuppressionTest extends LightQuickFixTestCa
boolean isOnTheFly,
@NotNull LocalInspectionToolSession session) {
return new JavaElementVisitor() {
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override
public void visitClass(PsiClass aClass) {
checkMember(aClass, inspection, holder);
@@ -105,4 +101,4 @@ public class RemoveRedundantUncheckedSuppressionTest extends LightQuickFixTestCa
return "/codeInsight/daemonCodeAnalyzer/quickFix/redundantUncheckedVarargs";
}
}
}
Binary file not shown.
@@ -86,9 +86,6 @@ public abstract class BaseJavaLocalInspectionTool extends LocalInspectionTool i
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override public void visitMethod(PsiMethod method) {
addDescriptors(checkMethod(method, holder.getManager(), isOnTheFly));
}
@@ -316,7 +316,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
*/
@Nullable
public VirtualFile findFileByRelativePath(@NotNull @NonNls String relPath) {
if (relPath.length() == 0) return this;
if (relPath.isEmpty()) return this;
relPath = StringUtil.trimStart(relPath, "/");
int index = relPath.indexOf('/');
@@ -498,15 +498,15 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
return getUserData(CHARSET_KEY) != null;
}
public final void setBinaryContent(byte[] content) throws IOException {
public final void setBinaryContent(@NotNull byte[] content) throws IOException {
setBinaryContent(content, -1, -1);
}
public void setBinaryContent(final byte[] content, long newModificationStamp, long newTimeStamp) throws IOException {
public void setBinaryContent(@NotNull byte[] content, long newModificationStamp, long newTimeStamp) throws IOException {
setBinaryContent(content, newModificationStamp, newTimeStamp, this);
}
public void setBinaryContent(final byte[] content, long newModificationStamp, long newTimeStamp, Object requestor) throws IOException {
public void setBinaryContent(@NotNull byte[] content, long newModificationStamp, long newTimeStamp, Object requestor) throws IOException {
OutputStream outputStream = null;
try {
outputStream = getOutputStream(requestor, newModificationStamp, newTimeStamp);
@@ -32,7 +32,7 @@ public class FileContextUtil {
private FileContextUtil() { }
@Nullable
public static PsiElement getFileContext(PsiFile file) {
public static PsiElement getFileContext(@NotNull PsiFile file) {
SmartPsiElementPointer pointer = file.getUserData(INJECTED_IN_ELEMENT);
return pointer == null ? null : pointer.getElement();
}
@@ -90,6 +90,7 @@ public abstract class ParenthesesInsertHandler<T extends LookupElement> implemen
public void handleInsert(final InsertionContext context, final T item) {
final Editor editor = context.getEditor();
final Document document = editor.getDocument();
context.commitDocument();
PsiElement element = findNextToken(context);
final char completionChar = context.getCompletionChar();
@@ -92,12 +92,17 @@ public class CompletionExtender extends HeavyweightHint {
if (!isVisible()) return;
final JList list = myLookup.getList();
final Point p = list.getLocationOnScreen();
p.y += list.indexToLocation(list.getSelectedIndex()).y;
final JComponent rootPane = UIUtil.getRootPane(myLookup.getEditor().getContentComponent());
if (rootPane != null) {
SwingUtilities.convertPointFromScreen(p, rootPane);
setLocation(new RelativePoint(rootPane, p));
final Point point = list.indexToLocation(list.getSelectedIndex());
if (point != null) {
p.y += point.y;
final JComponent rootPane = UIUtil.getRootPane(myLookup.getEditor().getContentComponent());
if (rootPane != null) {
SwingUtilities.convertPointFromScreen(p, rootPane);
setLocation(new RelativePoint(rootPane, p));
return;
}
}
hide();
}
@Override
@@ -46,6 +46,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.StringUtilRt;
import com.intellij.openapi.wm.IdeFocusManager;
@@ -1042,7 +1043,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
}
oldItem = item;
if (item != null && LookupImpl.this.isVisible()) {
if (item != null && LookupImpl.this.isVisible() && LookupImpl.this.isFocused() && !Registry.is("jeka")) {
if (extender == null || !extender.isVisible() || !extender.sameAsFor(item)) {
if (extender != null) extender.hide();
extender = new CompletionExtender(item, LookupImpl.this);
@@ -146,6 +146,7 @@ public class OrderRootsEnumeratorImpl implements OrderRootsEnumerator {
return result;
}
@NotNull
private Collection<String> computeRootsUrls() {
final Collection<String> result = new LinkedHashSet<String>();
myOrderEnumerator.forEach(new Processor<OrderEntry>() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,120 +20,135 @@ import com.intellij.ide.diff.DirDiffSettings;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.ApplicationStarterEx;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.UnknownFileType;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
import java.io.File;
import java.io.FileNotFoundException;
/**
* @author max
* @author Konstantin Bulenkov
*/
@SuppressWarnings({"UseOfSystemOutOrSystemErr"})
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"})
public class DiffApplication implements ApplicationStarterEx {
@Override
public String getCommandName() {
return "diff";
}
@Override
public void premain(String[] args) {
if (args.length != 3) {
printHelp();
System.err.println(getUsageMessage());
System.exit(1);
}
}
private static void printHelp() {
System.err.println(DiffBundle.message("diff.application.usage.parameters.and.description"));
System.exit(1);
}
@Override
public void main(String[] args) {
try {
processDiffCommand(args);
}
catch (FileNotFoundException e) {
catch (OperationFailedException e) {
System.err.println(e.getMessage());
System.exit(1);
}
catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
finally {
System.exit(0);
catch (Throwable t) {
t.printStackTrace();
System.exit(2);
}
System.exit(0);
}
@Override
public void processExternalCommandLine(String[] args) {
if (args.length != 3) {
String productName = ApplicationNamesInfo.getInstance().getProductName();
Messages.showMessageDialog("Usage: " + productName.toLowerCase() + " diff <file1> <file2>",
"Diff", Messages.getInformationIcon());
Messages.showMessageDialog(getUsageMessage(), "Diff", Messages.getInformationIcon());
return;
}
try {
processDiffCommand(args);
}
catch(Exception e) {
catch (Exception e) {
Messages.showMessageDialog("Error showing diff: " + e.getMessage(), "Diff", Messages.getErrorIcon());
}
}
private static void processDiffCommand(String[] args) throws FileNotFoundException {
private static String getUsageMessage() {
final String scriptName = ApplicationNamesInfo.getInstance().getScriptName();
return DiffBundle.message("diff.application.usage.parameters.and.description", scriptName);
}
private static void processDiffCommand(String[] args) throws OperationFailedException {
final String path1 = args[1];
final String path2 = args[2];
final VirtualFile file1 = findFile(path1);
final VirtualFile file2 = findFile(path2);
final boolean isDirs = isDirs(file1, file2);
final boolean isJars = isJars(file1, file2);
if (isDirs || isJars) {
final boolean areDirs = areDirs(file1, file2);
final boolean areJars = areJars(file1, file2);
if (areDirs || areJars) {
final DirDiffManager diffManager = DirDiffManager.getInstance(ProjectManager.getInstance().getDefaultProject());
final DiffElement d1 = diffManager.createDiffElement(file1);
final DiffElement d2 = diffManager.createDiffElement(file2);
if (d1 == null) {
System.err.println("Can't create diff element from " + path1);
return;
throw new OperationFailedException("cannot.create.diff.error", path1);
}
if (d2 == null) {
System.err.println("Can't create diff element from " + path2);
return;
throw new OperationFailedException("cannot.create.diff.error", path1);
}
if (!diffManager.canShow(d1, d2)) {
System.err.println("Diff manager can't compare '" + path1 + "' and '" + path2 + "'");
return;
else if (!diffManager.canShow(d1, d2)) {
throw new OperationFailedException("cannot.compare.error", path1, path2);
}
final DirDiffSettings settings = new DirDiffSettings();
settings.showInFrame = false;
diffManager.showDiff(d1, d2, settings, null);
} else {
}
else {
file1.refresh(false, false);
file2.refresh(false, false);
SimpleDiffRequest request = SimpleDiffRequest.compareFiles(file1, file2, null);
if (file1.getFileType() == UnknownFileType.INSTANCE) {
throw new OperationFailedException("unknown.file.type.error", path1);
}
else if (file2.getFileType() == UnknownFileType.INSTANCE) {
throw new OperationFailedException("unknown.file.type.error", path2);
}
SimpleDiffRequest request = SimpleDiffRequest.compareFiles(file1, file2, ProjectManager.getInstance().getDefaultProject());
request.addHint(DiffTool.HINT_SHOW_MODAL_DIALOG);
DiffManager.getInstance().getIdeaDiffTool().show(request);
FileDocumentManager.getInstance().saveAllDocuments();
}
}
private static boolean isJars(VirtualFile file1, VirtualFile file2) {
return JarFileSystem.PROTOCOL.equalsIgnoreCase(file1.getExtension())
&& JarFileSystem.PROTOCOL.equalsIgnoreCase(file2.getExtension());
private static boolean areJars(VirtualFile file1, VirtualFile file2) {
return JarFileSystem.PROTOCOL.equalsIgnoreCase(file1.getExtension()) && JarFileSystem.PROTOCOL.equalsIgnoreCase(file2.getExtension());
}
private static boolean isDirs(VirtualFile file1, VirtualFile file2) {
private static boolean areDirs(VirtualFile file1, VirtualFile file2) {
return file1.isDirectory() && file2.isDirectory();
}
private static VirtualFile findFile(final String path) throws FileNotFoundException {
@NotNull
private static VirtualFile findFile(final String path) throws OperationFailedException {
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path));
if (file == null) {
throw new FileNotFoundException(DiffBundle.message("cannot.file.file.error.message", path));
throw new OperationFailedException("cannot.file.file.error", path);
}
return file;
}
private static class OperationFailedException extends Exception {
public OperationFailedException(@NotNull @PropertyKey(resourceBundle = "messages.DiffBundle") String key, Object... params) {
super(DiffBundle.message(key, params));
}
}
}
@@ -62,9 +62,9 @@ public class SimpleDiffRequest extends DiffRequest {
return result;
}
public static SimpleDiffRequest compareFiles(VirtualFile file1, VirtualFile file2, Project project) {
return compareFiles(file1, file2, project,
DiffBundle.message("compare.file.vs.file.dialog.title", file1.getPresentableUrl(), file2.getPresentableUrl()));
public static SimpleDiffRequest compareFiles(@NotNull VirtualFile file1, @NotNull VirtualFile file2, @NotNull Project project) {
final String title = DiffBundle.message("compare.file.vs.file.dialog.title", file1.getPresentableUrl(), file2.getPresentableUrl());
return compareFiles(file1, file2, project, title);
}
private static class FileDiffRequest extends SimpleDiffRequest {
@@ -35,7 +35,7 @@ public class ShowRecentFilesAction extends DumbAwareAction {
final Project project = e.getData(PlatformDataKeys.PROJECT);
if (project != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.recent.files");
Switcher.createAndShowSwitcher(project, IdeBundle.message("title.popup.recent.files"), true).goForward();
Switcher.createAndShowSwitcher(project, IdeBundle.message("title.popup.recent.files"), true);
}
}
}
@@ -175,8 +175,8 @@ public class Switcher extends AnAction implements DumbAware {
private final int MAX_FILES_IN_SWITCHER;
final JBPopup myPopup;
final Map<ToolWindow, String> ids = new HashMap<ToolWindow, String>();
final JList toolWindows;
final JList files;
final MyList toolWindows;
final MyList files;
final JPanel separator;
final ToolWindowManager twManager;
final JLabel pathLabel = new JLabel(" ");
@@ -237,7 +237,7 @@ public class Switcher extends AnAction implements DumbAware {
twModel.addElement(window);
}
toolWindows = new JBList(twModel);
toolWindows = new MyList(twModel);
if (pinned) {
new NameFilteringListModel<ToolWindow>(toolWindows, new Function<ToolWindow, String>() {
@Override
@@ -327,9 +327,9 @@ public class Switcher extends AnAction implements DumbAware {
}
}
}
if (editors.size() == 1) selectionIndex++;
if (editors.size() == 1 && (filesData.isEmpty() || !editors.get(0).getFirst().equals(filesData.get(0).getFirst()))) {
filesData.add(0, editors.get(0));
selectionIndex--;
}
} else {
for (int i = 0; i < Math.min(MAX_FILES_IN_SWITCHER, editors.size()); i++) {
@@ -380,7 +380,7 @@ public class Switcher extends AnAction implements DumbAware {
}
};
files = new JBList(filesModel);
files = new MyList(filesModel);
if (pinned) {
new NameFilteringListModel<FileInfo>(files, new Function<FileInfo, String>() {
@Override
@@ -397,7 +397,7 @@ public class Switcher extends AnAction implements DumbAware {
}, mySpeedSearch);
}
files.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
files.setSelectionMode(pinned ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION);
files.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!files.isSelectionEmpty() && !toolWindows.isSelectionEmpty()) {
@@ -511,7 +511,7 @@ public class Switcher extends AnAction implements DumbAware {
return keymap;
}
private int getModifiers(ShortcutSet shortcutSet) {
private static int getModifiers(ShortcutSet shortcutSet) {
if (shortcutSet == null
|| shortcutSet.getShortcuts().length == 0
|| !(shortcutSet.getShortcuts()[0] instanceof KeyboardShortcut)) return Event.CTRL_MASK;
@@ -533,15 +533,24 @@ public class Switcher extends AnAction implements DumbAware {
}
}
KeyEvent lastEvent;
public void keyPressed(KeyEvent e) {
if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) return;
if ((mySpeedSearch != null && mySpeedSearch.isPopupActive()) || lastEvent == e) return;
lastEvent = e;
switch (e.getKeyCode()) {
case VK_UP:
goBack();
if (!isPinnedMode()) {
goBack();
} else {
getSelectedList().processKeyEvent(e);
}
break;
case VK_DOWN:
goForward();
if (!isPinnedMode()) {
goForward();
} else {
getSelectedList().processKeyEvent(e);
}
break;
case VK_ESCAPE:
cancel();
@@ -690,11 +699,11 @@ public class Switcher extends AnAction implements DumbAware {
list.ensureIndexIsVisible(index);
}
public JList getSelectedList() {
public MyList getSelectedList() {
return getSelectedList(files);
}
JList getSelectedList(JList preferable) {
MyList getSelectedList(MyList preferable) {
if (toolWindows.isSelectionEmpty() && files.isSelectionEmpty()) {
if (preferable != null && preferable.getModel().getSize() > 0) {
preferable.setSelectedIndex(0);
@@ -715,25 +724,29 @@ public class Switcher extends AnAction implements DumbAware {
}
void navigate() {
final Object value = getSelectedList().getSelectedValue();
final Object[] values = getSelectedList().getSelectedValues();
myPopup.closeOk(null);
if (value instanceof ToolWindow) {
((ToolWindow)value).activate(null, true, true);
}
else if (value instanceof FileInfo) {
final FileInfo info = (FileInfo)value;
if (values.length > 0 && values[0] instanceof ToolWindow) {
((ToolWindow)values[0]).activate(null, true, true);
} else{
IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
@Override
public void run() {
final FileEditorManagerImpl manager = (FileEditorManagerImpl)FileEditorManager.getInstance(project);
if (info.second != null) {
EditorWindow wnd = findAppropriateWindow(info);
if (wnd != null) {
manager.openFileImpl2(wnd, info.first, true);
manager.addSelectionRecord(info.first, wnd);
for (Object value : values) {
if (value instanceof FileInfo) {
final FileInfo info = (FileInfo)value;
if (info.second != null) {
EditorWindow wnd = findAppropriateWindow(info);
if (wnd != null) {
manager.openFileImpl2(wnd, info.first, true);
manager.addSelectionRecord(info.first, wnd);
}
} else {
manager.openFile(info.first, true);
}
}
} else {
manager.openFile(info.first, true);
}
}
});
@@ -741,7 +754,7 @@ public class Switcher extends AnAction implements DumbAware {
}
@Nullable
private EditorWindow findAppropriateWindow(FileInfo info) {
private static EditorWindow findAppropriateWindow(FileInfo info) {
if (info.second == null) return null;
final EditorWindow[] windows = info.second.getOwner().getWindows();
return ArrayUtil.contains(info.second, windows) ? info.second : windows.length > 0 ? windows[0] : null;
@@ -863,7 +876,7 @@ public class Switcher extends AnAction implements DumbAware {
@Override
public void propertyChange(PropertyChangeEvent evt) {
final JList list = getSelectedList();
final MyList list = getSelectedList();
final Object value = list.getSelectedValue();
((NameFilteringListModel)files.getModel()).refilter();
((NameFilteringListModel)toolWindows.getModel()).refilter();
@@ -912,4 +925,15 @@ public class Switcher extends AnAction implements DumbAware {
super(first, second);
}
}
private static class MyList extends JBList {
public MyList(DefaultListModel model) {
super(model);
}
@Override
public void processKeyEvent(KeyEvent e) {
super.processKeyEvent(e);
}
}
}
@@ -41,9 +41,7 @@ import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
@@ -532,7 +530,9 @@ public class EventLog implements Notifications {
RelativePoint target = EventLog.getProjectComponent(project).myConsole.getHyperlinkLocation(this);
if (target != null) {
Balloon balloon = NotificationsManagerImpl.createBalloon(myNotification, true, true);
IdeFrame frame = WindowManager.getInstance().getIdeFrame(project);
assert frame != null;
Balloon balloon = NotificationsManagerImpl.createBalloon(frame, myNotification, true, true);
Disposer.register(project, balloon);
balloon.show(target, Balloon.Position.above);
}
@@ -28,10 +28,12 @@ import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.*;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.ui.BalloonImpl;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.UIUtil;
@@ -203,7 +205,7 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
final ProjectManager projectManager = ProjectManager.getInstance();
final boolean noProjects = projectManager.getOpenProjects().length == 0;
final boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects;
final Balloon balloon = createBalloon(notification, false, false);
final Balloon balloon = createBalloon((IdeFrameImpl)window, notification, false, false);
Disposer.register(project != null ? project : ApplicationManager.getApplication(), balloon);
if (notification.isExpired()) {
@@ -251,7 +253,7 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
return frame;
}
public static Balloon createBalloon(final Notification notification, final boolean showCallout, final boolean hideOnClickOutside) {
public static Balloon createBalloon(@NotNull final IdeFrame window, final Notification notification, final boolean showCallout, final boolean hideOnClickOutside) {
final JEditorPane text = new JEditorPane();
text.setEditorKit(UIUtil.getHTMLEditorKit());
@@ -273,9 +275,14 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
final JPanel content = new NonOpaquePanel(new BorderLayout((int)(label.getIconTextGap() * 1.5), (int)(label.getIconTextGap() * 1.5)));
final NonOpaquePanel textWrapper = new NonOpaquePanel(new GridBagLayout());
textWrapper.add(text);
content.add(textWrapper, BorderLayout.CENTER);
text.setCaretPosition(0);
JScrollPane pane = ScrollPaneFactory.createScrollPane(text,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
pane.setBorder(null);
pane.setOpaque(false);
pane.getViewport().setOpaque(false);
content.add(pane, BorderLayout.CENTER);
final NonOpaquePanel north = new NonOpaquePanel(new BorderLayout());
north.add(new JLabel(NotificationsUtil.getIcon(notification)), BorderLayout.NORTH);
@@ -283,6 +290,12 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
content.setBorder(new EmptyBorder(2, 4, 2, 4));
Dimension preferredSize = pane.getPreferredSize();
int maxHeight = Math.min(400, window.getComponent().getHeight() - 20);
if (preferredSize.height > maxHeight) {
pane.setPreferredSize(new Dimension(preferredSize.width, maxHeight));
}
final BalloonBuilder builder = JBPopupFactory.getInstance().createBalloonBuilder(content);
builder.setFillColor(NotificationsUtil.getBackground(notification)).setCloseButtonEnabled(true).setShowCallout(showCallout)
.setHideOnClickOutside(hideOnClickOutside)
@@ -25,6 +25,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.messages.MessageBus;
import javax.swing.event.HyperlinkEvent;
@@ -61,7 +62,9 @@ public class NotificationTestAction extends AnAction implements DumbAware {
};
final Notification notification = new Notification(TEST_GROUP_ID, "This is a test notification", //"a",
"You can<br> close this very<p> very very very long notification by clicking <a href=\"close\">this link</a>. Long long long long. It should be long. Very long. Too long. And even longer.",
"You can<br> close this very<p> very very very long notification by clicking <a href=\"close\">this link</a>. Long long long long. It should be long. Very long. Too long." +
StringUtil.repeat("<br>line", 100) +
" And even longer.",
type, listener);
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.diff.actions;
import com.intellij.CommonBundle;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
@@ -40,16 +41,15 @@ public class IgnoreWhiteSpacesAction extends ComboBoxAction implements DumbAware
ComparisonPolicy.IGNORE_SPACE};
public IgnoreWhiteSpacesAction() {
myActions.put(ComparisonPolicy.DEFAULT, new IgnoringPolicyAction(DiffBundle.message("diff.acton.ignore.qhitespace.policy.do.not.ignore"), ComparisonPolicy.DEFAULT));
myActions.put(ComparisonPolicy.TRIM_SPACE, new IgnoringPolicyAction(
DiffBundle.message("diff.acton.ignore.qhitespace.policy.leading.and.trailing"), ComparisonPolicy.TRIM_SPACE));
myActions.put(ComparisonPolicy.IGNORE_SPACE, new IgnoringPolicyAction(DiffBundle.message("diff.acton.ignore.qhitespace.policy.all"), ComparisonPolicy.IGNORE_SPACE));
myActions.put(ComparisonPolicy.DEFAULT, new IgnoringPolicyAction(DiffBundle.message("diff.acton.ignore.whitespace.policy.do.not.ignore"), ComparisonPolicy.DEFAULT));
myActions.put(ComparisonPolicy.TRIM_SPACE, new IgnoringPolicyAction(DiffBundle.message("diff.acton.ignore.whitespace.policy.leading.and.trailing"), ComparisonPolicy.TRIM_SPACE));
myActions.put(ComparisonPolicy.IGNORE_SPACE, new IgnoringPolicyAction(DiffBundle.message("diff.acton.ignore.whitespace.policy.all"), ComparisonPolicy.IGNORE_SPACE));
}
@Override
public JComponent createCustomComponent(final Presentation presentation) {
JPanel panel = new JPanel(new BorderLayout());
final JLabel label = new JLabel(DiffBundle.message("comparison.ignore.whitespace.acton.name"));
final JLabel label = new JLabel(CommonBundle.message("comparison.ignore.whitespace.acton.name"));
label.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
panel.add(label, BorderLayout.WEST);
panel.add(super.createCustomComponent(presentation), BorderLayout.CENTER);
@@ -77,7 +77,7 @@ public class IgnoreWhiteSpacesAction extends ComboBoxAction implements DumbAware
presentation.setEnabled(true);
} else {
presentation.setIcon(null);
presentation.setText(DiffBundle.message("ignore.whitespace.action.not.avaliable.action.name"));
presentation.setText(DiffBundle.message("ignore.whitespace.action.not.available.action.name"));
presentation.setEnabled(false);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,7 +75,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.DiffPanelImpl");
private final DiffSplitterI mySplitter;
private final DiffPanelOutterComponent myPanel;
private final DiffPanelOuterComponent myPanel;
private final Window myOwnerWindow;
private final DiffPanelOptions myOptions;
@@ -91,7 +91,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
private final FontSizeSynchronizer myFontSizeSynchronizer = new FontSizeSynchronizer();
private DiffRequest myDiffRequest;
private boolean myIsRequestFocus = true;
private boolean myIsSynchScroll;
private boolean myIsSyncScroll;
private static final DiffRequest.ToolbarAddons TOOL_BAR = new DiffRequest.ToolbarAddons() {
public void customize(DiffToolbar toolbar) {
@@ -102,20 +102,19 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
private boolean myDisposed = false;
private final GenericDataProvider myDataProvider;
private final Project myProject;
private final boolean myIsHorisontal;
private final boolean myIsHorizontal;
private CanNotCalculateDiffPanel myNotCalculateDiffPanel;
private DiffIsApproximate myDiffIsApproximate;
private final VisibleAreaListener myVisibleAreaListener;
public DiffPanelImpl(final Window owner, Project project, boolean enableToolbar, boolean horisontal) {
public DiffPanelImpl(final Window owner, Project project, boolean enableToolbar, boolean horizontal) {
myProject = project;
myIsHorisontal = horisontal;
myIsHorizontal = horizontal;
myOptions = new DiffPanelOptions(this);
myPanel = new DiffPanelOutterComponent(TextDiffType.DIFF_TYPES, TOOL_BAR);
myPanel = new DiffPanelOuterComponent(TextDiffType.DIFF_TYPES, TOOL_BAR);
myPanel.disableToolbar(!enableToolbar);
if (enableToolbar) myPanel.resetToolbar();
myOwnerWindow = owner;
myIsSynchScroll = true;
myIsSyncScroll = true;
myLeftSide = new DiffSideView("", this);
myRightSide = new DiffSideView("", this);
myLeftSide.becomeMaster();
@@ -123,9 +122,9 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
myData = createDiffPanelState(this);
if (horisontal) {
if (horizontal) {
mySplitter = new DiffSplitter(myLeftSide.getComponent(), myRightSide.getComponent(),
new DiffDividerPaint(this, FragmentSide.SIDE1), myData);
new DiffDividerPaint(this, FragmentSide.SIDE1), myData);
}
else {
mySplitter = new HorizontalDiffSplitter(myLeftSide.getComponent(), myRightSide.getComponent());
@@ -164,7 +163,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
}
public boolean isHorisontal() {
return myIsHorisontal;
return myIsHorizontal;
}
public DiffPanelState getDiffPanelState() {
@@ -172,7 +171,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
}
public void noSynchScroll() {
myIsSynchScroll = false;
myIsSyncScroll = false;
}
public DiffSplitterI getSplitter() {
@@ -298,8 +297,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
public void setPatchAppliedApproximately() {
if (myNotCalculateDiffPanel == null) {
myDiffIsApproximate = new DiffIsApproximate();
myPanel.insertTopComponent(myDiffIsApproximate);
myPanel.insertTopComponent(new DiffIsApproximate());
}
}
@@ -402,7 +400,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
public void onContentChangedIn(EditorSource source) {
myDiffUpdater.contentRemoved(source);
final EditorEx editor = source.getEditor();
if (myIsHorisontal && source.getSide() == FragmentSide.SIDE1 && editor != null) {
if (myIsHorizontal && source.getSide() == FragmentSide.SIDE1 && editor != null) {
editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
}
DiffSideView viewSide = getSideView(source.getSide());
@@ -425,7 +423,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
Editor editor1 = getEditor(FragmentSide.SIDE1);
Editor editor2 = getEditor(FragmentSide.SIDE2);
if (editor1 != null && editor2 != null && myIsSynchScroll) {
if (editor1 != null && editor2 != null && myIsSyncScroll) {
myScrollSupport.install(new EditingSides[]{this});
}
@@ -572,7 +570,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
myIsRequestFocus = isRequestFocus;
}
private class MyScrollingPanel implements DiffPanelOutterComponent.ScrollingPanel {
private class MyScrollingPanel implements DiffPanelOuterComponent.ScrollingPanel {
public void scrollEditors() {
getOptions().onNewContent(myCurrentSide);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ import java.util.Collection;
public class MergePanel2 implements DiffViewer {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.incrementalMerge.ui.MergePanel2");
private final DiffPanelOutterComponent myPanel;
private final DiffPanelOuterComponent myPanel;
private DiffRequest myData;
private MergeList myMergeList;
private boolean myDuringCreation = false;
@@ -109,7 +109,7 @@ public class MergePanel2 implements DiffViewer {
myEditorsPanels[i].setComponent(editorPlace);
}
FontSizeSynchronizer.attachTo(editorPlaces);
myPanel = new DiffPanelOutterComponent(TextDiffType.MERGE_TYPES, TOOLBAR);
myPanel = new DiffPanelOuterComponent(TextDiffType.MERGE_TYPES, TOOLBAR);
myPanel.insertDiffComponent(new ThreePanels(myEditorsPanels, myDividers), new MyScrollingPanel());
myProvider = new MyDataProvider();
myPanel.setDataProvider(myProvider);
@@ -328,7 +328,7 @@ public class MergePanel2 implements DiffViewer {
}
}
private class MyScrollingPanel implements DiffPanelOutterComponent.ScrollingPanel {
private class MyScrollingPanel implements DiffPanelOuterComponent.ScrollingPanel {
public void scrollEditors() {
Editor centerEditor = getEditor(1);
JComponent centerComponent = centerEditor.getContentComponent();
@@ -504,9 +504,9 @@ public class MergePanel2 implements DiffViewer {
}
private static class StatusUpdater implements ChangeCounter.Listener {
private final DiffPanelOutterComponent myPanel;
private final DiffPanelOuterComponent myPanel;
private StatusUpdater(DiffPanelOutterComponent panel) {
private StatusUpdater(DiffPanelOuterComponent panel) {
myPanel = panel;
}
@@ -527,7 +527,7 @@ public class MergePanel2 implements DiffViewer {
ChangeCounter.getOrCreate(mergeList).removeListener(this);
}
public static StatusUpdater install(MergeList mergeList, DiffPanelOutterComponent panel) {
public static StatusUpdater install(MergeList mergeList, DiffPanelOuterComponent panel) {
ChangeCounter counters = ChangeCounter.getOrCreate(mergeList);
StatusUpdater updater = new StatusUpdater(panel);
counters.addListener(updater);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ import javax.swing.*;
import java.awt.*;
import java.util.List;
public class DiffPanelOutterComponent extends JPanel implements DataProvider {
public class DiffPanelOuterComponent extends JPanel implements DataProvider {
private final DiffStatusBar myStatusBar;
private final DiffToolbarComponent myToolbar;
private final DiffRequest.ToolbarAddons myDefaultActions;
@@ -43,7 +43,7 @@ public class DiffPanelOutterComponent extends JPanel implements DataProvider {
private int myPrefferedWidth;
private Getter<Integer> myDefaultHeight;
public DiffPanelOutterComponent(List<TextDiffType> diffTypes, DiffRequest.ToolbarAddons defaultActions) {
public DiffPanelOuterComponent(List<TextDiffType> diffTypes, DiffRequest.ToolbarAddons defaultActions) {
super(new BorderLayout());
myStatusBar = new DiffStatusBar(diffTypes);
myBottomContainer = new JPanel(new BorderLayout());
@@ -203,7 +203,7 @@ public class DiffPanelOutterComponent extends JPanel implements DataProvider {
private interface DeferScrollToFirstDiff {
DeferScrollToFirstDiff scrollNow(ScrollingPanel panel, JComponent component);
void deferScroll(DiffPanelOutterComponent outter);
void deferScroll(DiffPanelOuterComponent outer);
}
public interface ScrollingPanel {
@@ -215,7 +215,7 @@ public class DiffPanelOutterComponent extends JPanel implements DataProvider {
return NO_SCROLL_NEEDED;
}
public void deferScroll(DiffPanelOutterComponent outter) {
public void deferScroll(DiffPanelOuterComponent outer) {
}
};
@@ -226,11 +226,11 @@ public class DiffPanelOutterComponent extends JPanel implements DataProvider {
return NO_SCROLL_NEEDED;
}
public void deferScroll(final DiffPanelOutterComponent outter) {
if (!outter.isDisplayable()) return;
public void deferScroll(final DiffPanelOuterComponent outer) {
if (!outer.isDisplayable()) return;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
outter.performScroll();
outer.performScroll();
}
});
}
@@ -135,19 +135,17 @@ public final class IdeMouseEventDispatcher {
ignore = true;
}
patchClickCount(e);
if (e.isConsumed()
|| e.isPopupTrigger()
|| MouseEvent.MOUSE_RELEASED != e.getID()
|| e.getClickCount() < 1 // TODO[vova,anton] is it possible. it seems that yes! but how???
|| (e.getButton() > 3 ? e.getID() != MOUSE_PRESSED : e.getID() != MOUSE_RELEASED)
|| e.getClickCount() < 1
|| e.getButton() == MouseEvent.NOBUTTON) { // See #16995. It did happen
ignore = true;
}
if (e.getID() == MouseEvent.MOUSE_PRESSED && e.getButton() > 3) {
return true;
}
final JRootPane root = findRoot(e);
final JRootPane root = findRoot(e);
if (root != null) {
final Integer lastId = myRootPane2BlockedId.get(root);
if (lastId != null) {
@@ -213,7 +211,7 @@ public final class IdeMouseEventDispatcher {
if (actions.length > 0 && e.isConsumed())
return true;
}
return false;
return e.getButton() > 3;
}
private static void resetPopupTrigger(final MouseEvent e) {
@@ -225,6 +223,18 @@ public final class IdeMouseEventDispatcher {
catch (Exception ignored) { }
}
private static void patchClickCount(final MouseEvent e) {
if (e.getClickCount() == 0 && e.getButton() > 3) {
try {
final Field clickCount = e.getClass().getDeclaredField("clickCount");
clickCount.setAccessible(true);
clickCount.set(e, 1);
}
catch (Exception ignored) {
}
}
}
private boolean doHorizontalScrolling(Component c, MouseWheelEvent me) {
final JScrollBar scrollBar = findHorizontalScrollBar(c);
if (scrollBar != null) {
@@ -1,5 +1,10 @@
diff.application.usage.parameters.and.description=Usage: idea diff <file1> <file2>
cannot.file.file.error.message=Cannot find file: {0}
diff.application.usage.parameters.and.description=Usage: {0} diff <file1> <file2>
cannot.file.file.error=Cannot find file: {0}
cannot.create.diff.error=Cannot create diff element from: {0}
cannot.compare.error=Diff manager cannot compare ''{0}' and ''{1}''
unknown.file.type.error=Unknown file type: {0}
save.merge.result.command.name=Merge
compare.file.vs.file.dialog.title={0} vs {1}
diff.content.editor.content.title=Editor
@@ -23,10 +28,10 @@ diff.compare.element.type.with.editor.action.name=Compare File with Editor
diff.element.qualified.name.vs.editor.dialog.title={0} vs Editor
diff.element.qualified.name.vs.file.dialog.title={0} vs {1}
diff.element.qualified.name.vs.element.qualified.name.dialog.title={0} vs {1}
diff.acton.ignore.qhitespace.policy.do.not.ignore=Do not ignore
diff.acton.ignore.qhitespace.policy.leading.and.trailing=Leading and trailing
diff.acton.ignore.qhitespace.policy.all=All
ignore.whitespace.action.not.avaliable.action.name=<Not available>
diff.acton.ignore.whitespace.policy.do.not.ignore=Do not ignore
diff.acton.ignore.whitespace.policy.leading.and.trailing=Leading and trailing
diff.acton.ignore.whitespace.policy.all=All
ignore.whitespace.action.not.available.action.name=<Not available>
diff.dialog.select.change.action.name=Select Change
diff.dialog.select.change.action.description=Select changed text in this version and corresponding in other
merge.files.dialog.title=Merge
@@ -34,10 +39,6 @@ merge.dialog.cannot.load.file.error.message=Cannot load file: {0}
merge.editor.replace.operation.name=Replace
merge.editor.insert.operation.name=Insert
merge.editor.remove.operation.name=Remove
comparison.policy.default.name=Default
comparison.policy.trim.space.name=Trim space
comparison.policy.ignore.spaces.name=Ignore spaces
comparison.ignore.whitespace.acton.name=Ignore whitespace:
diff.count.differences.status.text={0, choice, 0#no differences|1#1 difference|2#{0, number} differences}
cant.launch.diff.tool.error.message=Can''t Launch Diff Tool
binary.files.are.identical.message=Binary files are identical
@@ -214,4 +214,5 @@ ide.goto.implementation.show.interfaces=false
ide.goto.implementation.show.interfaces.description=Whether to show sub-interfaces when invoking Goto Implementation (Ctrl+Alt+B) on an interface
ide.open.editors.asynchronously=false
ide.open.editors.asynchronously.description=Prepare editors in background thread
ide.open.editors.asynchronously.description=Prepare editors in background thread
jeka=false
@@ -32,7 +32,7 @@
</component>
<component>
<implementation-class>com.intellij.openapi.editor.LazyRangeMarkerFactory</implementation-class>
<loadForDefaultProject/>
</component>
</project-components>
</components>
@@ -326,7 +326,10 @@ public class LocalFileSystemTest extends PlatformLangTestCase {
if (!SystemInfo.isWindows) return;
File file = new File("c:\\Documents and Settings\\desktop.ini");
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
assertNotNull("File not found: " + file, virtualFile);
if (virtualFile == null) {
System.out.println("NO LUCK: " + file);
return;
}
NewVirtualFileSystem system = (NewVirtualFileSystem)virtualFile.getFileSystem();
system = PersistentFS.replaceWithNativeFS(system);
@@ -48,6 +48,8 @@ import java.io.OutputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import static junit.framework.Assert.assertTrue;
/**
* @author yole
*/
@@ -343,6 +345,8 @@ public abstract class AbstractVcsTestCase {
}
public static void editFileInCommand(final Project project, final VirtualFile file, final String newContent) {
assertTrue(file.isValid());
file.getTimeStamp();
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
@@ -146,8 +146,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
private boolean myEmptyLookup;
private InspectionProfileEntry[] myInspections;
private final Map<String, InspectionProfileEntry> myAvailableTools = new THashMap<String, InspectionProfileEntry>();
private final Map<String, InspectionTool> myAvailableLocalTools = new THashMap<String, InspectionTool>();
private final Map<String, InspectionTool> myAvailableTools = new THashMap<String, InspectionTool>();
private final TempDirTestFixture myTempDirFixture;
protected final IdeaProjectTestFixture myProjectFixture;
@@ -272,7 +271,6 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
@Override
public void disableInspections(InspectionProfileEntry... inspections) {
myAvailableTools.clear();
myAvailableLocalTools.clear();
final ArrayList<InspectionProfileEntry> tools = new ArrayList<InspectionProfileEntry>(Arrays.asList(myInspections));
for (Iterator<InspectionProfileEntry> i = tools.iterator(); i.hasNext();) {
final InspectionProfileEntry tool = i.next();
@@ -1069,8 +1067,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
myEditor = null;
myFile = null;
myPsiManager = null;
myInspections = null;
myAvailableLocalTools.clear();
myAvailableTools.clear();
myProjectFixture.tearDown();
@@ -1086,7 +1084,6 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
String id = tool instanceof LocalInspectionTool ? ((LocalInspectionTool)tool).getID() : shortName;
HighlightDisplayKey.register(shortName, tool.getDisplayName(), id);
}
myAvailableTools.put(shortName, tool);
InspectionTool inspectionTool;
if (tool instanceof LocalInspectionTool) {
LocalInspectionEP ep = myExtensions.get(tool.getShortName());
@@ -1095,7 +1092,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
else {
inspectionTool = (InspectionTool)tool;
}
myAvailableLocalTools.put(shortName, inspectionTool);
myAvailableTools.put(shortName, inspectionTool);
}
private void configureInspections(final InspectionProfileEntry[] tools) {
@@ -1114,7 +1111,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
@Override
@NotNull
public InspectionProfileEntry[] getInspectionTools(PsiElement element) {
final Collection<InspectionTool> tools = myAvailableLocalTools.values();
final Collection<InspectionTool> tools = myAvailableTools.values();
return tools.toArray(new InspectionTool[tools.size()]);
}
@@ -1148,8 +1145,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
}
@Override
public InspectionTool getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
return myAvailableLocalTools.get(shortName);
public InspectionProfileEntry getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
return myAvailableTools.get(shortName);
}
};
final InspectionProfileManager inspectionProfileManager = InspectionProfileManager.getInstance();
@@ -892,7 +892,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
@Override
public void addButtonToLowerPane(@NotNull Runnable runnable, @NotNull String text) {
int index = myButtonPanel.getComponentCount();
if (index > 0 && myPresentation.isShowCancelButton()) index--;
if (!SystemInfo.isMac && index > 0 && myPresentation.isShowCancelButton()) index--;
myButtonPanel.addButtonRunnable(index, runnable, text);
}
@@ -15,10 +15,10 @@
*/
package com.intellij.ui.mac.foundation;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import static com.intellij.ui.mac.foundation.Foundation.invoke;
@@ -52,11 +52,9 @@ public class MacUtil {
final ID windowTitle = invoke(window, "title");
if (windowTitle != null && windowTitle.intValue() != 0) {
final String titleString = toStringViaUTF8(windowTitle);
if (titleString.equals(title)) {
if (1 == invoke(window, "isVisible").intValue()) {
focusedWindow = window;
break;
}
if (Comparing.equal(titleString, title)) {
focusedWindow = window;
break;
}
}
}
@@ -13,10 +13,12 @@
package com.intellij.openapi.vcs.ui;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.IdeBorderFactory;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
@@ -36,8 +38,8 @@ public abstract class TextFieldAction extends AnAction implements CustomComponen
myField = new JTextField(initSize);
myField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if ('\n' == e.getKeyChar()) {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
e.consume();
actionPerformed(null);
}
@@ -45,6 +47,9 @@ public abstract class TextFieldAction extends AnAction implements CustomComponen
});
}
@Override
public abstract void actionPerformed(@Nullable AnActionEvent e);
public JComponent createCustomComponent(Presentation presentation) {
// honestly borrowed from SearchTextField
@@ -41,6 +41,7 @@ public class ZipperUpdater {
public void queue(final Runnable runnable, final boolean urgent) {
synchronized (myLock) {
if (myAlarm.isDisposed()) return;
final boolean wasRaised = myRaised;
myRaised = true;
if (! wasRaised) {
@@ -155,7 +155,12 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
CommitChangeListDialog dialog =
new CommitChangeListDialog(project, changes, initialSelection, executors, showVcsCommit, defaultList, changeLists, null, false,
comment);
dialog.show();
if (!ApplicationManager.getApplication().isUnitTestMode()) {
dialog.show();
}
else {
dialog.doOKAction();
}
return dialog.isOK();
}
@@ -193,7 +198,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
public static boolean commitChanges(final Project project, final Collection<Change> changes, final LocalChangeList initialSelection,
final List<CommitExecutor> executors, final boolean showVcsCommit, final String comment) {
if (changes.isEmpty()) {
if (changes.isEmpty() && !ApplicationManager.getApplication().isUnitTestMode()) {
Messages.showInfoMessage(project, VcsBundle.message("commit.dialog.no.changes.detected.text") ,
VcsBundle.message("commit.dialog.no.changes.detected.title"));
return false;
@@ -581,8 +581,8 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes
}
public void stopBackgroundVcsOperation() {
// in fact, the condition is "should not be called under ApplicationManager.invokeLater() and similiar"
assert ! ApplicationManager.getApplication().isDispatchThread();
// in fact, the condition is "should not be called under ApplicationManager.invokeLater() and similar"
assert !ApplicationManager.getApplication().isDispatchThread() || ApplicationManager.getApplication().isUnitTestMode();
LOG.assertTrue(myBackgroundOperationCounter > 0, "myBackgroundOperationCounter > 0");
myBackgroundOperationCounter--;
}
@@ -489,4 +489,9 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
super.setupPresentation(injection, presentation, isSelected);
}
}
@Override
public String getHelpId() {
return "reference.settings.injection.language.injection.settings.java.parameter";
}
}
@@ -116,7 +116,10 @@ public abstract class AbstractLanguageInjectionSupport extends LanguageInjection
final BaseInjectionPanel panel = new BaseInjectionPanel(injection, project);
panel.reset();
final DialogBuilder builder = new DialogBuilder(project);
builder.setHelpId("reference.settings.injection.language.injection.settings.java.parameter");
LanguageInjectionSupport support = InjectorUtils.findInjectionSupport(injection.getSupportId());
if (support != null && support instanceof AbstractLanguageInjectionSupport) {
builder.setHelpId(((AbstractLanguageInjectionSupport)support).getHelpId());
}
builder.addOkAction();
builder.addCancelAction();
builder.setDimensionServiceKey("#org.intellij.plugins.intelliLang.inject.config.ui.BaseInjectionDialog");
@@ -150,4 +153,9 @@ public abstract class AbstractLanguageInjectionSupport extends LanguageInjection
public boolean equals(Object obj) {
return obj instanceof LanguageInjectionSupport && getId().equals(((LanguageInjectionSupport)obj).getId());
}
@Nullable
public String getHelpId() {
return null;
}
}
@@ -3,7 +3,7 @@ package p1.p2;
public class Test1 {
public void f(int n) {
switch (n) {
case <error><warning descr="Resource IDs cannot be used in a switch statement in Android library modules">R.dr<caret>awable.icon</warning></error>:
case <error descr="Resource IDs cannot be used in a switch statement in Android library modules"><error descr="Constant expression required">R.dr<caret>awable.icon</error></error>:
System.out.println("Icon");
break;
}
@@ -32,6 +32,7 @@ import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
import com.intellij.testFramework.fixtures.*;
@@ -56,6 +57,7 @@ public abstract class AndroidTestCase extends UsefulTestCase {
public AndroidTestCase(boolean createManifest) {
this.myCreateManifest = createManifest;
IdeaTestCase.initPlatformPrefix();
}
public AndroidTestCase() {
+1 -1
View File
@@ -69,7 +69,7 @@
groupKey="inspections.group.name"
displayName="&lt;inspection&gt; tag consistency"
enabledByDefault="true"
level="ERROR"
level="WARNING"
implementationClass="org.jetbrains.idea.devkit.inspections.InspectionMappingConsistencyInspection"/>
<moduleConfigurationEditorProvider implementation="org.jetbrains.idea.devkit.module.PluginModuleEditorsProvider"/>
@@ -71,9 +71,6 @@ public class ClassHasNoToStringMethodInspection extends AbstractToStringInspecti
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override
public void visitClass(PsiClass clazz) {
if (log.isDebugEnabled()) log.debug("checkClass: clazz=" + clazz);
@@ -56,9 +56,6 @@ public class FieldNotUsedInToStringInspection extends AbstractToStringInspection
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override
public void visitClass(PsiClass clazz) {
checkFields(holder, clazz);
@@ -42,4 +42,9 @@ public class GroovyLanguageInjectionSupport extends AbstractLanguageInjectionSup
public boolean useDefaultInjector(final PsiElement host) {
return host instanceof GroovyPsiElement;
}
@Override
public String getHelpId() {
return "reference.settings.language.injection.groovy";
}
}
@@ -285,19 +285,30 @@ public class Maven2ServerEmbedderImpl extends MavenRemoteObject implements Maven
MavenProject project = RemoteNativeMavenProjectHolder.findProjectById(nativeMavenProjectId);
PluginDescriptor result = getComponent(PluginManager.class).verifyPlugin(mavenPlugin, project,
myImpl.getSettings(), myImpl.getLocalRepository());
if (!transitive) return Collections.emptyList();
// todo try to use parallel downloading
Map<MavenArtifactInfo, MavenArtifact> resolvedArtifacts = new THashMap<MavenArtifactInfo, MavenArtifact>();
for (Artifact each : (Iterable<Artifact>)result.getIntroducedDependencyArtifacts()) {
resolveIfNecessary(new MavenArtifactInfo(each.getGroupId(), each.getArtifactId(), each.getVersion(), each.getType(), null),
repositories, resolvedArtifacts);
}
for (ComponentDependency each : (List<ComponentDependency>)result.getDependencies()) {
resolveIfNecessary(new MavenArtifactInfo(each.getGroupId(), each.getArtifactId(), each.getVersion(), each.getType(), null),
repositories, resolvedArtifacts);
Artifact pluginArtifact = result.getPluginArtifact();
MavenArtifactInfo artifactInfo = new MavenArtifactInfo(pluginArtifact.getGroupId(),
pluginArtifact.getArtifactId(),
pluginArtifact.getVersion(),
pluginArtifact.getType(), null);
resolveIfNecessary(artifactInfo, repositories, resolvedArtifacts);
if (transitive) {
// todo try to use parallel downloading
for (Artifact each : (Iterable<Artifact>)result.getIntroducedDependencyArtifacts()) {
resolveIfNecessary(new MavenArtifactInfo(each.getGroupId(), each.getArtifactId(), each.getVersion(), each.getType(), null),
repositories, resolvedArtifacts);
}
for (ComponentDependency each : (List<ComponentDependency>)result.getDependencies()) {
resolveIfNecessary(new MavenArtifactInfo(each.getGroupId(), each.getArtifactId(), each.getVersion(), each.getType(), null),
repositories, resolvedArtifacts);
}
}
return new THashSet<MavenArtifact>(resolvedArtifacts.values());
}
catch (Exception e) {
@@ -111,45 +111,29 @@ public class MavenDomProjectProcessorUtils {
public static XmlTag searchProperty(@NotNull final String propertyName,
@NotNull MavenDomProjectModel projectDom,
@NotNull final Project project) {
return doSearchPropertyInProfile(propertyName, projectDom, null, project);
}
@Nullable
public static XmlTag searchPropertyInProfile(@NotNull final String propertyName,
@NotNull MavenDomProfile profileDom) {
return doSearchPropertyInProfile(propertyName, null, profileDom, null);
}
@Nullable
private static XmlTag doSearchPropertyInProfile(@NotNull final String propertyName,
@Nullable MavenDomProjectModel projectDom,
@Nullable MavenDomProfile profileDom,
@Nullable final Project project) {
final XmlTag[] property = new XmlTag[]{null};
Processor<MavenDomProperties> searchProcessor = new Processor<MavenDomProperties>() {
public boolean process(MavenDomProperties mavenDomProperties) {
XmlTag propertiesTag = mavenDomProperties.getXmlTag();
if (propertiesTag != null) {
for (XmlTag each : propertiesTag.getSubTags()) {
if (each.getName().equals(propertyName)) {
property[0] = each;
return true;
}
}
}
return false;
SearchProcessor<XmlTag, MavenDomProperties> searchProcessor = new SearchProcessor<XmlTag, MavenDomProperties>() {
@Override
protected XmlTag find(MavenDomProperties element) {
return findProperty(element, propertyName);
}
};
if (projectDom != null) {
processProperties(projectDom, searchProcessor, project);
}
else {
processPropertiesInProfile(profileDom, searchProcessor);
processProperties(projectDom, searchProcessor, project);
return searchProcessor.myResult;
}
@Nullable
public static XmlTag findProperty(@NotNull MavenDomProperties mavenDomProperties, @NotNull String propertyName) {
XmlTag propertiesTag = mavenDomProperties.getXmlTag();
if (propertiesTag == null) return null;
for (XmlTag each : propertiesTag.getSubTags()) {
if (each.getName().equals(propertyName)) {
return each;
}
}
return property[0];
return null;
}
public static Set<XmlTag> collectProperties(@NotNull MavenDomProjectModel projectDom, @NotNull final Project project) {
@@ -280,33 +264,31 @@ public class MavenDomProjectProcessorUtils {
@Nullable
public static MavenDomDependency searchManagingDependency(@NotNull final MavenDomDependency dependency, @NotNull final Project project) {
final MavenDomDependency[] parent = new MavenDomDependency[]{null};
final String artifactId = dependency.getArtifactId().getStringValue();
final String groupId = dependency.getGroupId().getStringValue();
if (artifactId != null && groupId != null) {
final MavenDomProjectModel model = dependency.getParentOfType(MavenDomProjectModel.class, false);
if (model != null) {
Processor<MavenDomDependencies> processor = new Processor<MavenDomDependencies>() {
public boolean process(MavenDomDependencies mavenDomDependencies) {
if (!model.equals(mavenDomDependencies.getParentOfType(MavenDomProjectModel.class, true))) {
for (MavenDomDependency domDependency : mavenDomDependencies.getDependencies()) {
if (domDependency.equals(dependency)) continue;
if (artifactId.equals(domDependency.getArtifactId().getStringValue()) &&
groupId.equals(domDependency.getGroupId().getStringValue())) {
parent[0] = domDependency;
return true;
}
}
}
return false;
}
};
processDependenciesInDependencyManagement(model, processor, project);
}
}
if (artifactId == null || groupId == null) return null;
return parent[0];
final MavenDomProjectModel model = dependency.getParentOfType(MavenDomProjectModel.class, false);
if (model == null) return null;
SearchProcessor<MavenDomDependency, MavenDomDependencies> processor = new SearchProcessor<MavenDomDependency, MavenDomDependencies>() {
@Override
protected MavenDomDependency find(MavenDomDependencies mavenDomDependencies) {
if (!model.equals(mavenDomDependencies.getParentOfType(MavenDomProjectModel.class, true))) {
for (MavenDomDependency domDependency : mavenDomDependencies.getDependencies()) {
if (artifactId.equals(domDependency.getArtifactId().getStringValue()) &&
groupId.equals(domDependency.getGroupId().getStringValue())) {
return domDependency;
}
}
}
return null;
}
};
processDependenciesInDependencyManagement(model, processor, project);
return processor.myResult;
}
@@ -346,16 +328,6 @@ public class MavenDomProjectProcessorUtils {
return process(projectDom, processor, project, domProfileFunction, projectDomFunction);
}
public static boolean processPropertiesInProfile(@NotNull MavenDomProfile profileDom,
@NotNull final Processor<MavenDomProperties> processor) {
return processProfile(profileDom, processor, new Function<MavenDomProfile, MavenDomProperties>() {
@Override
public MavenDomProperties fun(MavenDomProfile mavenDomProfile) {
return mavenDomProfile.getProperties();
}
});
}
public static <T> boolean process(@NotNull MavenDomProjectModel projectDom,
@NotNull final Processor<T> processor,
@NotNull final Project project,
@@ -500,4 +472,23 @@ public class MavenDomProjectProcessorUtils {
return process(myManager.getGeneralSettings(), MavenDomUtil.getVirtualFile(projectDom), parentDesc);
}
}
private abstract static class SearchProcessor<R, T> implements Processor<T> {
private R myResult;
@Override
public final boolean process(T t) {
R res = find(t);
if (res != null) {
myResult = res;
return true;
}
return false;
}
@Nullable
protected abstract R find(T element);
}
}
@@ -176,7 +176,7 @@ public class MavenPropertyPsiReference extends MavenPsiReference {
MavenDomProfile profile = DomUtil.findDomElement(myElement, MavenDomProfile.class);
if (profile != null) {
PsiElement result = MavenDomProjectProcessorUtils.searchPropertyInProfile(myText, profile);
PsiElement result = MavenDomProjectProcessorUtils.findProperty(profile.getProperties(), myText);
if (result != null) return result;
}
@@ -1021,16 +1021,33 @@ public class MavenProjectsTree {
embedder.customizeForResolve(console, process);
embedder.clearCachesFor(mavenProject.getMavenId());
Set<File> filesToRefresh = new HashSet<File>();
try {
process.setText(ProjectBundle.message("maven.downloading.pom.plugins", mavenProject.getDisplayName()));
for (MavenPlugin each : mavenProject.getDeclaredPlugins()) {
process.checkCanceled();
process.setText(ProjectBundle.message("maven.downloading.pom.plugins", mavenProject.getDisplayName()));
embedder.resolvePlugin(each, mavenProject.getRemoteRepositories(), nativeMavenProject, false);
Collection<MavenArtifact> artifacts = embedder.resolvePlugin(each, mavenProject.getRemoteRepositories(), nativeMavenProject, false);
for (MavenArtifact artifact : artifacts) {
File pluginJar = artifact.getFile();
File pluginDir = pluginJar.getParentFile();
if (pluginDir != null) {
filesToRefresh.add(pluginDir); // Refresh both *.pom and *.jar files.
}
}
}
mavenProject.resetCache();
firePluginsResolved(mavenProject);
}
finally {
if (filesToRefresh.size() > 0) {
LocalFileSystem.getInstance().refreshIoFiles(filesToRefresh);
}
embeddersManager.release(embedder);
}
}
@@ -66,6 +66,9 @@ public abstract class TaskManager {
@NotNull
public abstract LocalTask getActiveTask();
@Nullable
public abstract LocalTask findTask(String id);
/**
* Update issue cache asynchronously
* @param onComplete callback to be invoked after updating
@@ -20,11 +20,16 @@ import com.intellij.tasks.TaskRepository;
import com.intellij.tasks.TaskRepositoryType;
import com.intellij.util.xmlb.annotations.Tag;
import com.intellij.util.xmlb.annotations.Transient;
import org.jetbrains.annotations.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Dmitry Avdeev
*/
public abstract class BaseRepository extends TaskRepository {
private static final Pattern PATTERN = Pattern.compile("[A-Z]+\\-\\d+");
protected String myUsername = "";
protected String myPassword = "";
protected boolean myUseProxy;
@@ -110,4 +115,10 @@ public abstract class BaseRepository extends TaskRepository {
public void setUseHttpAuthentication(boolean useHttpAuthentication) {
myUseHttpAuthentication = useHttpAuthentication;
}
@Nullable
public String extractId(String taskName) {
Matcher matcher = PATTERN.matcher(taskName);
return matcher.find() ? matcher.group() : null;
}
}
@@ -11,8 +11,6 @@ import org.jetbrains.annotations.Nullable;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Base class for HTTP-based repositories.
@@ -26,8 +24,6 @@ public abstract class BaseRepositoryImpl extends BaseRepository {
Protocol.registerProtocol(EASY_HTTPS, new Protocol(EASY_HTTPS, (ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), 443));
}
private static final Pattern PATTERN = Pattern.compile("[A-Z]+\\-\\d+");
protected BaseRepositoryImpl() {
}
@@ -39,12 +35,6 @@ public abstract class BaseRepositoryImpl extends BaseRepository {
super(other);
}
@Nullable
public String extractId(String taskName) {
Matcher matcher = PATTERN.matcher(taskName);
return matcher.find() ? matcher.group() : null;
}
protected static String encodeUrl(String s) {
try {
return URLEncoder.encode(s, "UTF-8");
@@ -1,47 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.tasks.actions;
import com.intellij.tasks.Task;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ide.BrowserUtil;
/**
* @author Dmitry Avdeev
*/
public class TaskRenderer extends SimpleColoredComponent {
public void setTask(Task task) {
setIcon(task.getIcon());
if (task.isIssue()) {
final String url = task.getIssueUrl();
if (url == null) {
append(task.getId());
} else {
append(task.getId(), SimpleTextAttributes.LINK_ATTRIBUTES, new Runnable() {
public void run() {
BrowserUtil.launchBrowser(url);
}
});
}
append(": " + task.getSummary());
} else {
append(task.getSummary());
}
}
}
@@ -69,14 +69,17 @@ public class TaskCheckinHandlerFactory extends CheckinHandlerFactory {
}
@Nullable
private static Task findTask(String message, TaskManager manager) {
private static LocalTask findTask(String message, TaskManager manager) {
TaskRepository[] repositories = manager.getAllRepositories();
for (TaskRepository repository : repositories) {
String id = repository.extractId(message);
if (id == null) continue;
LocalTask localTask = manager.findTask(id);
if (localTask != null) return localTask;
try {
Task task = repository.findTask(id);
if (task != null) {
return task;
return manager.addTask(task);
}
}
catch (Exception ignore) {
@@ -226,6 +226,11 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
return myActiveTask;
}
@Override
public LocalTask findTask(String id) {
return myTasks.get(id);
}
@Override
public List<Task> getIssues(String query) {
return getIssues(query, true);
@@ -1,5 +1,6 @@
package com.intellij.tasks;
import com.intellij.tasks.impl.LocalTaskImpl;
import com.intellij.tasks.impl.TaskManagerImpl;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
@@ -21,11 +22,20 @@ public abstract class TaskManagerTestCase extends LightCodeInsightFixtureTestCas
protected void setUp() throws Exception {
super.setUp();
myManager = (TaskManagerImpl)TaskManager.getManager(getProject());
removeAllTasks();
}
@Override
protected void tearDown() throws Exception {
myManager.setRepositories(Collections.<TaskRepository>emptyList());
removeAllTasks();
super.tearDown();
}
private void removeAllTasks() {
LocalTaskImpl[] tasks = myManager.getLocalTasks();
for (LocalTaskImpl task : tasks) {
myManager.removeTask(task);
}
}
}
@@ -16,10 +16,12 @@
package com.intellij.tasks;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
import com.intellij.openapi.vcs.changes.LocalChangeList;
import com.intellij.openapi.vcs.changes.committed.MockAbstractVcs;
import com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog;
import com.intellij.openapi.vcs.impl.projectlevelman.AllVcses;
import com.intellij.tasks.impl.LocalTaskImpl;
import org.jetbrains.annotations.NotNull;
@@ -70,6 +72,28 @@ public class TaskVcsTest extends TaskManagerTestCase {
assertEquals("TEST-001 Summary 001 TEST", info.comment);
}
public void testSaveContextOnCommit() throws Exception {
Task task = myRepository.findTask("TEST-001");
assertNotNull(task);
myManager.activateTask(task, false, true);
assertEquals(1, myManager.getLocalTasks().length);
LocalTask localTask = myManager.getActiveTask();
List<ChangeListInfo> changelists = myManager.getOpenChangelists(localTask);
ChangeListInfo info = changelists.get(0);
LocalChangeList changeList = ChangeListManager.getInstance(getProject()).getChangeList(info.id);
assertNotNull(changeList);
assertEquals(changeList.getId(), localTask.getAssociatedChangelistId());
CommitChangeListDialog.commitChanges(getProject(), Collections.<Change>emptyList(), changeList, null, changeList.getName());
assertEquals(1, myManager.getLocalTasks().length); // no extra task created
LocalTask associatedTask = myManager.getAssociatedTask(changeList);
assertNotNull(associatedTask); // association should survive
}
private ChangeListInfo createChangelist(Task task) {
clearChangeLists();
LocalTaskImpl localTask = new LocalTaskImpl(task);
@@ -43,11 +43,6 @@ class TestRepository extends BaseRepository {
});
}
@Override
public String extractId(String taskName) {
return null;
}
@Override
public boolean isConfigured() {
return true;
@@ -39,9 +39,6 @@ public class ConvertAnnotationInspection extends BaseJavaLocalInspectionTool {
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(final PsiReferenceExpression expression) {
}
@Override public void visitAnnotation(final PsiAnnotation annotation) {
final @NonNls String qualifiedName = annotation.getQualifiedName();
if (qualifiedName != null && qualifiedName.startsWith("org.testng.annotations")) {
@@ -64,9 +64,6 @@ public class ConvertJavadocInspection extends BaseJavaLocalInspectionTool {
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(final PsiReferenceExpression expression) {
}
@Override public void visitDocTag(final PsiDocTag tag) {
if (tag.getName().startsWith(TESTNG_PREFIX)) {
holder.registerProblem(tag, DISPLAY_NAME, new ConvertJavadocQuickfix());
@@ -65,9 +65,6 @@ public class ConvertOldAnnotationInspection extends BaseJavaLocalInspectionTool
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(final PsiReferenceExpression expression) {
}
@Override public void visitAnnotation(final PsiAnnotation annotation) {
final String qualifiedName = annotation.getQualifiedName();
if (Comparing.strEqual(qualifiedName, "org.testng.annotations.Configuration")) {
@@ -132,4 +129,4 @@ public class ConvertOldAnnotationInspection extends BaseJavaLocalInspectionTool
}
}
}
}
@@ -56,9 +56,6 @@ public class BoundFieldAssignmentInspection extends BaseJavaLocalInspectionTool
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
}
@Override
public void visitAssignmentExpression(PsiAssignmentExpression expression) {
if (expression.getLExpression() instanceof PsiReferenceExpression) {