diff --git a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java index 5e795edd03bb..c31dcd5023fa 100644 --- a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java @@ -29,7 +29,10 @@ import com.intellij.psi.xml.XmlText; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; public class TargetElementUtil extends TargetElementUtilBase { public static final int NEW_AS_CONSTRUCTOR = 0x04; @@ -256,7 +259,8 @@ public class TargetElementUtil extends TargetElementUtilBase { psiClass = PsiTreeUtil.getParentOfType((PsiReferenceExpression)reference, PsiClass.class); } final PsiClass containingClass = ((PsiMember)element).getContainingClass(); - return psiClass != null && containingClass != null && containingClass.isInheritor(psiClass, true); + if (containingClass == psiClass) return true; + return psiClass != null && containingClass != null && (containingClass.isInheritor(psiClass, true) || psiClass.isInheritor(containingClass, true)); } }); } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCharFilter.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCharFilter.java index 2e79314ce444..8c7e707f002a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCharFilter.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCharFilter.java @@ -115,7 +115,7 @@ public class JavaCharFilter extends CharFilter { return Result.HIDE_LOOKUP; } - if ((c == '[' || c == '<' || c == '.' || c == ' ' || c == '(') && + if ((c == '[' || c == '<' || c == '.' || c == ' ' || c == '(' || c == ',') && isNonImportedClassEntered((LookupImpl)lookup, c == '.')) { return Result.HIDE_LOOKUP; } 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 e96d2c8f93df..f647004465c1 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 @@ -874,23 +874,10 @@ public class GenericsHighlightUtil { @Nullable public static HighlightInfo checkGenericArrayCreation(PsiElement element, PsiType type) { if (type instanceof PsiArrayType) { - PsiType componentType = type.getDeepComponentType(); - if (componentType instanceof PsiClassType) { - final PsiClassType classType = (PsiClassType)componentType; - PsiType[] parameters = classType.getParameters(); - for (PsiType parameter : parameters) { - if (!(parameter instanceof PsiWildcardType) || ((PsiWildcardType)parameter).getBound() != null) { - return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, - element, - JavaErrorMessages.message("generic.array.creation")); - } - } - final PsiClass resolved = ((PsiClassType)PsiUtil.convertAnonymousToBaseType(classType)).resolve(); - if (resolved instanceof PsiTypeParameter) { - return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, - element, - JavaErrorMessages.message("generic.array.creation")); - } + if (!isReifiableType(((PsiArrayType)type).getComponentType())) { + return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, + element, + JavaErrorMessages.message("generic.array.creation")); } } @@ -1179,7 +1166,18 @@ public class GenericsHighlightUtil { if (resolved instanceof PsiTypeParameter) { return false; } - return parameters.length == 0; + if (parameters.length == 0) { + if (resolved != null) { + final PsiClass containingClass = resolved.getContainingClass(); + if (containingClass != null) { + final PsiTypeParameter[] containingClassTypeParameters = containingClass.getTypeParameters(); + if (containingClassTypeParameters.length > 0) { + return false; + } + } + } + return true; + } } return false; diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java index 762e04cb600d..7225079c2220 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java @@ -472,7 +472,7 @@ public class OverrideImplementUtil { if (returnType == null) { returnType = PsiType.VOID; } - Properties properties = new Properties(); + Properties properties = FileTemplateManager.getInstance().getDefaultProperties(targetClass.getProject()); properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, returnType.getPresentableText()); properties.setProperty(FileTemplate.ATTRIBUTE_DEFAULT_RETURN_VALUE, PsiTypesUtil.getDefaultValueOfType(returnType)); properties.setProperty(FileTemplate.ATTRIBUTE_CALL_SUPER, callSuper(originalMethod, result)); diff --git a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java index 49134d57af49..4c613bb09245 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java @@ -966,10 +966,15 @@ public final class PsiUtil extends PsiUtilCore { } public static boolean isExtensionMethod(@Nullable final PsiMethod method) { - if (method == null) return false; + return findExtensionMethodMarker(method) != null; + } + + @Nullable + public static PsiJavaToken findExtensionMethodMarker(@Nullable final PsiMethod method) { + if (method == null) return null; final PsiCodeBlock body = method.getBody(); - if (body == null) return false; + if (body == null) return null; final PsiElement previous = PsiTreeUtil.skipSiblingsBackward(body, PsiComment.class, PsiWhiteSpace.class); - return isJavaToken(previous, JavaTokenType.DEFAULT_KEYWORD); + return previous instanceof PsiJavaToken && isJavaToken(previous, JavaTokenType.DEFAULT_KEYWORD) ? (PsiJavaToken)previous : null; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ReferenceTypeParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ReferenceTypeParams.java index 7148d6e6cd1a..0ef970a9c10d 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ReferenceTypeParams.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ReferenceTypeParams.java @@ -138,4 +138,10 @@ class ClassLiteral { Object c5 = List[].class; Object c6 = List.class; } +} + +class Outer { + final Inner[] i = new Inner[10]; + class Inner { + } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index 8337e7219d03..e1dff276da9b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -1331,6 +1331,14 @@ class Foo { myFixture.checkResult('class ') } + public void "test check for class existing globally when typing comma"() { + myFixture.addClass('package p; public class XYZ {}') + myFixture.addClass('public class XYZAspect {}') + myFixture.configureByText 'a.java', 'class Foo extends Map' + type '' + myFixture.checkResult 'class Foo extends Map' + } + void joinCompletion() { myTester.joinCompletion() } diff --git a/platform/indexing-impl/src/com/intellij/ide/highlighter/custom/AbstractCustomLexer.java b/platform/indexing-impl/src/com/intellij/ide/highlighter/custom/AbstractCustomLexer.java index 5ec0ecbe4d4d..f04851053b7b 100644 --- a/platform/indexing-impl/src/com/intellij/ide/highlighter/custom/AbstractCustomLexer.java +++ b/platform/indexing-impl/src/com/intellij/ide/highlighter/custom/AbstractCustomLexer.java @@ -77,6 +77,9 @@ public class AbstractCustomLexer extends LexerBase { for (TokenParser tokenParser : myTokenParsers) { if (tokenParser.hasToken(myPosition)) { tokenParser.getTokenInfo(myCurrentToken); + if (myCurrentToken.getEnd() <= myCurrentToken.getStart()) { + throw new AssertionError(tokenParser); + } tokenFound = true; break; } diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java index c3b7f3d1bc28..e5f03b9a354a 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java @@ -575,9 +575,11 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { sink.put(OpenFileDescriptor.NAVIGATE_IN_EDITOR, myConsoleEditor); return; } - FileEditorManager editorManager = FileEditorManager.getInstance(getProject()); - final Object o = ((FileEditorManagerImpl)editorManager).getData(key.getName(), myConsoleEditor, myVirtualFile); - sink.put(key, o); + else if (getProject().isInitialized()) { + FileEditorManager editorManager = FileEditorManager.getInstance(getProject()); + final Object o = ((FileEditorManagerImpl)editorManager).getData(key.getName(), myConsoleEditor, myVirtualFile); + sink.put(key, o); + } } private void installEditorFactoryListener() { diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java index 5717d694bc35..c11a61eba433 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java +++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java @@ -53,6 +53,10 @@ public class ConfigurableEP extends AbstractExtensionPointBean { @Attribute("id") public String id; + + @Attribute("nonDefaultProject") + public boolean nonDefaultProject; + /** * @deprecated use '{@link #instanceClass instance}' or '{@link #providerClass provider}' attribute instead */ diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java index 1adc8957329e..2998045167dc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java @@ -15,10 +15,7 @@ */ package com.intellij.openapi.options.ex; -import com.intellij.openapi.options.Configurable; -import com.intellij.openapi.options.ConfigurableEP; -import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.options.SearchableConfigurable; +import com.intellij.openapi.options.*; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nls; @@ -45,6 +42,11 @@ public class ConfigurableWrapper implements SearchableConfigurable, Configurable (configurable instanceof ConfigurableWrapper && ((ConfigurableWrapper)configurable).getConfigurable() instanceof NoScroll); } + public static boolean isNonDefaultProject(Configurable configurable) { + return configurable instanceof NonDefaultProjectConfigurable || + (configurable instanceof ConfigurableWrapper && ((ConfigurableWrapper)configurable).myEp.nonDefaultProject); + } + private final ConfigurableEP myEp; private final ConfigurableWrapper[] myKids; diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/ProjectConfigurablesGroup.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/ProjectConfigurablesGroup.java index 721392b5870d..1ef662fe7fc2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/ex/ProjectConfigurablesGroup.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/ProjectConfigurablesGroup.java @@ -17,7 +17,6 @@ package com.intellij.openapi.options.ex; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurableGroup; -import com.intellij.openapi.options.NonDefaultProjectConfigurable; import com.intellij.openapi.options.OptionsBundle; import com.intellij.openapi.project.Project; @@ -50,7 +49,7 @@ public class ProjectConfigurablesGroup extends ConfigurablesGroupBase implements protected ConfigurableFilter getConfigurableFilter() { return new ConfigurableFilter() { public boolean isIncluded(final Configurable configurable) { - return !isDefault() || !(configurable instanceof NonDefaultProjectConfigurable); + return !isDefault() || !ConfigurableWrapper.isNonDefaultProject(configurable); } }; } diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 42cd154a2319..72b413b849f8 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -698,7 +698,7 @@ - + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictTracker.java index 8666cc0a704a..21d6ce5205c6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictTracker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictTracker.java @@ -149,8 +149,7 @@ public class ChangelistConflictTracker { } private void checkOneFile(VirtualFile file, LocalChangeList defaultList) { - final LocalChangeList changeList = myChangeListManager.getChangeList(file); - if (file == null || Comparing.equal(changeList, defaultList) || ChangesUtil.isInternalOperation(file)) { + if (file == null || Comparing.equal(myChangeListManager.getChangeList(file), defaultList) || ChangesUtil.isInternalOperation(file)) { return; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsCalledOnArrayInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsCalledOnArrayInspection.java index cf316b0caa0c..8c05fc9b086b 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsCalledOnArrayInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsCalledOnArrayInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2010 Bas Leijdekkers + * Copyright 2010-2012 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.siyeh.ig.junit; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; import com.intellij.psi.*; +import com.intellij.psi.util.InheritanceUtil; import com.intellij.util.IncorrectOperationException; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; @@ -32,15 +33,13 @@ public class AssertEqualsCalledOnArrayInspection extends BaseInspection { @NotNull @Override public String getDisplayName() { - return InspectionGadgetsBundle.message( - "assertequals.called.on.arrays.display.name"); + return InspectionGadgetsBundle.message("assertequals.called.on.arrays.display.name"); } @NotNull @Override protected String buildErrorString(Object... infos) { - return InspectionGadgetsBundle.message( - "assertequals.called.on.arrays.problem.descriptor"); + return InspectionGadgetsBundle.message("assertequals.called.on.arrays.problem.descriptor"); } @Override @@ -51,30 +50,26 @@ public class AssertEqualsCalledOnArrayInspection extends BaseInspection { private static class AssertEqualsCalledOnArrayFix extends InspectionGadgetsFix { + @Override @NotNull public String getName() { - return InspectionGadgetsBundle.message( - "assertequals.called.on.arrays.quickfix"); + return InspectionGadgetsBundle.message("assertequals.called.on.arrays.quickfix"); } @Override - protected void doFix(Project project, ProblemDescriptor descriptor) - throws IncorrectOperationException { + protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { final PsiElement methodNameIdentifier = descriptor.getPsiElement(); - final PsiReferenceExpression methodExpression = - (PsiReferenceExpression)methodNameIdentifier.getParent(); + final PsiReferenceExpression methodExpression = (PsiReferenceExpression)methodNameIdentifier.getParent(); if (methodExpression == null) { return; } - final PsiExpression qualifier = - methodExpression.getQualifierExpression(); + final PsiExpression qualifier = methodExpression.getQualifierExpression(); if (qualifier == null) { replaceExpression(methodExpression, "assertArrayEquals"); } else { final String qualifierText = qualifier.getText(); - replaceExpression(methodExpression, - qualifierText + ".assertArrayEquals"); + replaceExpression(methodExpression, qualifierText + ".assertArrayEquals"); } } } @@ -84,17 +79,13 @@ public class AssertEqualsCalledOnArrayInspection extends BaseInspection { return new AssertEqualsOnArrayVisitor(); } - private static class AssertEqualsOnArrayVisitor - extends BaseInspectionVisitor { + private static class AssertEqualsOnArrayVisitor extends BaseInspectionVisitor { @Override - public void visitMethodCallExpression( - PsiMethodCallExpression expression) { + public void visitMethodCallExpression(PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); - final PsiReferenceExpression methodExpression = - expression.getMethodExpression(); - @NonNls final String methodName = - methodExpression.getReferenceName(); + final PsiReferenceExpression methodExpression = expression.getMethodExpression(); + @NonNls final String methodName = methodExpression.getReferenceName(); if (!"assertEquals".equals(methodName)) { return; } @@ -117,8 +108,17 @@ public class AssertEqualsCalledOnArrayInspection extends BaseInspection { else { return; } - if (!(type1 instanceof PsiArrayType) || - !(type2 instanceof PsiArrayType)) { + if (!(type1 instanceof PsiArrayType) || !(type2 instanceof PsiArrayType)) { + return; + } + final PsiMethod method = expression.resolveMethod(); + if (method == null) { + return; + } + final PsiClass containingClass = method.getContainingClass(); + if (!InheritanceUtil.isInheritor(containingClass, "junit.framework.Assert") && + !InheritanceUtil.isInheritor(containingClass, "org.junit.Assert") && + !InheritanceUtil.isInheritor(containingClass, "org.testng.AssertJUnit")) { return; } registerMethodCallError(expression); diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassIntention.java index f77ec847e48a..435c472bfc5f 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassIntention.java @@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.ClassInheritorsSearch; +import com.intellij.psi.util.PsiUtil; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.Query; @@ -31,16 +32,14 @@ import java.util.Collection; public class ConvertInterfaceToClassIntention extends Intention { - private static void changeInterfaceToClass(PsiClass anInterface) - throws IncorrectOperationException { + private static void changeInterfaceToClass(PsiClass anInterface) throws IncorrectOperationException { final PsiIdentifier nameIdentifier = anInterface.getNameIdentifier(); assert nameIdentifier != null; final PsiElement whiteSpace = nameIdentifier.getPrevSibling(); assert whiteSpace != null; final PsiElement interfaceToken = whiteSpace.getPrevSibling(); assert interfaceToken != null; - final PsiKeyword interfaceKeyword = - (PsiKeyword)interfaceToken.getOriginalElement(); + final PsiKeyword interfaceKeyword = (PsiKeyword)interfaceToken.getOriginalElement(); final Project project = anInterface.getProject(); final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); final PsiElementFactory factory = psiFacade.getElementFactory(); @@ -52,16 +51,25 @@ public class ConvertInterfaceToClassIntention extends Intention { return; } classModifierList.setModifierProperty(PsiModifier.ABSTRACT, true); + final PsiElement parent = anInterface.getParent(); if (parent instanceof PsiClass) { classModifierList.setModifierProperty(PsiModifier.STATIC, true); } + final PsiMethod[] methods = anInterface.getMethods(); for (final PsiMethod method : methods) { + final PsiJavaToken marker = PsiUtil.findExtensionMethodMarker(method); final PsiModifierList modifierList = method.getModifierList(); modifierList.setModifierProperty(PsiModifier.PUBLIC, true); - modifierList.setModifierProperty(PsiModifier.ABSTRACT, true); + if (marker != null) { + marker.delete(); + } + else { + modifierList.setModifierProperty(PsiModifier.ABSTRACT, true); + } } + final PsiField[] fields = anInterface.getFields(); for (final PsiField field : fields) { final PsiModifierList modifierList = field.getModifierList(); @@ -71,6 +79,7 @@ public class ConvertInterfaceToClassIntention extends Intention { modifierList.setModifierProperty(PsiModifier.FINAL, true); } } + final PsiClass[] innerClasses = anInterface.getInnerClasses(); for (PsiClass innerClass : innerClasses) { final PsiModifierList modifierList = innerClass.getModifierList(); diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/Basic.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/Basic.java new file mode 100644 index 000000000000..eb3c46c8fc51 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/Basic.java @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public interface I { + void m(); +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/Basic_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/Basic_after.java new file mode 100644 index 000000000000..a41677eee58b --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/Basic_after.java @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public abstract class I { + public abstract void m(); +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/ExtensionMethods.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/ExtensionMethods.java new file mode 100644 index 000000000000..394e20bbf423 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/ExtensionMethods.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public interface I { + void m() default { + System.out.println("Hi there."); + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/ExtensionMethods_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/ExtensionMethods_after.java new file mode 100644 index 000000000000..d616bc7ead37 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfaceToClass/ExtensionMethods_after.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public abstract class I { + public void m() { + System.out.println("Hi there."); + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClass.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClass.java deleted file mode 100644 index f3dbfd4f550c..000000000000 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClass.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.siyeh.ipp.interfacetoclass; - -public interface ConvertInterfaceToClass -{ - -} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassImpl.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassImpl.java deleted file mode 100644 index 7b23da8500eb..000000000000 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.siyeh.ipp.interfacetoclass; - -import javax.swing.AbstractAction; -import java.awt.event.ActionEvent; - -// make me readonly -public class ConvertInterfaceToClassImpl extends AbstractAction - implements ConvertInterfaceToClass -{ - - public void actionPerformed(ActionEvent e) - { - } -} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassTest.java new file mode 100644 index 000000000000..001553b72131 --- /dev/null +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassTest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ipp.interfacetoclass; + +import com.siyeh.IntentionPowerPackBundle; +import com.siyeh.ipp.IPPTestCase; + +public class ConvertInterfaceToClassTest extends IPPTestCase { + public void testBasic() { doTest(); } + public void testExtensionMethods() { doTest(); } + + @Override + protected String getRelativePath() { + return "interfaceToClass"; + } + + @Override + protected String getIntentionName() { + return IntentionPowerPackBundle.message("convert.interface.to.class.intention.name"); + } +} diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsConflictsParser.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsConflictsParser.java index b144facc94e4..b8e2b2b9d2b6 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsConflictsParser.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsConflictsParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,30 +15,28 @@ */ package com.intellij.cvsSupport2.actions.merge; -import org.jetbrains.annotations.Nullable; +import com.intellij.util.containers.Stack; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Stack; +import java.io.*; /** * @author lesya */ public class CvsConflictsParser { - private static final String RIGHT = "<<<<<<<"; - private static final String LEFT = "======="; - private static final String END = ">>>>>>>"; - enum State { + private static final String LEFT = "<<<<<<< "; + private static final String RIGHT = "======="; + private static final String END = ">>>>>>> "; + private static final int LENGTH = RIGHT.length(); + + private enum State { RIGHT, LEFT } - private final StringBuffer myLeftBuffer = new StringBuffer(); - private final StringBuffer myCenterBuffer = new StringBuffer(); - private final StringBuffer myRightBuffer = new StringBuffer(); - private final Stack myStateStack; + private final StringBuilder myLeftBuffer = new StringBuilder(); + private final StringBuilder myCenterBuffer = new StringBuilder(); + private final StringBuilder myRightBuffer = new StringBuilder(); + private final Stack myStateStack = new Stack(); public String getLeftVersion() { return myLeftBuffer.toString(); @@ -52,10 +50,7 @@ public class CvsConflictsParser { return myRightBuffer.toString(); } - private CvsConflictsParser() { - - myStateStack = new Stack(); - } + private CvsConflictsParser() {} public static CvsConflictsParser createOn(InputStream merged) throws IOException { final CvsConflictsParser result = new CvsConflictsParser(); @@ -64,30 +59,12 @@ public class CvsConflictsParser { } private void parseFile(final InputStream merged) throws IOException { - final InputStreamReader isr = new InputStreamReader(merged); - final BufferedReader br = new BufferedReader(isr); + final BufferedReader br = new BufferedReader(new InputStreamReader(merged)); try { - String line; - while ((line = br.readLine()) != null) { - String cutLine = findMarkerAndWriteTail(line, RIGHT); - if (cutLine != null) { - processRightMarker(cutLine); - continue; + for (String line; (line = br.readLine()) != null; ) { + if (!processLeftMarker(line) && !processRightMarker(line) && !processEndMarker(line)) { + appendToMainOrCurrent(line); } - - cutLine = findMarkerAndWriteTail(line, LEFT); - if (cutLine != null) { - processLeftMarker(cutLine); - continue; - } - - cutLine = findMarkerAndWriteTail(line, END); - if (cutLine != null) { - processEndMarker(cutLine); - continue; - } - - appendToMainOrCurrent(line); } } finally { @@ -95,85 +72,88 @@ public class CvsConflictsParser { } } - private void appendToMainOrCurrent(final String line) { + private boolean processLeftMarker(String line) { + final int idx = line.lastIndexOf(LEFT); + if (idx < 0) { + return false; + } if (myStateStack.isEmpty()) { - appendLine(line); - } else { - appendToCurrentBuffer(line); - } - } - - @Nullable - private String findMarkerAndWriteTail(final String s, final String marker) { - final int idx = s.indexOf(marker); - if (idx == -1) { - return null; - } - final String startFragment = s.substring(0, idx); - if (startFragment.length() > 0) { - appendToMainOrCurrent(startFragment); - } - return s.substring(idx); - } - - private void processEndMarker(final String line) { - if (myStateStack.isEmpty()) { - appendLine(line); - } - else { - myStateStack.pop(); - if (!myStateStack.isEmpty()) { - appendToCurrentBuffer(line); + final String fragment = line.substring(0, idx); + if (!fragment.isEmpty()) { + appendToMainOrCurrent(fragment); } } + else { + appendToMainOrCurrent(line); + } + myStateStack.push(State.LEFT); + return true; } - private void processLeftMarker(final String line) { - if (myStateStack.isEmpty()) { - appendLine(line); + private boolean processRightMarker(String line) { + if (!line.endsWith(RIGHT)) { + return false; } - else if (myStateStack.peek() == State.LEFT) { + if (!myStateStack.isEmpty() && myStateStack.peek() == State.LEFT) { + if (myStateStack.size() > 1) { + appendToMainOrCurrent(line); + } + else { + final String fragment = line.substring(0, line.length() - LENGTH); + if (!fragment.isEmpty()) { + appendToMainOrCurrent(fragment); + } + } myStateStack.pop(); myStateStack.push(State.RIGHT); + } + else { + appendToMainOrCurrent(line); + } + return true; + } + + private boolean processEndMarker(String line) { + final int idx = line.lastIndexOf(END); + if (idx < 0) { + return false; + } + if (!myStateStack.isEmpty()) { if (myStateStack.size() > 1) { - appendToCurrentBuffer(line); + appendToMainOrCurrent(line); + } + else { + final String fragment = line.substring(0, idx); + if (!fragment.isEmpty()) { + appendToMainOrCurrent(fragment); + } + } + myStateStack.pop(); + } + else { + appendToMainOrCurrent(line); + } + return true; + } + + private void appendToMainOrCurrent(String line) { + if (myStateStack.isEmpty()) { + append(line, myLeftBuffer); + append(line, myCenterBuffer); + append(line, myRightBuffer); + } else { + if (myStateStack.get(0) == State.RIGHT) { + append(line, myRightBuffer); + } else { + append(line, myLeftBuffer); } } - else { - appendToCurrentBuffer(line); - } } - private void processRightMarker(final String line) { - if (myStateStack.isEmpty()) { - myStateStack.push(State.LEFT); - } - else { - myStateStack.push(State.LEFT); - appendToCurrentBuffer(line); + private static void append(String line, StringBuilder out) { + if (out.length() > 0) { + out.append("\n"); } + out.append(line); } - - private void appendToCurrentBuffer(final String line) { - if (myStateStack.get(0) == State.RIGHT) { - appendLine(line, myRightBuffer); - } else { - appendLine(line, myLeftBuffer); - } - } - - private void appendLine(final String line) { - appendLine(line, myLeftBuffer); - appendLine(line, myCenterBuffer); - appendLine(line, myRightBuffer); - } - - private static void appendLine(final String line, final StringBuffer buffer) { - if (buffer.length() > 0) { - buffer.append("\n"); - } - buffer.append(line); - - } - } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyReferenceCharFilter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyReferenceCharFilter.java index f7d604d8fd67..c029930daeb2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyReferenceCharFilter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyReferenceCharFilter.java @@ -47,7 +47,7 @@ public class GroovyReferenceCharFilter extends CharFilter { return Result.ADD_TO_PREFIX; } - if ((c == '[' || c == '<' || c == '.' || c == ' ' || c == '(') && + if ((c == '[' || c == '<' || c == '.' || c == ' ' || c == '(' || c == ',') && JavaCharFilter.isNonImportedClassEntered((LookupImpl)lookup, c == '.')) { return Result.HIDE_LOOKUP; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java index 456b61de3a12..3076eea6ddf6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java @@ -180,7 +180,7 @@ public class GroovyOverrideImplementUtil { if (returnType != null) { returnTypeText = returnType.getPresentableText(); } - Properties properties = new Properties(); + Properties properties = FileTemplateManager.getInstance().getDefaultProperties(project); properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, returnTypeText); properties.setProperty(FileTemplate.ATTRIBUTE_DEFAULT_RETURN_VALUE, PsiTypesUtil.getDefaultValueOfType(returnType)); diff --git a/plugins/spellchecker/src/META-INF/SpellCheckerPlugin.xml b/plugins/spellchecker/src/META-INF/SpellCheckerPlugin.xml index 5a4a66dfba5f..553b24be8cc1 100644 --- a/plugins/spellchecker/src/META-INF/SpellCheckerPlugin.xml +++ b/plugins/spellchecker/src/META-INF/SpellCheckerPlugin.xml @@ -21,7 +21,7 @@ - + Code | Implement Method... function (Ctrl+I).  non-qualified name of the class where method is implemented + + All the predefined variables from "File Header" Include template are also available + (e.g. + ${USER}, + ${DATE}, + etc) + + \ No newline at end of file diff --git a/resources-en/src/fileTemplates/code/Overridden Method Body.java.html b/resources-en/src/fileTemplates/code/Overridden Method Body.java.html index fed614a6f9d0..0139f4297df1 100644 --- a/resources-en/src/fileTemplates/code/Overridden Method Body.java.html +++ b/resources-en/src/fileTemplates/code/Overridden Method Body.java.html @@ -46,6 +46,14 @@   non-qualified name of the class where method is implemented + + All the predefined variables from "File Header" Include template are also available + (e.g. + ${USER}, + ${DATE}, + etc) + + diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 725b554e3254..05fedd8849e7 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -253,10 +253,10 @@ - + - +