diff --git a/autotests/folding/test.jsx.fold b/autotests/folding/test.jsx.fold --- a/autotests/folding/test.jsx.fold +++ b/autotests/folding/test.jsx.fold @@ -50,3 +50,28 @@ . & | % /* comment*/ + +/> +> > + +/> + +// Non-ASCII tag name & attribute +<日本語>>; + 本本:本-本 aa本:本 aa:aa /> + + />; + { ... x } y +={2 } z />; + +let k1 = > > Hello > > world >>; +let k2 = > > Hello > >; + +// Empty tags +<>; // no whitespace +< >; // lots of whitespace +< /*starting wrap*/ >/*ending wrap*/>; // comments in the tags +<>hi; // text inside +<>>hi>>bye>; // children +<>>1><>>2.1>>2.2>>3>; // nested fragments +<>#; // # would cause scanning error if not in jsxtext diff --git a/autotests/folding/test.ts.fold b/autotests/folding/test.ts.fold --- a/autotests/folding/test.ts.fold +++ b/autotests/folding/test.ts.fold @@ -48,3 +48,64 @@ return ch === up ? ch.toLowerCase() : up; }); } + +for (var i in pieces) { + switch (true) { + case /^\"?Accession\"?/.test(pieces[i]): + numeration[0] = i; + break; + } +} + +// Numerics +var a = 0xA; +var b = 0b1; +var c = 0o7; +var d = 1.1E+3; +var e = 1.E+3; +var f = .1E+3; +var g = 1E+3; +var h = 1.1; +var i = 1.; +var j = .1; +var k = 1; +var l = 1__.e+3_22 | .2____e2 | 0o1_23 | 11__. ; + +// Types +let a: null = null; +let b: number = 123; +let c: number = 123.456; +let d: string = `Geeks`; +let e: undefined = undefined; +let f: boolean = true; +let g: number = 0b111001; // Binary +let h: number = 0o436; // Octal +let i: number = 0xadf0d; // Hexa-Decimal + +const query = query<[number], number>(` + SELECT * + FROM statistics + WHERE unit_id = $1`) + +function runQuery() { + const query = createQuery<[number[]], Table>(` + some SQL here + `) + return database.execute(query) +} + +aa: string ? string + string // Don't highlight +aa: string assa | + string + string ; + string + +aa: { string + string } // Don't highlight + +aa: [ string + string ] +aa: ( string + string ) // Don't highlight +aa: string diff --git a/autotests/folding/test.tsx.fold b/autotests/folding/test.tsx.fold --- a/autotests/folding/test.tsx.fold +++ b/autotests/folding/test.tsx.fold @@ -1,56 +1,111 @@ // TypeScript React -/** @author Willy - * @url https://reactjs.org/ **/ +/** @author Willy + * @url https://reactjs.org/ **/ import React from 'react'; -import { PhotoStory, VideoStory } from './stories'; +import { PhotoStory, VideoStory } from './stories'; function Story(props) { - const SpecificStory = components[props.storyType]; - return story={ props.story } attr2="&ref;" attr3="Hello\n" />; + const SpecificStory = components[props.storyType]; + return story={ props.story } attr2="&ref;" attr3="Hello\n" />; } function - attr1={ /> function return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;"> - /* no comment*/ function /> return class var 0x123 &ref; hello() React.Component() - ./> anyWord /> - { function return class var 0x123 hello() React.Component() } -> + attr1={ /> function return class var 0x123 { } &noRef; hello() React.Component() } attr2="&ref;"> + /* no comment*/ function /> return class var 0x123 &ref; hello() React.Component() + ./> anyWord /> + { function return class var 0x123 hello() React.Component() } +> -> > -> > -> > +> > +> > +> > -/*comment*/attr1/*comment*/= /*comment*/"value"/*comment*/attr2 /*comment*/attr3='a' key/*comment*/key2 /> +/*comment*/attr1/*comment*/= /*comment*/"value"/*comment*/attr2 /*comment*/attr3='a' key/*comment*/key2 /> // Detect Valid tags -/* comment */ >> -{ /* comment - */ /> +/* comment */ >> +{ /* comment + */ /> word . } -return /* comment - multiline */ /> /* comment */ /> -&& /*comment*/ /> -& /*comment*/ - - /> -{ >Hello> } -? />; -[ /> ( /> -,/> =/> -&&/> ||/> -return /> ; -default/> ; -> > /> > return > +return /* comment + multiline */ /> /* comment */ /> +&& /*comment*/ /> +& /*comment*/ + + /> +{ >Hello> } +? />; +[ /> ( /> +,/> =/> +&&/> ||/> +return /> ; +default/> ; +> > /> > return > anyWord -anyWord/*comment*/ +anyWord/*comment*/ . & | -% /* comment*/ +% /* comment*/ + +// TODO: Fix this (comment before the tag name): +var x = ; -annotation: /> -annotation: text [ /> ] +// Tag after ":" +annotation: /> +annotation: text [ /> ] console.log("hello") + +// Type assertion in tag +/> +> > + +/> + +// Non-ASCII tag name & attribute +<日本語>>; + 本本:本-本 aa本:本 aa:aa /> +<aaaa:ñ /> + + />; + { ... x } y +={2 } z />; + +let k1 = + a={10} b="hi" {...o} > + hi hi hi! + >; + +let k2 = + a={10} b="hi"> + > My Div > + {(name: string) => > My name {name} >} + >; + +let k3 = initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error + +// OK +let k1 = a={10} b="hi"><> /> />>; +let k2 = a={10} b="hi"><> /> />>; +let k3 = a={10} b="hi"><> /> />>; +let k4 = a={10} b="hi"><> /> />>; +// OK +let k1 = > > Hello > > world >>; +let k2 = > > Hello > {(user: any) => >{user.name}>}>; +let k3 = > {1} {"That is a number"} >; +let k4 = > > Hello > >; + +// Empty tags +hello<> +hello + +<>; // no whitespace +< >; // lots of whitespace +< /*starting wrap*/ >/*ending wrap*/>; // comments in the tags +<>hi; // text inside +<>>hi>>bye>; // children +<>>1><>>2.1>>2.2>>3>; // nested fragments +<>#; // # would cause scanning error if not in jsxtext diff --git a/autotests/html/test.jsx.html b/autotests/html/test.jsx.html --- a/autotests/html/test.jsx.html +++ b/autotests/html/test.jsx.html @@ -56,4 +56,29 @@ .<noTag> &<notag> | <noTag/> % /* comment*/ <noTag/> + +<C<number>/> +<C<number>> </C> +<C +<error /> + +// Non-ASCII tag name & attribute +<日本語></日本語>; +<Component 本本:本-本 aa本:本 aa:aa /> + +<Namespace.DeepNamespace.Component />; +<Component { ... x } y +={2 } z />; + +let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>; +let k2 = <Button> <h2> Hello </h2> </Button>; + +// Empty tags +<></>; // no whitespace +< ></ >; // lots of whitespace +< /*starting wrap*/ ></ /*ending wrap*/>; // comments in the tags +<>hi</>; // text inside +<><span>hi</span><div>bye</div></>; // children +<><span>1</span><><span>2.1</span><span>2.2</span></><span>3</span></>; // nested fragments +<>#</>; // # would cause scanning error if not in jsxtext diff --git a/autotests/html/test.ts.html b/autotests/html/test.ts.html --- a/autotests/html/test.ts.html +++ b/autotests/html/test.ts.html @@ -42,7 +42,7 @@ const defaultBrowser = os.platform() === "win32" ? "edge" : "chrome"; let browser: "edge" | "chrome" | "none" = defaultBrowser; -let grep: string | undefined; +let grep: string | undefined; interface FileBasedTestConfiguration { [setting: string]: string; @@ -54,4 +54,65 @@ return ch === up ? ch.toLowerCase() : up; }); } + +for (var i in pieces) { + switch (true) { + case /^\"?Accession\"?/.test(pieces[i]): + numeration[0] = i; + break; + } +} + +// Numerics +var a = 0xA; +var b = 0b1; +var c = 0o7; +var d = 1.1E+3; +var e = 1.E+3; +var f = .1E+3; +var g = 1E+3; +var h = 1.1; +var i = 1.; +var j = .1; +var k = 1; +var l = 1__.e+3_22 | .2____e2 | 0o1_23 | 11__. ; + +// Types +let a: null = null; +let b: number = 123; +let c: number = 123.456; +let d: string = `Geeks`; +let e: undefined = undefined; +let f: boolean = true; +let g: number = 0b111001; // Binary +let h: number = 0o436; // Octal +let i: number = 0xadf0d; // Hexa-Decimal + +const query = query<[number], number>(` + SELECT * + FROM statistics + WHERE unit_id = $1`) + +function runQuery() { + const query = createQuery<[number[]], Table<Columns>>(` + some SQL here + `) + return database.execute(query) +} + +aa: <sdf/> string ?<ssd/> string + string // Don't highlight +aa: string assa | + string + string ; + string + +aa: { string + string } // Don't highlight + +aa: [ string + string ] +aa: ( string + string ) // Don't highlight +aa: string <string> diff --git a/autotests/html/test.tsx.html b/autotests/html/test.tsx.html --- a/autotests/html/test.tsx.html +++ b/autotests/html/test.tsx.html @@ -57,7 +57,62 @@ &<notag> | <noTag/> % /* comment*/ <noTag/> +// TODO: Fix this (comment before the tag name): +var x = </**/div></div>; + +// Tag after ":" annotation: <tag/> annotation: text [ <tag/> ] console.log("hello") + +// Type assertion in tag +<C<number>/> +<C<number>> </C> +<C +<error /> + +// Non-ASCII tag name & attribute +<日本語></日本語>; +<Component 本本:本-本 aa本:本 aa:aa /> +<aaaa:ñ /> + +<Namespace.DeepNamespace.Component />; +<Component { ... x } y +={2 } z />; + +let k1 = + <Comp a={10} b="hi" {...o} > + hi hi hi! + </Comp>; + +let k2 = + <Comp a={10} b="hi"> + <div> My Div </div> + {(name: string) => <div> My name {name} </div>} + </Comp>; + +let k3 = <GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error + +// OK +let k1 = <Comp a={10} b="hi"><></><Button /><AnotherButton /></Comp>; +let k2 = <Comp a={10} b="hi"><><Button /></><AnotherButton /></Comp>; +let k3 = <Comp a={10} b="hi"><><Button /><AnotherButton /></></Comp>; +let k4 = <SingleChildComp a={10} b="hi"><><Button /><AnotherButton /></></SingleChildComp>; +// OK +let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>; +let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>; +let k3 = <div> {1} {"That is a number"} </div>; +let k4 = <Button> <h2> Hello </h2> </Button>; + +// Empty tags +hello<> +hello<string> + +<></>; // no whitespace +< ></ >; // lots of whitespace +< /*starting wrap*/ ></ /*ending wrap*/>; // comments in the tags +<>hi</>; // text inside +<><span>hi</span><div>bye</div></>; // children +<><span>1</span><><span>2.1</span><span>2.2</span></><span>3</span></>; // nested fragments +<>#</>; // # would cause scanning error if not in jsxtext diff --git a/autotests/input/test.jsx b/autotests/input/test.jsx --- a/autotests/input/test.jsx +++ b/autotests/input/test.jsx @@ -50,3 +50,28 @@ . & | % /* comment*/ + +/> +> + + +// Non-ASCII tag name & attribute +<日本語>; + + +; +; + +let k1 =

