From 71b97ad9af2ba00f153139c28b5c2ccdc139e67a Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 12 May 2016 11:44:19 +0200 Subject: SONAR-7512 Backport ability to use line/offset on Symbolizable API --- .../java/org/sonar/batch/source/DefaultSymbolizable.java | 10 ++++++++++ .../org/sonar/batch/source/DeprecatedDefaultSymbolTable.java | 12 ++++++++++++ 2 files changed, 22 insertions(+) (limited to 'sonar-scanner-engine') diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DefaultSymbolizable.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DefaultSymbolizable.java index 04c7f560e9e..a2a380c71e6 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DefaultSymbolizable.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DefaultSymbolizable.java @@ -40,6 +40,11 @@ public class DefaultSymbolizable implements Symbolizable { return NO_OP_SYMBOL; } + @Override + public Symbol newSymbol(int startLine, int startLineOffset, int endLine, int endLineOffset) { + return NO_OP_SYMBOL; + } + @Override public void newReference(Symbol symbol, int fromOffset) { // Do nothing @@ -50,6 +55,11 @@ public class DefaultSymbolizable implements Symbolizable { // Do nothing } + @Override + public void newReference(Symbol symbol, int startLine, int startLineOffset, int endLine, int endLineOffset) { + // Do nothing + } + @Override public SymbolTable build() { return NO_OP_SYMBOL_TABLE; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DeprecatedDefaultSymbolTable.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DeprecatedDefaultSymbolTable.java index a902b017e8c..78ab4ec11ff 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DeprecatedDefaultSymbolTable.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DeprecatedDefaultSymbolTable.java @@ -59,6 +59,13 @@ public class DeprecatedDefaultSymbolTable implements Symbolizable.SymbolTable { return new DeprecatedDefaultSymbol(symbolTable.newSymbol(fromOffset, toOffset), toOffset - fromOffset); } + @Override + public Symbol newSymbol(int startLine, int startLineOffset, int endLine, int endLineOffset) { + // This is wrong in case of multiline symbol bu I assume references will be added using start and end offsets so length is useless. + int length = endLineOffset - startLineOffset; + return new DeprecatedDefaultSymbol(symbolTable.newSymbol(startLine, startLineOffset, endLine, endLineOffset), length); + } + @Override public void newReference(Symbol symbol, int fromOffset) { ((DeprecatedDefaultSymbol) symbol).getWrapped().newReference(fromOffset, fromOffset + ((DeprecatedDefaultSymbol) symbol).getLength()); @@ -69,6 +76,11 @@ public class DeprecatedDefaultSymbolTable implements Symbolizable.SymbolTable { ((DeprecatedDefaultSymbol) symbol).getWrapped().newReference(fromOffset, toOffset); } + @Override + public void newReference(Symbol symbol, int startLine, int startLineOffset, int endLine, int endLineOffset) { + ((DeprecatedDefaultSymbol) symbol).getWrapped().newReference(startLine, startLineOffset, endLine, endLineOffset); + } + @Override public Symbolizable.SymbolTable build() { return new DeprecatedDefaultSymbolTable(symbolTable); -- cgit v1.2.3