Refactoring: rename and make public
This commit is contained in:
@@ -35,8 +35,8 @@ import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase;
|
|||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
import org.jetbrains.jet.plugin.highlighter.markers.SuperDeclarationMarkerNavigationHandler;
|
import org.jetbrains.jet.plugin.highlighter.markers.SuperDeclarationMarkerNavigationHandler;
|
||||||
import org.jetbrains.jet.plugin.navigation.NavigationTestUtils;
|
import org.jetbrains.jet.plugin.navigation.NavigationTestUtils;
|
||||||
import org.jetbrains.jet.testing.HighlightTestDataUtil;
|
|
||||||
import org.jetbrains.jet.testing.ReferenceUtils;
|
import org.jetbrains.jet.testing.ReferenceUtils;
|
||||||
|
import org.jetbrains.jet.testing.TagsTestDataUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -75,7 +75,7 @@ public abstract class AbstractLineMarkersTest extends JetLightCodeInsightFixture
|
|||||||
}
|
}
|
||||||
catch (AssertionError error) {
|
catch (AssertionError error) {
|
||||||
try {
|
try {
|
||||||
String actualTextWithTestData = HighlightTestDataUtil.insertInfoTags(markers, true, myFixture.getFile().getText());
|
String actualTextWithTestData = TagsTestDataUtil.insertInfoTags(markers, true, myFixture.getFile().getText());
|
||||||
JetTestUtils.assertEqualsToFile(new File(getTestDataPath(), fileName()), actualTextWithTestData);
|
JetTestUtils.assertEqualsToFile(new File(getTestDataPath(), fileName()), actualTextWithTestData);
|
||||||
}
|
}
|
||||||
catch (FileComparisonFailure failure) {
|
catch (FileComparisonFailure failure) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.InTextDirectivesUtils;
|
import org.jetbrains.jet.InTextDirectivesUtils;
|
||||||
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase;
|
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase;
|
||||||
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
||||||
import org.jetbrains.jet.testing.HighlightTestDataUtil;
|
import org.jetbrains.jet.testing.TagsTestDataUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -53,7 +53,7 @@ public abstract class AbstractHighlightingTest extends JetLightCodeInsightFixtur
|
|||||||
DaemonCodeAnalyzerImpl.getHighlights(myFixture.getDocument(myFixture.getFile()), null, myFixture.getProject());
|
DaemonCodeAnalyzerImpl.getHighlights(myFixture.getDocument(myFixture.getFile()), null, myFixture.getProject());
|
||||||
String text = myFixture.getFile().getText();
|
String text = myFixture.getFile().getText();
|
||||||
|
|
||||||
System.out.println(HighlightTestDataUtil.insertInfoTags(highlights, text));
|
System.out.println(TagsTestDataUtil.insertInfoTags(highlights, text));
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-14
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HighlightTestDataUtil {
|
public class TagsTestDataUtil {
|
||||||
public static String insertInfoTags(List<LineMarkerInfo> lineMarkers, boolean withDescription, String text) {
|
public static String insertInfoTags(List<LineMarkerInfo> lineMarkers, boolean withDescription, String text) {
|
||||||
List<LineMarkerTagPoint> lineMarkerPoints = Lists.newArrayList();
|
List<LineMarkerTagPoint> lineMarkerPoints = Lists.newArrayList();
|
||||||
for (LineMarkerInfo markerInfo : lineMarkers) {
|
for (LineMarkerInfo markerInfo : lineMarkers) {
|
||||||
@@ -46,13 +46,13 @@ public class HighlightTestDataUtil {
|
|||||||
return insertTagsInText(highlightPoints, text);
|
return insertTagsInText(highlightPoints, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String insertTagsInText(List<? extends HighlightTag> tags, String text) {
|
public static String insertTagsInText(List<? extends TagInfo> tags, String text) {
|
||||||
StringBuilder builder = new StringBuilder(text);
|
StringBuilder builder = new StringBuilder(text);
|
||||||
|
|
||||||
List<? extends HighlightTag> sortedTagPoints = Ordering.natural().reverse().sortedCopy(tags);
|
List<? extends TagInfo> sortedTagPoints = Ordering.natural().reverse().sortedCopy(tags);
|
||||||
|
|
||||||
// Insert tags into text starting from the end for preventing invalidating previous tags offsets
|
// Insert tags into text starting from the end for preventing invalidating previous tags offsets
|
||||||
for (HighlightTag point : sortedTagPoints) {
|
for (TagInfo point : sortedTagPoints) {
|
||||||
String tagText;
|
String tagText;
|
||||||
if (point.isStart) {
|
if (point.isStart) {
|
||||||
String attributesString = point.getAttributesString();
|
String attributesString = point.getAttributesString();
|
||||||
@@ -73,19 +73,19 @@ public class HighlightTestDataUtil {
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static abstract class HighlightTag<Data> implements Comparable<HighlightTag<?>> {
|
public static class TagInfo<Data> implements Comparable<TagInfo<?>> {
|
||||||
protected final int offset;
|
protected final int offset;
|
||||||
protected final boolean isStart;
|
protected final boolean isStart;
|
||||||
protected final Data data;
|
protected final Data data;
|
||||||
|
|
||||||
private HighlightTag(int offset, boolean start, Data data) {
|
public TagInfo(int offset, boolean start, Data data) {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
isStart = start;
|
isStart = start;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull HighlightTag<?> other) {
|
public int compareTo(@NotNull TagInfo<?> other) {
|
||||||
if (offset != other.offset) {
|
if (offset != other.offset) {
|
||||||
return ((Integer) offset).compareTo(other.offset);
|
return ((Integer) offset).compareTo(other.offset);
|
||||||
}
|
}
|
||||||
@@ -103,13 +103,17 @@ public class HighlightTestDataUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
abstract String getName();
|
public String getName() {
|
||||||
|
return data.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
abstract String getAttributesString();
|
public String getAttributesString() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class HighlightTagPoint extends HighlightTag<HighlightInfo> {
|
private static class HighlightTagPoint extends TagInfo<HighlightInfo> {
|
||||||
private final HighlightInfo highlightInfo;
|
private final HighlightInfo highlightInfo;
|
||||||
|
|
||||||
private HighlightTagPoint(int offset, boolean start, HighlightInfo info) {
|
private HighlightTagPoint(int offset, boolean start, HighlightInfo info) {
|
||||||
@@ -127,7 +131,7 @@ public class HighlightTestDataUtil {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
String getAttributesString() {
|
public String getAttributesString() {
|
||||||
if (isStart) {
|
if (isStart) {
|
||||||
if (highlightInfo.getDescription() != null) {
|
if (highlightInfo.getDescription() != null) {
|
||||||
return String.format("textAttributesKey=\"%s\" descr=%s",
|
return String.format("textAttributesKey=\"%s\" descr=%s",
|
||||||
@@ -144,7 +148,7 @@ public class HighlightTestDataUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LineMarkerTagPoint extends HighlightTag<LineMarkerInfo> {
|
private static class LineMarkerTagPoint extends TagInfo<LineMarkerInfo> {
|
||||||
private final boolean withDescription;
|
private final boolean withDescription;
|
||||||
|
|
||||||
public LineMarkerTagPoint(int offset, boolean start, LineMarkerInfo info, boolean withDescription) {
|
public LineMarkerTagPoint(int offset, boolean start, LineMarkerInfo info, boolean withDescription) {
|
||||||
@@ -154,13 +158,13 @@ public class HighlightTestDataUtil {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
String getName() {
|
public String getName() {
|
||||||
return "lineMarker";
|
return "lineMarker";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
String getAttributesString() {
|
public String getAttributesString() {
|
||||||
return withDescription ? String.format("descr=\"%s\"", data.getLineMarkerTooltip()) : "descr=\"*\"";
|
return withDescription ? String.format("descr=\"%s\"", data.getLineMarkerTooltip()) : "descr=\"*\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user