Hello

world

; +let k2 = ; + +// Empty tags +<>; // no whitespace +< >; // lots of whitespace +< /*starting wrap*/ >; // comments in the tags +<>hi; // text inside +<>hi
bye
; // children +<>1<>2.12.23; // nested fragments +<>#; // # would cause scanning error if not in jsxtext diff --git a/autotests/input/test.ts b/autotests/input/test.ts --- a/autotests/input/test.ts +++ b/autotests/input/test.ts @@ -48,3 +48,64 @@ return ch === up ? ch.toLowerCase() : up; }); } + +for (var i in pieces) { + switch (true) { + case /^\"?Accession\"?/.test(pieces[i]): + numeration[0] = i; + break; + } +} + +// Numerics +var a = 0xA; +var b = 0b1; +var c = 0o7; +var d = 1.1E+3; +var e = 1.E+3; +var f = .1E+3; +var g = 1E+3; +var h = 1.1; +var i = 1.; +var j = .1; +var k = 1; +var l = 1__.e+3_22 | .2____e2 | 0o1_23 | 11__. ; + +// Types +let a: null = null; +let b: number = 123; +let c: number = 123.456; +let d: string = `Geeks`; +let e: undefined = undefined; +let f: boolean = true; +let g: number = 0b111001; // Binary +let h: number = 0o436; // Octal +let i: number = 0xadf0d; // Hexa-Decimal + +const query = query<[number], number>(` + SELECT * + FROM statistics + WHERE unit_id = $1`) + +function runQuery() { + const query = createQuery<[number[]], Table>(` + some SQL here + `) + return database.execute(query) +} + +aa: string ? string + string // Don't highlight +aa: string assa | + string + string ; + string + +aa: { string + string } // Don't highlight + +aa: [ string + string ] +aa: ( string + string ) // Don't highlight +aa: string diff --git a/autotests/input/test.tsx b/autotests/input/test.tsx --- a/autotests/input/test.tsx +++ b/autotests/input/test.tsx @@ -51,6 +51,61 @@ & | % /* comment*/ +// TODO: Fix this (comment before the tag name): +var x = ; + +// Tag after ":" annotation: annotation: text [ ] console.log("hello") + +// Type assertion in tag +/> +>
+ + +// Non-ASCII tag name & attribute +<日本語>; + + + +; +; + +let k1 = + + hi hi hi! + ; + +let k2 = + +
My Div
+ {(name: string) =>
My name {name}
} +
; + +let k3 = ({ x: a.x })} />; // No Error + +// OK +let k1 = <>; + +// Empty tags +hello<> +hello + +<>; // no whitespace +< >; // lots of whitespace +< /*starting wrap*/ >; // comments in the tags +<>hi; // text inside +<>hi
bye
; // children +<>1<>2.12.23; // nested fragments +<>#; // # would cause scanning error if not in jsxtext diff --git a/autotests/reference/test.jsx.ref b/autotests/reference/test.jsx.ref --- a/autotests/reference/test.jsx.ref +++ b/autotests/reference/test.jsx.ref @@ -50,3 +50,28 @@ .<noTag>
&<notag> | <noTag/>
% /* comment*/ <noTag/>
+
+<number>/>
+<number>>

