Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3971 from adangel:filecollector-language
[core] Remember language when using FileCollector.addFile #3971
- Loading branch information
Showing
9 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...e/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.util.datasource.internal; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import net.sourceforge.pmd.annotation.InternalApi; | ||
import net.sourceforge.pmd.lang.LanguageVersion; | ||
import net.sourceforge.pmd.util.datasource.DataSource; | ||
|
||
@InternalApi | ||
public class LanguageAwareDataSource implements DataSource { | ||
private final DataSource base; // delegate DataSource methods to this | ||
private final LanguageVersion version; | ||
|
||
public LanguageAwareDataSource(DataSource base, LanguageVersion version) { | ||
this.base = base; | ||
this.version = version; | ||
} | ||
|
||
public LanguageVersion getLanguageVersion() { | ||
return version; | ||
} | ||
|
||
@Override | ||
public InputStream getInputStream() throws IOException { | ||
return base.getInputStream(); | ||
} | ||
|
||
@Override | ||
public String getNiceFileName(boolean shortNames, String inputFileName) { | ||
return base.getNiceFileName(shortNames, inputFileName); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
base.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SimpleTestTextFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.lang.document; | ||
|
||
import net.sourceforge.pmd.lang.LanguageVersion; | ||
|
||
/** | ||
* Makes {@link StringTextFile} publicly available for unit tests. | ||
*/ | ||
public class SimpleTestTextFile extends StringTextFile { | ||
|
||
public SimpleTestTextFile(String content, String pathId, String displayName, LanguageVersion languageVersion) { | ||
super(content, pathId, displayName, languageVersion); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A dummy file with file extension txt. |