Update forgotten swift module
This commit is contained in:
parent
7c45eb0ca9
commit
0e4676237b
@ -50,7 +50,7 @@
|
||||
<!-- Adapt parser. -->
|
||||
<replace file="${parser-file}">
|
||||
<replacefilter token="${root-node-name}Context extends ${lang-name}InnerNode"
|
||||
value="${root-node-name}Context extends ${lang-name}InnerNode implements net.sourceforge.pmd.lang.ast.RootNode"/>
|
||||
value="${root-node-name}Context extends ${lang-name}RootNode"/>
|
||||
|
||||
<replacefilter token="_ctx = _localctx;"
|
||||
value="_ctx = _localctx.asAntlrNode();"/>
|
||||
|
@ -8,8 +8,8 @@ import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.AstInfo;
|
||||
import net.sourceforge.pmd.lang.ast.Parser;
|
||||
import net.sourceforge.pmd.lang.ParserOptions;
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.ast.RootNode;
|
||||
|
||||
@ -25,19 +25,13 @@ public abstract class AntlrBaseParser<
|
||||
R extends BaseAntlrInnerNode<N> & RootNode
|
||||
> implements Parser {
|
||||
|
||||
protected final ParserOptions parserOptions;
|
||||
|
||||
public AntlrBaseParser(final ParserOptions parserOptions) {
|
||||
this.parserOptions = parserOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R parse(ParserTask task) throws ParseException {
|
||||
public AstInfo<R> parse(ParserTask task) throws ParseException {
|
||||
CharStream cs = CharStreams.fromString(task.getSourceText(), task.getFileDisplayName());
|
||||
return parse(getLexer(cs), task);
|
||||
}
|
||||
|
||||
protected abstract R parse(Lexer parser, ParserTask task);
|
||||
protected abstract AstInfo<R> parse(Lexer parser, ParserTask task);
|
||||
|
||||
protected abstract Lexer getLexer(CharStream source);
|
||||
}
|
||||
|
@ -5,14 +5,14 @@
|
||||
package net.sourceforge.pmd.lang.swift;
|
||||
|
||||
import net.sourceforge.pmd.lang.AbstractPmdLanguageVersionHandler;
|
||||
import net.sourceforge.pmd.lang.ast.Parser;
|
||||
import net.sourceforge.pmd.lang.ParserOptions;
|
||||
import net.sourceforge.pmd.lang.ast.Parser;
|
||||
import net.sourceforge.pmd.lang.swift.ast.PmdSwiftParser;
|
||||
|
||||
public class SwiftHandler extends AbstractPmdLanguageVersionHandler {
|
||||
|
||||
@Override
|
||||
public Parser getParser(final ParserOptions parserOptions) {
|
||||
return new PmdSwiftParser(parserOptions);
|
||||
return new PmdSwiftParser();
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
|
||||
import net.sourceforge.pmd.lang.ParserOptions;
|
||||
import net.sourceforge.pmd.lang.ast.AstInfo;
|
||||
import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrBaseParser;
|
||||
import net.sourceforge.pmd.lang.swift.ast.SwiftParser.SwTopLevel;
|
||||
|
||||
@ -17,14 +17,10 @@ import net.sourceforge.pmd.lang.swift.ast.SwiftParser.SwTopLevel;
|
||||
*/
|
||||
public final class PmdSwiftParser extends AntlrBaseParser<SwiftNode, SwTopLevel> {
|
||||
|
||||
public PmdSwiftParser(final ParserOptions parserOptions) {
|
||||
super(parserOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SwTopLevel parse(final Lexer lexer) {
|
||||
protected AstInfo<SwTopLevel> parse(final Lexer lexer, ParserTask task) {
|
||||
SwiftParser parser = new SwiftParser(new CommonTokenStream(lexer));
|
||||
return parser.topLevel();
|
||||
return parser.topLevel().makeAstInfo(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.swift.ast;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.AstInfo;
|
||||
import net.sourceforge.pmd.lang.ast.Parser.ParserTask;
|
||||
import net.sourceforge.pmd.lang.ast.RootNode;
|
||||
import net.sourceforge.pmd.lang.swift.ast.SwiftParser.SwTopLevel;
|
||||
|
||||
// package private base class
|
||||
abstract class SwiftRootNode extends SwiftInnerNode implements RootNode {
|
||||
|
||||
private AstInfo<SwTopLevel> astInfo;
|
||||
|
||||
SwiftRootNode() {
|
||||
super();
|
||||
}
|
||||
|
||||
SwiftRootNode(ParserRuleContext parent, int invokingStateNumber) {
|
||||
super(parent, invokingStateNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstInfo<SwTopLevel> getAstInfo() {
|
||||
return astInfo;
|
||||
}
|
||||
|
||||
AstInfo<SwTopLevel> makeAstInfo(ParserTask task) {
|
||||
this.astInfo = new AstInfo<>(task, (SwTopLevel) this);
|
||||
return astInfo;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user