mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-166240 Unordered line numbers in the "Find" panel
This commit is contained in:
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -13,12 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.find;
|
||||
package com.intellij.find.impl;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
|
||||
import com.intellij.find.impl.FindInProjectUtil;
|
||||
import com.intellij.find.impl.FindResultImpl;
|
||||
import com.intellij.find.*;
|
||||
import com.intellij.find.replaceInProject.ReplaceInProjectManager;
|
||||
import com.intellij.lang.properties.IProperty;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.find.impl;
|
||||
|
||||
import com.intellij.find.FindManager;
|
||||
import com.intellij.find.FindModel;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class FindResultTest extends PlatformTestCase {
|
||||
public void testFindResultHasCorrectCompare() throws IOException {
|
||||
VirtualFile file = createTempFile("txt", null, "xxxx", CharsetToolkit.UTF8_CHARSET);
|
||||
PsiFile psiFile = getPsiManager().findFile(file);
|
||||
FindResultUsageInfo info1 = new FindResultUsageInfo(FindManager.getInstance(myProject), psiFile, 1, new FindModel(), new FindResultImpl(1, 2));
|
||||
FindResultUsageInfo info2 = new FindResultUsageInfo(FindManager.getInstance(myProject), psiFile, 2, new FindModel(), new FindResultImpl(2, 3));
|
||||
assertTrue("result: "+info1.compareToByStartOffset(info2),info1.compareToByStartOffset(info2) < 0);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import com.intellij.testFramework.LightVirtualFile;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class FindManagerTestUtils {
|
||||
static void runFindInCommentsAndLiterals(FindManager findManager, FindModel findModel, String text) {
|
||||
public static void runFindInCommentsAndLiterals(FindManager findManager, FindModel findModel, String text) {
|
||||
runFindInCommentsAndLiterals(findManager, findModel, text, "java");
|
||||
}
|
||||
|
||||
@@ -38,11 +38,10 @@ public class FindManagerTestUtils {
|
||||
public static void runFindForwardAndBackward(FindManager findManager, FindModel findModel, String text, String ext) {
|
||||
findModel.setForward(true);
|
||||
LightVirtualFile file = new LightVirtualFile("A."+ext, text);
|
||||
int previousOffset;
|
||||
|
||||
FindResult findResult = findManager.findString(text, 0, findModel, file);
|
||||
Assert.assertTrue(findResult.isStringFound());
|
||||
previousOffset = findResult.getStartOffset();
|
||||
int previousOffset = findResult.getStartOffset();
|
||||
|
||||
findResult = findManager.findString(text, findResult.getEndOffset(), findModel, file);
|
||||
Assert.assertTrue(findResult.isStringFound());
|
||||
|
||||
@@ -256,9 +256,9 @@ public class UsageInfo {
|
||||
shift0 = ((VirtualFileWindow)containingFile0).getDocumentWindow().injectedToHost(0);
|
||||
containingFile0 = ((VirtualFileWindow)containingFile0).getDelegate();
|
||||
}
|
||||
Segment range0 = mySmartPointer.getPsiRange();
|
||||
if (range0 == null) return null;
|
||||
return Pair.create(containingFile0, range0.getStartOffset() + shift0);
|
||||
Segment range = myPsiFileRange == null ? mySmartPointer.getPsiRange() : myPsiFileRange.getPsiRange();
|
||||
if (range == null) return null;
|
||||
return Pair.create(containingFile0, range.getStartOffset() + shift0);
|
||||
}
|
||||
|
||||
public int compareToByStartOffset(@NotNull UsageInfo info) {
|
||||
|
||||
@@ -19,13 +19,14 @@ package com.intellij.find.impl;
|
||||
import com.intellij.find.FindResult;
|
||||
|
||||
public class FindResultImpl extends FindResult {
|
||||
private boolean isStringFound = true;
|
||||
private final boolean isStringFound;
|
||||
|
||||
public FindResultImpl(int startOffset, int endOffset) {
|
||||
super(startOffset, endOffset);
|
||||
isStringFound = true;
|
||||
}
|
||||
|
||||
public FindResultImpl() {
|
||||
FindResultImpl() {
|
||||
super(0, 0);
|
||||
isStringFound = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user