+
+ />
+
+// Non-ASCII tag name & attribute
+<日本語>;
+ 本本:本-本 aa本:本 aa:aa />
+
+ />;
+ { ... x } y
+={2 } z />;
+
+let k1 =

Hello

world

;
+let k2 = ;
+
+// Empty tags
+<>; // no whitespace
+< >; // lots of whitespace
+< /*starting wrap*/ >/*ending wrap*/>; // comments in the tags
+<>hi; // text inside
+<>hi
bye
; // children
+<>1<>2.12.23; // nested fragments
+<>#; // # would cause scanning error if not in jsxtext
diff --git a/autotests/reference/test.ts.ref b/autotests/reference/test.ts.ref --- a/autotests/reference/test.ts.ref +++ b/autotests/reference/test.ts.ref @@ -36,7 +36,7 @@
const defaultBrowser = os.platform() === "win32" ? "edge" : "chrome";
let browser: "edge" | "chrome" | "none" = defaultBrowser;
-let grep: string | undefined;
+let grep: string | undefined;

interface FileBasedTestConfiguration {
[setting: string]: string;
@@ -48,3 +48,64 @@ return ch === up ? ch.toLowerCase() : up;
});
}
+
+for (var i in pieces) {
+ switch (true) {
+ case /^\"?Accession\"?/.test(pieces[i]):
+ numeration[0] = i;
+ break;
+ }
+}
+
+// Numerics
+var a = 0xA;
+var b = 0b1;
+var c = 0o7;
+var d = 1.1E+3;
+var e = 1.E+3;
+var f = .1E+3;
+var g = 1E+3;
+var h = 1.1;
+var i = 1.;
+var j = .1;
+var k = 1;
+var l = 1__.e+3_22 | .2____e2 | 0o1_23 | 11__. ;
+
+// Types
+let a: null = null;
+let b: number = 123;
+let c: number = 123.456;
+let d: string = ;
+let e: undefined = undefined;
+let f: boolean = true;
+let g: number = 0b111001; // Binary
+let h: number = 0o436; // Octal
+let i: number = 0xadf0d; // Hexa-Decimal
+
+const query = query<[number], number>(
+
+
+)
+
+function runQuery() {
+ const query = createQuery<[number[]], Table<Columns>>(
+
+)
+ return database.execute(query)
+}
+
+aa: <sdf/> string ?<ssd/> string
+ string // Don't highlight
+aa: string assa |
+ string
+ string ;
+ string
+
+aa: { string
+ string } // Don't highlight
+
+aa: [ string
+ string ]
+aa: ( string
+ string ) // Don't highlight
+aa: string <string>
diff --git a/autotests/reference/test.tsx.ref b/autotests/reference/test.tsx.ref --- a/autotests/reference/test.tsx.ref +++ b/autotests/reference/test.tsx.ref @@ -48,9 +48,64 @@ anyWord<noTag>
anyWord/*comment*/ <noTag/>
.<noTag>
-&<notag> | <noTag/>
+&<notag> | <noTag/>
% /* comment*/ <noTag/>

