diff --git a/java/java-impl/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java b/java/java-impl/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java index 5d10f0714eda..3e91e7358999 100644 --- a/java/java-impl/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java +++ b/java/java-impl/src/com/intellij/spellchecker/LiteralExpressionTokenizer.java @@ -25,7 +25,6 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.spellchecker.inspections.PlainTextSplitter; import com.intellij.spellchecker.tokenizer.EscapeSequenceTokenizer; import com.intellij.spellchecker.tokenizer.TokenConsumer; -import com.intellij.spellchecker.tokenizer.Tokenizer; import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -33,7 +32,7 @@ import java.util.Collections; /** * @author shkate@jetbrains.com */ -public class LiteralExpressionTokenizer extends Tokenizer { +public class LiteralExpressionTokenizer extends EscapeSequenceTokenizer { @Override public void tokenize(@NotNull PsiLiteralExpression element, TokenConsumer consumer) { PsiLiteralExpressionImpl literalExpression = (PsiLiteralExpressionImpl)element; @@ -63,6 +62,6 @@ public class LiteralExpressionTokenizer extends Tokenizer int[] offsets = new int[text.length()+1]; PsiLiteralExpressionImpl.parseStringCharacters(text, unescapedText, offsets); - EscapeSequenceTokenizer.processTextWithOffsets(element, consumer, unescapedText, offsets, 1); + processTextWithOffsets(element, consumer, unescapedText, offsets, 1); } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java index 48cc1bdab9a8..90fcf812a672 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java @@ -790,21 +790,19 @@ public class PsiClassImplUtil { @Nullable public static PsiClass getSuperClass(@NotNull PsiClass psiClass) { - PsiManager manager = psiClass.getManager(); - GlobalSearchScope resolveScope = psiClass.getResolveScope(); - final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); if (psiClass.isInterface()) { - return facade.findClass(CommonClassNames.JAVA_LANG_OBJECT, resolveScope); + String className = CommonClassNames.JAVA_LANG_OBJECT; + return findSpecialSuperClass(psiClass, className); } if (psiClass.isEnum()) { - return facade.findClass(CommonClassNames.JAVA_LANG_ENUM, resolveScope); + return findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_ENUM); } if (psiClass instanceof PsiAnonymousClass) { PsiClassType baseClassReference = ((PsiAnonymousClass)psiClass).getBaseClassType(); PsiClass baseClass = baseClassReference.resolve(); - if (baseClass == null || baseClass.isInterface()) return facade.findClass(CommonClassNames.JAVA_LANG_OBJECT, resolveScope); + if (baseClass == null || baseClass.isInterface()) return findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT); return baseClass; } @@ -812,10 +810,15 @@ public class PsiClassImplUtil { final PsiClassType[] referenceElements = psiClass.getExtendsListTypes(); - if (referenceElements.length == 0) return facade.findClass(CommonClassNames.JAVA_LANG_OBJECT, resolveScope); + if (referenceElements.length == 0) return findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT); - PsiClass psiResoved = referenceElements[0].resolve(); - return psiResoved == null ? facade.findClass(CommonClassNames.JAVA_LANG_OBJECT, resolveScope) : psiResoved; + PsiClass psiResolved = referenceElements[0].resolve(); + return psiResolved == null ? findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT) : psiResolved; + } + + @Nullable + private static PsiClass findSpecialSuperClass(@NotNull PsiClass psiClass, String className) { + return JavaPsiFacade.getInstance(psiClass.getProject()).findClass(className, psiClass.getResolveScope()); } @NotNull @@ -832,7 +835,7 @@ public class PsiClassImplUtil { PsiClassType[] extendsListTypes = psiClass.getExtendsListTypes(); if (psiClass.isInterface()) { - return resolveClassReferenceList(extendsListTypes, psiClass.getManager(), psiClass.getResolveScope(), true); + return resolveClassReferenceList(extendsListTypes, psiClass, true); } if (psiClass instanceof PsiAnonymousClass) { @@ -841,28 +844,25 @@ public class PsiClassImplUtil { PsiClass baseClass = baseClassReference.resolve(); if (baseClass != null) { if (baseClass.isInterface()) { - PsiClass objectClass = - JavaPsiFacade.getInstance(psiClass.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, psiClass.getResolveScope()); + PsiClass objectClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT); return objectClass != null ? new PsiClass[]{objectClass, baseClass} : new PsiClass[]{baseClass}; } return new PsiClass[]{baseClass}; } - PsiClass objectClass = - JavaPsiFacade.getInstance(psiClass.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, psiClass.getResolveScope()); + PsiClass objectClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT); return objectClass != null ? new PsiClass[]{objectClass} : PsiClass.EMPTY_ARRAY; } if (psiClass instanceof PsiTypeParameter) { if (extendsListTypes.length == 0) { - final PsiClass objectClass = - JavaPsiFacade.getInstance(psiClass.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, psiClass.getResolveScope()); + final PsiClass objectClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT); return objectClass != null ? new PsiClass[]{objectClass} : PsiClass.EMPTY_ARRAY; } - return resolveClassReferenceList(extendsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false); + return resolveClassReferenceList(extendsListTypes, psiClass, false); } PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes(); - PsiClass[] interfaces = resolveClassReferenceList(implementsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false); + PsiClass[] interfaces = resolveClassReferenceList(implementsListTypes, psiClass, false); PsiClass superClass = getSuperClass(psiClass); if (superClass == null) return interfaces; @@ -917,11 +917,10 @@ public class PsiClassImplUtil { private static PsiClassType getEnumSuperType(@NotNull PsiClass psiClass, @NotNull PsiElementFactory factory) { PsiClassType superType; - final PsiManager manager = psiClass.getManager(); - final PsiClass enumClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.lang.Enum", psiClass.getResolveScope()); + final PsiClass enumClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_ENUM); if (enumClass == null) { try { - superType = (PsiClassType)factory.createTypeFromText("java.lang.Enum", null); + superType = (PsiClassType)factory.createTypeFromText(CommonClassNames.JAVA_LANG_ENUM, null); } catch (IncorrectOperationException e) { superType = null; @@ -957,8 +956,7 @@ public class PsiClassImplUtil { @NotNull public static PsiClass[] getInterfaces(@NotNull PsiClass psiClass) { if (psiClass.isInterface()) { - final PsiClassType[] extendsListTypes = psiClass.getExtendsListTypes(); - return resolveClassReferenceList(extendsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false); + return resolveClassReferenceList(psiClass.getExtendsListTypes(), psiClass, false); } if (psiClass instanceof PsiAnonymousClass) { @@ -968,17 +966,16 @@ public class PsiClassImplUtil { } final PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes(); - return resolveClassReferenceList(implementsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false); + return resolveClassReferenceList(implementsListTypes, psiClass, false); } @NotNull private static PsiClass[] resolveClassReferenceList(@NotNull PsiClassType[] listOfTypes, - @NotNull PsiManager manager, - @NotNull GlobalSearchScope resolveScope, + @NotNull PsiClass psiClass, boolean includeObject) { PsiClass objectClass = null; if (includeObject) { - objectClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, resolveScope); + objectClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT); if (objectClass == null) includeObject = false; } if (listOfTypes.length == 0) { diff --git a/platform/diff-impl/src/com/intellij/diff/actions/impl/SetEditorSettingsAction.java b/platform/diff-impl/src/com/intellij/diff/actions/impl/SetEditorSettingsAction.java index c93dc22b3656..1dcf1f000300 100644 --- a/platform/diff-impl/src/com/intellij/diff/actions/impl/SetEditorSettingsAction.java +++ b/platform/diff-impl/src/com/intellij/diff/actions/impl/SetEditorSettingsAction.java @@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.project.DumbAware; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -101,13 +102,16 @@ public abstract class SetEditorSettingsAction extends ActionGroup implements Dum } }, new EditorSettingToggleAction("EditorToggleUseSoftWraps") { + private boolean myForcedSoftWrap; + @Override public boolean isSelected() { - return myTextSettings.isUseSoftWraps(); + return myForcedSoftWrap || myTextSettings.isUseSoftWraps(); } @Override public void setSelected(boolean state) { + myForcedSoftWrap = false; myTextSettings.setUseSoftWraps(state); } @@ -117,15 +121,21 @@ public abstract class SetEditorSettingsAction extends ActionGroup implements Dum editor.getSettings().setUseSoftWraps(value); } } + + @Override + public void applyDefaults(@NotNull List editors) { + for (Editor editor : editors) { + if (editor.getUserData(EditorImpl.FORCED_SOFT_WRAPS) != null) myForcedSoftWrap = true; + } + super.applyDefaults(editors); + } }, }; } public void applyDefaults() { - for (Editor editor : myEditors) { - for (EditorSettingToggleAction action : myActions) { - action.apply(editor, action.isSelected()); - } + for (EditorSettingToggleAction action : myActions) { + action.applyDefaults(myEditors); } } @@ -158,5 +168,11 @@ public abstract class SetEditorSettingsAction extends ActionGroup implements Dum public abstract void setSelected(boolean value); public abstract void apply(@NotNull Editor editor, boolean value); + + public void applyDefaults(@NotNull List editors) { + for (Editor editor : editors) { + apply(editor, isSelected()); + } + } } } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java b/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java index 46d46e6ca742..8006a9829db7 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java @@ -120,7 +120,7 @@ public class DiffLineSeparatorRenderer implements LineMarkerRenderer, LineSepara int interval = getStepSize(lineHeight) * 2; int shiftX = -interval; // skip zero index painting - if (((EditorEx)myEditor).getVerticalScrollbarOrientation() == EditorEx.VERTICAL_SCROLLBAR_LEFT) { + if (DiffUtil.isMirrored(myEditor)) { int contentWidth = ((EditorEx)myEditor).getScrollPane().getViewport().getWidth(); shiftX += contentWidth % interval - interval; shiftX += gutterWidth % interval - interval; diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java index aa6ae354eff2..cc0e0d50959b 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java @@ -189,6 +189,13 @@ public class DiffUtil { editor.reinitSettings(); } + public static boolean isMirrored(@NotNull Editor editor) { + if (editor instanceof EditorEx) { + return ((EditorEx)editor).getVerticalScrollbarOrientation() == EditorEx.VERTICAL_SCROLLBAR_LEFT; + } + return false; + } + // // Scrolling // diff --git a/platform/dvcs-impl/dvcs-impl.iml b/platform/dvcs-impl/dvcs-impl.iml index 6cc08f6b74d7..1d2dd1bfa0c4 100644 --- a/platform/dvcs-impl/dvcs-impl.iml +++ b/platform/dvcs-impl/dvcs-impl.iml @@ -19,7 +19,6 @@ - \ No newline at end of file diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushTargetTextField.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushTargetTextField.java index ae745f473f23..5571c7e5df51 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushTargetTextField.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushTargetTextField.java @@ -15,9 +15,10 @@ */ package com.intellij.dvcs.push.ui; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.project.Project; -import com.intellij.spellchecker.ui.SpellCheckingEditorCustomization; +import com.intellij.ui.EditorCustomization; import com.intellij.ui.TextFieldWithAutoCompletion; import com.intellij.ui.TextFieldWithAutoCompletionListProvider; import com.intellij.util.containers.ContainerUtil; @@ -49,7 +50,10 @@ public class PushTargetTextField extends TextFieldWithAutoCompletion { protected EditorEx createEditor() { // editor created lazy, so we need to update editor customization after initialization EditorEx editorEx = super.createEditor(); - SpellCheckingEditorCustomization.DISABLED.customize(editorEx); + EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization(); + if (customization != null) { + customization.customize(editorEx); + } return editorEx; } diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java index ac5eef43e7cf..c03f11b94e97 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java @@ -37,13 +37,15 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.SimpleToolWindowPanel; -import com.intellij.openapi.util.*; +import com.intellij.openapi.util.AsyncResult; +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.Key; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.pom.Navigatable; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; -import com.intellij.psi.StubBasedPsiElement; -import com.intellij.psi.impl.source.tree.CompositeElement; +import com.intellij.psi.PsiManager; import com.intellij.psi.util.PsiUtilCore; import com.intellij.ui.*; import com.intellij.ui.treeStructure.actions.CollapseAllAction; @@ -824,15 +826,7 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre modificationCountForChildren = ourSettingsModificationCount; } - final Object o = unwrapValue(getValue()); - long currentStamp = -1; - if (o instanceof StubBasedPsiElement && ((StubBasedPsiElement)o).getStub() != null) { - currentStamp = ((StubBasedPsiElement)o).getContainingFile().getModificationStamp(); - } else if (o instanceof PsiElement && ((PsiElement)o).getNode() instanceof CompositeElement) { - currentStamp = ((CompositeElement)((PsiElement)o).getNode()).getModificationCount(); - } else if (o instanceof ModificationTracker) { - currentStamp = ((ModificationTracker)o).getModificationCount(); - } + final long currentStamp = myProject != null ? PsiManager.getInstance(myProject).getModificationTracker().getModificationCount() : -1; if (childrenStamp != currentStamp) { resetChildren(); childrenStamp = currentStamp; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/SpellCheckingEditorCustomizationProvider.java b/platform/platform-impl/src/com/intellij/openapi/editor/SpellCheckingEditorCustomizationProvider.java new file mode 100644 index 000000000000..a8ed0ea52241 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/SpellCheckingEditorCustomizationProvider.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor; + +import com.intellij.openapi.components.ServiceManager; +import com.intellij.ui.EditorCustomization; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author nik + */ +public class SpellCheckingEditorCustomizationProvider { + @NotNull + public static SpellCheckingEditorCustomizationProvider getInstance() { + return ServiceManager.getService(SpellCheckingEditorCustomizationProvider.class); + } + + @Nullable + public final EditorCustomization getCustomization(boolean enabled) { + return enabled ? getEnabledCustomization() : getDisabledCustomization(); + } + + @Nullable + public EditorCustomization getEnabledCustomization() { + return null; + } + + @Nullable + public EditorCustomization getDisabledCustomization() { + return null; + } +} diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 8105f02ef356..eb6eb6f24354 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -604,11 +604,6 @@ - - - - - - diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index f6acb328b40f..b327ce02bb15 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -292,6 +292,7 @@ serviceImplementation="com.intellij.openapi.actionSystem.impl.AbbreviationManagerImpl"/> + diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index a02ec711e0c4..f21505687c03 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -363,7 +363,7 @@ ui.no.bangs.and.whistles=false comment.by.line.bulk.lines.trigger=100 -junit_sm_runner=false +junit_sm_runner=true testng_sm_runner=false show.flex.debug.design.view=false diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java index 1fa2184c734c..56d4e1931fb6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java @@ -16,6 +16,7 @@ package com.intellij.openapi.vcs.changes.ui; import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.event.DocumentListener; import com.intellij.openapi.extensions.Extensions; @@ -25,7 +26,6 @@ import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vcs.changes.LocalChangeList; -import com.intellij.spellchecker.ui.SpellCheckingEditorCustomization; import com.intellij.ui.*; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; @@ -164,7 +164,7 @@ public abstract class NewEditChangelistPanel extends JPanel { final EditorTextField editorField; final Set editorFeatures = ContainerUtil.newHashSet(); - editorFeatures.add(SpellCheckingEditorCustomization.ENABLED); + ContainerUtil.addIfNotNull(editorFeatures, SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization()); if (defaultLines == 1) { editorFeatures.add(HorizontalScrollBarEditorCustomization.DISABLED); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java index 6f4292b203f3..283470cdd368 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java @@ -20,15 +20,16 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.*; -import com.intellij.spellchecker.ui.SpellCheckingEditorCustomization; import com.intellij.ui.*; import com.intellij.util.Consumer; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -119,11 +120,11 @@ public class CommitMessage extends AbstractDataProviderPanel implements Disposab VcsConfiguration configuration = VcsConfiguration.getInstance(project); if (configuration != null) { boolean enableSpellChecking = forceSpellCheckOn || configuration.CHECK_COMMIT_MESSAGE_SPELLING; - features.add(SpellCheckingEditorCustomization.getInstance(enableSpellChecking)); + ContainerUtil.addIfNotNull(features, SpellCheckingEditorCustomizationProvider.getInstance().getCustomization(enableSpellChecking)); features.add(new RightMarginEditorCustomization(configuration.USE_COMMIT_MESSAGE_MARGIN, configuration.COMMIT_MESSAGE_MARGIN_SIZE)); features.add(WrapWhenTypingReachesRightMarginCustomization.getInstance(configuration.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN)); } else { - features.add(SpellCheckingEditorCustomization.ENABLED); + ContainerUtil.addIfNotNull(features, SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization()); features.add(new RightMarginEditorCustomization(false, -1)); } @@ -177,7 +178,10 @@ public class CommitMessage extends AbstractDataProviderPanel implements Disposab return; } EditorEx editorEx = (EditorEx)editor; - SpellCheckingEditorCustomization.getInstance(check).customize(editorEx); + EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getCustomization(check); + if (customization != null) { + customization.customize(editorEx); + } } public void dispose() { diff --git a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/LocalChangesUnderRootsTest.java b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/LocalChangesUnderRootsTest.java new file mode 100644 index 000000000000..cd00c8f74afc --- /dev/null +++ b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/LocalChangesUnderRootsTest.java @@ -0,0 +1,123 @@ +package com.intellij.openapi.vcs; + +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vcs.changes.Change; +import com.intellij.openapi.vcs.changes.ChangeListManager; +import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.committed.MockAbstractVcs; +import com.intellij.testFramework.vcs.MockContentRevision; +import com.intellij.openapi.vcs.changes.ui.ChangesComparator; +import com.intellij.openapi.vcs.history.VcsRevisionNumber; +import com.intellij.openapi.vcs.impl.LocalChangesUnderRoots; +import com.intellij.openapi.vcs.impl.projectlevelman.AllVcses; +import com.intellij.openapi.vcs.impl.projectlevelman.AllVcsesI; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.testFramework.PlatformTestCase; +import com.intellij.testFramework.VfsTestUtil; +import com.intellij.testFramework.vcs.MockChangeListManager; +import org.junit.Before; +import org.junit.Test; + +import java.lang.reflect.Field; +import java.util.*; + +/** + * @author Kirill Likhodedov + */ +public class LocalChangesUnderRootsTest extends PlatformTestCase { + + private LocalChangesUnderRoots myLocalChangesUnderRoots; + private MockChangeListManager myChangeListManager; + private VirtualFile myBaseDir; + + @Before + protected void setUp() throws Exception { + super.setUp(); + + myChangeListManager = new MockChangeListManager(); + myBaseDir = myProject.getBaseDir(); + myLocalChangesUnderRoots = new LocalChangesUnderRoots(ChangeListManager.getInstance(myProject), + ProjectLevelVcsManager.getInstance(myProject)); + + substituteChangeListManager(); + } + + // This is not good, but declaring MockChangeListManager might break other tests + private void substituteChangeListManager() throws NoSuchFieldException, IllegalAccessException { + Field myChangeManager = LocalChangesUnderRoots.class.getDeclaredField("myChangeManager"); + myChangeManager.setAccessible(true); + myChangeManager.set(myLocalChangesUnderRoots, myChangeListManager); + } + + @Test + public void testChangesInTwoGitRoots() { + AllVcsesI myVcses = AllVcses.getInstance(myProject); + myVcses.registerManually(new MockAbstractVcs(myProject, "Mock")); + + List roots = createRootStructure( + Pair.create(myBaseDir.getPath(), "Mock"), + Pair.create("community", "Mock") + ); + + Change changeBeforeCommunity = createChangeForPath("a.txt"); + Change changeAfterCommunity = createChangeForPath("readme.txt"); + Change changeInCommunity = createChangeForPath("community/com.txt"); + myChangeListManager.addChanges(changeBeforeCommunity, changeAfterCommunity, changeInCommunity); + + Map> expected = new HashMap>(); + expected.put(roots.get(0), Arrays.asList(changeBeforeCommunity, changeAfterCommunity)); + expected.put(roots.get(1), Arrays.asList(changeInCommunity)); + + Map> changesUnderRoots = myLocalChangesUnderRoots.getChangesUnderRoots(roots); + assertEqualMaps(expected, changesUnderRoots); + } + + private static void assertEqualMaps(Map> expected, Map> actual) { + assertEquals("Maps size is different. " + expectedActualMessage(expected, actual), expected.size(), actual.size()); + for (Map.Entry> expectedEntry : expected.entrySet()) { + VirtualFile root = expectedEntry.getKey(); + if (!actual.containsKey(root)) { + fail("Didn't find root [" + root + "]. " + expectedActualMessage(expected, actual)); + } + List expectedChanges = new ArrayList(expectedEntry.getValue()); + List actualChanges = new ArrayList(actual.get(root)); + Collections.sort(expectedChanges, ChangesComparator.getInstance(false)); + Collections.sort(actualChanges, ChangesComparator.getInstance(false)); + assertEquals("Changes not equal for root [" + root + "]. " + expectedActualMessage(expected, actual), expectedChanges, actualChanges); + } + } + + private static String expectedActualMessage(Object expected, Object actual) { + return "\nExpected:\n " + expected + "\nActual:\n" + actual; + } + + private List createRootStructure(Pair... pathAndVcs) { + List roots = new ArrayList(); + List mappings = new ArrayList(); + for (Pair pathAndVc : pathAndVcs) { + String path = pathAndVc.first; + String vcs = pathAndVc.second; + + VirtualFile vf; + if (path.equals(myBaseDir.getPath())) { + vf = myBaseDir; + } else { + vf = VfsTestUtil.createDir(myBaseDir, path); + } + + mappings.add(new VcsDirectoryMapping(vf.getPath(), vcs)); + roots.add(vf); + } + ProjectLevelVcsManager.getInstance(myProject).setDirectoryMappings(mappings); + return roots; + } + + private Change createChangeForPath(String path) { + VirtualFile file = VfsTestUtil.createFile(myBaseDir, path); + FilePath filePath = new FilePathImpl(file); + ContentRevision beforeRevision = new MockContentRevision(filePath, new VcsRevisionNumber.Int(1)); + ContentRevision afterRevision = new MockContentRevision(filePath, new VcsRevisionNumber.Int(2)); + return new Change(beforeRevision, afterRevision); + } + +} diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/vcs/DuringChangeListManagerUpdateTestScheme.java b/platform/vcs-impl/testSrc/com/intellij/testFramework/vcs/DuringChangeListManagerUpdateTestScheme.java similarity index 100% rename from platform/testFramework/testSrc/com/intellij/testFramework/vcs/DuringChangeListManagerUpdateTestScheme.java rename to platform/vcs-impl/testSrc/com/intellij/testFramework/vcs/DuringChangeListManagerUpdateTestScheme.java diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/vcs/MockChangeListManager.java b/platform/vcs-impl/testSrc/com/intellij/testFramework/vcs/MockChangeListManager.java similarity index 100% rename from platform/testFramework/testSrc/com/intellij/testFramework/vcs/MockChangeListManager.java rename to platform/vcs-impl/testSrc/com/intellij/testFramework/vcs/MockChangeListManager.java diff --git a/platform/vcs-impl/vcs-impl.iml b/platform/vcs-impl/vcs-impl.iml index ad8923208bc4..b307c0806bb0 100644 --- a/platform/vcs-impl/vcs-impl.iml +++ b/platform/vcs-impl/vcs-impl.iml @@ -16,7 +16,6 @@ - diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/TextFieldWithProgress.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/TextFieldWithProgress.java index a465b571c4c9..29506c2ccc66 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/TextFieldWithProgress.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/TextFieldWithProgress.java @@ -15,26 +15,19 @@ */ package com.intellij.vcs.log.ui.actions; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.progress.PerformInBackgroundOption; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; -import com.intellij.spellchecker.ui.SpellCheckingEditorCustomization; +import com.intellij.ui.EditorCustomization; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.TextFieldWithAutoCompletion; import com.intellij.util.ui.AsyncProcessIcon; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.KeyEvent; import java.util.Collection; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; public abstract class TextFieldWithProgress extends JPanel { @NotNull private final TextFieldWithAutoCompletion myTextField; @@ -58,7 +51,10 @@ public abstract class TextFieldWithProgress extends JPanel { protected EditorEx createEditor() { // spell check is not needed EditorEx editor = super.createEditor(); - SpellCheckingEditorCustomization.getInstance(false).customize(editor); + EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization(); + if (customization != null) { + customization.customize(editor); + } return editor; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/MultilinePopupBuilder.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/MultilinePopupBuilder.java index 24a8abc7c52d..f5e333dff38a 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/MultilinePopupBuilder.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/MultilinePopupBuilder.java @@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.DumbAwareAction; @@ -29,7 +30,6 @@ import com.intellij.openapi.ui.popup.ComponentPopupBuilder; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.spellchecker.ui.SpellCheckingEditorCustomization; import com.intellij.ui.EditorCustomization; import com.intellij.ui.EditorTextField; import com.intellij.ui.EditorTextFieldProvider; @@ -42,7 +42,6 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.border.CompoundBorder; import java.awt.*; -import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -61,8 +60,8 @@ class MultilinePopupBuilder { @NotNull private static EditorTextField createTextField(@NotNull Project project) { final EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class); - List - features = Arrays.asList(SoftWrapsEditorCustomization.ENABLED, SpellCheckingEditorCustomization.DISABLED); + List features = ContainerUtil.packNullables(SoftWrapsEditorCustomization.ENABLED, + SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization()); EditorTextField textField = service.getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), project, features); textField.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), textField.getBorder())); textField.setOneLineMode(false); diff --git a/platform/vcs-log/impl/vcs-log-impl.iml b/platform/vcs-log/impl/vcs-log-impl.iml index 2c61af29860a..f5897bb633ef 100644 --- a/platform/vcs-log/impl/vcs-log-impl.iml +++ b/platform/vcs-log/impl/vcs-log-impl.iml @@ -19,7 +19,6 @@ - diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java index a6d481633eb8..e52bd30ed231 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 Bas Leijdekkers + * Copyright 2011-2015 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,6 +60,11 @@ public class EmptyDirectoryInspection extends BaseGlobalInspection { "onlyReportDirectoriesUnderSourceRoots"); } + @Override + public boolean isGraphNeeded() { + return false; + } + @Override public void runInspection(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager, @NotNull final GlobalInspectionContext context, diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/PackageWithTooFewClassesInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/PackageWithTooFewClassesInspection.java index 2f5c28d9988b..1143a9681bd2 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/PackageWithTooFewClassesInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/PackageWithTooFewClassesInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2006-2015 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,12 +58,16 @@ public class PackageWithTooFewClassesInspection extends BaseGlobalInspection { return null; } int numClasses = 0; + boolean subpackage = false; for (RefEntity child : children) { if (child instanceof RefClass) { numClasses++; } + else if (child instanceof RefPackage) { + subpackage = true; + } } - if (numClasses >= limit || numClasses == 0) { + if (numClasses >= limit || (numClasses == 0 && subpackage)) { return null; } final String errorString = InspectionGadgetsBundle.message( diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/SynchronizationUtil.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/SynchronizationUtil.java index 30b6a70d4692..297a862a2c1d 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/SynchronizationUtil.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/SynchronizationUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Bas Leijdekkers + * Copyright 2006-2015 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,16 +25,14 @@ public class SynchronizationUtil { public static boolean isInSynchronizedContext(PsiElement element) { final PsiElement context = - PsiTreeUtil.getParentOfType(element, PsiMethod.class, - PsiSynchronizedStatement.class); + PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiSynchronizedStatement.class, PsiClass.class, PsiLambdaExpression.class); if (context instanceof PsiSynchronizedStatement) { return true; } - if (context == null) { + if (!(context instanceof PsiMethod)) { return false; } - final PsiModifierListOwner modifierListOwner = - (PsiModifierListOwner)context; + final PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)context; return modifierListOwner.hasModifierProperty(PsiModifier.SYNCHRONIZED); } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/call_to_native_method_while_locked/CallToNativeMethodWhileLocked.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/call_to_native_method_while_locked/CallToNativeMethodWhileLocked.java new file mode 100644 index 000000000000..75e89d147a73 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/call_to_native_method_while_locked/CallToNativeMethodWhileLocked.java @@ -0,0 +1,14 @@ +package com.siyeh.igtest.threading.call_to_native_method_while_locked; + +public class CallToNativeMethodWhileLocked { + + synchronized void a() { + Double.doubleToLongBits(9.7); + Runnable r = () -> { + Double.doubleToLongBits(123.4); + }; + new Object() { + long l = Double.doubleToLongBits(42.0); + }; + } +} diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/threading/CallToNativeMethodWhileLockedInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/threading/CallToNativeMethodWhileLockedInspectionTest.java new file mode 100644 index 000000000000..ec87747a5bfb --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/threading/CallToNativeMethodWhileLockedInspectionTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2015 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.ig.threading; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers + */ +public class CallToNativeMethodWhileLockedInspectionTest extends LightInspectionTestCase { + + public void testCallToNativeMethodWhileLocked() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new CallToNativeMethodWhileLockedInspection(); + } +} \ No newline at end of file diff --git a/plugins/copyright/copyright.iml b/plugins/copyright/copyright.iml index 425e3c174a08..126c6110fa43 100644 --- a/plugins/copyright/copyright.iml +++ b/plugins/copyright/copyright.iml @@ -14,6 +14,5 @@ - \ No newline at end of file diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java index 06411bdf6654..9292cac28fff 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java @@ -17,14 +17,7 @@ package com.maddyhome.idea.copyright.ui; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.EditorSettings; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.EditorFontType; -import com.intellij.openapi.editor.ex.EditorEx; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; @@ -32,10 +25,9 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.NamedConfigurable; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vcs.VcsConfiguration; -import com.intellij.spellchecker.ui.SpellCheckingEditorCustomization; import com.intellij.ui.*; import com.intellij.util.DocumentUtil; +import com.intellij.util.containers.ContainerUtil; import com.maddyhome.idea.copyright.CopyrightManager; import com.maddyhome.idea.copyright.CopyrightProfile; import com.maddyhome.idea.copyright.pattern.EntityUtil; @@ -73,7 +65,7 @@ public class CopyrightConfigurable extends NamedConfigurable { myCopyrightProfile = copyrightProfile; myDisplayName = myCopyrightProfile.getName(); final Set features = new HashSet(); - features.add(SpellCheckingEditorCustomization.ENABLED); + ContainerUtil.addIfNotNull(features, SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization()); features.add(SoftWrapsEditorCustomization.ENABLED); features.add(AdditionalPageAtBottomEditorCustomization.DISABLED); EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class); diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml index 4ef6003ecd9f..c1bc9f22177a 100644 --- a/plugins/git4idea/git4idea.iml +++ b/plugins/git4idea/git4idea.iml @@ -53,7 +53,6 @@ - diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java index b98eaea7fee5..f88df6797c1e 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java +++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java @@ -21,6 +21,7 @@ import com.intellij.dvcs.DvcsUtil; import com.intellij.dvcs.push.ui.VcsPushDialog; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.Project; @@ -37,7 +38,7 @@ import com.intellij.openapi.vcs.checkin.CheckinChangeListSpecificComponent; import com.intellij.openapi.vcs.checkin.CheckinEnvironment; import com.intellij.openapi.vcs.ui.RefreshableOnComponent; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.spellchecker.ui.SpellCheckingEditorCustomization; +import com.intellij.ui.EditorCustomization; import com.intellij.ui.GuiUtils; import com.intellij.ui.StringComboboxEditor; import com.intellij.util.*; @@ -616,7 +617,10 @@ public class GitCheckinEnvironment implements CheckinEnvironment { myAuthorField.setEditor(comboboxEditor); EditorEx editor = (EditorEx)comboboxEditor.getEditor(); assert editor != null; - SpellCheckingEditorCustomization.getInstance(false).customize(editor); + EditorCustomization customization = SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization(); + if (customization != null) { + customization.customize(editor); + } } }; myAuthorField.setMinimumAndPreferredWidth(100); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/spellchecker/GroovySpellcheckingStrategy.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/spellchecker/GroovySpellcheckingStrategy.java index 9bc67a4355d0..d0a9997a58e2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/spellchecker/GroovySpellcheckingStrategy.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/spellchecker/GroovySpellcheckingStrategy.java @@ -32,7 +32,7 @@ import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil; */ public class GroovySpellcheckingStrategy extends SpellcheckingStrategy { private final GrDocCommentTokenizer myDocCommentTokenizer = new GrDocCommentTokenizer(); - private final Tokenizer myStringTokenizer = new Tokenizer() { + private final Tokenizer myStringTokenizer = new EscapeSequenceTokenizer() { @Override public void tokenize(@NotNull PsiElement literal, TokenConsumer consumer) { String text = GrStringUtil.removeQuotes(literal.getText()); @@ -43,7 +43,7 @@ public class GroovySpellcheckingStrategy extends SpellcheckingStrategy { StringBuilder unescapedText = new StringBuilder(); int[] offsets = new int[text.length() + 1]; GrStringUtil.parseStringCharacters(text, unescapedText, offsets); - EscapeSequenceTokenizer.processTextWithOffsets(literal, consumer, unescapedText, offsets, GrStringUtil.getStartQuote(literal.getText()).length()); + processTextWithOffsets(literal, consumer, unescapedText, offsets, GrStringUtil.getStartQuote(literal.getText()).length()); } } }; diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/inconsistentResourceBundle/InconsistentResourceBundleInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/inconsistentResourceBundle/InconsistentResourceBundleInspection.java index 1e71e5d1ce50..34c331fb0804 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/inconsistentResourceBundle/InconsistentResourceBundleInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/inconsistentResourceBundle/InconsistentResourceBundleInspection.java @@ -43,19 +43,22 @@ import java.util.*; public class InconsistentResourceBundleInspection extends GlobalSimpleInspectionTool { private static final Key> VISITED_BUNDLES_KEY = Key.create("VISITED_BUNDLES_KEY"); - private final InconsistentResourceBundleInspectionProvider[] myInspectionProviders; + private final NotNullLazyValue myInspectionProviders = + new NotNullLazyValue() { + @NotNull + @Override + protected InconsistentResourceBundleInspectionProvider[] compute() { + return new InconsistentResourceBundleInspectionProvider[] { + new PropertiesKeysConsistencyInspectionProvider(), + new DuplicatedPropertiesInspectionProvider(), + new MissingTranslationsInspectionProvider(), + new PropertiesPlaceholdersInspectionProvider(), + new InconsistentPropertiesEndsInspectionProvider(), + }; + } + }; private final Map mySettings = new LinkedHashMap(); - public InconsistentResourceBundleInspection() { - myInspectionProviders = new InconsistentResourceBundleInspectionProvider[] { - new PropertiesKeysConsistencyInspectionProvider(), - new DuplicatedPropertiesInspectionProvider(), - new MissingTranslationsInspectionProvider(), - new PropertiesPlaceholdersInspectionProvider(), - new InconsistentPropertiesEndsInspectionProvider(), - }; - } - @Override @NotNull public String getGroupDisplayName() { @@ -99,7 +102,7 @@ public class InconsistentResourceBundleInspection extends GlobalSimpleInspection } } }); - for (final InconsistentResourceBundleInspectionProvider provider : myInspectionProviders) { + for (final InconsistentResourceBundleInspectionProvider provider : myInspectionProviders.getValue()) { panel.addCheckbox(provider.getPresentableName(), provider.getName()); } return panel; @@ -170,7 +173,7 @@ public class InconsistentResourceBundleInspection extends GlobalSimpleInspection } keysUpToParent.put(f, keys); } - for (final InconsistentResourceBundleInspectionProvider provider : myInspectionProviders) { + for (final InconsistentResourceBundleInspectionProvider provider : myInspectionProviders.getValue()) { if (isProviderEnabled(provider.getName())) { provider.check(parents, files, keysUpToParent, propertiesFilesNamesMaps, manager, globalContext.getRefManager(), problemDescriptionsProcessor); @@ -185,7 +188,7 @@ public class InconsistentResourceBundleInspection extends GlobalSimpleInspection @TestOnly public void enableProviders(final Class... providerClasses) { Set> providersToEnable = ContainerUtil.newHashSet(providerClasses); - for (InconsistentResourceBundleInspectionProvider inspectionProvider : myInspectionProviders) { + for (InconsistentResourceBundleInspectionProvider inspectionProvider : myInspectionProviders.getValue()) { if (providersToEnable.contains(inspectionProvider.getClass())) { mySettings.put(inspectionProvider.getName(), true); } @@ -194,7 +197,7 @@ public class InconsistentResourceBundleInspection extends GlobalSimpleInspection @TestOnly public void disableAllProviders() { - for (InconsistentResourceBundleInspectionProvider inspectionProvider : myInspectionProviders) { + for (InconsistentResourceBundleInspectionProvider inspectionProvider : myInspectionProviders.getValue()) { mySettings.put(inspectionProvider.getName(), false); } } diff --git a/plugins/java-i18n/testSrc/com/intellij/spellchecker/inspection/LiteralExpressionTokenizerTest.java b/plugins/java-i18n/testSrc/com/intellij/spellchecker/inspection/LiteralExpressionTokenizerTest.java index 3c93adb12163..6bb8c04aa540 100644 --- a/plugins/java-i18n/testSrc/com/intellij/spellchecker/inspection/LiteralExpressionTokenizerTest.java +++ b/plugins/java-i18n/testSrc/com/intellij/spellchecker/inspection/LiteralExpressionTokenizerTest.java @@ -20,36 +20,40 @@ import com.intellij.psi.PsiElement; import com.intellij.spellchecker.LiteralExpressionTokenizer; import com.intellij.spellchecker.inspections.Splitter; import com.intellij.spellchecker.tokenizer.TokenConsumer; -import org.junit.Test; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.util.Consumer; import java.util.ArrayList; import java.util.List; -import static com.intellij.testFramework.UsefulTestCase.assertOrderedEquals; - /** * @author yole */ -public class LiteralExpressionTokenizerTest { - private static class TokenCollector extends TokenConsumer { +public class LiteralExpressionTokenizerTest extends LightPlatformCodeInsightFixtureTestCase { + private static class TokenCollector extends TokenConsumer implements Consumer { private final List myTokenTexts = new ArrayList(); + private String myText; @Override public void consumeToken(PsiElement element, String text, boolean useRename, int offset, TextRange rangeToCheck, Splitter splitter) { - myTokenTexts.add(text); + myText = text; + splitter.split(myText, rangeToCheck, this); } public List getTokenTexts() { return myTokenTexts; } + + @Override + public void consume(TextRange range) { + myTokenTexts.add(myText.substring(range.getStartOffset(), range.getEndOffset())); + } } - @Test public void testEscapeSequences() { doTest("hello\\nworld", "hello", "world"); } - @Test public void testEscapeSequences2() { doTest("\\nhello\\nworld\\n", "hello", "world"); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/properties/JUnitConsoleProperties.java b/plugins/junit/src/com/intellij/execution/junit2/ui/properties/JUnitConsoleProperties.java index c202fd0787b2..3f4531947b8c 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/properties/JUnitConsoleProperties.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/properties/JUnitConsoleProperties.java @@ -40,8 +40,18 @@ public class JUnitConsoleProperties extends JavaAwareTestConsoleProperties tests, String expectedTree, String expectedStart) throws Exception { @@ -244,9 +232,7 @@ public class JUnitTreeByDescriptionHierarchyTest { //start "##teamcity[enteredTheMatrix]\n" + - "\n" + "##teamcity[rootName name = 'root']\n" + - "\n" + "##teamcity[testSuiteFinished name='root']\n" + "##teamcity[testSuiteStarted name ='ATest']\n" + "##teamcity[testSuiteStarted name ='|[0|]']\n" + @@ -266,9 +252,7 @@ public class JUnitTreeByDescriptionHierarchyTest { "\n" + "##teamcity[testFinished name='test']\n" + "##teamcity[testSuiteFinished name='ATest']\n" + - "\n" + - "##teamcity[testSuiteFinished name='suite']\n" + - "\n"); + "##teamcity[testSuiteFinished name='suite']\n"); } @@ -304,13 +288,10 @@ public class JUnitTreeByDescriptionHierarchyTest { "##teamcity[enteredTheMatrix]\n" + - "\n" + "##teamcity[rootName name = 'TestA']\n" + - "\n" + "##teamcity[testStarted name='warning' locationHint='java:test://junit.framework.TestSuite$1.warning']\n" + "\n" + "##teamcity[testFinished name='warning']\n" + - "##teamcity[testSuiteFinished name='TestA']\n" + - "\n"); + "##teamcity[testSuiteFinished name='TestA']\n"); } } diff --git a/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java b/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java index 60318a25c2a7..27ada8d3b4b9 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java +++ b/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java @@ -39,7 +39,7 @@ public class JUnit3IdeaTestRunner extends TestRunner implements IdeaTestRunner { public int startRunnerWithArgs(String[] args, ArrayList listeners, String name, int count, boolean sendTree) { myListeners = listeners; mySendTree = sendTree && !(myTestsListener instanceof SMTestListener); - if (sendTree) { + if (mySendTree) { setPrinter(new TimeSender(myRegistry)); } else { diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java index fcdb82291eba..4f68466cdac3 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java @@ -51,9 +51,14 @@ public class JUnit4IdeaTestRunner implements IdeaTestRunner { else if (request instanceof FilterRequest) { description = getFilteredDescription(request, description); } - TreeSender.sendTree(this, description, sendTree); - if (myTestsListener instanceof SMTestSender && sendTree) { - ((SMTestSender)myTestsListener).sendTree(description); + + if (myTestsListener instanceof SMTestSender) { + if (sendTree) { + ((SMTestSender)myTestsListener).sendTree(description); + } + sendTree = false; + } else { + TreeSender.sendTree(this, description, sendTree); } } catch (Exception e) { diff --git a/plugins/junit_rt/src/com/intellij/junit4/SMTestSender.java b/plugins/junit_rt/src/com/intellij/junit4/SMTestSender.java index e5b831eaa3fd..0544f92d00e6 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/SMTestSender.java +++ b/plugins/junit_rt/src/com/intellij/junit4/SMTestSender.java @@ -61,7 +61,7 @@ public class SMTestSender extends RunListener { } public void testRunStarted(Description description) throws Exception { - myPrintStream.println("##teamcity[enteredTheMatrix]\n"); + myPrintStream.println("##teamcity[enteredTheMatrix]"); if (myCurrentClassName != null && !myCurrentClassName.startsWith("[")) { int lastPointIdx = myCurrentClassName.lastIndexOf('.'); String name = myCurrentClassName; @@ -73,20 +73,20 @@ public class SMTestSender extends RunListener { myPrintStream.println("##teamcity[rootName name = \'" + escapeName(name) + (comment != null ? ("\' comment = \'" + escapeName(comment)) : "") + - "\']\n"); + "\']"); myCurrentClassName = getShortName(myCurrentClassName); } } public void testRunFinished(Result result) throws Exception { if (myParamName != null) { - myPrintStream.println("##teamcity[testSuiteFinished name=\'" + escapeName(myParamName) + "\']\n"); + myPrintStream.println("##teamcity[testSuiteFinished name=\'" + escapeName(myParamName) + "\']"); } if (myCurrentClassName != null) { - myPrintStream.println("##teamcity[testSuiteFinished name=\'" + escapeName(myCurrentClassName) + "\']\n"); + myPrintStream.println("##teamcity[testSuiteFinished name=\'" + escapeName(myCurrentClassName) + "\']"); } if (myCurrentSuiteName != null) { - myPrintStream.println("##teamcity[testSuiteFinished name=\'" + escapeName(getShortName(myCurrentSuiteName)) + "\']\n"); + myPrintStream.println("##teamcity[testSuiteFinished name=\'" + escapeName(getShortName(myCurrentSuiteName)) + "\']"); } } diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitStarter.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitStarter.java index 8c5f6a37c553..eee0d2593da0 100644 --- a/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitStarter.java +++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitStarter.java @@ -225,7 +225,7 @@ public class JUnitStarter { } } testRunner.setStreams(out, err, 0); - return testRunner.startRunnerWithArgs(args, listeners, name, ourCount, !SM_RUNNER); + return testRunner.startRunnerWithArgs(args, listeners, name, ourCount, true); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/plugins/testng/src/com/theoryinpractice/testng/model/TestNGConsoleProperties.java b/plugins/testng/src/com/theoryinpractice/testng/model/TestNGConsoleProperties.java index 0dbc3942ee26..9bf17fa55363 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/model/TestNGConsoleProperties.java +++ b/plugins/testng/src/com/theoryinpractice/testng/model/TestNGConsoleProperties.java @@ -39,7 +39,14 @@ public class TestNGConsoleProperties extends JavaAwareTestConsoleProperties + + - diff --git a/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java b/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java index 55541d9aefd6..7924a90284c0 100644 --- a/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java +++ b/spellchecker/src/com/intellij/spellchecker/inspections/PlainTextSplitter.java @@ -18,7 +18,6 @@ package com.intellij.spellchecker.inspections; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.Consumer; -import org.jdom.Verifier; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,21 +52,6 @@ public class PlainTextSplitter extends BaseSplitter { if (text == null || StringUtil.isEmpty(text)) { return; } - String substring = range.substring(text); - if (Verifier.checkCharacterData(substring) != null) { - return; - } - //for(int i = 0; i < text.length(); ++i) { - // final char ch = text.charAt(i); - // if (ch >= '\u3040' && ch <= '\u309f' || // Hiragana - // ch >= '\u30A0' && ch <= '\u30ff' || // Katakana - // ch >= '\u4E00' && ch <= '\u9FFF' || // CJK Unified ideographs - // ch >= '\uF900' && ch <= '\uFAFF' || // CJK Compatibility Ideographs - // ch >= '\uFF00' && ch <= '\uFFEF' //Halfwidth and Fullwidth Forms of Katakana & Fullwidth ASCII variants - // ) { - // return; - // } - //} final TextSplitter ws = TextSplitter.getInstance(); int from = range.getStartOffset(); diff --git a/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java b/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java index e932a002beb1..b9e722331f31 100644 --- a/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java +++ b/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java @@ -160,9 +160,13 @@ public class SpellCheckingInspection extends LocalInspectionTool { tokenizer.tokenize(element, consumer); } - private static void addBatchDescriptor(PsiElement element, int offset, @NotNull TextRange textRange, @NotNull ProblemsHolder holder) { + private static void addBatchDescriptor(PsiElement element, + int offset, + @NotNull TextRange textRange, + @NotNull ProblemsHolder holder, + String wordWithTypo) { SpellCheckerQuickFix[] fixes = SpellcheckingStrategy.getDefaultBatchFixes(); - ProblemDescriptor problemDescriptor = createProblemDescriptor(element, offset, textRange, holder, fixes, false); + ProblemDescriptor problemDescriptor = createProblemDescriptor(element, offset, textRange, holder, fixes, false, wordWithTypo); holder.registerProblem(problemDescriptor); } @@ -174,19 +178,23 @@ public class SpellCheckingInspection extends LocalInspectionTool { ? strategy.getRegularFixes(element, offset, textRange, useRename, wordWithTypo) : SpellcheckingStrategy.getDefaultRegularFixes(useRename, wordWithTypo); - final ProblemDescriptor problemDescriptor = createProblemDescriptor(element, offset, textRange, holder, fixes, true); + final ProblemDescriptor problemDescriptor = createProblemDescriptor(element, offset, textRange, holder, fixes, true, wordWithTypo); holder.registerProblem(problemDescriptor); } private static ProblemDescriptor createProblemDescriptor(PsiElement element, int offset, TextRange textRange, ProblemsHolder holder, SpellCheckerQuickFix[] fixes, - boolean onTheFly) { - final String description = SpellCheckerBundle.message("typo.in.word.ref"); - final TextRange highlightRange = TextRange.from(offset + textRange.getStartOffset(), textRange.getLength()); - assert highlightRange.getStartOffset()>=0; + boolean onTheFly, String wordWithTypo) { + SpellcheckingStrategy strategy = getSpellcheckingStrategy(element, element.getLanguage()); + final Tokenizer tokenizer = strategy != null ? strategy.getTokenizer(element) : null; + if (tokenizer != null) { + textRange = tokenizer.getHighlightingRange(element, offset, textRange); + } + assert textRange.getStartOffset() >= 0; + final String description = SpellCheckerBundle.message("typo.in.word.ref", wordWithTypo); return holder.getManager() - .createProblemDescriptor(element, highlightRange, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly, fixes); + .createProblemDescriptor(element, textRange, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly, fixes); } @SuppressWarnings({"PublicField"}) @@ -266,7 +274,7 @@ public class SpellCheckingInspection extends LocalInspectionTool { } else { myAlreadyChecked.add(word); - addBatchDescriptor(myElement, myOffset, textRange, myHolder); + addBatchDescriptor(myElement, myOffset, textRange, myHolder, word); } } } diff --git a/spellchecker/src/com/intellij/spellchecker/tokenizer/EscapeSequenceTokenizer.java b/spellchecker/src/com/intellij/spellchecker/tokenizer/EscapeSequenceTokenizer.java index 5f6c9c285cc6..cc35f6137eeb 100644 --- a/spellchecker/src/com/intellij/spellchecker/tokenizer/EscapeSequenceTokenizer.java +++ b/spellchecker/src/com/intellij/spellchecker/tokenizer/EscapeSequenceTokenizer.java @@ -15,42 +15,35 @@ */ package com.intellij.spellchecker.tokenizer; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.spellchecker.inspections.PlainTextSplitter; +import org.jetbrains.annotations.NotNull; /** * @author yole */ -public class EscapeSequenceTokenizer { +public abstract class EscapeSequenceTokenizer extends Tokenizer { + private static Key ESCAPE_OFFSETS = Key.create("escape.tokenizer.offsets"); + public static void processTextWithOffsets(PsiElement element, TokenConsumer consumer, StringBuilder unescapedText, int[] offsets, int startOffset) { - StringBuilder currentToken = new StringBuilder(); - int currentTokenStart = startOffset; - for (int i = 0; i < unescapedText.length(); i++) { - if (offsets[i+1]-offsets[i] == 1 || !Character.isWhitespace(unescapedText.charAt(i))) { - if (currentToken.length() == 0) { - currentTokenStart = offsets[i] + startOffset; - } - currentToken.append(unescapedText.charAt(i)); - } - else { - if (currentToken.length() > 0) { - processCurrentToken(element, currentToken, currentTokenStart, consumer); - currentToken.setLength(0); - } - } - } - if (currentToken.length() > 0) { - processCurrentToken(element, currentToken, currentTokenStart, consumer); - } + if (element != null) element.putUserData(ESCAPE_OFFSETS, offsets); + final String text = unescapedText.toString(); + consumer.consumeToken(element, text, false, startOffset, TextRange.allOf(text), PlainTextSplitter.getInstance()); + if (element != null) element.putUserData(ESCAPE_OFFSETS, null); } - private static void processCurrentToken(PsiElement element, - StringBuilder currentToken, - int currentTokenStart, TokenConsumer consumer) { - final String token = currentToken.toString(); - // +1 for the starting quote of the string literal - consumer.consumeToken(element, token, false, currentTokenStart, TextRange.allOf(token), PlainTextSplitter.getInstance()); + @NotNull + public TextRange getHighlightingRange(PsiElement element, int offset, TextRange range) { + final int[] offsets = element.getUserData(ESCAPE_OFFSETS); + if (offsets != null) { + int start = offsets[range.getStartOffset()]; + int end = offsets[range.getEndOffset()]; + + return new TextRange(offset + start, offset + end); + } + return super.getHighlightingRange(element, offset, range); } } diff --git a/spellchecker/src/com/intellij/spellchecker/tokenizer/Tokenizer.java b/spellchecker/src/com/intellij/spellchecker/tokenizer/Tokenizer.java index 47863a710ac7..0c55bf163248 100644 --- a/spellchecker/src/com/intellij/spellchecker/tokenizer/Tokenizer.java +++ b/spellchecker/src/com/intellij/spellchecker/tokenizer/Tokenizer.java @@ -15,10 +15,16 @@ */ package com.intellij.spellchecker.tokenizer; +import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; public abstract class Tokenizer { public abstract void tokenize(@NotNull T element, TokenConsumer consumer); + + @NotNull + public TextRange getHighlightingRange(PsiElement element, int offset, TextRange textRange) { + return TextRange.from(offset + textRange.getStartOffset(), textRange.getLength()); + } } diff --git a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java index 53668c2e73ff..4f9ccdee0d8d 100644 --- a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java +++ b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java @@ -22,6 +22,7 @@ import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.codeInspection.ex.InspectionProfileWrapper; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiDocumentManager; @@ -45,19 +46,25 @@ import java.util.Map; * @since Aug 20, 2010 3:54:42 PM */ public class SpellCheckingEditorCustomization extends SimpleEditorCustomization { + /** + * @deprecated use {@link SpellCheckingEditorCustomizationProvider#getEnabledCustomization()} instead + */ + public static final SpellCheckingEditorCustomization ENABLED = (SpellCheckingEditorCustomization)SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization(); - public static final SpellCheckingEditorCustomization ENABLED = new SpellCheckingEditorCustomization(true); - public static final SpellCheckingEditorCustomization DISABLED = new SpellCheckingEditorCustomization(false); + /** + * @deprecated use {@link SpellCheckingEditorCustomizationProvider#getDisabledCustomization()} instead + */ + public static final SpellCheckingEditorCustomization DISABLED = (SpellCheckingEditorCustomization)SpellCheckingEditorCustomizationProvider.getInstance().getDisabledCustomization(); private static final Map SPELL_CHECK_TOOLS = new HashMap(); private static final boolean READY = init(); @NotNull public static SpellCheckingEditorCustomization getInstance(boolean enabled) { - return enabled ? ENABLED : DISABLED; + return (SpellCheckingEditorCustomization)SpellCheckingEditorCustomizationProvider.getInstance().getCustomization(enabled); } - private SpellCheckingEditorCustomization(boolean enabled) { + SpellCheckingEditorCustomization(boolean enabled) { super(enabled); } diff --git a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomizationProviderImpl.java b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomizationProviderImpl.java new file mode 100644 index 000000000000..e48fe863a2ad --- /dev/null +++ b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomizationProviderImpl.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2015 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.spellchecker.ui; + +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; +import com.intellij.ui.EditorCustomization; +import org.jetbrains.annotations.Nullable; + +/** + * @author nik + */ +public class SpellCheckingEditorCustomizationProviderImpl extends SpellCheckingEditorCustomizationProvider { + private static final SpellCheckingEditorCustomization ENABLED = new SpellCheckingEditorCustomization(true); + private static final SpellCheckingEditorCustomization DISABLED = new SpellCheckingEditorCustomization(false); + + @Nullable + @Override + public EditorCustomization getEnabledCustomization() { + return ENABLED; + } + + @Nullable + @Override + public EditorCustomization getDisabledCustomization() { + return DISABLED; + } +} diff --git a/spellchecker/src/com/intellij/spellchecker/util/SpellCheckerBundle.properties b/spellchecker/src/com/intellij/spellchecker/util/SpellCheckerBundle.properties index 286bcf2c5f78..543332dccc9d 100644 --- a/spellchecker/src/com/intellij/spellchecker/util/SpellCheckerBundle.properties +++ b/spellchecker/src/com/intellij/spellchecker/util/SpellCheckerBundle.properties @@ -5,7 +5,7 @@ rename.to=Typo: Rename to... spelling=Spelling spellchecking.inspection.name=Typo comments.with.mistakes=Comments with mistakes -typo.in.word.ref=Typo: In word '#ref' +typo.in.word.ref=Typo: In word ''{0}'' add.0.to.dictionary=Typo: Save ''{0}'' to dictionary add.to.dictionary=Save to dictionary class.name.with.mistakes=Class name with mistakes diff --git a/spellchecker/testSrc/com/intellij/spellchecker/ui/SpellCheckingEditorCustomizationTest.java b/spellchecker/testSrc/com/intellij/spellchecker/ui/SpellCheckingEditorCustomizationTest.java index 799fe3331740..32efe07e71b0 100644 --- a/spellchecker/testSrc/com/intellij/spellchecker/ui/SpellCheckingEditorCustomizationTest.java +++ b/spellchecker/testSrc/com/intellij/spellchecker/ui/SpellCheckingEditorCustomizationTest.java @@ -16,6 +16,7 @@ package com.intellij.spellchecker.ui; import com.intellij.codeInspection.ex.InspectionProfileImpl; +import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.fileTypes.PlainTextFileType; import com.intellij.spellchecker.inspections.SpellCheckingInspection; @@ -47,7 +48,7 @@ public class SpellCheckingEditorCustomizationTest extends LightPlatformCodeInsig myFixture.configureByText(PlainTextFileType.INSTANCE, document); myFixture.enableInspections(new SpellCheckingInspection()); - SpellCheckingEditorCustomization.getInstance(enabled).customize((EditorEx)myFixture.getEditor()); + SpellCheckingEditorCustomizationProvider.getInstance().getCustomization(enabled).customize((EditorEx)myFixture.getEditor()); myFixture.checkHighlighting(); }