@@ -78,6 +78,7 @@ export class VmtSemanticTokenProvider extends KvTokensProviderBase {
7878 case "scalar" : this . processValueScalar ( kv , contentRange , tokensBuilder , kvDoc ) ; break ;
7979 case "texture" : this . processValueTexture ( kv , contentRange , tokensBuilder , kvDoc ) ; break ;
8080 case "color" : this . processValueColor ( kv , contentRange , tokensBuilder , kvDoc ) ; break ;
81+ case "matrix" : this . processValueMatrix ( kv , contentRange , tokensBuilder , kvDoc ) ; break ;
8182 case "env_cubemap" : this . processValueCubemap ( kv , contentRange , tokensBuilder , kvDoc ) ; break ;
8283
8384 case "string" :
@@ -132,6 +133,15 @@ export class VmtSemanticTokenProvider extends KvTokensProviderBase {
132133 tokensBuilder . push ( range , "string" ) ;
133134 }
134135
136+ processValueMatrix ( kv : KeyValue , range : Range , tokensBuilder : SemanticTokensBuilder , kvDoc : KeyvalueDocument ) : void {
137+
138+ // Don't put any semantic tokens here. The textmate highlighting is good enough. We only validate the input and provide warning messages
139+ const matrixMatches = getMatrixMatches ( kv . value ) ;
140+ if ( ! matrixMatches . validFormat ) {
141+ this . diagnostics . push ( new Diagnostic ( range , "Invalid matrix format." , DiagnosticSeverity . Warning ) ) ;
142+ }
143+ }
144+
135145 processValueColor ( kv : KeyValue , range : Range , tokensBuilder : SemanticTokensBuilder , kvDoc : KeyvalueDocument ) : void {
136146
137147 // Don't put any semantic tokens here. The textmate highlighting is good enough. We only validate the input and provide warning messages
@@ -327,6 +337,21 @@ export class ShaderParamColorsProvider implements DocumentColorProvider {
327337
328338}
329339
340+ function getMatrixMatches ( matrixString : string ) : { validFormat : boolean , values : number [ ] } {
341+ const matches = matrixString . match ( / * \[ ( ( \d + ( \. \d + ) ? | \. \d + ) ? | ) + \] * / ) ;
342+ if ( ! matches ) return {
343+ validFormat : false ,
344+ values : [ ]
345+ } ;
346+
347+ const vals = matches [ 1 ] . split ( " " ) . map ( v => parseFloat ( v ) ) ;
348+
349+ return {
350+ validFormat : true ,
351+ values : vals
352+ } ;
353+ }
354+
330355function getColorMatches ( colorString : string ) : { validFormat : boolean , outOfBounds : boolean , color : Color | null , matches : RegExpMatchArray | null } {
331356 const matches = colorString . match ( / * \[ * ( 0 ? \. \d + | 1 | 0 ) ( 0 ? \. \d + | 1 | 0 ) ( 0 ? \. \d + | 1 | 0 ) * \] * / ) ;
332357 if ( ! matches ) return {
0 commit comments