+// TODO: Fix this (comment before the tag name):
+var x = **/div>
>;
+
+// Tag after ":"
annotation:
annotation: text [ ]
console.log("hello")
+
+// Type assertion in tag
+<number>/>
+<number>>
+
+ />
+
+// Non-ASCII tag name & attribute
+<日本語>;
+ 本本:本-本 aa本:本 aa:aa />
+ />
+
+ />;
+ { ... x } y
+={2 } z />;
+
+let k1 =
+ a={10} b="hi" {...o} >
+ hi hi hi!
+ ;
+
+let k2 =
+ a={10} b="hi">
+
My Div

+ {(name: string) =>
My name {name}
}
+ ;
+
+let k3 = initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error
+
+// OK
+let k1 = a={10} b="hi"><> /> />;
+let k2 = a={10} b="hi"><> /> />;
+let k3 = a={10} b="hi"><> /> />;
+let k4 = a={10} b="hi"><> /> />;
+// OK
+let k1 =

Hello

world

;
+let k2 =

Hello

{(user: any) =>

{user.name}

}
;
+let k3 =
{1} {"That is a number"}
;
+let k4 = ;
+
+// Empty tags
+hello<>
+hello<string>
+
+<>; // no whitespace
+< >; // lots of whitespace
+< /*starting wrap*/ >/*ending wrap*/>; // comments in the tags
+<>hi; // text inside
+<>hi
bye
; // children
+<>1<>2.12.23; // nested fragments
+<>#; // # would cause scanning error if not in jsxtext
diff --git a/data/syntax/javascript-react.xml b/data/syntax/javascript-react.xml --- a/data/syntax/javascript-react.xml +++ b/data/syntax/javascript-react.xml @@ -2,9 +2,13 @@ - - - + + + + + + + ]> @@ -30,12 +34,15 @@ available at: https://github.com/Microsoft/TypeScript-TmLanguage Change log: - * v3 [2018-11-18]: Fix Doxygen comments & shebang. Remove TS extension. + * v4 [2018-12-30]: Allow type assertion in the tag name. + Allow tags after the keywords "await" & "yield". + Allow empty tags and non-ASCII tag name & attributes. + * v3 [2018-11-18]: Fix Doxygen comments & shebang. Remove TSX extension. * v2 [2018-08-18]: Remove "Conditional Expression" context. * v1 [2018-06-20]: Initial version --> - @@ -85,22 +92,40 @@ - + + + + + + + + + + + + + + + @@ -110,22 +135,23 @@ - - - - - - + + + + + - + + @@ -136,27 +162,67 @@ + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + @@ -169,21 +235,23 @@ + + - - + + - + - - + + @@ -195,12 +263,23 @@ + + + + + + + + + + + @@ -222,9 +301,11 @@ + + diff --git a/data/syntax/typescript-react.xml b/data/syntax/typescript-react.xml --- a/data/syntax/typescript-react.xml +++ b/data/syntax/typescript-react.xml @@ -2,10 +2,15 @@ - - - + + + + + + + + ]> - @@ -58,10 +67,13 @@ - - - + + + + + + @@ -78,31 +90,84 @@ - - - + - - + + + + + + + + + + + + + + + + + + + + - + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + - + + + - + - - - + + + - + + + + + + + + + + + + + + @@ -112,58 +177,80 @@ - + + + - + + + - - - - - - - - + - + + + + - + - + + + + + + + + + + + + + + + + + - + + @@ -174,27 +261,67 @@ + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + @@ -207,21 +334,23 @@ + + - - + + - + - - + + @@ -233,6 +362,16 @@ + + + + + + + + + + @@ -265,6 +404,7 @@ + diff --git a/data/syntax/typescript.xml b/data/syntax/typescript.xml --- a/data/syntax/typescript.xml +++ b/data/syntax/typescript.xml @@ -36,11 +36,13 @@ incorporate these keywords (for example: "qml.xml"). Change log: + * v2 [2018-12-29]: Don't highlight built-in classes as functions, + fix float-points, improve types detection and other fixes. * v1 [2018-11-18]: Initial version --> void never unknown + undefined + null @@ -1643,7 +1647,7 @@ - + @@ -1658,27 +1662,43 @@ - + - + - + + + + + + + + + + + + - + + + - + + + + @@ -1688,27 +1708,27 @@ - + + + + + + + - - - - - - @@ -1719,46 +1739,109 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + - - - - + + + + + + - + + - + + + - + + + + + + + + - + + + + - + + - + + + + + + + + + + + @@ -1771,25 +1854,11 @@ - + - - - - - - - - - - - - - - - + @@ -1820,6 +1889,8 @@ + +