parent
8285d70fe5
commit
d1c3212ea7
@ -211,6 +211,9 @@ package or made (package) private and are not accessible anymore.
|
||||
* {%jdoc modelica::resolver.internal.Watchdog %} (note: not previously marked as internal api)
|
||||
* pmd-plsql
|
||||
* {%jdoc plsql::rule.design.AbstractNcssCountRule (now package private)
|
||||
* pmd-scala
|
||||
* {%jdoc scala::ScalaLanguageModule %}
|
||||
* The method `dialectOf(LanguageVersion)` has been removed
|
||||
|
||||
**Newly internal classes, interfaces and methods**
|
||||
|
||||
|
@ -11,7 +11,7 @@ import net.sourceforge.pmd.lang.LanguagePropertyBundle;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.TokenManager;
|
||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||
import net.sourceforge.pmd.lang.scala.ScalaLanguageModule;
|
||||
import net.sourceforge.pmd.lang.scala.internal.ScalaDialect;
|
||||
|
||||
import scala.collection.Iterator;
|
||||
import scala.meta.Dialect;
|
||||
@ -33,7 +33,7 @@ public class ScalaTokenizer implements Tokenizer {
|
||||
*/
|
||||
public ScalaTokenizer(LanguagePropertyBundle bundle) {
|
||||
LanguageVersion langVer = bundle.getLanguageVersion();
|
||||
dialect = ScalaLanguageModule.dialectOf(langVer);
|
||||
dialect = ScalaDialect.dialectOf(langVer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,18 +4,12 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.scala;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.cpd.ScalaTokenizer;
|
||||
import net.sourceforge.pmd.cpd.Tokenizer;
|
||||
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.impl.SimpleLanguageModuleBase;
|
||||
|
||||
import scala.meta.Dialect;
|
||||
|
||||
/**
|
||||
* Language Module for Scala.
|
||||
*/
|
||||
@ -39,18 +33,6 @@ public class ScalaLanguageModule extends SimpleLanguageModuleBase {
|
||||
return (ScalaLanguageModule) LanguageRegistry.PMD.getLanguageById(ID);
|
||||
}
|
||||
|
||||
@InternalApi
|
||||
public static @NonNull Dialect dialectOf(LanguageVersion v) {
|
||||
switch (v.getVersion()) {
|
||||
case "2.10": return scala.meta.dialects.package$.MODULE$.Scala210();
|
||||
case "2.11": return scala.meta.dialects.package$.MODULE$.Scala211();
|
||||
case "2.12": return scala.meta.dialects.package$.MODULE$.Scala212();
|
||||
case "2.13": return scala.meta.dialects.package$.MODULE$.Scala213();
|
||||
default:
|
||||
throw new IllegalArgumentException(v.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tokenizer createCpdTokenizer(LanguagePropertyBundle bundle) {
|
||||
return new ScalaTokenizer(bundle);
|
||||
|
@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.scala.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.ast.Parser;
|
||||
import net.sourceforge.pmd.lang.scala.ScalaLanguageModule;
|
||||
import net.sourceforge.pmd.lang.scala.internal.ScalaDialect;
|
||||
|
||||
import scala.meta.Dialect;
|
||||
import scala.meta.Source;
|
||||
@ -23,7 +23,7 @@ public final class ScalaParser implements Parser {
|
||||
@Override
|
||||
public ASTSource parse(ParserTask task) throws ParseException {
|
||||
Input.VirtualFile virtualFile = new Input.VirtualFile(task.getFileId().getAbsolutePath(), task.getSourceText());
|
||||
Dialect dialect = ScalaLanguageModule.dialectOf(task.getLanguageVersion());
|
||||
Dialect dialect = ScalaDialect.dialectOf(task.getLanguageVersion());
|
||||
Source src = new ScalametaParser(virtualFile, dialect).parseSource();
|
||||
ASTSource root = (ASTSource) new ScalaTreeBuilder().build(src);
|
||||
root.addTaskInfo(task);
|
||||
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.scala.internal;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
|
||||
import scala.meta.Dialect;
|
||||
|
||||
public final class ScalaDialect {
|
||||
private ScalaDialect() {}
|
||||
|
||||
public static @NonNull Dialect dialectOf(LanguageVersion v) {
|
||||
switch (v.getVersion()) {
|
||||
case "2.10": return scala.meta.dialects.package$.MODULE$.Scala210();
|
||||
case "2.11": return scala.meta.dialects.package$.MODULE$.Scala211();
|
||||
case "2.12": return scala.meta.dialects.package$.MODULE$.Scala212();
|
||||
case "2.13": return scala.meta.dialects.package$.MODULE$.Scala213();
|
||||
default:
|
||||
throw new IllegalArgumentException(v.getVersion());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user