diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java index f6ef8ff88889..bd874ee26aff 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -28,10 +28,10 @@ import com.intellij.psi.util.PsiUtil; import com.intellij.refactoring.BaseRefactoringProcessor; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.listeners.RefactoringEventData; -import com.intellij.refactoring.listeners.RefactoringEventListener; import com.intellij.refactoring.rename.NonCodeUsageInfoFactory; import com.intellij.refactoring.util.*; import com.intellij.usageView.UsageInfo; +import com.intellij.usageView.UsageInfoFactory; import com.intellij.usageView.UsageViewDescriptor; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.MultiMap; @@ -107,7 +107,7 @@ public class InlineConstantFieldProcessor extends BaseRefactoringProcessor { usages.add(info); } if (mySearchInCommentsAndStrings || mySearchForTextOccurrences) { - TextOccurrencesUtil.UsageInfoFactory nonCodeUsageFactory = new NonCodeUsageInfoFactory(myField, myField.getName()){ + UsageInfoFactory nonCodeUsageFactory = new NonCodeUsageInfoFactory(myField, myField.getName()){ @Override public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) { if (PsiTreeUtil.isAncestor(myField, usage, false)) return null; diff --git a/platform/core-api/src/com/intellij/usageView/UsageInfoFactory.java b/platform/core-api/src/com/intellij/usageView/UsageInfoFactory.java new file mode 100644 index 000000000000..fd30223f186f --- /dev/null +++ b/platform/core-api/src/com/intellij/usageView/UsageInfoFactory.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2014 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.usageView; + +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface UsageInfoFactory { + @Nullable + UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset); +} diff --git a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java index fb98b191bdce..ac7770687027 100644 --- a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java +++ b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java @@ -31,6 +31,7 @@ import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiUtilCore; import com.intellij.refactoring.util.TextOccurrencesUtil; +import com.intellij.usageView.UsageInfoFactory; import com.intellij.usageView.UsageInfo; import com.intellij.util.IncorrectOperationException; import com.intellij.util.Processor; @@ -169,7 +170,7 @@ public abstract class FindUsagesHandler { return element.getTextRange(); } }); - TextOccurrencesUtil.UsageInfoFactory factory = new TextOccurrencesUtil.UsageInfoFactory() { + UsageInfoFactory factory = new UsageInfoFactory() { @Override public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) { if (elementTextRange != null diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/NonCodeUsageInfoFactory.java b/platform/lang-impl/src/com/intellij/refactoring/rename/NonCodeUsageInfoFactory.java index 7fbad73451c6..ed8738371d45 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/NonCodeUsageInfoFactory.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/NonCodeUsageInfoFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,14 @@ package com.intellij.refactoring.rename; import com.intellij.refactoring.util.NonCodeUsageInfo; -import com.intellij.refactoring.util.TextOccurrencesUtil; import com.intellij.psi.PsiElement; +import com.intellij.usageView.UsageInfoFactory; import com.intellij.usageView.UsageInfo; import com.intellij.codeInsight.TargetElementUtilBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class NonCodeUsageInfoFactory implements TextOccurrencesUtil.UsageInfoFactory { +public class NonCodeUsageInfoFactory implements UsageInfoFactory { private final PsiElement myElement; private final String myStringToReplace; diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameUtil.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameUtil.java index 490efeea1734..bcbe187fb9e5 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameUtil.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -42,6 +42,7 @@ import com.intellij.refactoring.listeners.RefactoringElementListener; import com.intellij.refactoring.listeners.UndoRefactoringElementListener; import com.intellij.refactoring.util.*; import com.intellij.usageView.UsageInfo; +import com.intellij.usageView.UsageInfoFactory; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.HashMap; import com.intellij.util.containers.MultiMap; @@ -88,7 +89,7 @@ public class RenameUtil { String stringToSearch = ElementDescriptionUtil.getElementDescription(searchForInComments, NonCodeSearchDescriptionLocation.STRINGS_AND_COMMENTS); if (stringToSearch.length() > 0) { final String stringToReplace = getStringToReplace(element, newName, false, processor); - TextOccurrencesUtil.UsageInfoFactory factory = new NonCodeUsageInfoFactory(searchForInComments, stringToReplace); + UsageInfoFactory factory = new NonCodeUsageInfoFactory(searchForInComments, stringToReplace); TextOccurrencesUtil.addUsagesInStringsAndComments(searchForInComments, stringToSearch, result, factory); } } @@ -111,7 +112,7 @@ public class RenameUtil { private static void addTextOccurrence(final PsiElement element, final List result, final GlobalSearchScope projectScope, final String stringToSearch, final String stringToReplace) { - TextOccurrencesUtil.UsageInfoFactory factory = new TextOccurrencesUtil.UsageInfoFactory() { + UsageInfoFactory factory = new UsageInfoFactory() { @Override public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) { TextRange textRange = usage.getTextRange(); diff --git a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java index b8f069d5f142..23688a08aded 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java @@ -42,6 +42,7 @@ import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteUsageInfo; import com.intellij.refactoring.util.NonCodeSearchDescriptionLocation; import com.intellij.refactoring.util.RefactoringUIUtil; import com.intellij.refactoring.util.TextOccurrencesUtil; +import com.intellij.usageView.UsageInfoFactory; import com.intellij.usageView.UsageInfo; import com.intellij.usageView.UsageViewDescriptor; import com.intellij.usageView.UsageViewUtil; @@ -422,7 +423,7 @@ public class SafeDeleteProcessor extends BaseRefactoringProcessor { private void addNonCodeUsages(final PsiElement element, List usages, @Nullable final Condition insideElements) { - TextOccurrencesUtil.UsageInfoFactory nonCodeUsageFactory = new TextOccurrencesUtil.UsageInfoFactory() { + UsageInfoFactory nonCodeUsageFactory = new UsageInfoFactory() { @Override public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) { if (insideElements != null && insideElements.value(usage)) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java b/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java index 48a4879a7bf4..e77206812f7d 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java +++ b/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java @@ -35,10 +35,10 @@ import com.intellij.psi.PsiPolyVariantReference; import com.intellij.psi.PsiReference; import com.intellij.psi.search.*; import com.intellij.usageView.UsageInfo; +import com.intellij.usageView.UsageInfoFactory; import com.intellij.util.PairProcessor; import com.intellij.util.Processor; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -219,9 +219,4 @@ public class TextOccurrencesUtil { } }; } - - public interface UsageInfoFactory { - @Nullable - UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset); - } }