diff --git a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java index 1e2c60b20114..6752d00cd87d 100644 --- a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java +++ b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java @@ -19,8 +19,6 @@ */ package com.intellij.ide.impl; -import com.intellij.ide.GeneralSettings; -import com.intellij.ide.IdeBundle; import com.intellij.ide.util.newProjectWizard.AddModuleWizard; import com.intellij.ide.util.projectWizard.ProjectBuilder; import com.intellij.openapi.application.ApplicationManager; @@ -41,7 +39,6 @@ import com.intellij.openapi.roots.ex.ProjectRootManagerEx; import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; import com.intellij.openapi.startup.StartupManager; -import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtil; @@ -197,17 +194,8 @@ public class NewProjectUtil { public static void closePreviousProject(final Project projectToClose) { Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (openProjects.length > 0) { - final GeneralSettings settings = GeneralSettings.getInstance(); - int exitCode = settings.getConfirmOpenNewProject(); - if (exitCode == GeneralSettings.OPEN_PROJECT_ASK) { - exitCode = Messages.showOkCancelDialog(projectToClose, - IdeBundle.message("prompt.open.project.in.new.frame"), - IdeBundle.message("title.new.project"), - IdeBundle.message("button.existingframe"), - IdeBundle.message("button.newframe"), - Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); - } - if (exitCode == DialogWrapper.OK_EXIT_CODE) { // "No" option + int exitCode = ProjectUtil.confirmOpenNewProject(true); + if (exitCode == 0) { // this window option ProjectUtil.closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1]); } } diff --git a/java/idea-ui/src/com/intellij/projectImport/ProjectOpenProcessorBase.java b/java/idea-ui/src/com/intellij/projectImport/ProjectOpenProcessorBase.java index fa9d47c43bfb..ffbd40f4d8d8 100644 --- a/java/idea-ui/src/com/intellij/projectImport/ProjectOpenProcessorBase.java +++ b/java/idea-ui/src/com/intellij/projectImport/ProjectOpenProcessorBase.java @@ -151,8 +151,6 @@ public abstract class ProjectOpenProcessorBase extends ProjectOpenProcessor { final String projectFilePath = wizardContext.getProjectFileDirectory() + File.separator + wizardContext.getProjectName() + ProjectFileType.DOT_DEFAULT_EXTENSION; - boolean shouldOpenExisting = false; - File dotIdeaFile = new File(dotIdeaFilePath); File projectFile = new File(projectFilePath); @@ -163,12 +161,14 @@ public abstract class ProjectOpenProcessorBase extends ProjectOpenProcessor { pathToOpen = dotIdeaFile.getParent(); } + boolean shouldOpenExisting = false; if (!ApplicationManager.getApplication().isHeadlessEnvironment() && (projectFile.exists() || dotIdeaFile.exists())) { String existingName; if (dotIdeaFile.exists()) { existingName = "an existing project"; pathToOpen = dotIdeaFile.getParent(); - } else { + } + else { existingName = "'" + projectFile.getName() + "'"; pathToOpen = projectFilePath; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java index 6b577f774f3e..3b4b793ae16f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java @@ -34,6 +34,10 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.search.searches.SuperMethodsSearch; import com.intellij.psi.util.*; +import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; +import com.intellij.refactoring.extractSuperclass.ExtractSuperclassHandler; +import com.intellij.refactoring.memberPullUp.JavaPullUpHandler; +import com.intellij.refactoring.memberPullUp.PullUpHelper; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.HashMap; import com.intellij.util.containers.HashSet; @@ -1016,8 +1020,10 @@ public class GenericsHighlightUtil { try { MethodSignatureBackedByPsiMethod superMethod = SuperMethodsSearch.search(method, null, true, false).findFirst(); if (superMethod == null) { - return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, overrideAnnotation, - JavaErrorMessages.message("method.doesnot.override.super")); + HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, overrideAnnotation, + JavaErrorMessages.message("method.doesnot.override.super")); + PullAsAbstractUpFix.registerQuickFix(highlightInfo, method); + return highlightInfo; } LanguageLevel languageLevel = PsiUtil.getLanguageLevel(method); PsiClass superClass = superMethod.getMethod().getContainingClass(); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java new file mode 100644 index 000000000000..1be7e9aaf249 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java @@ -0,0 +1,173 @@ +/* + * 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.codeInsight.daemon.impl.quickfix; + +import com.intellij.codeInsight.CodeInsightUtilBase; +import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.codeInsight.navigation.NavigationUtil; +import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement; +import com.intellij.ide.util.PsiClassListCellRenderer; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.*; +import com.intellij.psi.search.PsiElementProcessor; +import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; +import com.intellij.refactoring.extractSuperclass.ExtractSuperclassHandler; +import com.intellij.refactoring.memberPullUp.JavaPullUpHandler; +import com.intellij.refactoring.memberPullUp.PullUpHelper; +import com.intellij.refactoring.util.DocCommentPolicy; +import com.intellij.refactoring.util.classMembers.MemberInfo; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.LinkedHashSet; + +public class PullAsAbstractUpFix extends LocalQuickFixAndIntentionActionOnPsiElement { + private static final Logger LOG = Logger.getInstance("#" + PullAsAbstractUpFix.class.getName()); + private String myName; + + public PullAsAbstractUpFix(PsiMethod psiMethod, final String name) { + super(psiMethod); + myName = name; + } + + @NotNull + public String getText() { + return myName; + } + + @NotNull + public String getFamilyName() { + return "Pull up"; + } + + @Override + public boolean isAvailable(@NotNull Project project, + @NotNull PsiFile file, + @NotNull PsiElement startElement, + @NotNull PsiElement endElement) { + return startElement instanceof PsiMethod && startElement.isValid() && ((PsiMethod)startElement).getContainingClass() != null; + } + + @Override + public void invoke(@NotNull Project project, + @NotNull PsiFile file, + @Nullable("is null when called from inspection") Editor editor, + @NotNull PsiElement startElement, + @NotNull PsiElement endElement) { + final PsiMethod method = (PsiMethod)startElement; + if (!CodeInsightUtilBase.prepareFileForWrite(method.getContainingFile())) return; + + final PsiClass containingClass = method.getContainingClass(); + LOG.assertTrue(containingClass != null); + + PsiManager manager = containingClass.getManager(); + if (containingClass instanceof PsiAnonymousClass) { + final PsiClassType baseClassType = ((PsiAnonymousClass)containingClass).getBaseClassType(); + final PsiClass baseClass = baseClassType.resolve(); + if (baseClass != null && manager.isInProject(baseClass)) { + pullUp(method, containingClass, baseClass); + } + } + else { + final LinkedHashSet classesToPullUp = new LinkedHashSet(); + collectClassesToPullUp(manager, classesToPullUp, containingClass.getExtendsListTypes()); + collectClassesToPullUp(manager, classesToPullUp, containingClass.getImplementsListTypes()); + + if (classesToPullUp.size() == 0) { + //check visibility + new ExtractInterfaceHandler().invoke(project, new PsiElement[]{containingClass}, null); + } + else if (classesToPullUp.size() == 1) { + pullUp(method, containingClass, classesToPullUp.iterator().next()); + } + else if (editor != null) { + NavigationUtil.getPsiElementPopup(classesToPullUp.toArray(new PsiClass[classesToPullUp.size()]), new PsiClassListCellRenderer(), + "Choose super class", + new PsiElementProcessor() { + @Override + public boolean execute(PsiClass aClass) { + pullUp(method, containingClass, aClass); + return false; + } + }, classesToPullUp.iterator().next()).showInBestPositionFor(editor); + } + } + } + + + private static void collectClassesToPullUp(PsiManager manager, LinkedHashSet classesToPullUp, PsiClassType[] extendsListTypes) { + for (PsiClassType extendsListType : extendsListTypes) { + PsiClass resolve = extendsListType.resolve(); + if (resolve != null && manager.isInProject(resolve)) { + classesToPullUp.add(resolve); + } + } + } + + private static void pullUp(PsiMethod method, PsiClass containingClass, PsiClass baseClass) { + final MemberInfo memberInfo = new MemberInfo(method); + memberInfo.setChecked(true); + memberInfo.setToAbstract(true); + new PullUpHelper(containingClass, baseClass, new MemberInfo[]{memberInfo}, new DocCommentPolicy(DocCommentPolicy.ASIS)).run(); + } + + @Override + public boolean startInWriteAction() { + return false; + } + + public static void registerQuickFix(HighlightInfo highlightInfo, PsiMethod methodWithOverrides) { + PsiClass containingClass = methodWithOverrides.getContainingClass(); + if (containingClass == null) return; + final PsiManager manager = containingClass.getManager(); + + boolean canBePulledUp = true; + String name = "Pull method \'" + methodWithOverrides.getName() + "\' up"; + if (containingClass instanceof PsiAnonymousClass) { + final PsiClassType baseClassType = ((PsiAnonymousClass)containingClass).getBaseClassType(); + final PsiClass baseClass = baseClassType.resolve(); + if (baseClass == null) return; + if (!manager.isInProject(baseClass)) return; + if (!baseClass.hasModifierProperty(PsiModifier.ABSTRACT)) { + name = "Pull method \'" + methodWithOverrides.getName() + "\' up and make it abstract"; + } + } else { + final LinkedHashSet classesToPullUp = new LinkedHashSet(); + collectClassesToPullUp(manager, classesToPullUp, containingClass.getExtendsListTypes()); + collectClassesToPullUp(manager, classesToPullUp, containingClass.getImplementsListTypes()); + if (classesToPullUp.size() == 0) { + name = "Extract method \'" + methodWithOverrides.getName() + "\' to new interface"; + canBePulledUp = false; + } else if (classesToPullUp.size() == 1) { + final PsiClass baseClass = classesToPullUp.iterator().next(); + name = "Pull method \'" + methodWithOverrides.getName() + "\' to \'" + baseClass.getName() + "\'"; + if (!baseClass.hasModifierProperty(PsiModifier.ABSTRACT)) { + name+= " and make it abstract"; + } + } + QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new ExtractInterfaceHandler(), "Extract interface")); + QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new ExtractSuperclassHandler(), "Extract superclass")); + } + + + if (canBePulledUp) { + QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new JavaPullUpHandler(), "Pull members up")); + } + QuickFixAction.registerQuickFixAction(highlightInfo, new PullAsAbstractUpFix(methodWithOverrides, name)); + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RunRefactoringIntention.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RunRefactoringIntention.java new file mode 100644 index 000000000000..f35ecc3bf051 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RunRefactoringIntention.java @@ -0,0 +1,76 @@ +/* + * 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.codeInsight.daemon.impl.quickfix; + +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInsight.intention.LowPriorityAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.util.Iconable; +import com.intellij.psi.PsiFile; +import com.intellij.refactoring.RefactoringActionHandler; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; + +/** + * User: anna + * Date: 9/5/11 + */ +public class RunRefactoringIntention implements IntentionAction, Iconable, LowPriorityAction { + public static final Icon REFACTORING_BULB = IconLoader.getIcon("/actions/refactoringBulb.png"); + private final RefactoringActionHandler myHandler; + private final String myCommandName; + + public RunRefactoringIntention(RefactoringActionHandler handler, String commandName) { + myHandler = handler; + myCommandName = commandName; + } + + @NotNull + @Override + public String getText() { + return myCommandName; + } + + @NotNull + @Override + public String getFamilyName() { + return "Refactorings"; + } + + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + return true; + } + + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + myHandler.invoke(project, editor, file, null); + } + + @Override + public boolean startInWriteAction() { + return false; + } + + @Override + public Icon getIcon(int flags) { + return REFACTORING_BULB; + } +} diff --git a/java/java-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java b/java/java-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java index ac2afc346ab8..a71a149a14aa 100644 --- a/java/java-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java @@ -298,7 +298,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor { PsiType substitutedBoundType = boundType.accept(mySimpleSubstitutionVisitor); PsiWildcardType wildcardType = (PsiWildcardType)substituted; if (substitutedBoundType != null && !(substitutedBoundType instanceof PsiWildcardType) && !substitutedBoundType.equalsToText("java.lang.Object")) { - if (originalBound == null || !TypeConversionUtil.erasure(substitutedBoundType).isAssignableFrom(originalBound)) { //erasure is essential to avoid infinite recursion + if (originalBound == null || !TypeConversionUtil.erasure(substitutedBoundType).isAssignableFrom(TypeConversionUtil.erasure(originalBound))) { //erasure is essential to avoid infinite recursion if (wildcardType.isExtends()) { final PsiType glb = GenericsUtil.getGreatestLowerBound(wildcardType.getBound(), substitutedBoundType); if (glb != null) { diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiLocalVariableImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiLocalVariableImpl.java index 12347227ffc1..d3c2bc6b1caf 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiLocalVariableImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiLocalVariableImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.SearchScope; import com.intellij.psi.tree.ChildRoleBase; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilBase; import com.intellij.ui.RowIcon; import com.intellij.util.CharTable; @@ -47,6 +48,7 @@ import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.util.Arrays; import java.util.Set; public class PsiLocalVariableImpl extends CompositePsiElement implements PsiLocalVariable, PsiVariableEx, Constants { @@ -100,13 +102,16 @@ public class PsiLocalVariableImpl extends CompositePsiElement implements PsiLoca @NotNull public PsiTypeElement getTypeElement() { - final CompositeElement parent = getTreeParent(); - assert parent != null : this + "; [" + getText() + "]"; - final ASTNode first = parent.findChildByType(LOCAL_VARIABLE); - assert first != null : this + "; [" + getText() + "]"; - final ASTNode type = first.findChildByType(TYPE); - assert type != null : this + "; [" + getText() + "]"; - return SourceTreeToPsiMap.treeToPsiNotNull(type); + PsiTypeElement typeElement = PsiTreeUtil.getChildOfType(this, PsiTypeElement.class); + if (typeElement != null) return typeElement; + + final PsiElement parent = getParent(); + assert parent != null : "no parent; " + this + "; [" + getText() + "]"; + final PsiLocalVariable localVariable = PsiTreeUtil.getChildOfType(parent, PsiLocalVariable.class); + assert localVariable != null : "no local variable in " + Arrays.toString(parent.getChildren()); + typeElement = PsiTreeUtil.getChildOfType(localVariable, PsiTypeElement.class); + assert typeElement != null : "no type element in " + Arrays.toString(localVariable.getChildren()); + return typeElement; } public PsiModifierList getModifierList() { @@ -177,13 +182,13 @@ public class PsiLocalVariableImpl extends CompositePsiElement implements PsiLoca CompositeElement statement1 = Factory.createCompositeElement(DECLARATION_STATEMENT, charTableByTree, getManager()); statement1.addChild(variable, null); - ASTNode space = Factory.createSingleLeafElement(JavaTokenType.WHITE_SPACE, " ", 0, 1, treeCharTab, getManager()); + ASTNode space = Factory.createSingleLeafElement(TokenType.WHITE_SPACE, " ", 0, 1, treeCharTab, getManager()); variable.addChild(space, variable.getFirstChildNode()); variable.addChild(typeCopy, variable.getFirstChildNode()); if (modifierListCopy.getTextLength() > 0) { - space = Factory.createSingleLeafElement(JavaTokenType.WHITE_SPACE, " ", 0, 1, treeCharTab, getManager()); + space = Factory.createSingleLeafElement(TokenType.WHITE_SPACE, " ", 0, 1, treeCharTab, getManager()); variable.addChild(space, variable.getFirstChildNode()); } diff --git a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java index 5bda67d58f57..d5e8a6ec2155 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperclassHandler.java @@ -86,7 +86,7 @@ public class ExtractSuperclassHandler implements RefactoringActionHandler, Extra if (!CommonRefactoringUtil.checkReadOnlyStatus(project, mySubclass)) return; - Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); + Editor editor = dataContext != null ? PlatformDataKeys.EDITOR.getData(dataContext) : null; if (mySubclass.isInterface()) { String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("superclass.cannot.be.extracted.from.an.interface")); diff --git a/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java b/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java index 3017c9d072b3..82b1b5fbe5b9 100644 --- a/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java @@ -44,6 +44,7 @@ import com.intellij.util.Processor;import com.intellij.util.containers.HashMap; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -65,13 +66,36 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori return true; } }); - final List members = memberInfoStorage.getClassMemberInfos(mySuperClass); + List members = memberInfoStorage.getClassMemberInfos(mySuperClass); for (MemberInfo member : members) { member.setChecked(true); } + members = appendSuperRefs(members); myMemberInfos = members.toArray(new MemberInfo[members.size()]); } + private List appendSuperRefs(List members) { + if (!mySuperClass.isInterface()) { + PsiReferenceList extendsList = mySuperClass.getExtendsList(); + if (extendsList != null && extendsList.getReferenceElements().length > 0) { + PsiElement resolve = extendsList.getReferenceElements()[0].resolve(); + if (resolve instanceof PsiClass) { + members = new ArrayList(members); + + MemberInfo memberInfo = new MemberInfo((PsiMember)resolve, true, extendsList) { + { + overrides = false; + } + }; + + memberInfo.setChecked(true); + members.add(memberInfo); + } + } + } + return members; + } + protected UsageViewDescriptor createUsageViewDescriptor(final UsageInfo[] usages) { return new InlineSuperClassUsageViewDescriptor(mySuperClass); } diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/JavaPullUpHandler.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/JavaPullUpHandler.java index dbff1406c357..2da0a50732a9 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/JavaPullUpHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/JavaPullUpHandler.java @@ -105,7 +105,7 @@ public class JavaPullUpHandler implements RefactoringActionHandler, PullUpDialog } private void invoke(Project project, DataContext dataContext, PsiClass aClass, PsiElement aMember) { - Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); + final Editor editor = dataContext != null ? PlatformDataKeys.EDITOR.getData(dataContext) : null; if (aClass == null) { String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("is.not.supported.in.the.current.context", REFACTORING_NAME)); diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java index d110d6e1943a..627b698c4345 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java @@ -204,15 +204,15 @@ public class PullUpHelper extends BaseRefactoringProcessor{ for (MemberInfo info : myMembersToMove) { if (info.getMember() instanceof PsiMethod) { PsiMethod method = (PsiMethod)info.getMember(); + PsiMethod methodCopy = (PsiMethod)method.copy(); + if (method.findDeepestSuperMethods().length == 0) { + deleteOverrideAnnotationIfFound(methodCopy); + } final boolean isOriginalMethodAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT); if (myIsTargetInterface || info.isToAbstract()) { - PsiMethod methodCopy = (PsiMethod)method.copy(); ChangeContextUtil.clearContextInfo(method); RefactoringUtil.abstractizeMethod(myTargetSuperClass, methodCopy); RefactoringUtil.replaceMovedMemberTypeParameters(methodCopy, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory); - if (method.findDeepestSuperMethods().length == 0 || (myTargetSuperClass.isInterface() && !PsiUtil.isLanguageLevel6OrHigher(mySourceClass))) { - deleteOverrideAnnotationIfFound(methodCopy); - } myJavaDocPolicy.processCopiedJavaDoc(methodCopy.getDocComment(), method.getDocComment(), isOriginalMethodAbstract); @@ -240,14 +240,14 @@ public class PullUpHelper extends BaseRefactoringProcessor{ if (isOriginalMethodAbstract) { PsiUtil.setModifierProperty(myTargetSuperClass, PsiModifier.ABSTRACT, true); } - RefactoringUtil.replaceMovedMemberTypeParameters(method, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory); - fixReferencesToStatic(method, movedMembers); - final PsiMethod superClassMethod = myTargetSuperClass.findMethodBySignature(method, false); + RefactoringUtil.replaceMovedMemberTypeParameters(methodCopy, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory); + fixReferencesToStatic(methodCopy, movedMembers); + final PsiMethod superClassMethod = myTargetSuperClass.findMethodBySignature(methodCopy, false); if (superClassMethod != null && superClassMethod.hasModifierProperty(PsiModifier.ABSTRACT)) { - superClassMethod.replace(method); + superClassMethod.replace(methodCopy); } else { - final PsiMember movedElement = (PsiMember)myTargetSuperClass.add(method); + final PsiMember movedElement = (PsiMember)myTargetSuperClass.add(methodCopy); myMembersAfterMove.add(movedElement); } method.delete(); diff --git a/java/java-impl/src/com/intellij/refactoring/memberPushDown/PushDownProcessor.java b/java/java-impl/src/com/intellij/refactoring/memberPushDown/PushDownProcessor.java index 618fb1655703..726637dfc7e7 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPushDown/PushDownProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPushDown/PushDownProcessor.java @@ -385,10 +385,14 @@ public class PushDownProcessor extends BaseRefactoringProcessor { } else if (member instanceof PsiClass) { if (Boolean.FALSE.equals(memberInfo.getOverrides())) { - final PsiClass aClass = (PsiClass)member; + final PsiClass aClass = (PsiClass)memberInfo.getMember(); if (!targetClass.isInheritor(aClass, false)) { PsiJavaCodeReferenceElement classRef = factory.createClassReferenceElement(aClass); - targetClass.getImplementsList().add(classRef); + if (aClass.isInterface()) { + targetClass.getImplementsList().add(classRef); + } else { + targetClass.getExtendsList().add(classRef); + } } } else { diff --git a/java/java-tests/java-tests.iml b/java/java-tests/java-tests.iml index e2708d77ad84..faf2fc05a870 100644 --- a/java/java-tests/java-tests.iml +++ b/java/java-tests/java-tests.iml @@ -26,6 +26,8 @@ + + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOE.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOE.java new file mode 100644 index 000000000000..a5f43e18be90 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOE.java @@ -0,0 +1,24 @@ +public class SOE { +} +abstract class VersionEntity, R extends Ref> + implements Version{} + +interface Version, R extends Ref>{} + +abstract class RefEntity, R extends Ref> + implements Ref {} + +interface Ref, R extends Ref>{} + + +abstract class Node, + GR extends NodeRef> extends VersionEntity {} + +abstract class NodeRef, GR extends NodeRef> extends RefEntity {} + + +class D { + void f() { + Version v = new Node<?, ?>(){} + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after1.java new file mode 100644 index 000000000000..8a3a824c50e9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after1.java @@ -0,0 +1,9 @@ +// "Pull method 'foo' to 'Int'" "true" +public class Test implements Int { + @Override + public void foo(){} +} + +interface Int { + void foo(); +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after3.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after3.java new file mode 100644 index 000000000000..f6fc3daeb9c9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after3.java @@ -0,0 +1,15 @@ +// "Pull method 'foo' up and make it abstract" "true" +public class Test{ + void main(){ + new Int(){ + @Override + void foo(){ + + } + }; + } +} + +abstract class Int { + abstract void foo(); +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before1.java new file mode 100644 index 000000000000..75cbb92d0810 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before1.java @@ -0,0 +1,7 @@ +// "Pull method 'foo' to 'Int'" "true" +public class Test implements Int { + @Override + void foo(){} +} + +interface Int {} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before2.java new file mode 100644 index 000000000000..4e95750e1027 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before2.java @@ -0,0 +1,7 @@ +// "Pull method 'foo' to 'List'" "false" +import java.util.List; + +public abstract class Test implements List{ + @Override + void foo(){} +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before3.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before3.java new file mode 100644 index 000000000000..f748ab95a4b0 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before3.java @@ -0,0 +1,13 @@ +// "Pull method 'foo' up and make it abstract" "true" +public class Test{ + void main(){ + new Int(){ + @Override + void foo(){ + + } + }; + } +} + +class Int {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before4.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before4.java new file mode 100644 index 000000000000..4dbd66ca1bc8 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before4.java @@ -0,0 +1,13 @@ +// "Extract interface" "false" +public class Test{ + void main(){ + new Int(){ + @Override + void foo(){ + + } + }; + } +} + +class Int {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before5.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before5.java new file mode 100644 index 000000000000..2dd219f051bd --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before5.java @@ -0,0 +1,7 @@ +import java.util.ArrayList; +public abstract class Test extends ArrayList implements Int { + @Override + void foo(){} +} + +interface Int {} diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/after/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/after/Super.java new file mode 100644 index 000000000000..ffe4e5228e56 --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/after/Super.java @@ -0,0 +1,5 @@ + +interface Int {} + +class Dummy {} + diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/after/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/after/Test.java new file mode 100644 index 000000000000..5204deef43da --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/after/Test.java @@ -0,0 +1,11 @@ +class Test extends Dummy implements Int { + Test(){} + + public void main() {} +} + +class U { + public static void main(String[] args) { + new Test().main(); + } +} diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/before/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/before/Super.java new file mode 100644 index 000000000000..4cd4a5a3cd37 --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/before/Super.java @@ -0,0 +1,9 @@ + +interface Int {} + +class Dummy {} + +public class Super extends Dummy implements Int { + public void main() {} +} + diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/before/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/before/Test.java new file mode 100644 index 000000000000..c1f4e72916ea --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineSuperClass/inlineSuperclassExtendsList/before/Test.java @@ -0,0 +1,9 @@ +class Test extends Super{ + Test(){} +} + +class U { + public static void main(String[] args) { + new Test().main(); + } +} diff --git a/java/java-tests/testData/refactoring/pullUp/PreserveOverrideInPulledMethod.java b/java/java-tests/testData/refactoring/pullUp/PreserveOverrideInPulledMethod.java new file mode 100644 index 000000000000..f24091f456ad --- /dev/null +++ b/java/java-tests/testData/refactoring/pullUp/PreserveOverrideInPulledMethod.java @@ -0,0 +1,12 @@ +public class Test { + abstract class Base extends IntImpl { + @Override + public abstract String foo(); + } + + class IntImpl extends Int {} + + class Int { + public abstract String foo(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pullUp/PreserveOverrideInPulledMethod_after.java b/java/java-tests/testData/refactoring/pullUp/PreserveOverrideInPulledMethod_after.java new file mode 100644 index 000000000000..c17800d29aa8 --- /dev/null +++ b/java/java-tests/testData/refactoring/pullUp/PreserveOverrideInPulledMethod_after.java @@ -0,0 +1,13 @@ +public class Test { + abstract class Base extends IntImpl { + } + + abstract class IntImpl extends Int { + @Override + public abstract String foo(); + } + + class Int { + public abstract String foo(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pullUp/RemoveOverrideFromPulledMethod.java b/java/java-tests/testData/refactoring/pullUp/RemoveOverrideFromPulledMethod.java new file mode 100644 index 000000000000..555f2e5db032 --- /dev/null +++ b/java/java-tests/testData/refactoring/pullUp/RemoveOverrideFromPulledMethod.java @@ -0,0 +1,9 @@ +public class Test { + abstract class Base extends Int { + @Override + public abstract String foo(); + } + + class Int { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pullUp/RemoveOverrideFromPulledMethod_after.java b/java/java-tests/testData/refactoring/pullUp/RemoveOverrideFromPulledMethod_after.java new file mode 100644 index 000000000000..7388dd161263 --- /dev/null +++ b/java/java-tests/testData/refactoring/pullUp/RemoveOverrideFromPulledMethod_after.java @@ -0,0 +1,8 @@ +public class Test { + abstract class Base extends Int { + } + + abstract class Int { + public abstract String foo(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/SameClassInterface.java b/java/java-tests/testData/refactoring/pushDown/SameClassInterface.java new file mode 100644 index 000000000000..5f5a5cafabd8 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/SameClassInterface.java @@ -0,0 +1,3 @@ +interface Int {} +public class Test implements Int {} +class B extends Test implements Int {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/SameClassInterface.java.after b/java/java-tests/testData/refactoring/pushDown/SameClassInterface.java.after new file mode 100644 index 000000000000..65379b70149c --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/SameClassInterface.java.after @@ -0,0 +1,3 @@ +interface Int {} +public class Test {} +class B extends Test implements Int {} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index efabf585cf53..00fab84cb81c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -81,6 +81,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEADEV24166() throws Exception { doTest(true); } public void testIDEADEV25778() throws Exception { doTest(true); } public void testIDEADEV57343() throws Exception { doTest(false); } + public void testSOE() throws Exception { doTest(true); } public void testGenericExtendException() throws Exception { doTest(false); } public void testSameErasureDifferentReturnTypes() throws Exception { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/PullOverrideMethodUpFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/PullOverrideMethodUpFixTest.java new file mode 100644 index 000000000000..2d6115085c70 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/PullOverrideMethodUpFixTest.java @@ -0,0 +1,55 @@ +/* + * 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.codeInsight.daemon.quickFix; + +import com.intellij.codeInsight.intention.IntentionAction; + +public class PullOverrideMethodUpFixTest extends LightQuickFixTestCase { + public void test1() throws Exception { + doSingleTest("1.java"); + } + + public void test2() throws Exception { + doSingleTest("2.java"); + } + + public void test3() throws Exception { + doSingleTest("3.java"); + } + + public void test4() throws Exception { + doSingleTest("4.java"); + } + + public void testRefactoringIntentionsAvailable() throws Exception { + doTestActionAvailable(5, "Pull members up"); + doTestActionAvailable(5, "Extract interface"); + doTestActionAvailable(5, "Extract superclass"); + } + + private void doTestActionAvailable(final int suffix, final String actionText) { + final String testFullPath = getBasePath() + "/before" + suffix + ".java"; + configureByFile(testFullPath); + doHighlighting(); + final IntentionAction action = findActionWithText(actionText); + assertNotNull(action); + } + + @Override + protected String getBasePath() { + return "/codeInsight/daemonCodeAnalyzer/quickFix/pullUp"; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/BlockIndentOnPasteTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/BlockIndentOnPasteTest.groovy index eb43d1c08517..cc1c4f22fd13 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/BlockIndentOnPasteTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/BlockIndentOnPasteTest.groovy @@ -58,7 +58,7 @@ class Test { doTest(before, toPaste, expected) } - void _testStringBeforeAnotherStringShouldNotIncreaseIndentOfTheFollowingString() { + void testStringBeforeAnotherStringShouldNotIncreaseIndentOfTheFollowingString() { def before = '''\ class Test { void test() { @@ -75,7 +75,7 @@ class Test { class Test { void test() { int b = 200; - int a = 100; + int a = 100; int b = 200; }\ ''' diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java index 7351495b2e35..3dac8660529a 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java @@ -171,6 +171,10 @@ public class InlineSuperClassTest extends MultiFileTestCase { doTestMultipleSubclasses(); } + public void testInlineSuperclassExtendsList() throws Exception { + doTest(); + } + private void doTestMultipleSubclasses() throws Exception { doTest(new PerformAction() { @Override diff --git a/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java b/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java index 7c637436c796..42230c401e1f 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java @@ -105,6 +105,14 @@ public class PullUpTest extends LightCodeInsightTestCase { doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class)); } + public void testRemoveOverrideFromPulledMethod() throws Exception { + doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class)); + } + + public void testPreserveOverrideInPulledMethod() throws Exception { + doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class)); + } + private void doTest(RefactoringTestUtil.MemberDescriptor... membersToFind) throws Exception { doTest(true, membersToFind); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java b/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java index d47d05e04abe..7fc7f2afe716 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java @@ -9,6 +9,7 @@ import com.intellij.psi.*; import com.intellij.refactoring.memberPushDown.PushDownProcessor; import com.intellij.refactoring.util.DocCommentPolicy; import com.intellij.refactoring.util.classMembers.MemberInfo; +import com.intellij.refactoring.util.classMembers.MemberInfoStorage; import com.intellij.testFramework.LightCodeInsightTestCase; import com.intellij.JavaTestUtil; import com.intellij.usageView.UsageInfo; @@ -28,7 +29,7 @@ public class PushDownTest extends LightCodeInsightTestCase { } private void doTest(final boolean failure) throws Exception { - final String filePath = "/refactoring/pushDown/" + getTestName(false)+ ".java"; + final String filePath = "/refactoring/pushDown/" + getTestName(false) + ".java"; configureByFile(filePath); final PsiElement targetElement = TargetElementUtilBase.findTargetElement(getEditor(), TargetElementUtilBase.ELEMENT_NAME_ACCEPTED); @@ -53,7 +54,8 @@ public class PushDownTest extends LightCodeInsightTestCase { memberInfo.setChecked(true); membersToMove.add(memberInfo); - new PushDownProcessor(getProject(), membersToMove.toArray(new MemberInfo[membersToMove.size()]), currentClass, new DocCommentPolicy(DocCommentPolicy.ASIS)){ + new PushDownProcessor(getProject(), membersToMove.toArray(new MemberInfo[membersToMove.size()]), currentClass, + new DocCommentPolicy(DocCommentPolicy.ASIS)) { @Override protected boolean showConflicts(MultiMap conflicts, UsageInfo[] usages) { if (failure ? conflicts.isEmpty() : !conflicts.isEmpty()) { @@ -109,4 +111,30 @@ public class PushDownTest extends LightCodeInsightTestCase { public void testMethodTypeParametersList() throws Exception { doTest(); } + + public void testSameClassInterface() throws Exception { + final String filePath = "/refactoring/pushDown/" + getTestName(false) + ".java"; + configureByFile(filePath); + + PsiClass currentClass = JavaPsiFacade.getInstance(getProject()).findClass("Test"); + MemberInfoStorage memberInfoStorage = new MemberInfoStorage(currentClass, new MemberInfo.Filter() { + public boolean includeMember(PsiMember element) { + return true; + } + }); + List members = memberInfoStorage.getClassMemberInfos(currentClass); + for (MemberInfo member : members) { + member.setChecked(true); + } + + new PushDownProcessor(getProject(), members.toArray(new MemberInfo[members.size()]), currentClass, + new DocCommentPolicy(DocCommentPolicy.ASIS)) { + @Override + protected boolean showConflicts(MultiMap conflicts, UsageInfo[] usages) { + return true; + } + }.run(); + + checkResultByFile(filePath + ".after"); + } } diff --git a/java/openapi/src/com/intellij/psi/PsiDiamondType.java b/java/openapi/src/com/intellij/psi/PsiDiamondType.java index 64ef616d2e50..0b2e3087b4a5 100644 --- a/java/openapi/src/com/intellij/psi/PsiDiamondType.java +++ b/java/openapi/src/com/intellij/psi/PsiDiamondType.java @@ -114,6 +114,10 @@ public class PsiDiamondType extends PsiType { return DiamondInferenceResult.EXPLICIT_CONSTRUCTOR_TYPE_ARGS; } + return resolveInferredTypesNoCheck(newExpression, context); + } + + public static DiamondInferenceResult resolveInferredTypesNoCheck(PsiNewExpression newExpression, PsiElement context) { final PsiClass psiClass = findClass(newExpression); if (psiClass == null) return DiamondInferenceResult.NULL_RESULT; final PsiExpressionList argumentList = newExpression.getArgumentList(); @@ -129,7 +133,8 @@ public class PsiDiamondType extends PsiType { final PsiTypeParameter[] classParameters = psiClass.getTypeParameters(); final PsiJavaCodeReferenceElement classOrAnonymousClassReference = newExpression.getClassOrAnonymousClassReference(); LOG.assertTrue(classOrAnonymousClassReference != null); - final DiamondInferenceResult result = new DiamondInferenceResult(classOrAnonymousClassReference.getReferenceName() + "<>", newExpression.getProject()); + final DiamondInferenceResult + result = new DiamondInferenceResult(classOrAnonymousClassReference.getReferenceName() + "<>", newExpression.getProject()); for (PsiTypeParameter parameter : parameters) { for (PsiTypeParameter classParameter : classParameters) { if (Comparing.strEqual(classParameter.getName(), parameter.getName())) { diff --git a/platform/core-api/src/com/intellij/lang/ASTNode.java b/platform/core-api/src/com/intellij/lang/ASTNode.java index b6629e5b4d74..11918df3b20c 100644 --- a/platform/core-api/src/com/intellij/lang/ASTNode.java +++ b/platform/core-api/src/com/intellij/lang/ASTNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -142,9 +142,9 @@ public interface ASTNode extends UserDataHolder { * Adds the specified child node at the specified position in the child list. * * @param child the child node to add. - * @param anchorBefore the node before which the child node is inserted. + * @param anchorBefore the node before which the child node is inserted (null to add a child as a last node). */ - void addChild(@NotNull ASTNode child, ASTNode anchorBefore); + void addChild(@NotNull ASTNode child, @Nullable ASTNode anchorBefore); /** * Add leaf element with specified type and text in the child list. diff --git a/platform/lang-api/src/com/intellij/openapi/editor/LanguageLineWrapPositionStrategy.java b/platform/lang-api/src/com/intellij/openapi/editor/LanguageLineWrapPositionStrategy.java index dea60f04a53a..ee7a4a28b794 100644 --- a/platform/lang-api/src/com/intellij/openapi/editor/LanguageLineWrapPositionStrategy.java +++ b/platform/lang-api/src/com/intellij/openapi/editor/LanguageLineWrapPositionStrategy.java @@ -45,7 +45,7 @@ public class LanguageLineWrapPositionStrategy extends LanguageExtension firstLineStart) { + document.insertString(start, chars.subSequence(firstLineStart, indentToKeepEndOffset)); + } } else { lastLine = document.getLineNumber(endOffset); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java index c097339bacb9..e17b016a84b0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java @@ -19,10 +19,12 @@ package com.intellij.codeInsight.template.impl; import com.intellij.codeInsight.CodeInsightActionHandler; import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.codeInsight.CodeInsightUtilBase; +import com.intellij.codeInsight.completion.CompletionUtil; import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInsight.template.CustomLiveTemplate; import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopupFactory; @@ -108,6 +110,15 @@ public class SurroundWithTemplateHandler implements CodeInsightActionHandler { final int selEnd = editor.getSelectionModel().getSelectionEnd(); startOffset = (offset == selStart) ? selEnd : selStart; } + + if (!selection) { + file = (PsiFile)file.copy(); + final Document document = file.getViewProvider().getDocument(); + assert document != null; + document.insertString(offset, CompletionUtil.DUMMY_IDENTIFIER_TRIMMED); + PsiDocumentManager.getInstance(file.getProject()).commitDocument(document); + } + ArrayList list = new ArrayList(); for (TemplateImpl template : TemplateSettings.getInstance().getTemplates()) { if (!template.isDeactivated() && diff --git a/platform/lang-impl/src/com/intellij/pom/tree/events/impl/TreeChangeEventImpl.java b/platform/lang-impl/src/com/intellij/pom/tree/events/impl/TreeChangeEventImpl.java index f3a8398f6ca6..f93004c3a6f3 100644 --- a/platform/lang-impl/src/com/intellij/pom/tree/events/impl/TreeChangeEventImpl.java +++ b/platform/lang-impl/src/com/intellij/pom/tree/events/impl/TreeChangeEventImpl.java @@ -39,8 +39,7 @@ import java.util.*; public class TreeChangeEventImpl implements TreeChangeEvent{ private static final Logger LOG = Logger.getInstance("#com.intellij.pom.tree.events.impl.TreeChangeEventImpl"); private final Map myChangedElements = new THashMap(); - private final List myChangedInOrder = new ArrayList(); - private List myChangedInOrderNew; + private List myChangedInOrder; private final List> myOfEqualDepth = new ArrayList>(10); private final PomModelAspect myAspect; private final FileElement myFileElement; @@ -57,10 +56,10 @@ public class TreeChangeEventImpl implements TreeChangeEvent{ @NotNull public ASTNode[] getChangedElements() { - if (myChangedInOrderNew == null) { - myChangedInOrderNew = new ArrayList(myChangedElements.keySet()); + if (myChangedInOrder == null) { + myChangedInOrder = new ArrayList(myChangedElements.keySet()); - Collections.sort(myChangedInOrderNew, new Comparator() { + Collections.sort(myChangedInOrder, new Comparator() { final Map routeMap = new THashMap(myChangedElements.size()); final TObjectIntHashMap nodeIndex = new TObjectIntHashMap(myChangedElements.size()); @@ -73,23 +72,8 @@ public class TreeChangeEventImpl implements TreeChangeEvent{ return compareRoutes(route, route2); } }); - - int size = myChangedInOrderNew.size(); - if (size == myChangedInOrder.size()) { - for(int i = 0; i < size; ++i) { - if (myChangedInOrderNew.get(i) != myChangedInOrder.get(i)) { - LOG.error("Unexpected changed elements difference"); - return myChangedInOrder.toArray(new ASTNode[myChangedInOrder.size()]); - } - } - } - else { - LOG.error("Unexpected changed elements difference"); - return myChangedInOrder.toArray(new ASTNode[myChangedInOrder.size()]); - } } - - return myChangedInOrderNew.toArray(new ASTNode[myChangedInOrderNew.size()]); + return myChangedInOrder.toArray(new ASTNode[myChangedInOrder.size()]); } public TreeChange getChangesByElement(@NotNull ASTNode element) { @@ -141,8 +125,7 @@ public class TreeChangeEventImpl implements TreeChangeEvent{ } public void clear() { - myChangedInOrderNew = null; - myChangedInOrder.clear(); + myChangedInOrder = null; myChangedElements.clear(); myOfEqualDepth.clear(); } @@ -152,7 +135,6 @@ public class TreeChangeEventImpl implements TreeChangeEvent{ if (treeChange == null) { treeChange = new TreeChangeImpl(parent); myChangedElements.put(parent, treeChange); - insertAtList(parent); final int index = depth >= 0 ? depth : getDepth(parent); addToEqualsDepthList(index, parent); @@ -221,7 +203,6 @@ public class TreeChangeEventImpl implements TreeChangeEvent{ private void removeAssociatedChanges(ASTNode treeElement, int depth) { if(myChangedElements.remove(treeElement) != null) { - myChangedInOrder.remove(treeElement); if (depth < 0) depth = getDepth(treeElement); if (depth < myOfEqualDepth.size()) { myOfEqualDepth.get(depth < 0 ? getDepth(treeElement) : depth).remove(treeElement); @@ -229,41 +210,6 @@ public class TreeChangeEventImpl implements TreeChangeEvent{ } } - private void insertAtList(ASTNode node){ - if (!myChangedInOrder.isEmpty()) { - final int[] nodeRoute = getRoute(node); - for (int index = 0; index < myChangedInOrder.size(); index++) { - final ASTNode current = myChangedInOrder.get(index); - final int[] route = getRoute(current); - if (compareRoutes(nodeRoute, route) < 0) { - myChangedInOrder.add(index, node); - return; - } - } - } - myChangedInOrder.add(node); - } - - private static int[] getRoute(ASTNode node){ - final List parents = new ArrayList(20); - while(node != null){ - parents.add(node); - node = node.getTreeParent(); - } - final int[] root = new int[parents.size() - 1]; - for(int i = 0; i < root.length; i++){ - final ASTNode parent = parents.get(root.length - i - 1); - int rootIndex = 0; - ASTNode current = parent.getTreeParent().getFirstChildNode(); - while(current != parent){ - current = current.getTreeNext(); - rootIndex++; - } - root[i] = rootIndex; - } - return root; - } - private static int[] getRoute(ASTNode node, TObjectIntHashMap index){ final List parents = new ArrayList(20); while(node != null){ @@ -361,7 +307,6 @@ public class TreeChangeEventImpl implements TreeChangeEvent{ for (final Map.Entry entry : changedElements.entrySet()) { final ASTNode changed = entry.getKey(); myChangedElements.put(changed, entry.getValue()); - insertAtList(changed); addToEqualsDepthList(depth, changed); compactChanges(changed, depth); } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java index a8ac05100c11..cee41867efd1 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public class CompositeElement extends TreeElement { return myModificationsCount; } - public Object clone() { + public CompositeElement clone() { CompositeElement clone = (CompositeElement)super.clone(); synchronized (PsiLock.LOCK) { @@ -109,8 +109,8 @@ public class CompositeElement extends TreeElement { PsiFile psiFile = null; boolean ok = ApplicationManager.getApplication().isWriteAccessAllowed() || Thread.holdsLock(START_OFFSET_LOCK) || - wrapper != null && !wrapper.isPhysical() || (fileElement = TreeUtil.getFileElement(this)) == null || + wrapper != null && !wrapper.isPhysical() || (psiFile = (PsiFile)fileElement.getPsi()) == null || psiFile instanceof DummyHolder || psiFile.getViewProvider() instanceof FreeThreadedFileViewProvider || @@ -612,7 +612,7 @@ public class CompositeElement extends TreeElement { this.lastChild = lastChild; } - public void addChild(@NotNull ASTNode child, final ASTNode anchorBefore) { + public void addChild(@NotNull ASTNode child, @Nullable final ASTNode anchorBefore) { LOG.assertTrue(anchorBefore == null || ((TreeElement)anchorBefore).getTreeParent() == this, "anchorBefore == null || anchorBefore.getTreeParent() == parent"); TreeUtil.ensureParsed(getFirstChildNode()); TreeUtil.ensureParsed(child); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositePsiElement.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositePsiElement.java index 9a135a13f673..591a5fc5a76c 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositePsiElement.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositePsiElement.java @@ -43,6 +43,14 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps protected CompositePsiElement(IElementType type) { super(type); + setPsi(this); + } + + @Override + public CompositePsiElement clone() { + CompositePsiElement clone = (CompositePsiElement)super.clone(); + clone.setPsi(clone); + return clone; } @NotNull @@ -259,11 +267,6 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps return this; } - @Override - protected PsiElement createPsiNoLock() { - return this; - } - private PsiElement addInnerBefore(final PsiElement element, final PsiElement anchor) throws IncorrectOperationException { CheckUtil.checkWritable(this); TreeElement elementCopy = ChangeUtil.copyToElement(element); @@ -276,3 +279,4 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps return this == another; } } + diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java index bd49759d983f..973a9a6dff20 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java @@ -146,38 +146,36 @@ public class LazyParseableElement extends CompositeElement { } private void ensureParsed() { - ASTNode parsedNode; + CharSequence text = myText(); + if (text == null) return; + + if (TreeUtil.getFileElement(this) == null) { + LOG.error("Chameleons must not be parsed till they're in file tree: " + this); + } + + ApplicationManager.getApplication().assertReadAccessAllowed(); + + ILazyParseableElementType type = (ILazyParseableElementType)getElementType(); + ASTNode parsedNode = type.parseContents(this); + + if (parsedNode == null && text.length() > 0) { + CharSequence diagText = ApplicationManager.getApplication().isInternal() ? text : ""; + LOG.error("No parse for a non-empty string: " + diagText + "; type=" + LogUtil.objectAndClass(type)); + } + synchronized (lock) { if (myText == null) return; if (rawFirstChild() != null) { LOG.error("Reentrant parsing?"); } - if (TreeUtil.getFileElement(this) == null) { - LOG.error("Chameleons must not be parsed till they're in file tree: " + this); - } - - ApplicationManager.getApplication().assertReadAccessAllowed(); - - ILazyParseableElementType type = (ILazyParseableElementType)getElementType(); - parsedNode = type.parseContents(this); - - if (parsedNode == null && myText.length() > 0) { - if (ApplicationManager.getApplication().isInternal() && !ApplicationManager.getApplication().isUnitTestMode()) { - LOG.error("No parse for a non-empty string: " + myText + "; type=" + LogUtil.objectAndClass(type)); - } else { - LOG.error("No parse for a non-empty string: type=" + LogUtil.objectAndClass(type)); - } - } - - //CharSequence text = myText; myText = null; if (parsedNode == null) return; - rawAddChildrenWithoutNotifications((TreeElement)parsedNode); + super.rawAddChildrenWithoutNotifications((TreeElement)parsedNode); //if (getNotCachedLength() != text.length()) { - // if (ApplicationManagerEx.getApplicationEx().isInternal()) { + // if (ApplicationManager.getApplication().isInternal()) { // LOG.error("Inconsistent reparse: type=" + getElementType() + "; text=" + text + "; treeText=" + getText()); // } else { // LOG.error("Inconsistent reparse: type=" + getElementType()); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseablePsiElement.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseablePsiElement.java index 6e930f422839..efc31d120b4c 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseablePsiElement.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseablePsiElement.java @@ -51,6 +51,14 @@ public class LazyParseablePsiElement extends LazyParseableElement implements Psi public LazyParseablePsiElement(@NotNull IElementType type, CharSequence buffer) { super(type, buffer); + setPsi(this); + } + + @Override + public LazyParseablePsiElement clone() { + LazyParseablePsiElement clone = (LazyParseablePsiElement)super.clone(); + clone.setPsi(clone); + return clone; } @NotNull @@ -72,7 +80,7 @@ public class LazyParseablePsiElement extends LazyParseableElement implements Psi for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (ReflectionCache.isInstance(cur, aClass)) result.add((T)cur); } - return result.toArray((T[]) Array.newInstance(aClass, result.size())); + return result.toArray((T[])Array.newInstance(aClass, result.size())); } public PsiElement getFirstChild() { @@ -287,11 +295,6 @@ public class LazyParseablePsiElement extends LazyParseableElement implements Psi return this; } - @Override - protected PsiElement createPsiNoLock() { - return this; - } - private PsiElement addInnerBefore(final PsiElement element, final PsiElement anchor) throws IncorrectOperationException { CheckUtil.checkWritable(this); TreeElement elementCopy = ChangeUtil.copyToElement(element); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxWithWidePopup.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxWithWidePopup.java index 9f211b15429e..9fbbfb59d7c2 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxWithWidePopup.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxWithWidePopup.java @@ -20,12 +20,13 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.util.ui.UIUtil; import javax.swing.*; -import java.util.Vector; import java.awt.*; +import java.util.Vector; public class ComboBoxWithWidePopup extends JComboBox { private boolean myLayingOut = false; + private int myMinLength = 20; public ComboBoxWithWidePopup(final ComboBoxModel aModel) { super(aModel); @@ -47,6 +48,23 @@ public class ComboBoxWithWidePopup extends JComboBox { public ComboBoxWithWidePopup() { } + + @SuppressWarnings("GtkPreferredJComboBoxRenderer") + @Override + public void setRenderer(ListCellRenderer renderer) { + super.setRenderer(new AdjustingListCellRenderer(this, renderer)); + } + + public void setMinLength(int minLength) { + myMinLength = minLength; + } + + /** + * @return min string len to show + */ + protected int getMinLength() { + return myMinLength; + } public void doLayout() { try { @@ -65,8 +83,46 @@ public class ComboBoxWithWidePopup extends JComboBox { } return size; } + + private Dimension _getSuperSize() { + return super.getSize(); + } protected Dimension getOriginalPreferredSize() { return getPreferredSize(); } + + private class AdjustingListCellRenderer implements ListCellRenderer { + JLabel myTempLabel; + private final ListCellRenderer myOldRenderer; + private final ComboBoxWithWidePopup myComboBox; + + public AdjustingListCellRenderer(ComboBoxWithWidePopup comboBox, ListCellRenderer oldRenderer) { + myComboBox = comboBox; + myOldRenderer = oldRenderer; + myTempLabel = new JLabel(); + if (oldRenderer instanceof JComponent) { + myTempLabel.setFont(((JComponent)oldRenderer).getFont()); + } + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + Object _value = value; + if (index == -1 && _value instanceof String && !myComboBox.isValid()) { + int minLength = getMinLength(); + + Dimension size = myComboBox._getSuperSize(); + String stringValue = (String)_value; + + if (size.width == 0) { + if (stringValue.length() > minLength) { + _value = stringValue.substring(0, minLength); + } + } + } + + return myOldRenderer.getListCellRendererComponent(list, _value, index, isSelected, cellHasFocus); + } + } } diff --git a/platform/platform-api/src/com/intellij/ui/TextFieldWithHistory.java b/platform/platform-api/src/com/intellij/ui/TextFieldWithHistory.java index 23f24de62f84..0baed3e769b4 100644 --- a/platform/platform-api/src/com/intellij/ui/TextFieldWithHistory.java +++ b/platform/platform-api/src/com/intellij/ui/TextFieldWithHistory.java @@ -15,7 +15,7 @@ */ package com.intellij.ui; -import com.intellij.openapi.ui.ComboBox; +import com.intellij.openapi.ui.ComboBoxWithWidePopup; import javax.swing.*; import javax.swing.event.DocumentListener; @@ -24,7 +24,7 @@ import java.awt.event.KeyListener; import java.util.ArrayList; import java.util.List; -public class TextFieldWithHistory extends ComboBox { +public class TextFieldWithHistory extends ComboBoxWithWidePopup { private int myHistorySize = 5; private final MyModel myModel; diff --git a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java index dc77ee485e98..ce2ed4ee054c 100644 --- a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java @@ -146,11 +146,11 @@ public class ProjectUtil { } if (!forceOpenInNewFrame && openProjects.length > 0) { - int exitCode = confirmOpenNewProject(); - if (exitCode == 0) { // "Yes" option + int exitCode = confirmOpenNewProject(false); + if (exitCode == 0) { // this window option if (!closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null; } - else if (exitCode != 1) { // not "No" + else if (exitCode != 1) { // not in a new window return null; } } @@ -177,11 +177,17 @@ public class ProjectUtil { return project; } - public static int confirmOpenNewProject() { + /** + * @return 0 - this window + * 1 - new window + * 2 - cancel + * @param isNewProject + */ + public static int confirmOpenNewProject(boolean isNewProject) { final GeneralSettings settings = GeneralSettings.getInstance(); if (settings.getConfirmOpenNewProject() == GeneralSettings.OPEN_PROJECT_ASK) { return Messages.showYesNoCancelDialog(IdeBundle.message("prompt.open.project.in.new.frame"), - IdeBundle.message("title.open.project"), + isNewProject ? IdeBundle.message("title.new.project") : IdeBundle.message("title.open.project"), IdeBundle.message("button.existingframe"), IdeBundle.message("button.newframe"), CommonBundle.getCancelButtonText(), Messages.getQuestionIcon(), diff --git a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java index e5b14e20d265..fe75759b4123 100644 --- a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java +++ b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java @@ -99,11 +99,11 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor { Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (!forceOpenInNewFrame && openProjects.length > 0) { - int exitCode = ProjectUtil.confirmOpenNewProject(); - if (exitCode == 1) { // "No" option + int exitCode = ProjectUtil.confirmOpenNewProject(false); + if (exitCode == 0) { // this window option if (!ProjectUtil.closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null; } - else if (exitCode != 0) { // not "Yes" + else if (exitCode != 1) { // not in a new window return null; } } diff --git a/platform/util/src/com/intellij/openapi/util/Computable.java b/platform/util/src/com/intellij/openapi/util/Computable.java index a6aa14fd99a4..72dd5b451a89 100644 --- a/platform/util/src/com/intellij/openapi/util/Computable.java +++ b/platform/util/src/com/intellij/openapi/util/Computable.java @@ -23,7 +23,6 @@ import org.jetbrains.annotations.Nullable; */ public interface Computable { - @Nullable T compute(); class PredefinedValueComputable implements Computable { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java index 051943e90f3f..792ca5bb5dd8 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java @@ -75,6 +75,7 @@ public class ChangesFragmentedDiffPanel implements Disposable { private boolean myCurrentHorizontal; private JPanel myTopPanel; + // todo here public ChangesFragmentedDiffPanel(final Project project, final FragmentedContent fragmentedContent, final LinkedList cache, String filePath) { myProject = project; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java index 6c5783fe3473..569a9f07ceda 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java @@ -202,23 +202,8 @@ public class FragmentedDiffRequestFromChange { private String notNullContentRevision(final ContentRevision cr) throws VcsException { if (cr == null) return ""; - final Ref ref = new Ref(); - final String s = new BackgroundSynchronousInvisibleComputable() { - @Override - protected String runImpl() { - try { - return cr.getContent(); - } - catch (VcsException e) { - ref.set(e); - return null; - } - } - }.compute(); - if (! ref.isNull()) { - throw ref.get(); - } - return s == null ? "" : s; + String content = cr.getContent(); + return content == null ? "" : content; } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsChangeDetailsManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsChangeDetailsManager.java index b7260836afff..fcd2b1381780 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsChangeDetailsManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsChangeDetailsManager.java @@ -26,12 +26,14 @@ import com.intellij.openapi.progress.BackgroundTaskQueue; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vcs.Details; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.VcsKey; +import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; import com.intellij.util.BeforeAfter; import com.intellij.util.containers.HashMap; import com.intellij.util.continuation.ModalityIgnorantBackgroundableTask; @@ -125,12 +127,11 @@ public class VcsChangeDetailsManager { @Override protected void doInAwtIfFail(Exception e) { - System.out.println("FAIL"); + VcsBalloonProblemNotifier.showOverChangesView(myProject, e.getMessage(), MessageType.ERROR); } @Override protected void doInAwtIfCancel() { - System.out.println("CANCEL"); } @Override diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java index b25577cdcefc..fe426da465ff 100644 --- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java +++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java @@ -130,7 +130,7 @@ public class XDebuggerTestUtil { node.myName = ((XNamedValue)value).getName(); } value.computePresentation(node, XValuePlace.TREE); - Assert.assertTrue(node.waitFor(TIMEOUT)); + Assert.assertTrue("timed out", node.waitFor(TIMEOUT)); return node; } diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeArgumentsIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeArgumentsIntention.java index c99213a881e3..9823e94505d7 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeArgumentsIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeArgumentsIntention.java @@ -16,6 +16,7 @@ package com.siyeh.ipp.types; import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import com.siyeh.ipp.base.Intention; import com.siyeh.ipp.base.PsiElementPredicate; @@ -45,9 +46,11 @@ public class ReplaceDiamondWithExplicitTypeArgumentsIntention extends Intention final StringBuilder text = new StringBuilder(); text.append(javaCodeReferenceElement.getQualifiedName()); text.append('<'); - final PsiType[] typeArguments = referenceParameterList.getTypeArguments(); + final PsiTypeElement[] typeElements = referenceParameterList.getTypeParameterElements(); + final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(typeElements[0], PsiNewExpression.class); + final PsiDiamondType.DiamondInferenceResult result = PsiDiamondType.resolveInferredTypesNoCheck(newExpression, newExpression); boolean first = true; - for (PsiType typeArgument : typeArguments) { + for (PsiType typeArgument : result.getInferredTypes()) { if (first) { first = false; } else { diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/AnonymousClass.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/AnonymousClass.java new file mode 100644 index 000000000000..7baa48df8d01 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/AnonymousClass.java @@ -0,0 +1,7 @@ +public interface Anonymous {} + +class Test { + public static void main(String[] args) { + Anonymous anon = new Anonymous<>() {}; + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/AnonymousClass_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/AnonymousClass_after.java new file mode 100644 index 000000000000..7218c605ba07 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/AnonymousClass_after.java @@ -0,0 +1,7 @@ +public interface Anonymous {} + +class Test { + public static void main(String[] args) { + Anonymous anon = new Anonymous() {}; + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamond.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamond.java new file mode 100644 index 000000000000..09b88455d476 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamond.java @@ -0,0 +1,7 @@ +public class MyClass {} + +class Test { + public static void main(String[] args) { + MyClass anon = new MyClass<>(); + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamond_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamond_after.java new file mode 100644 index 000000000000..4e230dcf5553 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ApplicableDiamond_after.java @@ -0,0 +1,7 @@ +public class MyClass {} + +class Test { + public static void main(String[] args) { + MyClass anon = new MyClass(); + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ExplicitTypeArgs.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ExplicitTypeArgs.java new file mode 100644 index 000000000000..08b91cee6a6c --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ExplicitTypeArgs.java @@ -0,0 +1,9 @@ +class Foo { + Foo(T t) {} +} + +class Test { + public static void main(String[] args) { + Foo c = new Foo<>(""); + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ExplicitTypeArgs_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ExplicitTypeArgs_after.java new file mode 100644 index 000000000000..0e1b659ed60d --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/diamond2explicit/ExplicitTypeArgs_after.java @@ -0,0 +1,9 @@ +class Foo { + Foo(T t) {} +} + +class Test { + public static void main(String[] args) { + Foo c = new Foo(""); + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeIntentionTest.java new file mode 100644 index 000000000000..e51a00b0667e --- /dev/null +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceDiamondWithExplicitTypeIntentionTest.java @@ -0,0 +1,43 @@ +/* + * 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.siyeh.ipp.types; + +import com.siyeh.IntentionPowerPackBundle; +import com.siyeh.ipp.IPPTestCase; + +public class ReplaceDiamondWithExplicitTypeIntentionTest extends IPPTestCase { + public void testAnonymousClass() { + doTest(); + } + + public void testApplicableDiamond() { + doTest(); + } + + public void testExplicitTypeArgs() { + doTest(); + } + + @Override + protected String getIntentionName() { + return IntentionPowerPackBundle.message("replace.diamond.with.explicit.type.arguments.intention.name"); + } + + @Override + protected String getRelativePath() { + return "types/diamond2explicit"; + } +} diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileActionGroup.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileActionGroup.java index cf180469efc6..105469459c98 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileActionGroup.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileActionGroup.java @@ -34,6 +34,7 @@ public class CreateResourceFileActionGroup extends DefaultActionGroup { a.add(new CreateTypedResourceFileAction("Layout", "layout", "LinearLayout")); a.add(new CreateTypedResourceFileAction("XML", "xml", "PreferenceScreen")); a.add(new CreateTypedResourceFileAction("Drawable", "drawable", "selector")); + a.add(new CreateTypedResourceFileAction("Color", "color", "selector", false, false)); a.add(new CreateTypedResourceFileAction("Values", "values", "resources", true, false)); a.add(new CreateTypedResourceFileAction("Menu", "menu", "menu", false, false)); a.add(new CreateTypedResourceFileAction("Animation", "anim", "set")); diff --git a/plugins/android/src/org/jetbrains/android/dom/manifest/AndroidManifestUtils.java b/plugins/android/src/org/jetbrains/android/dom/manifest/AndroidManifestUtils.java index a1ce9837da1d..b2e2e980b5a7 100644 --- a/plugins/android/src/org/jetbrains/android/dom/manifest/AndroidManifestUtils.java +++ b/plugins/android/src/org/jetbrains/android/dom/manifest/AndroidManifestUtils.java @@ -81,7 +81,7 @@ public class AndroidManifestUtils { else if (element instanceof Application) { Collections.addAll(strings, "activity", "service", "provider", "receiver", "uses-library"); } - else if (element instanceof Activity || element instanceof ActivityAlias) { + else if (element instanceof Activity || element instanceof ActivityAlias || element instanceof Receiver || element instanceof Service) { strings.add("intent-filter"); } else if (element instanceof IntentFilter) { diff --git a/plugins/android/src/org/jetbrains/android/dom/manifest/Receiver.java b/plugins/android/src/org/jetbrains/android/dom/manifest/Receiver.java index 8a824af1cf5a..770e7c5db6c4 100644 --- a/plugins/android/src/org/jetbrains/android/dom/manifest/Receiver.java +++ b/plugins/android/src/org/jetbrains/android/dom/manifest/Receiver.java @@ -21,6 +21,8 @@ import org.jetbrains.android.dom.AndroidAttributeValue; import org.jetbrains.android.dom.converters.PackageClassConverter; import org.jetbrains.android.util.AndroidUtils; +import java.util.List; + /** * @author yole */ @@ -31,4 +33,8 @@ public interface Receiver extends ApplicationComponent { @Convert(PackageClassConverter.class) @ExtendClass(AndroidUtils.RECEIVER_CLASS_NAME) AndroidAttributeValue getReceiverClass(); + + List getIntentFilters(); + + IntentFilter addIntentFilter(); } \ No newline at end of file diff --git a/plugins/android/src/org/jetbrains/android/dom/manifest/Service.java b/plugins/android/src/org/jetbrains/android/dom/manifest/Service.java index 22a8f8c01a97..c693755c7092 100644 --- a/plugins/android/src/org/jetbrains/android/dom/manifest/Service.java +++ b/plugins/android/src/org/jetbrains/android/dom/manifest/Service.java @@ -21,6 +21,8 @@ import org.jetbrains.android.dom.AndroidAttributeValue; import org.jetbrains.android.dom.converters.PackageClassConverter; import org.jetbrains.android.util.AndroidUtils; +import java.util.List; + /** * @author yole */ @@ -31,4 +33,8 @@ public interface Service extends ApplicationComponent { @Convert(PackageClassConverter.class) @ExtendClass(AndroidUtils.SERVICE_CLASS_NAME) AndroidAttributeValue getServiceClass(); + + List getIntentFilters(); + + IntentFilter addIntentFilter(); } diff --git a/plugins/android/testData/dom/manifest/intentsCompletion1.xml b/plugins/android/testData/dom/manifest/intentsCompletion1.xml new file mode 100644 index 000000000000..053aa4ed1aec --- /dev/null +++ b/plugins/android/testData/dom/manifest/intentsCompletion1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/manifest/intentsCompletion1_after.xml b/plugins/android/testData/dom/manifest/intentsCompletion1_after.xml new file mode 100644 index 000000000000..a92ef89a7be8 --- /dev/null +++ b/plugins/android/testData/dom/manifest/intentsCompletion1_after.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/manifest/intentsCompletion2.xml b/plugins/android/testData/dom/manifest/intentsCompletion2.xml new file mode 100644 index 000000000000..2d32d88eca25 --- /dev/null +++ b/plugins/android/testData/dom/manifest/intentsCompletion2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/manifest/intentsCompletion2_after.xml b/plugins/android/testData/dom/manifest/intentsCompletion2_after.xml new file mode 100644 index 000000000000..8eb309fdb2e8 --- /dev/null +++ b/plugins/android/testData/dom/manifest/intentsCompletion2_after.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidManifestDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidManifestDomTest.java index f5f3268b6bfd..b43a7a8db03b 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidManifestDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidManifestDomTest.java @@ -154,4 +154,12 @@ public class AndroidManifestDomTest extends AndroidDomTest { copyFileToProject("MyActivity.java", "src/p1/p2/MyActivity.java"); doTestCompletion(false); } + + public void testIntentsCompletion1() throws Throwable { + doTestCompletion(); + } + + public void testIntentsCompletion2() throws Throwable { + doTestCompletion(); + } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/IOFilesBasedDirectoryPruner.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/IOFilesBasedDirectoryPruner.java index 7c3e65de4abe..9561315a5bf4 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/IOFilesBasedDirectoryPruner.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/IOFilesBasedDirectoryPruner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,9 +60,8 @@ public class IOFilesBasedDirectoryPruner { final File[] subFiles = file.listFiles(); if (subFiles == null) return true; - boolean canPrune = true; - if (!new File(file, CvsUtil.CVS).isDirectory()) return false; + boolean canPrune = true; for (File subFile : subFiles) { if (!isAdminDirectory(subFile)) { canPrune &= execute(subFile); @@ -74,7 +73,6 @@ public class IOFilesBasedDirectoryPruner { if (!canPrune) return false; if (!FileUtil.delete(file)) return false; - CvsUtil.removeEntryFor(file); return true; } @@ -87,9 +85,8 @@ public class IOFilesBasedDirectoryPruner { catch (IOException e) { return false; } - final Collection entries = entriesHandler.getEntries().getEntries(); - for (final Object entry1 : entries) { - Entry entry = (Entry)entry1; + final Collection entries = entriesHandler.getEntries().getEntries(); + for (final Entry entry : entries) { if (!entry.isDirectory()) return true; } return false; @@ -98,5 +95,4 @@ public class IOFilesBasedDirectoryPruner { private static boolean isAdminDirectory(final File file) { return file.isDirectory() && file.getName().equals(CvsUtil.CVS); } - } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java index d8a95c75f452..409d4d691036 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/UpdateHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,31 +19,20 @@ import com.intellij.CvsBundle; import com.intellij.cvsSupport2.CvsVcs2; import com.intellij.cvsSupport2.actions.update.UpdateSettings; import com.intellij.cvsSupport2.config.CvsConfiguration; -import com.intellij.cvsSupport2.connections.CvsRootProvider; import com.intellij.cvsSupport2.cvsExecution.ModalityContext; -import com.intellij.cvsSupport2.cvsoperations.common.FindAllRoots; -import com.intellij.cvsSupport2.cvsoperations.common.FindAllRootsHelper; import com.intellij.cvsSupport2.cvsoperations.common.PostCvsActivity; import com.intellij.cvsSupport2.cvsoperations.cvsUpdate.MergedWithConflictProjectOrModuleFile; import com.intellij.cvsSupport2.cvsoperations.cvsUpdate.UpdateOperation; import com.intellij.cvsSupport2.cvsoperations.cvsUpdate.ui.CorruptedProjectFilesDialog; -import com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException; -import com.intellij.openapi.progress.ProcessCanceledException; -import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.update.FileGroup; import com.intellij.openapi.vcs.update.UpdatedFiles; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Options; -import com.intellij.util.containers.HashSet; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.netbeans.lib.cvsclient.file.ICvsFileSystem; -import java.io.File; import java.util.ArrayList; import java.util.Collection; @@ -52,18 +41,14 @@ import java.util.Collection; */ public class UpdateHandler extends CommandCvsHandler implements PostCvsActivity { private final FilePath[] myFiles; - private final Collection myRoots = new ArrayList(); - private final Collection myNotProcessedRepositories = new HashSet(); - private double myDirectoriesToBeProcessedCount; - private static final CvsMessagePattern UPDATE_PATTERN = new CvsMessagePattern(new String[]{"cvs server: Updating ", "*"}, 2); private final Project myProject; private final Collection myCorruptedFiles = new ArrayList(); private final UpdatedFiles myUpdatedFiles; private final UpdateSettings myUpdateSettings; public UpdateHandler(FilePath[] files, UpdateSettings updateSettings, @NotNull Project project, @NotNull UpdatedFiles updatedFiles) { - super(CvsBundle.message("operation.name.update"), new UpdateOperation(new FilePath[0], updateSettings, project), + super(CvsBundle.message("operation.name.update"), new UpdateOperation(files, updateSettings, project), FileSetToBeUpdated.selectedFiles(files)); myFiles = files; myProject = project; @@ -71,65 +56,21 @@ public class UpdateHandler extends CommandCvsHandler implements PostCvsActivity myUpdateSettings = updateSettings; } - public void beforeLogin() { - try { - super.beforeLogin(); - FindAllRoots findAllRoots = new FindAllRoots(myProject); - final FilePath[] filteredFiles = FindAllRootsHelper.findVersionedUnder(myFiles); - myRoots.addAll(findAllRoots.executeOn(filteredFiles)); - myNotProcessedRepositories.addAll(findAllRoots.getDirectoriesToBeUpdated()); - myDirectoriesToBeProcessedCount = myNotProcessedRepositories.size(); - for(VirtualFile file: myRoots) { - if (getValidCvsRoot(file) != null) { - ((UpdateOperation)myCvsOperation).addFile(file); - } - } - } - catch (ProcessCanceledException ex) { - myIsCanceled = true; - } - - } - - @Nullable - private static CvsRootProvider getValidCvsRoot(final VirtualFile file) { - try { - return CvsRootProvider.createOn(new File(file.getPath())); - } - catch (CannotFindCvsRootException e) { - return null; - } - } - - public void addFileMessage(String message, ICvsFileSystem cvsFileSystem) { - super.addFileMessage(message, cvsFileSystem); - ProgressIndicator progress = getProgress(); - if (progress == null) return; - if (UPDATE_PATTERN.matches(message)) { - String relativeFileName = UPDATE_PATTERN.getRelativeFileName(message); - myNotProcessedRepositories.remove(cvsFileSystem.getLocalFileSystem().getFile(relativeFileName)); - int notProcessedSize = myNotProcessedRepositories.size(); - progress.setFraction(0.5 + (myDirectoriesToBeProcessedCount - notProcessedSize) / (2 * myDirectoriesToBeProcessedCount)); - } - } - public void registerCorruptedProjectOrModuleFile(MergedWithConflictProjectOrModuleFile mergedWithConflictProjectOrModuleFile) { myCorruptedFiles.add(mergedWithConflictProjectOrModuleFile); } protected void onOperationFinished(ModalityContext modalityContext) { - if (myUpdateSettings.getPruneEmptyDirectories()) { final IOFilesBasedDirectoryPruner pruner = new IOFilesBasedDirectoryPruner(ProgressManager.getInstance().getProgressIndicator()); - for (final VirtualFile myRoot : myRoots) { - pruner.addFile(new File(myRoot.getPath())); + for (FilePath file : myFiles) { + pruner.addFile(file.getIOFile()); } - pruner.execute(); } if (!myCorruptedFiles.isEmpty()) { - int showOptions = CvsConfiguration.getInstance(myProject).SHOW_CORRUPTED_PROJECT_FILES; + final int showOptions = CvsConfiguration.getInstance(myProject).SHOW_CORRUPTED_PROJECT_FILES; if (showOptions == Options.PERFORM_ACTION_AUTOMATICALLY) { for (final MergedWithConflictProjectOrModuleFile myCorruptedFile : myCorruptedFiles) { @@ -142,7 +83,6 @@ public class UpdateHandler extends CommandCvsHandler implements PostCvsActivity new CorruptedProjectFilesDialog(myProject, myCorruptedFiles).show(); } }, myProject); - } final VcsKey vcsKey = CvsVcs2.getKey(); @@ -154,9 +94,7 @@ public class UpdateHandler extends CommandCvsHandler implements PostCvsActivity myUpdatedFiles.getGroupById(FileGroup.MODIFIED_ID).add(myCorruptedFile.getOriginal().getPath(), vcsKey, null); } } - } - } protected PostCvsActivity getPostActivityHandler() { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/CvsCommandOperation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/CvsCommandOperation.java index 23b69fcadf33..cc3029498871 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/CvsCommandOperation.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/CvsCommandOperation.java @@ -255,6 +255,8 @@ public abstract class CvsCommandOperation extends CvsOperation implements IFileI try { command.execute(requestProcessor, eventManager, eventManager, clientEnvironment, new IProgressViewer() { public void setProgress(double value) { + ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); + if (progressIndicator != null) progressIndicator.setFraction(value); } }); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/FindAllRoots.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/FindAllRoots.java deleted file mode 100644 index fe743b1832ce..000000000000 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/FindAllRoots.java +++ /dev/null @@ -1,184 +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.cvsSupport2.cvsoperations.common; - -import com.intellij.CvsBundle; -import com.intellij.cvsSupport2.CvsUtil; -import com.intellij.cvsSupport2.application.CvsEntriesManager; -import com.intellij.cvsSupport2.connections.CvsEnvironment; -import com.intellij.cvsSupport2.util.CvsVfsUtil; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.vcs.FilePath; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VirtualFile; - -import java.io.File; -import java.util.*; - -/** - * author: lesya - */ - -public class FindAllRoots { - private final CvsEntriesManager myManager = CvsEntriesManager.getInstance(); - private int myProcessedFiles; - private int mySuitableFiles; - private final Collection myRepositories = new HashSet(); - - private final Collection myResult = new ArrayList(); - private final ProgressIndicator myProgress; - private final ProjectRootManager myProjectRootManager; - - public FindAllRoots(Project project) { - myProgress = ProgressManager.getInstance().getProgressIndicator(); - myProjectRootManager = ProjectRootManager.getInstance(project); - } - - public Collection executeOn(final FilePath[] roots) { - final Collection rootsWithoutIntersections = getRootsWithoutIntersections(roots); - setText(CvsBundle.message("progress.text.searching.for.cvs.root")); - myManager.lockSynchronizationActions(); - mySuitableFiles = calcVirtualFilesUnderCvsIn(rootsWithoutIntersections) * 2; - myProcessedFiles = 0; - try { - ApplicationManager.getApplication().runReadAction(new Runnable() { - public void run() { - for (final FilePath file : rootsWithoutIntersections) { - VirtualFile virtualFile = file.getVirtualFile(); - if (virtualFile != null) { - myResult.add(virtualFile); - process(virtualFile); - } - else { - VirtualFile virtualFileParent = file.getVirtualFileParent(); - if (virtualFileParent != null) { - myResult.add(virtualFileParent); - } - } - } - } - }); - } - finally { - myManager.unlockSynchronizationActions(); - } - - return myResult; - } - - private int calcVirtualFilesUnderCvsIn(Collection rootsWithoutIntersections) { - int result = 0; - for (final FilePath cvsFileWrapper : rootsWithoutIntersections) { - if (!cvsFileWrapper.isDirectory()) { - result += 1; - } - else { - result += calcVirtualFilesUnderCvsIn(cvsFileWrapper.getVirtualFile()); - } - } - return result; - } - - private int calcVirtualFilesUnderCvsIn(VirtualFile file) { - if (file == null || !file.isDirectory()) return 0; - if (!myProjectRootManager.getFileIndex().isInContent(file)) return 0; - int result = 0; - if (file.findChild(CvsUtil.CVS) == null) return result; - result += 1; - VirtualFile[] children = file.getChildren(); - if (children == null) return result; - for (VirtualFile child : children) { - if (child.getName() == CvsUtil.CVS) continue; - result += calcVirtualFilesUnderCvsIn(child); - } - return result; - } - - private static Collection getRootsWithoutIntersections(FilePath[] roots) { - ArrayList result = new ArrayList(); - List list = Arrays.asList(roots); - Collections.sort(list, new Comparator() { - public int compare(FilePath file, FilePath file1) { - return file.getPath().compareTo(file1.getPath()); - } - }); - FilePath[] sortedRoots = list.toArray(new FilePath[list.size()]); - for (int i = 0; i < sortedRoots.length; i++) { - FilePath root = sortedRoots[i]; - if (i == 0) { - result.add(root); - } - else { - FilePath prevRoot = result.isEmpty() ? null : result.get(result.size() - 1); - if ((prevRoot == null) || ! VfsUtil.isAncestor(prevRoot.getIOFile(), root.getIOFile(), false)){ - result.add(root); - } - } - } - - return result; - } - - private void setText(final String text) { - if (myProgress == null) return; - myProgress.setText(text); - ProgressManager.checkCanceled(); - } - - private void setText2(final String text) { - if (myProgress == null) return; - myProgress.setText2(text); - ProgressManager.checkCanceled(); - } - - private void process(VirtualFile root) { - if (!myProjectRootManager.getFileIndex().isInContent(root)) return; - setText2(CvsVfsUtil.getPresentablePathFor(root)); - myProcessedFiles++; - setFraction(); - VirtualFile[] children = root.getChildren(); - if (children == null) return; - CvsEnvironment parentEnv = myManager.getCvsConnectionSettingsFor(root); - if (!parentEnv.isValid()) return; - myManager.cacheCvsAdminInfoIn(root); - myRepositories.add(CvsVfsUtil.getFileFor(root)); - for (VirtualFile child : children) { - if (!child.isDirectory()) continue; - if (!myProjectRootManager.getFileIndex().isInContent(child)) continue; - CvsEnvironment childEnv = myManager.getCvsConnectionSettingsFor(child); - if (childEnv == null || !childEnv.isValid()) continue; - if (!childEnv.equals(parentEnv)) { - myResult.add(child); - } - process(child); - } - } - - private void setFraction() { - if (myProgress == null) return; - myProgress.setFraction((double)myProcessedFiles / (double)mySuitableFiles); - ProgressManager.checkCanceled(); - } - - public Collection getDirectoriesToBeUpdated() { - return myRepositories; - } - -} diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsImport/ImportOperation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsImport/ImportOperation.java index 303232aa5759..78307f6235d7 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsImport/ImportOperation.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsImport/ImportOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.intellij.cvsSupport2.cvsoperations.cvsImport; +import com.intellij.CvsBundle; import com.intellij.cvsSupport2.connections.CvsEnvironment; import com.intellij.cvsSupport2.connections.CvsRootProvider; import com.intellij.cvsSupport2.cvsoperations.common.CvsCommandOperation; @@ -42,20 +43,21 @@ public class ImportOperation extends CvsCommandOperation { } protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) { - ImportCommand result = new ImportCommand(); + final ImportCommand result = new ImportCommand(); myDetails.prepareCommand(result); return result; } public static ImportOperation createTestInstance(File sourceLocation, CvsEnvironment env) { - ImportDetails details = new ImportDetails(sourceLocation, com.intellij.CvsBundle.message("import.defaults.vendor"), - com.intellij.CvsBundle.message("import.defaults.release_tag"), - com.intellij.CvsBundle.message("import.defaults.log.message"), - sourceLocation.getName(), env, new ArrayList(), new IIgnoreFileFilter(){ - public boolean shouldBeIgnored(AbstractFileObject abstractFileObject, ICvsFileSystem cvsFileSystem) { - return false; - } - }); + final ImportDetails details = new ImportDetails(sourceLocation, CvsBundle.message("import.defaults.vendor"), + CvsBundle.message("import.defaults.release_tag"), + CvsBundle.message("import.defaults.log.message"), + sourceLocation.getName(), env, new ArrayList(), + new IIgnoreFileFilter(){ + public boolean shouldBeIgnored(AbstractFileObject abstractFileObject, ICvsFileSystem cvsFileSystem) { + return false; + } + }); return new ImportOperation(details); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsUpdate/UpdateOperation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsUpdate/UpdateOperation.java index dbe050e173cc..28c65e1b8f29 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsUpdate/UpdateOperation.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsUpdate/UpdateOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,18 +46,21 @@ import java.io.File; public class UpdateOperation extends CvsOperationOnFiles { private final UpdateSettings myUpdateSettings; - private final Project myProject; private final ProjectLevelVcsManager myVcsManager; private final CvsVcs2 myVcs; public UpdateOperation(FilePath[] files, UpdateSettings updateSettings, Project project) { myUpdateSettings = updateSettings; - myProject = project; myVcsManager = ProjectLevelVcsManager.getInstance(project); myVcs = CvsVcs2.getInstance(project); addAllFiles(files); } + public UpdateOperation(FilePath[] files, String branchName, + boolean makeNewFilesReadOnly, Project project) { + this(files, new UpdateByBranchUpdateSettings(branchName, makeNewFilesReadOnly), project); + } + public void addAllFiles(FilePath[] files) { for (FilePath file : files) { addFile(file.getIOFile()); @@ -74,17 +77,8 @@ public class UpdateOperation extends CvsOperationOnFiles { return "update"; } - public UpdateOperation(UpdateSettings updateSettings, Project project) { - this(new FilePath[0], updateSettings, project); - } - - public UpdateOperation(FilePath[] files, String branchName, - boolean makeNewFilesReadOnly, Project project) { - this(files, new UpdateByBranchUpdateSettings(branchName, makeNewFilesReadOnly), project); - } - protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) { - UpdateCommand updateCommand = new UpdateCommand(); + final UpdateCommand updateCommand = new UpdateCommand(); addFilesToCommand(root, updateCommand); //updateCommand.setPruneDirectories(myUpdateSettings.getPruneEmptyDirectories()); updateCommand.setCleanCopy(myUpdateSettings.getCleanCopy()); @@ -103,7 +97,6 @@ public class UpdateOperation extends CvsOperationOnFiles { return updateCommand; } - public void modifyOptions(GlobalOptions options) { super.modifyOptions(options); options.setDoNoChanges(myUpdateSettings.getDontMakeAnyChanges()); @@ -141,7 +134,7 @@ public class UpdateOperation extends CvsOperationOnFiles { if (ignoreFileFilterFromSuper.shouldBeIgnored(abstractFileObject, cvsFileSystem)) { return true; } - VirtualFile fileByIoFile = CvsVfsUtil.findFileByIoFile(cvsFileSystem.getLocalFileSystem().getFile(abstractFileObject)); + final VirtualFile fileByIoFile = CvsVfsUtil.findFileByIoFile(cvsFileSystem.getLocalFileSystem().getFile(abstractFileObject)); return fileByIoFile != null && myVcsManager.getVcsFor(fileByIoFile) != myVcs; } }; diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/importcmd/ImportCommand.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/importcmd/ImportCommand.java index baa72e942a77..6faabea98f6d 100644 --- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/importcmd/ImportCommand.java +++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/importcmd/ImportCommand.java @@ -40,13 +40,9 @@ import java.util.*; */ public final class ImportCommand extends Command { - // Constants ============================================================== - - @NonNls public static final String EXAM_DIR = "server: Importing "; - // Fields ================================================================= - private final Map wrapperMap = new HashMap(); + private final Map wrapperMap = new HashMap(); private String logMessage; private String module; private String releaseTag; @@ -56,8 +52,7 @@ public final class ImportCommand extends Command { // Setup ================================================================== - public ImportCommand() { - } + public ImportCommand() {} // Implemented ============================================================ @@ -110,7 +105,7 @@ public final class ImportCommand extends Command { } public String getCvsCommandLine() { - @NonNls final StringBuffer cvsArguments = new StringBuffer("import "); + @NonNls final StringBuilder cvsArguments = new StringBuilder("import "); cvsArguments.append(getCvsArguments()); cvsArguments.append(' '); @@ -199,7 +194,7 @@ public final class ImportCommand extends Command { // Utils ================================================================== private String getCvsArguments() { - @NonNls final StringBuffer cvsArguments = new StringBuffer(); + @NonNls final StringBuilder cvsArguments = new StringBuilder(); cvsArguments.append("-m \""); cvsArguments.append(CommandUtils.getMessageNotNull(getLogMessage())); cvsArguments.append("\" "); @@ -215,10 +210,8 @@ public final class ImportCommand extends Command { cvsArguments.append(" "); } if (wrapperMap.size() > 0) { - final Iterator it = wrapperMap.keySet().iterator(); - while (it.hasNext()) { - final SimpleStringPattern pattern = (SimpleStringPattern)it.next(); - final KeywordSubstitution keywordSubstitutionOptions = (KeywordSubstitution)wrapperMap.get(pattern); + for (final SimpleStringPattern pattern : wrapperMap.keySet()) { + final KeywordSubstitution keywordSubstitutionOptions = wrapperMap.get(pattern); cvsArguments.append("-W "); cvsArguments.append(pattern.toString()); cvsArguments.append(" -k '"); @@ -232,15 +225,14 @@ public final class ImportCommand extends Command { /** * Adds requests for specified wrappers to the specified requestList. */ - private static void addWrapperRequests(Requests requests, Map wrapperMap) { + private static void addWrapperRequests(Requests requests, Map wrapperMap) { // override the server's ignore list requests.addArgumentRequest("-I !"); - for (Iterator it = wrapperMap.keySet().iterator(); it.hasNext();) { - final SimpleStringPattern pattern = (SimpleStringPattern)it.next(); - final KeywordSubstitution keywordSubstitutionOptions = (KeywordSubstitution)wrapperMap.get(pattern); + for (final SimpleStringPattern pattern : wrapperMap.keySet()) { + final KeywordSubstitution keywordSubstitutionOptions = wrapperMap.get(pattern); - @NonNls final StringBuffer buffer = new StringBuffer(); + @NonNls final StringBuilder buffer = new StringBuilder(); buffer.append(pattern.toString()); buffer.append(" -k '"); buffer.append(keywordSubstitutionOptions.toString()); @@ -270,11 +262,9 @@ public final class ImportCommand extends Command { return; } - final List subdirectories = new ArrayList(); - - for (int i = 0; i < files.length; i++) { - final File file = files[i]; + final List subdirectories = new ArrayList(); + for (final File file : files) { if (file.isDirectory()) { final DirectoryObject subDirObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getDirectoryObject(file); @@ -300,8 +290,7 @@ public final class ImportCommand extends Command { } } - for (Iterator it = subdirectories.iterator(); it.hasNext();) { - final File subdirectory = (File)it.next(); + for (final File subdirectory : subdirectories) { addFileRequests(subdirectory, requests, requestProcessor, clientEnvironment); } } @@ -324,10 +313,9 @@ public final class ImportCommand extends Command { private KeywordSubstitution getKeywordSubstMode(String fileName) { KeywordSubstitution keywordSubstMode = getKeywordSubstitutionOption(); - for (Iterator it = wrapperMap.keySet().iterator(); it.hasNext();) { - final SimpleStringPattern pattern = (SimpleStringPattern)it.next(); + for (final SimpleStringPattern pattern : wrapperMap.keySet()) { if (pattern.doesMatch(fileName)) { - keywordSubstMode = (KeywordSubstitution)wrapperMap.get(pattern); + keywordSubstMode = wrapperMap.get(pattern); break; } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleConfigurable.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleConfigurable.java index 5c6506f7fe94..26ec00ff440c 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleConfigurable.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleConfigurable.java @@ -142,6 +142,9 @@ public class GradleConfigurable implements SearchableConfigurable { if (myGradleHomeSettingType == GradleHomeSettingType.EXPLICIT_INCORRECT) { new DelayedBalloonInfo(MessageType.ERROR, myGradleHomeSettingType).run(); } + else { + myAlarm.cancelAllRequests(); + } myGradleHomeComponent.setPath(valueToUse); return; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java index f2d267b4c9b3..6bb55ed4d9a4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java @@ -202,7 +202,9 @@ public class GroovyCompiler extends GroovyCompilerBase { final CompilerManager compilerManager = CompilerManager.getInstance(myProject); Set modules = new HashSet(); for (VirtualFile file : files) { - if (scriptExtensions.contains(file.getExtension()) || compilerManager.isExcludedFromCompilation(file)) { + if (scriptExtensions.contains(file.getExtension()) || + compilerManager.isExcludedFromCompilation(file) || + CompilerConfiguration.getInstance(myProject).isResourceFile(file)) { continue; } diff --git a/xml/impl/src/com/intellij/codeInsight/template/zencoding/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/zencoding/ZenCodingTemplate.java index e0e607e978c9..a63e79ad3075 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/zencoding/ZenCodingTemplate.java +++ b/xml/impl/src/com/intellij/codeInsight/template/zencoding/ZenCodingTemplate.java @@ -829,7 +829,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate { myIndex++; token = nextToken(); if (token != ZenCodingTokens.EQ) { - return null; + return new Pair(name, ""); } myIndex++; diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java index eb920c654a50..38d8cedcecf0 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java @@ -31,6 +31,7 @@ import com.intellij.psi.*; import com.intellij.psi.impl.PsiCachedValueImpl; import com.intellij.psi.impl.meta.MetaRegistry; import com.intellij.psi.impl.source.html.dtd.HtmlNSDescriptorImpl; +import com.intellij.psi.impl.source.tree.CompositePsiElement; import com.intellij.psi.impl.source.tree.TreeElement; import com.intellij.psi.meta.PsiMetaData; import com.intellij.psi.meta.PsiMetaOwner; @@ -287,7 +288,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { return descriptor; } - public Object clone() { + public CompositePsiElement clone() { HashMap> cacheStrict = new HashMap>( myDefaultDescriptorsCacheStrict );