@Test public void ignores_empty_tag() { GherkinLine gherkinLine = new GherkinLine("@", line); List<GherkinLineSpan> gherkinLineSpans = gherkinLine.getTags(); assertEquals(Collections.emptyList(), gherkinLineSpans); }
@Override public List<GherkinLineSpan> getTags() { String uncommentedLine = trimmedLineText.split("\\s" + COMMENT_PREFIX, 2)[0]; List<GherkinLineSpan> tags = new ArrayList<>(); int indexInUncommentedLine = 0; String[] elements = uncommentedLine.split(TAG_PREFIX); for (String element : elements) { String token = rtrim(element); if (token.isEmpty()) { continue; } int symbolLength = uncommentedLine.codePointCount(0, indexInUncommentedLine); int column = indent() + symbolLength + 1; if (!token.matches("^\\S+$")) { throw new ParserException("A tag may not contain whitespace", new Location(line, column)); } tags.add(new GherkinLineSpan(column, TAG_PREFIX + token)); indexInUncommentedLine += element.length() + 1; } return tags; }
GherkinLine implements IGherkinLine { @Override public List<GherkinLineSpan> getTags() { String uncommentedLine = trimmedLineText.split("\\s" + COMMENT_PREFIX, 2)[0]; List<GherkinLineSpan> tags = new ArrayList<>(); int indexInUncommentedLine = 0; String[] elements = uncommentedLine.split(TAG_PREFIX); for (String element : elements) { String token = rtrim(element); if (token.isEmpty()) { continue; } int symbolLength = uncommentedLine.codePointCount(0, indexInUncommentedLine); int column = indent() + symbolLength + 1; if (!token.matches("^\\S+$")) { throw new ParserException("A tag may not contain whitespace", new Location(line, column)); } tags.add(new GherkinLineSpan(column, TAG_PREFIX + token)); indexInUncommentedLine += element.length() + 1; } return tags; } }
GherkinLine implements IGherkinLine { @Override public List<GherkinLineSpan> getTags() { String uncommentedLine = trimmedLineText.split("\\s" + COMMENT_PREFIX, 2)[0]; List<GherkinLineSpan> tags = new ArrayList<>(); int indexInUncommentedLine = 0; String[] elements = uncommentedLine.split(TAG_PREFIX); for (String element : elements) { String token = rtrim(element); if (token.isEmpty()) { continue; } int symbolLength = uncommentedLine.codePointCount(0, indexInUncommentedLine); int column = indent() + symbolLength + 1; if (!token.matches("^\\S+$")) { throw new ParserException("A tag may not contain whitespace", new Location(line, column)); } tags.add(new GherkinLineSpan(column, TAG_PREFIX + token)); indexInUncommentedLine += element.length() + 1; } return tags; } GherkinLine(String lineText, int line); }
GherkinLine implements IGherkinLine { @Override public List<GherkinLineSpan> getTags() { String uncommentedLine = trimmedLineText.split("\\s" + COMMENT_PREFIX, 2)[0]; List<GherkinLineSpan> tags = new ArrayList<>(); int indexInUncommentedLine = 0; String[] elements = uncommentedLine.split(TAG_PREFIX); for (String element : elements) { String token = rtrim(element); if (token.isEmpty()) { continue; } int symbolLength = uncommentedLine.codePointCount(0, indexInUncommentedLine); int column = indent() + symbolLength + 1; if (!token.matches("^\\S+$")) { throw new ParserException("A tag may not contain whitespace", new Location(line, column)); } tags.add(new GherkinLineSpan(column, TAG_PREFIX + token)); indexInUncommentedLine += element.length() + 1; } return tags; } GherkinLine(String lineText, int line); @Override int indent(); @Override void detach(); @Override String getLineText(int indentToRemove); @Override boolean isEmpty(); @Override boolean startsWith(String prefix); @Override String getRestTrimmed(int length); @Override List<GherkinLineSpan> getTags(); @Override List<GherkinLineSpan> getTableCells(); @Override boolean startsWithTitleKeyword(String text); }
GherkinLine implements IGherkinLine { @Override public List<GherkinLineSpan> getTags() { String uncommentedLine = trimmedLineText.split("\\s" + COMMENT_PREFIX, 2)[0]; List<GherkinLineSpan> tags = new ArrayList<>(); int indexInUncommentedLine = 0; String[] elements = uncommentedLine.split(TAG_PREFIX); for (String element : elements) { String token = rtrim(element); if (token.isEmpty()) { continue; } int symbolLength = uncommentedLine.codePointCount(0, indexInUncommentedLine); int column = indent() + symbolLength + 1; if (!token.matches("^\\S+$")) { throw new ParserException("A tag may not contain whitespace", new Location(line, column)); } tags.add(new GherkinLineSpan(column, TAG_PREFIX + token)); indexInUncommentedLine += element.length() + 1; } return tags; } GherkinLine(String lineText, int line); @Override int indent(); @Override void detach(); @Override String getLineText(int indentToRemove); @Override boolean isEmpty(); @Override boolean startsWith(String prefix); @Override String getRestTrimmed(int length); @Override List<GherkinLineSpan> getTags(); @Override List<GherkinLineSpan> getTableCells(); @Override boolean startsWithTitleKeyword(String text);  }