org.eclipse.xtext.formatting2.debug.TextRegionsToString Java Examples
The following examples show how to use
org.eclipse.xtext.formatting2.debug.TextRegionsToString.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FormatterTester.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void assertAllWhitespaceIsFormatted(ITextRegionAccess access, List<ITextReplacement> replacements) { List<ITextSegment> expected = Lists.newArrayList(); IHiddenRegion current = access.regionForRootEObject().getPreviousHiddenRegion(); while (current != null) { expected.addAll(current.getMergedSpaces()); current = current.getNextHiddenRegion(); } List<ITextSegment> missing = TextRegions.difference(expected, replacements); if (!missing.isEmpty()) { TextRegionsToString toString = new TextRegionsToString().setTextRegionAccess(access); for (ITextSegment region : missing) toString.add(region, region.getClass().getSimpleName()); String msg = "The following regions are not formatted:\n" + toString; System.err.println(msg); Assert.fail(msg); } }
Example #2
Source File: FormatterTester.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void assertAllWhitespaceIsFormatted(ITextRegionAccess access, List<ITextReplacement> replacements) { List<ITextSegment> expected = Lists.newArrayList(); IHiddenRegion current = access.regionForRootEObject().getPreviousHiddenRegion(); while (current != null) { expected.addAll(current.getMergedSpaces()); current = current.getNextHiddenRegion(); } List<ITextSegment> missing = TextRegions.difference(expected, replacements); if (!missing.isEmpty()) { TextRegionsToString toString = new TextRegionsToString().setTextRegionAccess(access); for (ITextSegment region : missing) toString.add(region, region.getClass().getSimpleName()); String msg = "The following regions are not formatted:\n" + toString; System.err.println(msg); Assert.fail(msg); } }
Example #3
Source File: FormatterTestHelper.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected void assertAllWhitespaceIsFormatted(ITextRegionAccess access, List<ITextReplacement> replacements) { List<ITextSegment> expected = Lists.newArrayList(); IHiddenRegion current = access.regionForRootEObject().getPreviousHiddenRegion(); while (current != null) { expected.addAll(current.getMergedSpaces()); current = current.getNextHiddenRegion(); } List<ITextSegment> missing = TextRegions.difference(expected, replacements); if (!missing.isEmpty()) { TextRegionsToString toString = new TextRegionsToString().setTextRegionAccess(access); for (ITextSegment region : missing) toString.add(region, region.getClass().getSimpleName()); String msg = "The following regions are not formatted:\n" + toString; System.err.println(msg); Assert.fail(msg); } }
Example #4
Source File: TextDocumentChangeToString.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public String toString() { List<String> result = Lists.newArrayList(); for (IEmfResourceChange c : changes) { String title = getTitle(c); if (c instanceof ITextDocumentChange) { ITextDocumentChange change = (ITextDocumentChange) c; TextRegionsToString textRegionsToString = new TextRegionsToString(); textRegionsToString.setIgnoreCarriageReturnInQuotes(true); textRegionsToString.addAllReplacements(change.getReplacements()); textRegionsToString.setTitle(title); result.add(textRegionsToString.toString()); } else { String box = box(title, c.toString()); result.add(box); } } return Joiner.on("\n").join(result); }
Example #5
Source File: FormatterTester.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void assertReplacementsAreInRegion(List<ITextReplacement> rep, Collection<ITextRegion> regions, String doc) { Set<ITextReplacement> invalid = Sets.newHashSet(); ALLOWED: for (ITextRegion allowed : regions) for (ITextReplacement r : rep) { if (allowed.contains(r)) continue ALLOWED; invalid.add(r); } if (!invalid.isEmpty()) { String visualized = new TextRegionsToString().addAllReplacements(invalid).toString(); fail("One or more TextReplacements are outside of the allowed region. Region: " + regions, visualized); } }
Example #6
Source File: FormatterTester.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void assertReplacementsAreInRegion(List<ITextReplacement> rep, Collection<ITextRegion> regions, String doc) { Set<ITextReplacement> invalid = Sets.newHashSet(); ALLOWED: for (ITextRegion allowed : regions) for (ITextReplacement r : rep) { if (allowed.contains(r)) continue ALLOWED; invalid.add(r); } if (!invalid.isEmpty()) { String visualized = new TextRegionsToString().addAllReplacements(invalid).toString(); fail("One or more TextReplacements are outside of the allowed region. Region: " + regions, visualized); } }
Example #7
Source File: FormatterTestHelper.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void assertReplacementsAreInRegion(List<ITextReplacement> rep, Collection<ITextRegion> regions, String doc) { Set<ITextReplacement> invalid = Sets.newHashSet(); ALLOWED: for (ITextRegion allowed : regions) for (ITextReplacement r : rep) { if (allowed.contains(r)) continue ALLOWED; invalid.add(r); } if (!invalid.isEmpty()) { String visualized = new TextRegionsToString().addAllReplacements(invalid).toString(); fail("One or more TextReplacements are outside of the allowed region. Region: " + regions, visualized); } }
Example #8
Source File: TextReplacementList.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public String toString() { return new TextRegionsToString().setTitle(getClass().getSimpleName()).addAllReplacements(this).toString(); }