diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-02-10 16:00:27 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-02-10 16:23:07 +0100 |
commit | 5eaa8f5ba79468354e84bb3fd9c8b8a581e65faa (patch) | |
tree | f46612a5eee00f38c8e44dfbfa85bf49e48ce96e /sonar-plugin-api/src | |
parent | bdee87ee4aa439e188604afd46d5c5b374599dbe (diff) | |
download | sonarqube-5eaa8f5ba79468354e84bb3fd9c8b8a581e65faa.tar.gz sonarqube-5eaa8f5ba79468354e84bb3fd9c8b8a581e65faa.zip |
SONAR-926 improve computation of number of lines
Diffstat (limited to 'sonar-plugin-api/src')
2 files changed, 76 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputDir.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputDir.java index 2e83b122d02..3789f0c5759 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputDir.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputDir.java @@ -19,6 +19,7 @@ */ package org.sonar.api.scan.filesystem.internal; +import com.google.common.collect.Maps; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.scan.filesystem.InputDir; @@ -51,6 +52,12 @@ public class DefaultInputDir implements InputDir { this.attributes = attributes; } + public DefaultInputDir(String absolutePath, String path) { + this.absolutePath = absolutePath; + this.path = path; + this.attributes = Maps.newHashMap(); + } + /** * Plugins must not build their own instances of {@link InputDir}. * {@link org.sonar.api.scan.filesystem.ModuleFileSystem} must be used to search for inputDir. @@ -116,4 +123,9 @@ public class DefaultInputDir implements InputDir { public String toString() { return String.format("[%s]", path); } + + public DefaultInputDir setKey(String s) { + attributes.put(ATTRIBUTE_COMPONENT_KEY, s); + return this; + } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java index e8ea24e1715..8509d14e329 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java @@ -26,7 +26,6 @@ import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.utils.PathUtils; import javax.annotation.CheckForNull; - import java.io.File; import java.nio.charset.Charset; import java.util.Map; @@ -67,6 +66,7 @@ public class DefaultInputFile implements InputFile { private final String path; private final Map<String, String> attributes; private final String encoding; + private long lines = 0L; private DefaultInputFile(File file, Charset encoding, String path, Map<String, String> attributes) { this.encoding = encoding.name(); @@ -148,6 +148,69 @@ public class DefaultInputFile implements InputFile { return absolutePath.hashCode(); } + public DefaultInputFile setLines(long l) { + this.lines = l; + return this; + } + + public String language() { + return attributes.get(ATTRIBUTE_LANGUAGE); + } + + public DefaultInputFile setLanguage(String s) { + attributes.put(ATTRIBUTE_LANGUAGE, s); + return this; + } + + public DefaultInputFile setHash(String s) { + attributes.put(ATTRIBUTE_HASH, s); + return this; + } + + public DefaultInputFile setStatus(String s) { + attributes.put(ATTRIBUTE_STATUS, s); + return this; + } + + public DefaultInputFile setKey(String s) { + attributes.put(ATTRIBUTE_COMPONENT_KEY, s); + return this; + } + + public DefaultInputFile setDeprecatedKey(String s) { + attributes.put(ATTRIBUTE_COMPONENT_DEPRECATED_KEY, s); + return this; + } + + public DefaultInputFile setType(String s) { + attributes.put(ATTRIBUTE_TYPE, s); + return this; + } + + /** + * Used only for backward-compatibility. Meaningless since version 4.2. + */ + public String sourceDirAbsolutePath() { + return attributes.get(ATTRIBUTE_SOURCEDIR_PATH); + } + + public DefaultInputFile setSourceDirAbsolutePath(String s) { + attributes.put(ATTRIBUTE_SOURCEDIR_PATH, FilenameUtils.normalize(s, true)); + return this; + } + + /** + * Used only for backward-compatibility. Meaningless since version 4.2. + */ + public String pathRelativeToSourceDir() { + return attributes.get(ATTRIBUTE_SOURCE_RELATIVE_PATH); + } + + public DefaultInputFile setPathRelativeToSourceDir(String s) { + attributes.put(ATTRIBUTE_SOURCE_RELATIVE_PATH, FilenameUtils.normalize(s, true)); + return this; + } + @Override public String toString() { return String.format("[%s,%s]", path, type()); |