diff options
author | Jean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com> | 2013-05-30 10:32:04 +0200 |
---|---|---|
committer | Jean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com> | 2013-05-30 10:32:04 +0200 |
commit | a9882f1d1b2e0fa5f89e3e8ee7c536b4ddc94c6e (patch) | |
tree | a2b192ab3d4947ae5f4c0f87156a181751ee0156 /sonar-batch/src | |
parent | 472b1db308672f592f984b253ac7aa245db68452 (diff) | |
download | sonarqube-a9882f1d1b2e0fa5f89e3e8ee7c536b4ddc94c6e.tar.gz sonarqube-a9882f1d1b2e0fa5f89e3e8ee7c536b4ddc94c6e.zip |
Fixed quality issues
Diffstat (limited to 'sonar-batch/src')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/source/DefaultHighlightable.java | 8 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java | 5 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingData.java | 58 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingDataBuilder.java | 105 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRule.java | 4 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRuleSet.java | 149 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/source/DefaultHighlightableTest.java | 2 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingDataBuilderTest.java (renamed from sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingRuleSetTest.java) | 41 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingDataTest.java | 46 |
9 files changed, 235 insertions, 183 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/DefaultHighlightable.java b/sonar-batch/src/main/java/org/sonar/batch/source/DefaultHighlightable.java index 39fb1288317..c60997dceed 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/source/DefaultHighlightable.java +++ b/sonar-batch/src/main/java/org/sonar/batch/source/DefaultHighlightable.java @@ -31,12 +31,12 @@ public class DefaultHighlightable implements Highlightable { private final Component component; private final ComponentDataCache cache; - private final SyntaxHighlightingRuleSet.Builder builder; + private final SyntaxHighlightingDataBuilder builder; public DefaultHighlightable(Component component, ComponentDataCache cache) { this.component = component; this.cache = cache; - this.builder = SyntaxHighlightingRuleSet.builder(); + this.builder = new SyntaxHighlightingDataBuilder(); } @Override @@ -49,8 +49,8 @@ public class DefaultHighlightable implements Highlightable { return component; } - public SyntaxHighlightingRuleSet getHighlightingRules() { - return builder.build(); + public SyntaxHighlightingDataBuilder getHighlightingRules() { + return builder; } private class DefaultHighlightingBuilder implements HighlightingBuilder { diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java b/sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java index c4f78b74502..a17e6eb2c10 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java +++ b/sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java @@ -25,6 +25,7 @@ import com.google.common.collect.TreeMultimap; import org.sonar.api.source.Symbol; import org.sonar.api.source.Symbolizable; +import java.io.Serializable; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -83,14 +84,14 @@ public class DefaultSymbolTable implements Symbolizable.SymbolTable { return new DefaultSymbolTable(referencesBySymbol); } - private static class SymbolComparator implements Comparator<Symbol> { + private static class SymbolComparator implements Comparator<Symbol>, Serializable { @Override public int compare(Symbol left, Symbol right) { return left.getDeclarationStartOffset() - right.getDeclarationStartOffset(); } } - private static class ReferenceComparator implements Comparator<Integer> { + private static class ReferenceComparator implements Comparator<Integer>, Serializable { @Override public int compare(Integer left, Integer right) { int result; diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingData.java b/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingData.java new file mode 100644 index 00000000000..51543f44b32 --- /dev/null +++ b/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingData.java @@ -0,0 +1,58 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.batch.source; + +import org.sonar.batch.index.Data; + +import java.util.List; + +public class SyntaxHighlightingData implements Data { + + private static final String FIELD_SEPARATOR = ","; + private static final String RULE_SEPARATOR = ";"; + + private List<SyntaxHighlightingRule> syntaxHighlightingRuleSet; + + public SyntaxHighlightingData(List<SyntaxHighlightingRule> syntaxHighlightingRuleSet) { + this.syntaxHighlightingRuleSet = syntaxHighlightingRuleSet; + } + + @Override + public String writeString() { + StringBuilder sb = new StringBuilder(); + List<SyntaxHighlightingRule> orderedRules = syntaxHighlightingRuleSet; + + for (SyntaxHighlightingRule highlightingRule : orderedRules) { + sb.append(highlightingRule.getStartPosition()) + .append(FIELD_SEPARATOR) + .append(highlightingRule.getEndPosition()) + .append(FIELD_SEPARATOR) + .append(highlightingRule.getTextType()) + .append(RULE_SEPARATOR); + } + + return sb.toString(); + } + + @Override + public void readString(String s) { + throw new UnsupportedOperationException(); + } +} diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingDataBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingDataBuilder.java new file mode 100644 index 00000000000..6cb0f1c580f --- /dev/null +++ b/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingDataBuilder.java @@ -0,0 +1,105 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.batch.source; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Predicate; +import com.google.common.collect.Collections2; +import com.google.common.collect.Ordering; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; +import java.util.Collection; +import java.util.List; + +import static com.google.common.collect.Lists.newArrayList; + +/** + * @since 3.6 + */ +public class SyntaxHighlightingDataBuilder { + + private List<SyntaxHighlightingRule> syntaxHighlightingRuleSet; + + public SyntaxHighlightingDataBuilder() { + syntaxHighlightingRuleSet = newArrayList(); + } + + public SyntaxHighlightingDataBuilder registerHighlightingRule(int startOffset, int endOffset, String typeOfText) { + if (ruleConflictsWithExistingRules(startOffset, endOffset)) { + String errorMsg = String.format("Cannot register highlighting rule for characters from %s to %s as it " + + "overlaps at least one existing rule", startOffset, endOffset); + LoggerFactory.getLogger(SyntaxHighlightingDataBuilder.class).error(errorMsg); + throw new UnsupportedOperationException(errorMsg); + } + SyntaxHighlightingRule syntaxHighlightingRule = SyntaxHighlightingRule.create(startOffset, endOffset, + typeOfText); + this.syntaxHighlightingRuleSet.add(syntaxHighlightingRule); + return this; + } + + public SyntaxHighlightingData build() { + return new SyntaxHighlightingData(getSortedRules()); + } + + private boolean ruleConflictsWithExistingRules(final int startOffset, final int endOffset) { + Collection<SyntaxHighlightingRule> conflictingRules = Collections2 + .filter(syntaxHighlightingRuleSet, new Predicate<SyntaxHighlightingRule>() { + @Override + public boolean apply(@Nullable SyntaxHighlightingRule syntaxHighlightingRule) { + + if (syntaxHighlightingRule != null) { + boolean overlapsStartBoundary = startOffset < syntaxHighlightingRule.getStartPosition() + && endOffset >= syntaxHighlightingRule.getStartPosition() + 1 + && endOffset < syntaxHighlightingRule.getEndPosition(); + + boolean overlapsEndBoundary = startOffset > syntaxHighlightingRule.getStartPosition() + && startOffset < syntaxHighlightingRule.getEndPosition() + && endOffset > syntaxHighlightingRule.getEndPosition(); + + return overlapsStartBoundary || overlapsEndBoundary; + } + return false; + } + }); + return !conflictingRules.isEmpty(); + } + + @VisibleForTesting + protected List<SyntaxHighlightingRule> getSortedRules() { + Ordering<SyntaxHighlightingRule> ruleOrdering = new Ordering<SyntaxHighlightingRule>() { + @Override + public int compare(@Nullable SyntaxHighlightingRule left, + @Nullable SyntaxHighlightingRule right) { + int result; + if (left != null && right != null) { + result = left.getStartPosition() - right.getStartPosition(); + if (result == 0) { + result = left.getEndPosition() - right.getEndPosition(); + } + return result; + } + return left != null ? 1 : -1; + } + }; + + return ruleOrdering.immutableSortedCopy(syntaxHighlightingRuleSet); + } +} diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRule.java b/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRule.java index 9ebae160a2b..ce906989e87 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRule.java @@ -19,10 +19,12 @@ */ package org.sonar.batch.source; +import java.io.Serializable; + /** * @since 3.6 */ -public class SyntaxHighlightingRule { +public class SyntaxHighlightingRule implements Serializable { private final int startPosition; private final int endPosition; diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRuleSet.java b/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRuleSet.java deleted file mode 100644 index f367f3bf1db..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/source/SyntaxHighlightingRuleSet.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.batch.source; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Predicate; -import com.google.common.collect.Collections2; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Ordering; -import org.slf4j.LoggerFactory; -import org.sonar.batch.index.Data; - -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.List; - -import static com.google.common.collect.Lists.newArrayList; - -/** - * @since 3.6 - */ -public class SyntaxHighlightingRuleSet implements Data { - - private static final String FIELD_SEPARATOR = ","; - private static final String RULE_SEPARATOR = ";"; - - private List<SyntaxHighlightingRule> syntaxHighlightingRuleSet; - - private SyntaxHighlightingRuleSet(List<SyntaxHighlightingRule> syntaxHighlightingRules) { - syntaxHighlightingRuleSet = syntaxHighlightingRules; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private List<SyntaxHighlightingRule> syntaxHighlightingRuleSet; - - public Builder() { - syntaxHighlightingRuleSet = newArrayList(); - } - - public Builder registerHighlightingRule(int startOffset, int endOffset, String typeOfText) { - if (ruleConflictsWithExistingRules(startOffset, endOffset)) { - String errorMsg = String.format("Cannot register highlighting rule for characters from %s to %s as it " + - "overlaps at least one existing rule", startOffset, endOffset); - LoggerFactory.getLogger(SyntaxHighlightingRuleSet.class).error(errorMsg); - throw new UnsupportedOperationException(errorMsg); - } - SyntaxHighlightingRule syntaxHighlightingRule = SyntaxHighlightingRule.create(startOffset, endOffset, - typeOfText); - this.syntaxHighlightingRuleSet.add(syntaxHighlightingRule); - return this; - } - - public SyntaxHighlightingRuleSet build() { - return new SyntaxHighlightingRuleSet(ImmutableList.copyOf(syntaxHighlightingRuleSet)); - } - - private boolean ruleConflictsWithExistingRules(final int startOffset, final int endOffset) { - Collection<SyntaxHighlightingRule> conflictingRules = Collections2 - .filter(syntaxHighlightingRuleSet, new Predicate<SyntaxHighlightingRule>() { - @Override - public boolean apply(@Nullable SyntaxHighlightingRule syntaxHighlightingRule) { - - if (syntaxHighlightingRule != null) { - boolean overlapsStartBoundary = startOffset < syntaxHighlightingRule.getStartPosition() - && endOffset >= syntaxHighlightingRule.getStartPosition() + 1 - && endOffset < syntaxHighlightingRule.getEndPosition(); - - boolean overlapsEndBoundary = startOffset > syntaxHighlightingRule.getStartPosition() - && startOffset < syntaxHighlightingRule.getEndPosition() - && endOffset > syntaxHighlightingRule.getEndPosition(); - - return overlapsStartBoundary || overlapsEndBoundary; - } - return false; - } - }); - return !conflictingRules.isEmpty(); - } - } - - public List<SyntaxHighlightingRule> getSyntaxHighlightingRuleSet() { - return syntaxHighlightingRuleSet; - } - - @Override - public String writeString() { - StringBuilder sb = new StringBuilder(); - List<SyntaxHighlightingRule> orderedRules = getOrderedHighlightingRules(); - - for (SyntaxHighlightingRule highlightingRule : orderedRules) { - sb.append(highlightingRule.getStartPosition()) - .append(FIELD_SEPARATOR) - .append(highlightingRule.getEndPosition()) - .append(FIELD_SEPARATOR) - .append(highlightingRule.getTextType()) - .append(RULE_SEPARATOR); - } - - return sb.toString(); - } - - @Override - public void readString(String s) { - throw new UnsupportedOperationException(); - } - - @VisibleForTesting - protected List<SyntaxHighlightingRule> getOrderedHighlightingRules() { - Ordering<SyntaxHighlightingRule> ruleOrdering = new Ordering<SyntaxHighlightingRule>() { - @Override - public int compare(@Nullable SyntaxHighlightingRule left, - @Nullable SyntaxHighlightingRule right) { - int result = 0; - if (left != null && right != null) { - result = left.getStartPosition() - right.getStartPosition(); - if (result == 0) { - result = left.getEndPosition() - right.getEndPosition(); - } - return result; - } - return left != null ? 1 : -1; - } - }; - - return ruleOrdering.sortedCopy(syntaxHighlightingRuleSet); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/source/DefaultHighlightableTest.java b/sonar-batch/src/test/java/org/sonar/batch/source/DefaultHighlightableTest.java index b08289de62f..05bdb0ac0a8 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/source/DefaultHighlightableTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/source/DefaultHighlightableTest.java @@ -39,7 +39,7 @@ public class DefaultHighlightableTest { DefaultHighlightable highlightablePerspective = new DefaultHighlightable(null, null); highlightablePerspective.newHighlighting().highlight(0, 10, "k").highlight(20, 30, "cppd"); - assertThat(highlightablePerspective.getHighlightingRules().getSyntaxHighlightingRuleSet()).hasSize(2); + assertThat(highlightablePerspective.getHighlightingRules().getSortedRules()).hasSize(2); } @Test diff --git a/sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingRuleSetTest.java b/sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingDataBuilderTest.java index 0db6dc5116f..8eec1229136 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingRuleSetTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingDataBuilderTest.java @@ -29,9 +29,9 @@ import java.util.List; import static org.fest.assertions.Assertions.assertThat; -public class SyntaxHighlightingRuleSetTest { +public class SyntaxHighlightingDataBuilderTest { - private SyntaxHighlightingRuleSet highlightingRules; + private List<SyntaxHighlightingRule> highlightingRules; @Rule public ExpectedException throwable = ExpectedException.none(); @@ -39,45 +39,34 @@ public class SyntaxHighlightingRuleSetTest { @Before public void setUpSampleRules() { - SyntaxHighlightingRuleSet.Builder highlightingRuleSet = SyntaxHighlightingRuleSet.builder(); - highlightingRuleSet.registerHighlightingRule(0, 10, "cd"); - highlightingRuleSet.registerHighlightingRule(10, 12, "k"); - highlightingRuleSet.registerHighlightingRule(24, 38, "k"); - highlightingRuleSet.registerHighlightingRule(42, 50, "k"); - highlightingRuleSet.registerHighlightingRule(24, 65, "cppd"); - highlightingRuleSet.registerHighlightingRule(12, 20, "cd"); + SyntaxHighlightingDataBuilder highlightingDataBuilder = new SyntaxHighlightingDataBuilder(); + highlightingDataBuilder.registerHighlightingRule(0, 10, "cd"); + highlightingDataBuilder.registerHighlightingRule(10, 12, "k"); + highlightingDataBuilder.registerHighlightingRule(24, 38, "k"); + highlightingDataBuilder.registerHighlightingRule(42, 50, "k"); + highlightingDataBuilder.registerHighlightingRule(24, 65, "cppd"); + highlightingDataBuilder.registerHighlightingRule(12, 20, "cd"); - highlightingRules = highlightingRuleSet.build(); + highlightingRules = highlightingDataBuilder.getSortedRules(); } @Test public void should_register_highlighting_rule() throws Exception { - assertThat(highlightingRules.getSyntaxHighlightingRuleSet()).hasSize(6); + assertThat(highlightingRules).hasSize(6); } @Test public void should_order_by_start_then_end_offset() throws Exception { - - List<SyntaxHighlightingRule> orderedRules = highlightingRules.getOrderedHighlightingRules(); - - assertThat(orderedRules).onProperty("startPosition").containsExactly(0, 10, 12, 24, 24, 42); - assertThat(orderedRules).onProperty("endPosition").containsExactly(10, 12, 20, 38, 65, 50); - assertThat(orderedRules).onProperty("textType").containsExactly("cd", "k", "cd", "k", "cppd", "k"); - } - - @Test - public void should_serialize_rules_to_string() throws Exception { - - String serializedRules = highlightingRules.writeString(); - assertThat(serializedRules).isEqualTo("0,10,cd;10,12,k;12,20,cd;24,38,k;24,65,cppd;42,50,k;"); + assertThat(highlightingRules).onProperty("startPosition").containsExactly(0, 10, 12, 24, 24, 42); + assertThat(highlightingRules).onProperty("endPosition").containsExactly(10, 12, 20, 38, 65, 50); + assertThat(highlightingRules).onProperty("textType").containsExactly("cd", "k", "cd", "k", "cppd", "k"); } @Test public void should_prevent_rules_overlapping() throws Exception { - throwable.expect(UnsupportedOperationException.class); - SyntaxHighlightingRuleSet.Builder builder = SyntaxHighlightingRuleSet.builder(); + SyntaxHighlightingDataBuilder builder = new SyntaxHighlightingDataBuilder(); builder.registerHighlightingRule(0, 10, "k"); builder.registerHighlightingRule(8, 15, "k"); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingDataTest.java b/sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingDataTest.java new file mode 100644 index 00000000000..f0f917115ba --- /dev/null +++ b/sonar-batch/src/test/java/org/sonar/batch/source/SyntaxHighlightingDataTest.java @@ -0,0 +1,46 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.batch.source; + +import com.google.common.collect.Lists; +import org.junit.Test; + +import java.util.List; + +import static org.fest.assertions.Assertions.assertThat; + +public class SyntaxHighlightingDataTest { + + @Test + public void should_serialize_rules_to_string() throws Exception { + + List<SyntaxHighlightingRule> orderedHighlightingRules = Lists.newArrayList( + SyntaxHighlightingRule.create(0, 10, "cd"), + SyntaxHighlightingRule.create(10, 12, "k"), + SyntaxHighlightingRule.create(12, 20, "cd"), + SyntaxHighlightingRule.create(24, 38, "k"), + SyntaxHighlightingRule.create(24, 65, "cppd"), + SyntaxHighlightingRule.create(42, 50, "k") + ); + + String serializedRules = new SyntaxHighlightingData(orderedHighlightingRules).writeString(); + assertThat(serializedRules).isEqualTo("0,10,cd;10,12,k;12,20,cd;24,38,k;24,65,cppd;42,50,k;"); + } +} |