Skip to content

Commit

Permalink
GH-2627: d.ts parser fails on specific input (#2628)
Browse files Browse the repository at this point in the history
* update antlr4

* fix grammar

* generate grammar

* update antlr4 (amend)

* update gitignore

* add test

* remove complete jar due to maven problem

* adjust gitignore

* adjust due to antlr-runtime upgrade
  • Loading branch information
mmews-n4 authored May 22, 2024
1 parent 0675e08 commit 7f27b50
Show file tree
Hide file tree
Showing 17 changed files with 3,122 additions and 2,017 deletions.
2 changes: 1 addition & 1 deletion plugins/org.eclipse.n4js.dts/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen-antlr"/>
<classpathentry kind="lib" path="lib/antlr4-runtime-4.7.2.jar"/>
<classpathentry kind="lib" path="lib/antlr-runtime-4.13.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 1 addition & 1 deletion plugins/org.eclipse.n4js.dts/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"package": "org.eclipse.n4js.dts",
"listeners": true,
"visitors": true,
"alternativeJar": "../lib/antlr4-4.7.2-complete.jar"
"alternativeJar": "../lib/antlr-4.13.1-complete.jar"
}
}
2 changes: 1 addition & 1 deletion plugins/org.eclipse.n4js.dts/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.n4js.dts;singleton:=true
Bundle-Version: 0.0.1.qualifier
Bundle-ClassPath: .,
lib/antlr4-runtime-4.7.2.jar
lib/antlr-runtime-4.13.1.jar
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.emf.ecore.xcore.lib,
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ propertyName
;

computedPropertyName
: '[' (identifierName '.' identifierName // usually Symbol.iterator
: '[' (identifierName ('.' identifierName)? // usually Symbol.iterator
| StringLiteral
)
']'
Expand Down
3 changes: 2 additions & 1 deletion plugins/org.eclipse.n4js.dts/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*
!.gitignore
!antlr4-runtime-4.7.2.jar
!antlr-runtime-4.13.1.jar
#!antlr-4.13.1-complete.jar comment out due to conflict in maven build
Binary file not shown.
Binary file not shown.
8 changes: 4 additions & 4 deletions plugins/org.eclipse.n4js.dts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Contributors:
</parent>

<!--
The following configuration will integrate the file lib/antlr4-runtime-4.7.2.jar
The following configuration will integrate the file lib/antlr-runtime-4.*.jar
into the jar of this bundle. An alternative approach would be to upstream/install
the lib/antlr4-runtime-4.7.2.jar into the .m2 location during 'mvn clean install'.
One of these options is necessary to make the packages inside lib/antlr4-runtime-4.7.2.jar
the lib/antlr-runtime-4.*.jar into the .m2 location during 'mvn clean install'.
One of these options is necessary to make the packages inside lib/antlr-runtime-4.*.jar
available for other jars during testing.
-->
<build>
Expand Down Expand Up @@ -95,7 +95,7 @@ Contributors:
<configuration>
<artifactSet>
<includes>
<include>*:*antlr4-runtime-4.7.2*</include>
<include>*:*antlr-runtime-*</include>
</includes>
</artifactSet>
</configuration>
Expand Down

Large diffs are not rendered by default.

3,341 changes: 2,009 additions & 1,332 deletions plugins/org.eclipse.n4js.dts/src-gen-antlr/org/eclipse/n4js/dts/TypeScriptParser.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from /Users/marcusmews/Eclipses/ECL1/git/n4js/plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4 by ANTLR 4.7.2
// Generated from /Users/marcusmews/Eclipses/ECL3/git/n4js/plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4 by ANTLR 4.13.1
package org.eclipse.n4js.dts;

import org.antlr.v4.runtime.ParserRuleContext;
Expand All @@ -10,6 +10,7 @@
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
@SuppressWarnings("CheckReturnValue")
public class TypeScriptParserBaseListener implements TypeScriptParserListener {
/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from /Users/marcusmews/Eclipses/ECL1/git/n4js/plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4 by ANTLR 4.7.2
// Generated from /Users/marcusmews/Eclipses/ECL3/git/n4js/plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4 by ANTLR 4.13.1
package org.eclipse.n4js.dts;
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;

Expand All @@ -10,6 +10,7 @@
* @param <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
@SuppressWarnings("CheckReturnValue")
public class TypeScriptParserBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements TypeScriptParserVisitor<T> {
/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from /Users/marcusmews/Eclipses/ECL1/git/n4js/plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4 by ANTLR 4.7.2
// Generated from /Users/marcusmews/Eclipses/ECL3/git/n4js/plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4 by ANTLR 4.13.1
package org.eclipse.n4js.dts;
import org.antlr.v4.runtime.tree.ParseTreeListener;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from /Users/marcusmews/Eclipses/ECL1/git/n4js/plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4 by ANTLR 4.7.2
// Generated from /Users/marcusmews/Eclipses/ECL3/git/n4js/plugins/org.eclipse.n4js.dts/grammar/TypeScriptParser.g4 by ANTLR 4.13.1
package org.eclipse.n4js.dts;
import org.antlr.v4.runtime.tree.ParseTreeVisitor;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2022 NumberFour AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* NumberFour AG - Initial API and implementation
*/

/* XPECT_SETUP org.eclipse.n4js.xpect.tests.N4jsXtTest
File "tslib.d.ts" {
export const uniqueSymbol: unique symbol;
export type PropertyName = string | number | symbol;
export interface LoDashStaticX {
has<T, K extends PropertyName>(object: T, path: K): object is T & { [P in K]: P extends keyof T ? T[P] : Record<string, unknown> extends T ? T[keyof T] : unknown} & {[Symbol.uniqueSymbol]: unknown};
has<T>(object: T, path: string): boolean;
}
export const aa : {[uniqueSymbol]: unknown};
export interface Other {}
}
END_SETUP
*/


// XPECT noerrors -->
import * as tslib from "tslib"


tslib.uniqueSymbol;

let x : tslib.LoDashStaticX;
x.has();


let y : tslib.Other;

let z = tslib.aa;

0 comments on commit 7f27b50

Please sign in to comment.