Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Settings/Code Style/JavaDoc: fix highlighting of changed fragments
* do not highlight whole line, if there are found inner fragments -- before this change, whole modified line was highlighted. Now only changed whitespaces are highlighted. -- it was broken in 7af486c (DiffMarkup was not intended to be used like this) * Use new diff API
- Loading branch information
1 parent
cb6b52b
commit 30d0673
Showing
3 changed files
with
113 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...orm/lang-impl/testSources/com/intellij/application/options/ChangesDiffCalculatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2000-2016 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.application.options; | ||
|
||
import com.intellij.openapi.editor.impl.DocumentImpl; | ||
import com.intellij.openapi.util.TextRange; | ||
import com.intellij.testFramework.LightPlatformTestCase; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ChangesDiffCalculatorTest extends LightPlatformTestCase { | ||
public void testEmpty() { | ||
doTest("", ""); | ||
|
||
doTest("a b c", "a b c"); | ||
|
||
doTest("a\nb\nc\n", "a\nb\nc\n"); | ||
} | ||
|
||
public void testSimple() { | ||
doTest("", "X", | ||
new TextRange(0, 1)); | ||
|
||
doTest("a B c", "a X c", | ||
new TextRange(2, 3)); | ||
|
||
doTest("while()", "while ()", | ||
new TextRange(5, 6)); | ||
|
||
doTest("else {", "else\n {", | ||
new TextRange(4, 8)); | ||
|
||
doTest("while ()", "while()", | ||
new TextRange(5, 5)); | ||
|
||
doTest("if\n then", "if\n\n then", | ||
new TextRange(3, 4)); | ||
} | ||
|
||
public void testWhitespaceSequences() { | ||
doTest("X Y", "X Y", | ||
new TextRange(3, 3)); | ||
|
||
doTest("X Y", "X Y", | ||
new TextRange(3, 6)); | ||
} | ||
|
||
private static void doTest(@NotNull String before, @NotNull String current, @NotNull TextRange... expectedRanges) { | ||
DocumentImpl beforeDocument = new DocumentImpl(before); | ||
DocumentImpl currentDocument = new DocumentImpl(current); | ||
|
||
List<TextRange> actualRanges = ChangesDiffCalculator.calculateDiff(beforeDocument, currentDocument); | ||
|
||
assertEquals(Arrays.asList(expectedRanges), actualRanges); | ||
} | ||
} |