use of net.sourceforge.pmd.lang.LanguageVersion in project pmd by pmd.
the class LanguageVersionDiscovererTest method testComponentFile.
@Test
public void testComponentFile() {
LanguageVersionDiscoverer discoverer = new LanguageVersionDiscoverer();
File vfFile = new File("/path/to/MyPage.component");
LanguageVersion languageVersion = discoverer.getDefaultLanguageVersionForFile(vfFile);
assertEquals("LanguageVersion must be VF!", LanguageRegistry.getLanguage(VfLanguageModule.NAME).getDefaultVersion(), languageVersion);
}
use of net.sourceforge.pmd.lang.LanguageVersion in project pmd by pmd.
the class LanguageVersionDiscovererTest method testVFFile.
/**
* Test on VF file.
*/
@Test
public void testVFFile() {
LanguageVersionDiscoverer discoverer = new LanguageVersionDiscoverer();
File vfFile = new File("/path/to/MyPage.page");
LanguageVersion languageVersion = discoverer.getDefaultLanguageVersionForFile(vfFile);
assertEquals("LanguageVersion must be VF!", LanguageRegistry.getLanguage(VfLanguageModule.NAME).getDefaultVersion(), languageVersion);
}
use of net.sourceforge.pmd.lang.LanguageVersion in project pmd by pmd.
the class RuleTstTest method shouldCallStartAndEnd.
@Test
public void shouldCallStartAndEnd() {
RuleTst ruleTester = new RuleTst() {
};
LanguageVersion languageVersion = LanguageRegistry.findLanguageByTerseName("dummy").getDefaultVersion();
Report report = new Report();
Rule rule = mock(Rule.class);
when(rule.getLanguage()).thenReturn(languageVersion.getLanguage());
when(rule.getName()).thenReturn("test rule");
ruleTester.runTestFromString("the code", rule, report, languageVersion, false);
verify(rule).start(any(RuleContext.class));
verify(rule).end(any(RuleContext.class));
verify(rule, times(5)).getLanguage();
verify(rule).isDfa();
verify(rule).isTypeResolution();
verify(rule).isMultifile();
verify(rule, times(2)).isRuleChain();
verify(rule).getMinimumLanguageVersion();
verify(rule).getMaximumLanguageVersion();
verify(rule).apply(anyList(), any(RuleContext.class));
verify(rule, times(4)).getName();
verify(rule).getPropertiesByPropertyDescriptor();
verifyNoMoreInteractions(rule);
}
use of net.sourceforge.pmd.lang.LanguageVersion in project pmd by pmd.
the class AbstractLanguageVersionTest method testFindVersionsForLanguageNameAndVersion.
/**
* Checks that the expected {@link LanguageVersion} can be found via
* {@link #name} and {@link #version}.
*/
@Test
public void testFindVersionsForLanguageNameAndVersion() {
SourceLanguage sourceLanguage = new SourceLanguage();
sourceLanguage.setName(name);
sourceLanguage.setVersion(version);
Language language = LanguageRegistry.getLanguage(sourceLanguage.getName());
LanguageVersion languageVersion = null;
if (language != null) {
languageVersion = language.getVersion(sourceLanguage.getVersion());
}
assertEquals(expected, languageVersion);
}
use of net.sourceforge.pmd.lang.LanguageVersion in project pmd by pmd.
the class DesignerUtil method getSupportedLanguageVersions.
public static synchronized List<LanguageVersion> getSupportedLanguageVersions() {
if (supportedLanguageVersions == null) {
List<LanguageVersion> languageVersions = new ArrayList<>();
for (LanguageVersion languageVersion : LanguageRegistry.findAllVersions()) {
Optional.ofNullable(languageVersion.getLanguageVersionHandler()).map(handler -> handler.getParser(handler.getDefaultParserOptions())).filter(Parser::canParse).ifPresent(p -> languageVersions.add(languageVersion));
}
supportedLanguageVersions = languageVersions;
}
return supportedLanguageVersions;
}
Aggregations