Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Store languageVersion in DataSource
in order to support FileCollector.addFile with language Fixes pmd#3970
- Loading branch information
Showing
11 changed files
with
121 additions
and
33 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
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
26 changes: 26 additions & 0 deletions
26
...rc/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.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,26 @@ | ||
/* | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.util.datasource.internal; | ||
|
||
import java.io.File; | ||
|
||
import net.sourceforge.pmd.annotation.InternalApi; | ||
import net.sourceforge.pmd.lang.LanguageVersion; | ||
import net.sourceforge.pmd.util.datasource.FileDataSource; | ||
|
||
@InternalApi | ||
public class FileDataSourceWithLanguage extends FileDataSource implements LanguageAwareDataSource { | ||
private final LanguageVersion languageVersion; | ||
|
||
public FileDataSourceWithLanguage(File file, LanguageVersion languageVersion) { | ||
super(file); | ||
this.languageVersion = languageVersion; | ||
} | ||
|
||
@Override | ||
public LanguageVersion getLanguageVersion() { | ||
return languageVersion; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...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,13 @@ | ||
/* | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.util.datasource.internal; | ||
|
||
import net.sourceforge.pmd.annotation.InternalApi; | ||
import net.sourceforge.pmd.lang.LanguageVersion; | ||
|
||
@InternalApi | ||
public interface LanguageAwareDataSource { | ||
LanguageVersion getLanguageVersion(); | ||
} |
26 changes: 26 additions & 0 deletions
26
.../main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.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,26 @@ | ||
/* | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.util.datasource.internal; | ||
|
||
import java.io.Reader; | ||
|
||
import net.sourceforge.pmd.annotation.InternalApi; | ||
import net.sourceforge.pmd.lang.LanguageVersion; | ||
import net.sourceforge.pmd.util.datasource.ReaderDataSource; | ||
|
||
@InternalApi | ||
public class ReaderDataSourceWithLanguage extends ReaderDataSource implements LanguageAwareDataSource { | ||
private final LanguageVersion languageVersion; | ||
|
||
public ReaderDataSourceWithLanguage(Reader reader, String dataSourceName, LanguageVersion languageVersion) { | ||
super(reader, dataSourceName); | ||
this.languageVersion = languageVersion; | ||
} | ||
|
||
@Override | ||
public LanguageVersion getLanguageVersion() { | ||
return 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
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); | ||
} | ||
} |