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);
+ "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);
+ typeOfText);
this.syntaxHighlightingRuleSet.add(syntaxHighlightingRule);
return this;
}
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;
- }
- });
+ .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();
}
}
for (SyntaxHighlightingRule highlightingRule : orderedRules) {
serializedRules.append(highlightingRule.getStartPosition())
- .append(FIELD_SEPARATOR)
- .append(highlightingRule.getEndPosition())
- .append(FIELD_SEPARATOR)
- .append(highlightingRule.getTextType())
- .append(RULE_SEPARATOR);
+ .append(FIELD_SEPARATOR)
+ .append(highlightingRule.getEndPosition())
+ .append(FIELD_SEPARATOR)
+ .append(highlightingRule.getTextType())
+ .append(RULE_SEPARATOR);
}
return serializedRules.toString();
public void setDataType(String dataType) {
this.dataType = dataType;
}
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- SnapshotDataDto that = (SnapshotDataDto) o;
-
- if (id != that.id) return false;
- if (resourceId != that.resourceId) return false;
- if (snapshotId != that.snapshotId) return false;
- if (data != null ? !data.equals(that.data) : that.data != null) return false;
- if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = (int) (id ^ (id >>> 32));
- result = 31 * result + (int) (snapshotId ^ (snapshotId >>> 32));
- result = 31 * result + (int) (resourceId ^ (resourceId >>> 32));
- result = 31 * result + (data != null ? data.hashCode() : 0);
- result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
- return result;
- }
}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.api.scan.source;
+
+public interface Symbol {
+
+ public int getDeclarationStartOffset();
+
+ public int getDeclarationEndOffset();
+
+ public String getFullyQualifiedName();
+}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.api.scan.source;
+
+import org.sonar.api.component.Perspective;
+
+/**
+ * @since 3.6
+ */
+public interface SymbolPerspective extends Perspective {
+
+ interface SymbolBuilder {
+
+ SymbolBuilder setDeclaration(int startOffset, int endOffset);
+
+ SymbolBuilder setFullyQualifiedName(String fullyQualifiedName);
+
+ Symbol build();
+ }
+
+ interface ReferencesBuilder {
+
+ ReferencesBuilder addReference(int startOffset);
+ }
+
+ SymbolPerspective begin();
+
+ SymbolBuilder newSymbol();
+
+ ReferencesBuilder declareReferences(Symbol symbol);
+
+ void end();
+}
+
+
+