diff options
Diffstat (limited to 'main')
136 files changed, 16693 insertions, 6636 deletions
diff --git a/main/Main.sln b/main/Main.sln index 9d6c686a46..a18bf9b21e 100644 --- a/main/Main.sln +++ b/main/Main.sln @@ -1773,8 +1773,8 @@ Global {DD14AD77-6FBB-4F0D-8083-CEC28A9D0BBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD14AD77-6FBB-4F0D-8083-CEC28A9D0BBD}.ReleaseGnome|Any CPU.ActiveCfg = Release|Any CPU
{DD14AD77-6FBB-4F0D-8083-CEC28A9D0BBD}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
+ {DD14AD77-6FBB-4F0D-8083-CEC28A9D0BBD}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
{DD14AD77-6FBB-4F0D-8083-CEC28A9D0BBD}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
- {DD14AD77-6FBB-4F0D-8083-CEC28A9D0BBD}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
{3FDB97B5-916E-4817-8098-41659687A8FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FDB97B5-916E-4817-8098-41659687A8FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FDB97B5-916E-4817-8098-41659687A8FF}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
diff --git a/main/external/RefactoringEssentials b/main/external/RefactoringEssentials -Subproject 7253fd8228898a864d45b68b4003b6e6350b1af +Subproject 4e790eab7f65f0cb2afb3eca854b2aff7661ff3 diff --git a/main/external/mono-addins b/main/external/mono-addins -Subproject 619d1f5f74d7f4cbd57b4f72eca2a0cb8dbc801 +Subproject a543fa0011098232041c99bc5acb6416cb4acbe diff --git a/main/src/addins/AspNet/Projects/AspNetAppProjectFlavor.cs b/main/src/addins/AspNet/Projects/AspNetAppProjectFlavor.cs index bffd2966e8..852c7dee79 100644 --- a/main/src/addins/AspNet/Projects/AspNetAppProjectFlavor.cs +++ b/main/src/addins/AspNet/Projects/AspNetAppProjectFlavor.cs @@ -627,21 +627,6 @@ namespace MonoDevelop.AspNet.Projects return files; } - protected override void OnPopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration) - { - base.OnPopulateSupportFileList (list, configuration); - - //HACK: workaround for MD not local-copying package references - foreach (MonoDevelop.Projects.ProjectReference projectReference in Project.References) { - if (projectReference.Package != null && projectReference.Package.Name == "system.web.mvc") { - if (projectReference.ReferenceType == ReferenceType.Package) - foreach (SystemAssembly assem in projectReference.Package.Assemblies) - list.Add (assem.Location); - break; - } - } - } - public string GetAspNetMvcVersion () { foreach (var pref in Project.References) { diff --git a/main/src/addins/CSharpBinding/CSharpBinding.csproj b/main/src/addins/CSharpBinding/CSharpBinding.csproj index 577cee7d8b..56f03b1dbf 100644 --- a/main/src/addins/CSharpBinding/CSharpBinding.csproj +++ b/main/src/addins/CSharpBinding/CSharpBinding.csproj @@ -195,7 +195,6 @@ <Compile Include="MonoDevelop.CSharp.Formatting\CSharpTextPasteHandler.cs" /> <Compile Include="MonoDevelop.CSharp.Resolver\TextEditorResolverProvider.cs" /> <Compile Include="MonoDevelop.CSharp.Parser\CSharpParsedDocument.cs" /> - <Compile Include="MonoDevelop.CSharp.Resolver\DebuggerExpressionResolver.cs" /> <Compile Include="MonoDevelop.CSharp.Completion\ImportSymbolCompletionData.cs" /> <Compile Include="MonoDevelop.JSon\JSonIndentationTracker.cs" /> <Compile Include="MonoDevelop.JSon\JSonIndentEngine.cs" /> @@ -307,6 +306,10 @@ <Compile Include="Gui\MonoDevelop.CSharp.Project.CompilerOptionsPanelWidget.cs" /> <Compile Include="MonoDevelop.CSharp.Completion\CSharpCompletionTextEditorExtension.IDebuggerCompletionProvider.cs" /> <Compile Include="MonoDevelop.CSharp.Refactoring\CSharpFindReferenceUsagesProvider.cs" /> + <Compile Include="MonoDevelop.CSharp.Resolver\CSharpLanguageDebugInfoService.cs" /> + <Compile Include="MonoDevelop.CSharp.Resolver\LocationInfoGetter.cs" /> + <Compile Include="MonoDevelop.CSharp.Resolver\DataTipInfoGetter.cs" /> + <Compile Include="MonoDevelop.CSharp.Completion\CSharpCompletionTextEditorExtension.IDebuggerExpressionResolver.cs" /> </ItemGroup> <ItemGroup> <None Include="MonoDevelop.CSharp.CodeRefactorings\ConvertToEnum\ConvertToEnumCodeRefactoringProvider.cs" /> diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DebuggerExpressionResolver.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.IDebuggerExpressionResolver.cs index e0f321fee4..cd1f70c8c8 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DebuggerExpressionResolver.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.IDebuggerExpressionResolver.cs @@ -1,13 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -// -// DebuggerExpressionResolver.cs +// +// CSharpCompletionTextEditorExtension.IDebuggerExpressionResolver.cs // // Author: // David Karlaš <david.karlas@xamarin.com> +// Mike Krüger <mikkrg@microsoft.com> // -// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com) - +// Copyright (c) 2018 Microsoft Corporation. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -26,76 +24,69 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.CSharp; -using System.Linq; + + +using System.Reflection; using System.Threading; using System.Threading.Tasks; -using ICSharpCode.NRefactory6.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Shared.Extensions; -using MonoDevelop.Ide.Editor; +using Microsoft.CodeAnalysis.Text; using MonoDevelop.Debugger; +using MonoDevelop.Ide.Editor; using MonoDevelop.Ide.TypeSystem; -namespace MonoDevelop.CSharp.Resolver +namespace MonoDevelop.CSharp.Completion { - static class DebuggerExpressionResolver + partial class CSharpCompletionTextEditorExtension : IDebuggerExpressionResolver { - public static async Task<DebugDataTipInfo> ResolveAsync (IReadonlyTextDocument editor, DocumentContext document, int offset, CancellationToken cancellationToken) + async Task<DebugDataTipInfo> IDebuggerExpressionResolver.ResolveExpressionAsync (IReadonlyTextDocument editor, DocumentContext doc, int offset, CancellationToken cancellationToken) { - var analysisDocument = document.AnalysisDocument; - DebugDataTipInfo result; - CompilationUnitSyntax compilationUnit = null; - if (analysisDocument == null) { - compilationUnit = SyntaxFactory.ParseCompilationUnit (editor.Text); - result = GetInfo (compilationUnit, null, offset, default(CancellationToken)); - } else { - compilationUnit = await analysisDocument.GetCSharpSyntaxRootAsync (cancellationToken).ConfigureAwait (false); - var semantic = await analysisDocument.GetSemanticModelAsync (cancellationToken); - result = GetInfo (compilationUnit, semantic, offset, default(CancellationToken)); - } - if (result.IsDefault || !result.Span.Contains(offset)) { - return new DebugDataTipInfo (result.Span, null); - } else if (result.Text == null) { - return new DebugDataTipInfo (result.Span, compilationUnit.GetText ().ToString (result.Span)); - } else { - return result; - } + var analysisDocument = doc.AnalysisDocument; + if (analysisDocument == null) + return default (DebugDataTipInfo); + var debugInfoService = analysisDocument.GetLanguageService<Microsoft.CodeAnalysis.Editor.Implementation.Debugging.ILanguageDebugInfoService> (); + if (debugInfoService == null) + return default (DebugDataTipInfo); + + var tipInfo = await debugInfoService.GetDataTipInfoAsync (analysisDocument, offset, cancellationToken).ConfigureAwait (false); + var text = tipInfo.Text; + if (text == null && !tipInfo.IsDefault) + text = editor.GetTextAt (tipInfo.Span.Start, tipInfo.Span.Length); + + var semanticModel = await analysisDocument.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false); + var root = await semanticModel.SyntaxTree.GetRootAsync (cancellationToken).ConfigureAwait (false); + var syntaxNode = root.FindNode (tipInfo.Span); + if (syntaxNode == null) + return new DebugDataTipInfo (tipInfo.Span, text); + return GetInfo (root, semanticModel, syntaxNode, text, cancellationToken); } - static DebugDataTipInfo GetInfo (CompilationUnitSyntax root, SemanticModel semanticModel, int position, CancellationToken cancellationToken) + static DebugDataTipInfo GetInfo (SyntaxNode root, SemanticModel semanticModel, SyntaxNode node, string textOpt, CancellationToken cancellationToken) { - var token = root.FindToken (position); - string textOpt = null; - - var expression = token.Parent as ExpressionSyntax; + var expression = node as ExpressionSyntax; if (expression == null) { - if (Microsoft.CodeAnalysis.CSharpExtensions.IsKind (token, SyntaxKind.IdentifierToken)) { - if (token.Parent is MethodDeclarationSyntax) { - return default(DebugDataTipInfo); - } - if (semanticModel != null) { - if (token.Parent is PropertyDeclarationSyntax) { - var propertySymbol = semanticModel.GetDeclaredSymbol ((PropertyDeclarationSyntax)token.Parent); - if (propertySymbol.IsStatic) { - textOpt = propertySymbol.ContainingType.GetFullName () + "." + propertySymbol.Name; - } - } else if (token.GetAncestor<FieldDeclarationSyntax> () != null) { - var fieldSymbol = semanticModel.GetDeclaredSymbol (token.GetAncestor<VariableDeclaratorSyntax> ()); - if (fieldSymbol.IsStatic) { - textOpt = fieldSymbol.ContainingType.GetFullName () + "." + fieldSymbol.Name; - } + if (node is MethodDeclarationSyntax) { + return default (DebugDataTipInfo); + } + if (semanticModel != null) { + if (node is PropertyDeclarationSyntax) { + var propertySymbol = semanticModel.GetDeclaredSymbol ((PropertyDeclarationSyntax)node); + if (propertySymbol.IsStatic) { + textOpt = propertySymbol.ContainingType.GetFullName () + "." + propertySymbol.Name; + } + } else if (node.GetAncestor<FieldDeclarationSyntax> () != null) { + var fieldSymbol = semanticModel.GetDeclaredSymbol (node.GetAncestorOrThis<VariableDeclaratorSyntax> ()); + if (fieldSymbol.IsStatic) { + textOpt = fieldSymbol.ContainingType.GetFullName () + "." + fieldSymbol.Name; } } - - return new DebugDataTipInfo (token.Span, text: textOpt); - } else { - return default(DebugDataTipInfo); } + + return new DebugDataTipInfo (node.Span, text: textOpt); } if (expression.IsAnyLiteralExpression ()) { @@ -105,20 +96,14 @@ namespace MonoDevelop.CSharp.Resolver // of a literal can always easily be determined. var type = semanticModel?.GetTypeInfo (expression, cancellationToken).Type; return type == null - ? default(DebugDataTipInfo) + ? default (DebugDataTipInfo) : new DebugDataTipInfo (expression.Span, type.GetFullName ()); - }
-
- // Check if we are invoking method and if we do return null so we don't invoke it
- if (expression.Parent is InvocationExpressionSyntax || - (semanticModel != null &&
- expression.Parent is MemberAccessExpressionSyntax &&
- expression.Parent.Parent is InvocationExpressionSyntax &&
- semanticModel.GetSymbolInfo (token).Symbol is IMethodSymbol))
- { - return default(DebugDataTipInfo); } + // Check if we are invoking method and if we do return null so we don't invoke it + if (expression.Parent is InvocationExpressionSyntax || semanticModel.GetSymbolInfo (expression).Symbol is IMethodSymbol) + return default (DebugDataTipInfo); + if (expression.IsRightSideOfDotOrArrow ()) { var curr = expression; while (true) { @@ -167,4 +152,3 @@ namespace MonoDevelop.CSharp.Resolver } } } - diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs index 1ca7aef3ce..148faa6dce 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs @@ -65,7 +65,7 @@ using MonoDevelop.CSharp.Completion.Provider; namespace MonoDevelop.CSharp.Completion { - sealed partial class CSharpCompletionTextEditorExtension : CompletionTextEditorExtension, IDebuggerExpressionResolver + sealed partial class CSharpCompletionTextEditorExtension : CompletionTextEditorExtension { /* internal protected virtual Mono.TextEditor.TextEditorData TextEditorData { get { @@ -753,14 +753,6 @@ namespace MonoDevelop.CSharp.Completion return result.ParameterIndex; } - #region IDebuggerExpressionResolver implementation - - async Task<DebugDataTipInfo> IDebuggerExpressionResolver.ResolveExpressionAsync (IReadonlyTextDocument editor, DocumentContext doc, int offset, CancellationToken cancellationToken) - { - return await Resolver.DebuggerExpressionResolver.ResolveAsync (editor, doc, offset, cancellationToken).ConfigureAwait (false); - } - - #endregion [CommandHandler (RefactoryCommands.ImportSymbol)] async void ImportSymbolCommand () diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs index 75403e6e33..a2802d650e 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs @@ -24,25 +24,26 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; -using System.Collections.Generic; - - -using MonoDevelop.CSharp.Formatting; -using MonoDevelop.Ide.Gui.Content; -using MonoDevelop.Projects.Policies; -using System.Linq; -using MonoDevelop.Ide.CodeFormatting; -using MonoDevelop.Core; -using MonoDevelop.CSharp.Refactoring; -using MonoDevelop.Ide.Editor; +using ICSharpCode.NRefactory6.CSharp; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.Editor.Shared.Preview; using Microsoft.CodeAnalysis.Formatting; -using MonoDevelop.Ide.TypeSystem; -using ICSharpCode.NRefactory6.CSharp; -using MonoDevelop.Ide; +using Microsoft.CodeAnalysis.Text; +using MonoDevelop.Core; using MonoDevelop.Core.Text; -using Mono.Options; +using MonoDevelop.Ide; +using MonoDevelop.Ide.CodeFormatting; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Ide.TypeSystem; +using MonoDevelop.Projects.Policies; +using Roslyn.Utilities; +using System.Threading; +using Microsoft.CodeAnalysis.Options; +using MonoDevelop.CSharp.OptionProvider; +using Microsoft.VisualStudio.CodingConventions; +using System.Collections.Generic; namespace MonoDevelop.CSharp.Formatting { @@ -114,13 +115,48 @@ namespace MonoDevelop.CSharp.Formatting return result.Substring (startOffset, endOffset + result.Length - input.Length - startOffset); } - protected override ITextSource FormatImplementation (PolicyContainer policyParent, string mimeType, ITextSource input, int startOffset, int length) + protected override ITextSource FormatImplementation (PolicyContainer policyParent, string mimeType, ITextSource input, int startOffset, int length) { var chain = DesktopService.GetMimeTypeInheritanceChain (mimeType); var policy = policyParent.Get<CSharpFormattingPolicy> (chain); var textPolicy = policyParent.Get<TextStylePolicy> (chain); + var optionSet = policy.CreateOptions (textPolicy); + + if (input is IReadonlyTextDocument doc) { + try { + var conventions = EditorConfigService.GetEditorConfigContext (doc.FileName).WaitAndGetResult (); + if (conventions != null) + optionSet = new FormattingDocumentOptionSet (optionSet, new CSharpDocumentOptionsProvider.DocumentOptions (optionSet, conventions.CurrentConventions)); + } catch (Exception e) { + LoggingService.LogError ("Error while loading coding conventions.", e); + } + } - return new StringTextSource (FormatText (policy.CreateOptions (textPolicy), input.Text, startOffset, startOffset + length)); + return new StringTextSource (FormatText (optionSet, input.Text, startOffset, startOffset + length)); } + + sealed class FormattingDocumentOptionSet : OptionSet + { + readonly OptionSet fallbackOptionSet; + readonly CSharpDocumentOptionsProvider.DocumentOptions optionsProvider; + + internal FormattingDocumentOptionSet (OptionSet fallbackOptionSet, CSharpDocumentOptionsProvider.DocumentOptions optionsProvider) + { + this.fallbackOptionSet = fallbackOptionSet; + this.optionsProvider = optionsProvider; + } + + public override object GetOption (OptionKey optionKey) + { + if (optionsProvider.TryGetDocumentOption (optionKey, fallbackOptionSet, out object value)) + return value; + return fallbackOptionSet.GetOption (optionKey); + } + + public override OptionSet WithChangedOption (OptionKey optionAndLanguage, object value) => throw new InvalidOperationException (); + + internal override IEnumerable<OptionKey> GetChangedOptions (OptionSet optionSet) => throw new InvalidOperationException (); + } + } } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/CSharpDocumentOptionsProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/CSharpDocumentOptionsProvider.cs index c59851f78d..0ce4818552 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/CSharpDocumentOptionsProvider.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/CSharpDocumentOptionsProvider.cs @@ -85,7 +85,7 @@ namespace MonoDevelop.CSharp.OptionProvider return null; } - class DocumentOptions : IDocumentOptions + internal class DocumentOptions : IDocumentOptions { readonly OptionSet optionSet; readonly ICodingConventionsSnapshot codingConventionsSnapshot; diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpProjectExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpProjectExtension.cs index 257a84b33b..a37caee681 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpProjectExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpProjectExtension.cs @@ -24,13 +24,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; -using MonoDevelop.Projects; -using MonoDevelop.Projects.MSBuild; -using MonoDevelop.Core; -using MonoDevelop.Core.Serialization; -using MonoDevelop.Projects.Extensions; using System.Collections.Generic; + +using MonoDevelop.Core; using MonoDevelop.Core.Instrumentation; +using MonoDevelop.Core.Serialization; +using MonoDevelop.Projects; namespace MonoDevelop.CSharp.Project { @@ -128,6 +127,7 @@ namespace MonoDevelop.CSharp.Project codePage = int.Parse (prop.Value); } + [Obsolete] protected override BuildResult OnCompileSources (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor) { return CSharpBindingCompilerManager.Compile (items, configuration, configSelector, monitor); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/CSharpLanguageDebugInfoService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/CSharpLanguageDebugInfoService.cs new file mode 100644 index 0000000000..cf8f222ff9 --- /dev/null +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/CSharpLanguageDebugInfoService.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Composition; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Editor.Implementation.Debugging; +using Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.VisualStudio.LanguageServices.CSharp.Debugging +{ + [ExportLanguageService (typeof (ILanguageDebugInfoService), LanguageNames.CSharp), Shared] + internal partial class CSharpLanguageDebugInfoService : ILanguageDebugInfoService + { + public Task<DebugLocationInfo> GetLocationInfoAsync (Document document, int position, CancellationToken cancellationToken) + { + return LocationInfoGetter.GetInfoAsync (document, position, cancellationToken); + } + + public Task<DebugDataTipInfo> GetDataTipInfoAsync ( + Document document, int position, CancellationToken cancellationToken) + { + return DataTipInfoGetter.GetInfoAsync (document, position, cancellationToken); + } + } +} diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DataTipInfoGetter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DataTipInfoGetter.cs new file mode 100644 index 0000000000..58ac7ad979 --- /dev/null +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/DataTipInfoGetter.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Extensions; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Editor.Implementation.Debugging; +using Microsoft.CodeAnalysis.ErrorReporting; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.VisualStudio.LanguageServices.CSharp.Debugging +{ + internal static class DataTipInfoGetter + { + internal static async Task<DebugDataTipInfo> GetInfoAsync (Document document, int position, CancellationToken cancellationToken) + { + try { + var root = await document.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false); + if (root == null) { + return default (DebugDataTipInfo); + } + + var token = root.FindToken (position); + + var expression = token.Parent as ExpressionSyntax; + if (expression == null) { + return token.IsKind (SyntaxKind.IdentifierToken) + ? new DebugDataTipInfo (token.Span, text: null) + : default (DebugDataTipInfo); + } + + if (expression.IsAnyLiteralExpression ()) { + // If the user hovers over a literal, give them a DataTip for the type of the + // literal they're hovering over. + // Partial semantics should always be sufficient because the (unconverted) type + // of a literal can always easily be determined. + var semanticModel = await document.GetPartialSemanticModelAsync (cancellationToken).ConfigureAwait (false); + var type = semanticModel.GetTypeInfo (expression, cancellationToken).Type; + return type == null + ? default (DebugDataTipInfo) + : new DebugDataTipInfo (expression.Span, type.ToNameDisplayString ()); + } + + if (expression.IsRightSideOfDotOrArrow ()) { + var curr = expression; + while (true) { + var conditionalAccess = curr.GetParentConditionalAccessExpression (); + if (conditionalAccess == null) { + break; + } + + curr = conditionalAccess; + } + + if (curr == expression) { + // NB: Parent.Span, not Span as below. + return new DebugDataTipInfo (expression.Parent.Span, text: null); + } + + // NOTE: There may not be an ExpressionSyntax corresponding to the range we want. + // For example, for input a?.$$B?.C, we want span [|a?.B|]?.C. + return new DebugDataTipInfo (TextSpan.FromBounds (curr.SpanStart, expression.Span.End), text: null); + } + + // NOTE(cyrusn): This behavior is to mimic what we did in Dev10, I'm not sure if it's + // necessary or not. + if (expression.IsKind (SyntaxKind.InvocationExpression)) { + expression = ((InvocationExpressionSyntax)expression).Expression; + } + + string textOpt = null; + if (expression is TypeSyntax typeSyntax && typeSyntax.IsVar) { + // If the user is hovering over 'var', then pass back the full type name that 'var' + // binds to. + var semanticModel = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false); + var type = semanticModel.GetTypeInfo (typeSyntax, cancellationToken).Type; + if (type != null) { + textOpt = type.ToNameDisplayString (); + } + } + + return new DebugDataTipInfo (expression.Span, textOpt); + } catch (Exception e) when (FatalError.ReportWithoutCrashUnlessCanceled (e)) { + return default (DebugDataTipInfo); + } + } + } +} diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/LocationInfoGetter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/LocationInfoGetter.cs new file mode 100644 index 0000000000..02982deec7 --- /dev/null +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/LocationInfoGetter.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Editor.Implementation.Debugging; +using Microsoft.CodeAnalysis.LanguageServices; +using Microsoft.CodeAnalysis.Shared.Extensions; + +namespace Microsoft.VisualStudio.LanguageServices.CSharp.Debugging +{ + internal static class LocationInfoGetter + { + internal static async Task<DebugLocationInfo> GetInfoAsync (Document document, int position, CancellationToken cancellationToken) + { + // PERF: This method will be called synchronously on the UI thread for every breakpoint in the solution. + // Therefore, it is important that we make this call as cheap as possible. Rather than constructing a + // containing Symbol and using ToDisplayString (which might be more *correct*), we'll just do the best we + // can with Syntax. This approach is capable of providing parity with the pre-Roslyn implementation. + var tree = await document.GetSyntaxTreeAsync (cancellationToken).ConfigureAwait (false); + var root = await tree.GetRootAsync (cancellationToken).ConfigureAwait (false); + var syntaxFactsService = document.GetLanguageService<ISyntaxFactsService> (); + var memberDeclaration = syntaxFactsService.GetContainingMemberDeclaration (root, position, useFullSpan: true); + + // It might be reasonable to return an empty Name and a LineOffset from the beginning of the + // file for GlobalStatements. However, the only known caller (Breakpoints Window) doesn't + // appear to consume this information, so we'll just return the simplest thing (no location). + if ((memberDeclaration == null) || (memberDeclaration.Kind () == SyntaxKind.GlobalStatement)) { + return default(DebugLocationInfo); + } + + // field or event field declarations may contain multiple variable declarators. Try finding the correct one. + // If the position does not point to one, try using the first one. + VariableDeclaratorSyntax fieldDeclarator = null; + if (memberDeclaration.Kind () == SyntaxKind.FieldDeclaration || memberDeclaration.Kind () == SyntaxKind.EventFieldDeclaration) { + SeparatedSyntaxList<VariableDeclaratorSyntax> variableDeclarators = ((BaseFieldDeclarationSyntax)memberDeclaration).Declaration.Variables; + + foreach (var declarator in variableDeclarators) { + if (declarator.FullSpan.Contains (position)) { + fieldDeclarator = declarator; + break; + } + } + + if (fieldDeclarator == null) { + fieldDeclarator = variableDeclarators.Count > 0 ? variableDeclarators [0] : null; + } + } + + var name = syntaxFactsService.GetDisplayName (fieldDeclarator ?? memberDeclaration, + DisplayNameOptions.IncludeNamespaces | + DisplayNameOptions.IncludeParameters); + + var text = await document.GetTextAsync (cancellationToken).ConfigureAwait (false); + var lineNumber = text.Lines.GetLineFromPosition (position).LineNumber; + var accessor = memberDeclaration.GetAncestorOrThis<AccessorDeclarationSyntax> (); + var memberLine = text.Lines.GetLineFromPosition (accessor?.SpanStart ?? memberDeclaration.SpanStart).LineNumber; + var lineOffset = lineNumber - memberLine; + + return new DebugLocationInfo (name, lineOffset); + } + } +} diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Tooltips/LanguageItemTooltipProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Tooltips/LanguageItemTooltipProvider.cs index 4fa19ed9d5..f10b669f94 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Tooltips/LanguageItemTooltipProvider.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Tooltips/LanguageItemTooltipProvider.cs @@ -69,11 +69,13 @@ namespace MonoDevelop.SourceEditor } catch (ArgumentOutOfRangeException) { return null; } - if (!syntaxToken.Span.IntersectsWith (offset)) + if (!syntaxToken.Span.Contains (offset)) return null; var node = GetBestFitResolveableNode (syntaxToken.Parent); var symbolInfo = unit.GetSymbolInfo (node, token); - var symbol = symbolInfo.Symbol ?? unit.GetDeclaredSymbol (node, token); + var symbol = symbolInfo.Symbol; + if (symbol == null && syntaxToken.IsKind (SyntaxKind.IdentifierToken)) + symbol = unit.GetDeclaredSymbol (node, token); var tooltipInformation = await CreateTooltip (symbol, syntaxToken, caretOffset, theme, ctx, offset); if (tooltipInformation == null || string.IsNullOrEmpty (tooltipInformation.SignatureMarkup)) return null; diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs index 42af703adb..29fa4a5f5d 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs @@ -26,24 +26,24 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; -using System.Diagnostics; -using System.Text.RegularExpressions; using System.Text; +using System.Text.RegularExpressions; +using System.Threading; -using MonoDevelop.Projects; using MonoDevelop.Core; -using MonoDevelop.Core.Execution; using MonoDevelop.Core.Assemblies; +using MonoDevelop.Core.Execution; using MonoDevelop.CSharp.Project; -using System.Threading; using MonoDevelop.Ide; -using MonoDevelop.Core.ProgressMonitoring; +using MonoDevelop.Projects; namespace MonoDevelop.CSharp { + [Obsolete] static class CSharpBindingCompilerManager { static void AppendQuoted (StringBuilder sb, string option, string val) diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DefaultDeployServiceExtension.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DefaultDeployServiceExtension.cs index 3b6554e7be..4cec8f48b9 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DefaultDeployServiceExtension.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DefaultDeployServiceExtension.cs @@ -1,8 +1,6 @@ - -using System; -using System.IO; -using MonoDevelop.Projects; using MonoDevelop.Core; +using MonoDevelop.Projects; +using MonoDevelop.Projects.MSBuild; namespace MonoDevelop.Deployment { @@ -18,19 +16,36 @@ namespace MonoDevelop.Deployment public override DeployFileCollection GetProjectDeployFiles (DeployContext ctx, Project project, ConfigurationSelector configuration) { - DeployFileCollection deployFiles = new DeployFileCollection (); + var deployFiles = new DeployFileCollection (); base.GetProjectDeployFiles (ctx, project, configuration); // Add the compiled output files - ProjectConfiguration pconf = (ProjectConfiguration) project.GetConfiguration (configuration); - FilePath outDir = pconf.OutputDirectory; - foreach (FilePath file in project.GetOutputFiles (configuration)) { - deployFiles.Add (new DeployFile (project, file, file.ToRelative (outDir), TargetDirectory.ProgramFiles)); + var pconf = (ProjectConfiguration) project.GetConfiguration (configuration); + var evalCtx = new TargetEvaluationContext (); + evalCtx.ItemsToEvaluate.Add ("AllPublishItemsFullPathWithTargetPath"); + + if (project.MSBuildProject.UseMSBuildEngine) { + var result = project.RunTarget (null, "GetCopyToPublishDirectoryItems", configuration, evalCtx).Result; + foreach (var item in result.Items) { + if (item.Name == "AllPublishItemsFullPathWithTargetPath") { + var fromPath = MSBuildProjectService.FromMSBuildPath (project.ItemDirectory, item.Include); + var toPath = item.Metadata.GetPathValue ("TargetPath", relativeToPath: pconf.OutputDirectory); + deployFiles.Add (new DeployFile (project, fromPath, toPath, TargetDirectory.ProgramFiles)); + } + } + } else { +#pragma warning disable 618 //obsolete + FilePath outDir = pconf.OutputDirectory; + foreach (FilePath file in project.GetOutputFiles (configuration)) { + deployFiles.Add (new DeployFile (project, file, file.ToRelative (outDir), TargetDirectory.ProgramFiles)); + } + foreach (FileCopySet.Item item in project.GetSupportFileList (configuration)) { + deployFiles.Add (new DeployFile (project, item.Src, item.Target, TargetDirectory.ProgramFiles)); + } +#pragma warning restore 618 } -// FilePath outputFile = project.GetOutputFileName (configuration); - // Collect deployable files foreach (ProjectFile file in project.Files) { // skip CopyToOutputDirectory files when it's just a project build, because @@ -39,17 +54,13 @@ namespace MonoDevelop.Deployment if (file.CopyToOutputDirectory != FileCopyMode.None) continue; - DeployProperties props = new DeployProperties (file); + var props = new DeployProperties (file); if (props.ShouldDeploy) { - DeployFile dp = new DeployFile (file); + var dp = new DeployFile (file); deployFiles.Add (dp); } } - - foreach (FileCopySet.Item item in project.GetSupportFileList (configuration)) { - deployFiles.Add (new DeployFile (project, item.Src, item.Target, TargetDirectory.ProgramFiles)); - } - + return deployFiles; } } diff --git a/main/src/addins/GnomePlatform/GnomePlatform.cs b/main/src/addins/GnomePlatform/GnomePlatform.cs index afddedcee5..6f1abf8d73 100644 --- a/main/src/addins/GnomePlatform/GnomePlatform.cs +++ b/main/src/addins/GnomePlatform/GnomePlatform.cs @@ -267,12 +267,11 @@ namespace MonoDevelop.Platform ? BashPause.Replace ("'", "\"") : String.Empty; - return String.Format (@" --nofork --caption ""{4}"" --workdir=""{3}"" -e ""bash"" -c '{0} {1} ; {2}'", + return String.Format (@" --nofork --workdir=""{3}"" -e ""bash"" -c '{0} {1} ; {2}'", command, args, extra_commands, - EscapeDir (dir), - title); + EscapeDir (dir)); } private static string GnomeTerminalOpenFolderRunner (string dir) { diff --git a/main/src/addins/ILAsmBinding/ILAsmProject.cs b/main/src/addins/ILAsmBinding/ILAsmProject.cs index da8ba321f0..869e443737 100644 --- a/main/src/addins/ILAsmBinding/ILAsmProject.cs +++ b/main/src/addins/ILAsmBinding/ILAsmProject.cs @@ -31,6 +31,7 @@ namespace ILAsmBinding { public class ILAsmProject: DotNetProject { + [Obsolete] protected override BuildResult OnCompileSources (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor) { return ILAsmCompilerManager.Compile (items, configuration, configSelector, monitor); diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index 681d2a2d5e..c68a64420e 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -598,6 +598,7 @@ namespace MonoDevelop.MacIntegration ApplicationEvents.OpenDocuments += delegate (object sender, ApplicationDocumentEventArgs e) { //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout GLib.Timeout.Add (10, delegate { + IdeApp.ReportTimeToCode = true; IdeApp.OpenFiles (e.Documents.Select ( doc => new FileOpenInformation (doc.Key, null, doc.Value, 1, OpenDocumentOptions.DefaultInternal)) ); @@ -608,6 +609,7 @@ namespace MonoDevelop.MacIntegration ApplicationEvents.OpenUrls += delegate (object sender, ApplicationUrlEventArgs e) { GLib.Timeout.Add (10, delegate { + IdeApp.ReportTimeToCode = true; // Open files via the monodevelop:// URI scheme, compatible with the // common TextMate scheme: http://blog.macromates.com/2007/the-textmate-url-scheme/ IdeApp.OpenFiles (e.Urls.Select (url => { diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/EventDefinitionNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/EventDefinitionNodeBuilder.cs index 735559a4eb..6c04242d51 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/EventDefinitionNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/EventDefinitionNodeBuilder.cs @@ -66,7 +66,7 @@ namespace MonoDevelop.AssemblyBrowser nodeInfo.Label = evt.Name + " : " + CSharpLanguage.Instance.TypeToString (evt.EventType, false, evt); var accessor = evt.AddMethod ?? evt.RemoveMethod; - if (((MethodAttributes.Private | MethodAttributes.Assembly) & accessor.Attributes) != 0) + if (!accessor.IsPublic) nodeInfo.Label = MethodDefinitionNodeBuilder.FormatPrivate (nodeInfo.Label); nodeInfo.Icon = Context.GetIcon (GetStockIcon (evt)); diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/FieldDefinitionNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/FieldDefinitionNodeBuilder.cs index 2b01a95dda..262f896d17 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/FieldDefinitionNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/FieldDefinitionNodeBuilder.cs @@ -58,7 +58,7 @@ namespace MonoDevelop.AssemblyBrowser var field = (FieldDefinition)dataObject; nodeInfo.Label = field.Name + " : " + CSharpLanguage.Instance.TypeToString (field.FieldType, false, field); - if (((FieldAttributes.Private | FieldAttributes.Assembly) & field.Attributes) != 0) + if (!field.IsPublic) nodeInfo.Label = MethodDefinitionNodeBuilder.FormatPrivate (nodeInfo.Label); nodeInfo.Icon = Context.GetIcon (GetStockIcon(field)); } diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/PropertyDefinitionNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/PropertyDefinitionNodeBuilder.cs index eca7adcb10..495084e2ea 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/PropertyDefinitionNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/PropertyDefinitionNodeBuilder.cs @@ -68,7 +68,7 @@ namespace MonoDevelop.AssemblyBrowser var accessor = property.GetMethod ?? property.SetMethod; - if (((MethodAttributes.Private | MethodAttributes.Assembly) & accessor.Attributes) != 0) + if (!accessor.IsPublic) nodeInfo.Label = MethodDefinitionNodeBuilder.FormatPrivate (nodeInfo.Label); nodeInfo.Icon = Context.GetIcon (GetStockIcon (property)); diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/TypeDefinitionNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/TypeDefinitionNodeBuilder.cs index bd74132fef..002611033a 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/TypeDefinitionNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/Cecil/TypeDefinitionNodeBuilder.cs @@ -70,7 +70,7 @@ namespace MonoDevelop.AssemblyBrowser { var type = (TypeDefinition)dataObject; nodeInfo.Label = MonoDevelop.Ide.TypeSystem.Ambience.EscapeText (CSharpLanguage.Instance.FormatTypeName (type)); - if (IsNonPublic(type)) + if (!type.IsPublic) nodeInfo.Label = MethodDefinitionNodeBuilder.FormatPrivate (nodeInfo.Label); nodeInfo.Icon = Context.GetIcon (GetStockIcon(type)); } @@ -113,11 +113,6 @@ namespace MonoDevelop.AssemblyBrowser } } - bool IsNonPublic (TypeDefinition type) - { - return (type.Attributes & (TypeAttributes.Public | TypeAttributes.NestedPublic)) == 0; - } - public override void BuildChildNodes (ITreeBuilder builder, object dataObject) { var type = (TypeDefinition)dataObject; @@ -127,33 +122,35 @@ namespace MonoDevelop.AssemblyBrowser bool publicOnly = Widget.PublicApiOnly; foreach (var nestedType in type.NestedTypes.OrderBy (m => m.Name, StringComparer.InvariantCulture)) { - if (publicOnly && IsNonPublic (nestedType)) + if (publicOnly && !nestedType.IsPublic) continue; builder.AddChild (nestedType); } foreach (var field in type.Fields.OrderBy (m => m.Name, StringComparer.InvariantCulture)) { - if (publicOnly && ((FieldAttributes.Private | FieldAttributes.Assembly) & field.Attributes) != 0) + if (publicOnly && !field.IsPublic) continue; builder.AddChild (field); } foreach (var property in type.Properties.OrderBy (m => m.Name, StringComparer.InvariantCulture)) { var accessor = property.GetMethod ?? property.SetMethod; - if (publicOnly && ((MethodAttributes.Private | MethodAttributes.Assembly) & accessor.Attributes) != 0) + if (publicOnly && !accessor.IsPublic) continue; builder.AddChild (property); } foreach (var evt in type.Events.OrderBy (m => m.Name, StringComparer.InvariantCulture)) { var accessor = evt.AddMethod ?? evt.RemoveMethod; - if (publicOnly && ((MethodAttributes.Private | MethodAttributes.Assembly) & accessor.Attributes) != 0) + if (publicOnly && !accessor.IsPublic) continue; builder.AddChild (evt); } var accessorMethods = type.GetAccessorMethods (); foreach (var method in type.Methods.OrderBy (m => m.Name, StringComparer.InvariantCulture)) { + if (publicOnly && !method.IsPublic) + continue; if (!accessorMethods.Contains (method)) { builder.AddChild (method); } diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/Counters.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/Counters.cs index 83c1330cc0..4fed6bfbab 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/Counters.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/Counters.cs @@ -25,6 +25,7 @@ // THE SOFTWARE. using MonoDevelop.Core.Instrumentation; +using System; namespace MonoDevelop.Debugger { @@ -32,5 +33,46 @@ namespace MonoDevelop.Debugger { public static Counter DebugSession = InstrumentationService.CreateCounter ("Debug Session", "Debugger", id: "Debugger.DebugSession"); public static Counter EvaluationStats = InstrumentationService.CreateCounter ("Evaluation Statistics", "Debugger", id: "Debugger.EvaluationStatistics"); + public static TimerCounter<DebuggerStartMetadata> DebuggerStart = InstrumentationService.CreateTimerCounter<DebuggerStartMetadata> ("Debugger Start", "Debugger", id: "Debugger.Start"); + public static TimerCounter<DebuggerActionMetadata> DebuggerAction = InstrumentationService.CreateTimerCounter<DebuggerActionMetadata> ("Debugger Action", "Debugger", id: "Debugger.Action"); + } + + class DebuggerStartMetadata : CounterMetadata + { + public DebuggerStartMetadata () + { + } + + public string Name { + get => GetProperty<string> (); + set => SetProperty (value); + } + } + + class DebuggerActionMetadata : CounterMetadata + { + public enum ActionType { + Unknown, + StepOver, + StepInto, + StepOut + }; + + public DebuggerActionMetadata () + { + } + + public ActionType Type { + get { + var result = GetProperty<string> (); + if (Enum.TryParse<ActionType> (result, out var eResult)) { + return eResult; + } + + return ActionType.Unknown; + } + + set => SetProperty (value.ToString ()); + } } } diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs index d2bbbc897e..f852bfc07b 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs @@ -48,6 +48,8 @@ using System.Linq; using System.Threading.Tasks; using System.Collections.Concurrent; using System.Threading; +using MonoDevelop.Core.Instrumentation; +using MonoDevelop.Components; namespace MonoDevelop.Debugger { @@ -606,7 +608,7 @@ namespace MonoDevelop.Debugger { var session = debugger.CreateSession (); var monitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor (proc.Name); - var sessionManager = new SessionManager (session, monitor.Console, debugger); + var sessionManager = new SessionManager (session, monitor.Console, debugger, null); SetupSession (sessionManager); session.TargetExited += delegate { monitor.Dispose (); @@ -677,12 +679,23 @@ namespace MonoDevelop.Debugger internal static ProcessAsyncOperation InternalRun (ExecutionCommand cmd, DebuggerEngine factory, OperationConsole c) { + // Start assuming success, update on failure + var metadata = new DebuggerStartMetadata { + Result = CounterResult.Success + }; + var timer = Counters.DebuggerStart.BeginTiming (metadata); + if (factory == null) { factory = GetFactoryForCommand (cmd); - if (factory == null) + if (factory == null) { + metadata.SetFailure (); + timer.Dispose (); throw new InvalidOperationException ("Unsupported command: " + cmd); + } } + metadata.Name = factory.Name; + DebuggerStartInfo startInfo = factory.CreateDebuggerStartInfo (cmd); startInfo.UseExternalConsole = c is ExternalConsole; if (startInfo.UseExternalConsole) @@ -694,9 +707,9 @@ namespace MonoDevelop.Debugger // When using an external console, create a new internal console which will be used // to show the debugger log if (startInfo.UseExternalConsole) - sessionManager = new SessionManager (session, IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor (System.IO.Path.GetFileNameWithoutExtension (startInfo.Command)).Console, factory); + sessionManager = new SessionManager (session, IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor (System.IO.Path.GetFileNameWithoutExtension (startInfo.Command)).Console, factory, timer); else - sessionManager = new SessionManager (session, c, factory); + sessionManager = new SessionManager (session, c, factory, timer); SetupSession (sessionManager); SetDebugLayout (); @@ -707,6 +720,7 @@ namespace MonoDevelop.Debugger } catch { sessionManager.SessionError = true; Cleanup (sessionManager); + metadata.SetFailure (); throw; } return sessionManager.debugOperation; @@ -732,14 +746,21 @@ namespace MonoDevelop.Debugger public readonly DebuggerSession Session; public readonly DebugAsyncOperation debugOperation; public readonly DebuggerEngine Engine; + internal ITimeTracker<DebuggerStartMetadata> StartTimer { get; set; } - public SessionManager (DebuggerSession session, OperationConsole console, DebuggerEngine engine) + internal bool TrackActionTelemetry { get; set; } + internal DebuggerActionMetadata.ActionType CurrentAction { get; set; } + internal ITimeTracker ActionTimeTracker { get; set; } + + public SessionManager (DebuggerSession session, OperationConsole console, DebuggerEngine engine, ITimeTracker<DebuggerStartMetadata> timeTracker) { Engine = engine; Session = session; session.ExceptionHandler = ExceptionHandler; session.AssemblyLoaded += OnAssemblyLoaded; this.console = console; + StartTimer = timeTracker; + cancelRegistration = console.CancellationToken.Register (Cancel); debugOperation = new DebugAsyncOperation (session); } @@ -747,6 +768,7 @@ namespace MonoDevelop.Debugger void Cancel () { Session.Exit (); + StartTimer?.Metadata.SetUserCancel (); Cleanup (this); } @@ -789,13 +811,22 @@ namespace MonoDevelop.Debugger debugOperation.Cleanup (); cancelRegistration?.Dispose (); cancelRegistration = null; + + StartTimer?.Dispose (); } + bool sessionError; /// <summary> /// Indicates whether the debug session failed to an exception or any debugger /// operation failed and was reported to the user. /// </summary> - public bool SessionError { get; set; } + public bool SessionError { + get => sessionError; + set { + sessionError = value; + StartTimer?.Metadata.SetFailure (); + } + } void UpdateDebugSessionCounter () { @@ -894,6 +925,7 @@ namespace MonoDevelop.Debugger static void OnStarted (object s, EventArgs a) { nextStatementLocations.Clear (); + if (currentSession?.Session == s) { currentBacktrace = null; currentSession = null; @@ -916,6 +948,7 @@ namespace MonoDevelop.Debugger return; nextStatementLocations.Clear (); + SessionManager sessionManager = null; try { switch (args.Type) { case TargetEventType.TargetExited: @@ -931,23 +964,44 @@ namespace MonoDevelop.Debugger case TargetEventType.UnhandledException: case TargetEventType.ExceptionThrown: var action = new Func<bool> (delegate { - SessionManager sessionManager; if (!sessions.TryGetValue (session, out sessionManager)) return false; + + if (sessionManager.TrackActionTelemetry) { + var metadata = new DebuggerActionMetadata () { + Type = sessionManager.CurrentAction + }; + sessionManager.ActionTimeTracker = Counters.DebuggerAction.BeginTiming ("Debugger action", metadata); + } Breakpoints.RemoveRunToCursorBreakpoints (); currentSession = sessionManager; ActiveThread = args.Thread; - NotifyPaused (); + NotifyPaused (currentSession); NotifyException (args); return true; }); if (currentSession != null && currentSession != sessions [session]) { StopsQueue.Enqueue (action); - NotifyPaused ();//Notify about pause again, so ThreadsPad can update, to show all processes + NotifyPaused (null);//Notify about pause again, so ThreadsPad can update, to show all processes } else { action (); } break; + case TargetEventType.TargetReady: + if (!sessions.TryGetValue (session, out sessionManager)) { + return; + } + + sessionManager.StartTimer?.Metadata.SetSuccess (); + + sessionManager.StartTimer?.Dispose (); + sessionManager.StartTimer = null; + + if (Ide.Counters.TrackingBuildAndDeploy) { + Ide.Counters.BuildAndDeploy.EndTiming (); + Ide.Counters.TrackingBuildAndDeploy = false; + } + break; } } catch (Exception ex) { LoggingService.LogError ("Error handling debugger target event", ex); @@ -961,7 +1015,7 @@ namespace MonoDevelop.Debugger handler (null, e); } - static void NotifyPaused () + static void NotifyPaused (SessionManager sessionManager) { Runtime.RunInMainThread (delegate { stepSwitchCts?.Cancel (); @@ -969,6 +1023,16 @@ namespace MonoDevelop.Debugger PausedEvent (null, EventArgs.Empty); NotifyLocationChanged (); IdeApp.Workbench.GrabDesktopFocus (); + + }).ContinueWith ((arg) => { + // PausedEventHandlers may queue additional UI events that can cause a freeze. + // Ensure those UI events have completed before we stop tracking the time. + Runtime.RunInMainThread (() => { + if (sessionManager.TrackActionTelemetry) { + sessionManager.ActionTimeTracker.Dispose (); + sessionManager.TrackActionTelemetry = false; + } + }); }); } @@ -1017,10 +1081,15 @@ namespace MonoDevelop.Debugger public static void StepInto () { + Runtime.AssertMainThread (); if (!IsDebugging || !IsPaused || CheckIsBusy ()) return; + + currentSession.TrackActionTelemetry = true; + currentSession.CurrentAction = DebuggerActionMetadata.ActionType.StepInto; + currentSession.Session.StepLine (); NotifyLocationChanged (); DelayHandleStopQueue (); @@ -1032,6 +1101,10 @@ namespace MonoDevelop.Debugger if (!IsDebugging || !IsPaused || CheckIsBusy ()) return; + + currentSession.TrackActionTelemetry = true; + currentSession.CurrentAction = DebuggerActionMetadata.ActionType.StepOver; + currentSession.Session.NextLine (); NotifyLocationChanged (); DelayHandleStopQueue (); @@ -1043,6 +1116,10 @@ namespace MonoDevelop.Debugger if (!IsDebugging || !IsPaused || CheckIsBusy ()) return; + + currentSession.TrackActionTelemetry = true; + currentSession.CurrentAction = DebuggerActionMetadata.ActionType.StepOut; + currentSession.Session.Finish (); NotifyLocationChanged (); DelayHandleStopQueue (); diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs index 5b3e025e70..bb545fe25d 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs @@ -429,13 +429,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder return null; monitor.Log.WriteLine (GettextCatalog.GetString ("Generating GUI code for project '{0}'...", project.Name)); - - timer.Trace ("Copy support files"); - - // Make sure the referenced assemblies are up to date. It is necessary to do - // it now since they may contain widget libraries. - project.CopySupportFiles (monitor, configuration); - + timer.Trace ("Update libraries"); info.GuiBuilderProject.UpdateLibraries (); diff --git a/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingProject.cs b/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingProject.cs index 4718375346..7a5a3a4912 100644 --- a/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingProject.cs +++ b/main/src/addins/MonoDevelop.Packaging/MonoDevelop.Packaging/PackagingProject.cs @@ -121,13 +121,6 @@ namespace MonoDevelop.Packaging return false; } - protected override void PopulateOutputFileList ( - List<FilePath> list, - ConfigurationSelector configuration) - { - list.Add (OnGetOutputFileName (configuration)); - } - protected override void OnPrepareForEvaluation (MSBuildProject project) { MSBuildPropertyGroup globalGroup = project.GetGlobalPropertyGroup (); diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs index 0352ac3924..de33c0f746 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs @@ -284,7 +284,9 @@ namespace MonoDevelop.AnalysisCore.Gui if (cancellationToken.IsCancellationRequested) return; if (id != null) - ext.tasks.Remove (id); + lock (ext.tasks) { + ext.tasks.Remove (id); + } GLib.Idle.Add (IdleHandler); } @@ -329,7 +331,8 @@ namespace MonoDevelop.AnalysisCore.Gui editor.RemoveMarker (markerQueue.Value.Dequeue ()); } ext.markers.Clear (); - ext.tasks.Clear (); + lock (ext.tasks) + ext.tasks.Clear (); ext.OnTasksUpdated (EventArgs.Empty); return false; } @@ -345,7 +348,8 @@ namespace MonoDevelop.AnalysisCore.Gui //add in the new markers for (int i = 0; i < UPDATE_COUNT; i++) { if (!enumerator.MoveNext ()) { - ext.tasks [id] = builder.ToImmutable (); + lock (ext.tasks) + ext.tasks [id] = builder.ToImmutable (); ext.OnTasksUpdated (EventArgs.Empty); // remove remaining old markers while (oldMarkers > 0) { @@ -415,7 +419,7 @@ namespace MonoDevelop.AnalysisCore.Gui } #region IQuickTaskProvider implementation - Dictionary<object, ImmutableArray<QuickTask>> tasks = new Dictionary<object, ImmutableArray<QuickTask>> (); + readonly Dictionary<object, ImmutableArray<QuickTask>> tasks = new Dictionary<object, ImmutableArray<QuickTask>>(); public event EventHandler TasksUpdated; @@ -428,7 +432,8 @@ namespace MonoDevelop.AnalysisCore.Gui public ImmutableArray<QuickTask> QuickTasks { get { - return tasks.SelectMany(x => x.Value).AsImmutable (); + lock (tasks) + return tasks.SelectMany(x => x.Value).AsImmutable (); } } diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs index 19ab118b73..c4b5183b0d 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs @@ -173,31 +173,33 @@ namespace MonoDevelop.CodeActions async void PopupQuickFixMenu (Gdk.EventButton evt, Action<CodeFixMenu> menuAction) { - var token = quickFixCancellationTokenSource.Token; + using (Counters.FixesMenu.BeginTiming ("Show quick fixes menu")) { + var token = quickFixCancellationTokenSource.Token; - var fixes = await GetCurrentFixesAsync (token); - if (token.IsCancellationRequested) - return; + var fixes = await GetCurrentFixesAsync (token); + if (token.IsCancellationRequested) + return; - var menu = CodeFixMenuService.CreateFixMenu (Editor, fixes, token); - if (token.IsCancellationRequested) - return; + var menu = CodeFixMenuService.CreateFixMenu (Editor, fixes, token); + if (token.IsCancellationRequested) + return; - if (menu.Items.Count == 0) { - return; - } + if (menu.Items.Count == 0) { + return; + } - Editor.SuppressTooltips = true; - if (menuAction != null) - menuAction (menu); + Editor.SuppressTooltips = true; + if (menuAction != null) + menuAction (menu); - var p = Editor.LocationToPoint (Editor.OffsetToLocation (currentSmartTagBegin)); - Widget widget = Editor; - var rect = new Gdk.Rectangle ( - (int)p.X + widget.Allocation.X, - (int)p.Y + widget.Allocation.Y, 0, 0); + var p = Editor.LocationToPoint (Editor.OffsetToLocation (currentSmartTagBegin)); + Widget widget = Editor; + var rect = new Gdk.Rectangle ( + (int)p.X + widget.Allocation.X, + (int)p.Y + widget.Allocation.Y, 0, 0); - ShowFixesMenu (widget, rect, menu); + ShowFixesMenu (widget, rect, menu); + } } bool ShowFixesMenu (Widget parent, Gdk.Rectangle evt, CodeFixMenu entrySet) @@ -224,6 +226,7 @@ namespace MonoDevelop.CodeActions } catch (Exception ex) { LoggingService.LogError ("Error while context menu popup.", ex); } + return true; } @@ -365,6 +368,7 @@ namespace MonoDevelop.CodeActions { if (!AnalysisOptions.EnableFancyFeatures || currentSmartTag == null) { //Fixes = RefactoringService.GetValidActions (Editor, DocumentContext, Editor.CaretLocation).Result; + currentSmartTagBegin = Editor.CaretOffset; PopupQuickFixMenu (null, null); return; diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs index ece56c1b54..7c5efeb519 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs @@ -113,6 +113,27 @@ namespace MonoDevelop.Refactoring.Rename var editor = doc.Editor; var oldVersion = editor.Version; + var links = await GetTextLinksAsync (doc, editor.CaretOffset, symbol); + + editor.StartTextLinkMode (new TextLinkModeOptions (links, (arg) => { + //If user cancel renaming revert changes + if (!arg.Success) { + var textChanges = editor.Version.GetChangesTo (oldVersion).ToList (); + for (int i = textChanges.Count - 1; i >= 0; i--) { + var change = textChanges [i]; + var rollbackChanges = new List<Microsoft.CodeAnalysis.Text.TextChange> (); + for (int j = 0; j < change.TextChanges.Count; j++) { + var textChange = change.TextChanges [j]; + rollbackChanges.Add (new Microsoft.CodeAnalysis.Text.TextChange (new TextSpan (textChange.Offset, textChange.InsertionLength), textChange.RemovedText.Text)); + } + editor.ApplyTextChanges (rollbackChanges); + } + } + }) { TextLinkPurpose = TextLinkPurpose.Rename }); + } + + internal static async Task<List<TextLink>> GetTextLinksAsync (Ide.Gui.Document doc, int caretOffset, ISymbol symbol) + { var links = new List<TextLink> (); var link = new TextLink ("name"); @@ -126,18 +147,9 @@ namespace MonoDevelop.Refactoring.Rename foreach (var mref in await SymbolFinder.FindReferencesAsync (symbol, doc.AnalysisDocument.Project.Solution, documents, default (CancellationToken))) { foreach (var loc in mref.Locations) { - TextSpan span = loc.Location.SourceSpan; - var root = loc.Location.SourceTree.GetRoot (); - var node = root.FindNode (loc.Location.SourceSpan); - var trivia = root.FindTrivia (loc.Location.SourceSpan.Start); - if (!trivia.IsKind (SyntaxKind.SingleLineDocumentationCommentTrivia)) { - span = node.Span; - } - if (span.Start != loc.Location.SourceSpan.Start) { - span = loc.Location.SourceSpan; - } + var span = loc.Location.SourceSpan; var segment = new TextSegment (span.Start, span.Length); - if (segment.Offset <= editor.CaretOffset && editor.CaretOffset <= segment.EndOffset) { + if (segment.Offset <= caretOffset && caretOffset <= segment.EndOffset) { link.Links.Insert (0, segment); } else { link.AddLink (segment); @@ -145,22 +157,7 @@ namespace MonoDevelop.Refactoring.Rename } } links.Add (link); - - editor.StartTextLinkMode (new TextLinkModeOptions (links, (arg) => { - //If user cancel renaming revert changes - if (!arg.Success) { - var textChanges = editor.Version.GetChangesTo (oldVersion).ToList (); - for (int i = textChanges.Count - 1; i >= 0; i--) { - var change = textChanges [i]; - var rollbackChanges = new List<Microsoft.CodeAnalysis.Text.TextChange> (); - for (int j = 0; j < change.TextChanges.Count; j++) { - var textChange = change.TextChanges [j]; - rollbackChanges.Add (new Microsoft.CodeAnalysis.Text.TextChange (new TextSpan (textChange.Offset, textChange.InsertionLength), textChange.RemovedText.Text)); - } - editor.ApplyTextChanges (rollbackChanges); - } - } - }) { TextLinkPurpose = TextLinkPurpose.Rename }); + return links; } public class RenameProperties diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs index bb39c4d200..fb4ea03ca0 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/QuickFixMenuHandler.cs @@ -41,25 +41,31 @@ namespace MonoDevelop.Refactoring var ext = editor?.GetContent<CodeActionEditorExtension> (); if (ext == null) return; - try { - info.Add (new CommandInfo (GettextCatalog.GetString ("Loading..."), false, false), null); - var currentFixes = await ext.GetCurrentFixesAsync (cancelToken); - var menu = CodeFixMenuService.CreateFixMenu (editor, currentFixes, cancelToken); - info.Clear (); - foreach (var item in menu.Items) { - AddItem (info, item); - } - if (menu.Items.Count == 0) { + + var metadata = new Counters.FixesMenuMetadata (); + using (var timer = Counters.FixesMenu.BeginTiming ("Quick Fix menu", metadata)) { + try { + info.Add (new CommandInfo (GettextCatalog.GetString ("Loading..."), false, false), null); + var currentFixes = await ext.GetCurrentFixesAsync (cancelToken); + var menu = CodeFixMenuService.CreateFixMenu (editor, currentFixes, cancelToken); + info.Clear (); + foreach (var item in menu.Items) { + AddItem (info, item); + } + if (menu.Items.Count == 0) { + info.Add (new CommandInfo (GettextCatalog.GetString ("No code fixes available"), false, false), null); + } + metadata.SetSuccess (); + info.NotifyChanged (); + } catch (OperationCanceledException) { + metadata.SetUserCancel (); + } catch (Exception e) { + metadata.SetFailure (); + LoggingService.LogError ("Error while creating quick fix menu.", e); + info.Clear (); info.Add (new CommandInfo (GettextCatalog.GetString ("No code fixes available"), false, false), null); + info.NotifyChanged (); } - info.NotifyChanged (); - } catch (OperationCanceledException) { - - } catch (Exception e) { - LoggingService.LogError ("Error while creating quick fix menu.", e); - info.Clear (); - info.Add (new CommandInfo (GettextCatalog.GetString ("No code fixes available"), false, false), null); - info.NotifyChanged (); } } diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs index d660336c0a..c7f52715d4 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs @@ -50,11 +50,9 @@ namespace MonoDevelop.Refactoring CancellationTokenSource popupSrc = new CancellationTokenSource (); ITextDocument changedTextDocument; - List<DiffHunk> diff; - - int lineHeight; - int indentLength; - FontDescription fontDescription; + ProcessResult diff; + readonly int lineHeight; + readonly FontDescription fontDescription; static RefactoringPreviewTooltipWindow currentPreviewWindow; @@ -88,50 +86,218 @@ namespace MonoDevelop.Refactoring } } - async void RequestPopup (Xwt.Rectangle rect) + void RequestPopup (Xwt.Rectangle rect) { var token = popupSrc.Token; - - diff = await Task.Run (async delegate { + Task.Run (async delegate { try { foreach (var op in await codeAction.GetPreviewOperationsAsync (token)) { - var ac = op as ApplyChangesOperation; - if (ac == null) { + if (!(op is ApplyChangesOperation ac)) { continue; } var changedDocument = ac.ChangedSolution.GetDocument (documentContext.AnalysisDocument.Id); - changedTextDocument = TextEditorFactory.CreateNewDocument (new StringTextSource ((await changedDocument.GetTextAsync (token)).ToString ()), editor.FileName); + var changedText = await changedDocument.GetTextAsync (token); + var changedTextSource = new StringTextSource (changedText.ToString ()); + changedTextDocument = TextEditorFactory.CreateNewDocument (changedTextSource, editor.FileName); + try { - var list = new List<DiffHunk> (editor.GetDiff (changedTextDocument, new DiffOptions (false, true))); - if (list.Count > 0) - return list; + var processor = new DiffProcessor (editor, changedTextDocument); + return processor.Process (); } catch (Exception e) { LoggingService.LogError ("Error while getting preview list diff.", e); } + } + } catch (OperationCanceledException) { } + + return new ProcessResult (); + }).ContinueWith (t => { + diff = t.Result; + if (diff.LineResults.Count > 0 && !token.IsCancellationRequested) { + var pos = PopupPosition.Left; + if (Platform.IsMac) { + var screenRect = GtkUtil.ToScreenCoordinates (IdeApp.Workbench.RootWindow, IdeApp.Workbench.RootWindow.GdkWindow, rect.ToGdkRectangle ()); + var geometry = Screen.GetUsableMonitorGeometry (Screen.GetMonitorAtPoint (screenRect.X, screenRect.Y)); + var request = SizeRequest (); + if (screenRect.X - geometry.X < request.Width) { + pos = PopupPosition.Top; + if (geometry.Bottom - screenRect.Bottom < request.Height) + pos = PopupPosition.Bottom; + } else { + pos = PopupPosition.Right; + } + } + ShowPopup (rect, pos); + } + }, Runtime.MainTaskScheduler); + } + + enum LineKind + { + Normal, + Removed, + Added + } + + struct LineResult + { + public bool XNeedsMeasure; + public string TextOrMarkup; + public LineKind LineKind; + } + + class ProcessResult + { + public List<LineResult> LineResults = new List<LineResult> (); + public HslColor AddedForeground, AddedBackground, RemovedForeground, RemovedBackground; + } + class DiffProcessor + { + readonly TextEditor baseDocument; + readonly IReadonlyTextDocument changedTextDocument; + + public int IndentLength { get; set; } + + public DiffProcessor (TextEditor baseDocument, IReadonlyTextDocument changedTextDocument) + { + this.baseDocument = baseDocument; + this.changedTextDocument = changedTextDocument; + + IndentLength = -1; + } + + public ProcessResult Process () + { + var he = baseDocument.GetDiff (changedTextDocument, new DiffOptions (false, true)).GetEnumerator (); + he.MoveNext (); + var current = he.Current; + + var qh = new Queue<DiffHunk> (); + qh.Enqueue (current); + + IndentLength = -1; + + var result = new ProcessResult { + AddedBackground = SyntaxHighlightingService.GetColor (baseDocument.Options.GetEditorTheme (), EditorThemeColors.PreviewDiffAddedBackground), + AddedForeground = SyntaxHighlightingService.GetColor (baseDocument.Options.GetEditorTheme (), EditorThemeColors.PreviewDiffAdded), + RemovedBackground = SyntaxHighlightingService.GetColor (baseDocument.Options.GetEditorTheme (), EditorThemeColors.PreviewDiffRemovedBackground), + RemovedForeground = SyntaxHighlightingService.GetColor (baseDocument.Options.GetEditorTheme (), EditorThemeColors.PreviewDiffRemoved), + }; + + while (he.MoveNext ()) { + var next = he.Current; + + if (current.Overlaps (next)) { + // Change upper bounds. + } else { + ProcessHunks (qh, result); } - } catch (OperationCanceledException) {} - return new List<DiffHunk> (); - }); - if (diff.Count > 0 && !token.IsCancellationRequested) { - var pos = PopupPosition.Left; - if (Platform.IsMac) { - var screenRect = GtkUtil.ToScreenCoordinates (IdeApp.Workbench.RootWindow, IdeApp.Workbench.RootWindow.GdkWindow, rect.ToGdkRectangle ()); - var geometry = Screen.GetUsableMonitorGeometry (Screen.GetMonitorAtPoint (screenRect.X, screenRect.Y)); - var request = SizeRequest (); - if (screenRect.X - geometry.X < request.Width) { - pos = PopupPosition.Top; - if (geometry.Bottom - screenRect.Bottom < request.Height) - pos = PopupPosition.Bottom; + qh.Enqueue (next); + + current = next; + } + + if (qh.Count != 0) { + ProcessHunks (qh, result); + } + + return result; + } + + void ProcessHunks (Queue<DiffHunk> qh, ProcessResult result) + { + DiffHunk item; + int remStart; + int insStart; + int distance = 0; + + do { + item = qh.Dequeue (); + remStart = Math.Max (1, item.RemoveStart - (distance != 0 ? distance : item.Context)); + insStart = Math.Max (1, item.InsertStart - (distance != 0 ? distance : item.Context)); + + for (int i = Math.Min (remStart, insStart); i < item.RemoveStart; i++) { + ProcessLine (baseDocument, i, LineKind.Normal, result); + } + + for (int i = item.RemoveStart; i < item.RemoveStart + item.Removed; i++) { + ProcessLine (baseDocument, i, LineKind.Removed, result); + } + + for (int i = item.InsertStart; i < item.InsertStart + item.Inserted; i++) { + ProcessLine (changedTextDocument, i, LineKind.Added, result); + } + + if (qh.Count != 0) + distance = item.DistanceTo (qh.Peek ()); + } while (qh.Count != 0); + + int remEnd = Math.Min (baseDocument.LineCount, item.RemoveStart + item.Removed + item.Context); + for (int i = item.RemoveStart + item.Removed; i < remEnd; i++) { + ProcessLine (baseDocument, i, LineKind.Normal, result); + } + } + + void ProcessLine (IReadonlyTextDocument document, int lineNumber, LineKind lineKind, ProcessResult result) + { + var line = document.GetLine (lineNumber); + var curLineIndent = CalcIndentLength (line.GetIndentation (document)); + + if (IndentLength < 0 || IndentLength > curLineIndent) + IndentLength = curLineIndent; + + var correctedIndentLength = CorrectIndent (document, line, IndentLength); + var offset = line.Offset + Math.Min (correctedIndentLength, line.Length); + var length = Math.Max (0, line.Length - correctedIndentLength); + + string text; + if (lineKind == LineKind.Normal && document is TextEditor editor) { + text = editor.GetMarkup (offset, length, new MarkupOptions (MarkupFormat.Pango, false)); + } else { + text = document.GetTextAt (offset, length); + } + + var lineResult = new LineResult { + XNeedsMeasure = line.Length != curLineIndent, + TextOrMarkup = text, + LineKind = lineKind, + }; + + result.LineResults.Add (lineResult); + } + + static int CalcIndentLength (string indent) + { + int indentLen = 0; + foreach (var ch in indent) { + if (ch == '\t') { + indentLen = indentLen - indentLen % DefaultSourceEditorOptions.Instance.TabSize + DefaultSourceEditorOptions.Instance.TabSize; } else { - pos = PopupPosition.Right; + indentLen++; } } - ShowPopup (rect, pos); + return indentLen; } - } + static int CorrectIndent (IReadonlyTextDocument document, IDocumentLine line, int indentLength) + { + int result = 0; + int o = line.Offset; + while (indentLength > 0) { + char ch = document [o + result]; + if (ch == '\t') { + indentLength = indentLength + indentLength % DefaultSourceEditorOptions.Instance.TabSize - DefaultSourceEditorOptions.Instance.TabSize; + } else if (ch == ' ') { + indentLength--; + } else { + break; + } + result++; + } + return result; + } + } protected override void OnDestroyed () { @@ -142,108 +308,43 @@ namespace MonoDevelop.Refactoring // Layout constants const int verticalTextBorder = 10; const int verticalTextSpace = 7; - const int textBorder = 12; protected override void OnSizeRequested (ref Gtk.Requisition requisition) { base.OnSizeRequested (ref requisition); - int y = verticalTextBorder * 2 - verticalTextSpace + (Core.Platform.IsWindows ? 10 : 2); - - var qh = new Queue<DiffHunk> (); - var he = diff.GetEnumerator (); - he.MoveNext (); - var current = he.Current; - DiffHunk next; - qh.Enqueue (current); - int x = 0; - indentLength = -1; - while (he.MoveNext ()) { - next = he.Current; - if (current.Overlaps (next)) { - // Change upper bounds. - } else { - MeasureHunks (qh, editor, changedTextDocument, ref x, ref y); - } - qh.Enqueue (next); + int y = verticalTextBorder * 2 - verticalTextSpace + (Platform.IsWindows ? 10 : 2); + int x = 0; - current = next; - } - if (qh.Count != 0) { - MeasureHunks (qh, editor, changedTextDocument, ref x, ref y); + foreach (var line in diff.LineResults) { + MeasureLine (line, ref x, ref y); } + requisition.Height = y; requisition.Width = x + textBorder * 2; } - void MeasureHunks (Queue<DiffHunk> qh, IReadonlyTextDocument baseDocument, IReadonlyTextDocument changedDocument, ref int x, ref int y) + void MeasureLine (LineResult lineResult, ref int x, ref int y) { - DiffHunk item; - int remStart; - int insStart; - int distance = 0; - do { - item = qh.Dequeue (); - remStart = System.Math.Max (1, item.RemoveStart - (distance != 0 ? distance : item.Context)); - insStart = System.Math.Max (1, item.InsertStart - (distance != 0 ? distance : item.Context)); - - for (int i = System.Math.Min (remStart, insStart); i < item.RemoveStart; i++) { - MeasureLine (editor, i, ref x, ref y); - } - - for (int i = item.RemoveStart; i < item.RemoveStart + item.Removed; i++) { - MeasureLine (editor, i, ref x, ref y); - } - - for (int i = item.InsertStart; i < item.InsertStart + item.Inserted; i++) { - MeasureLine ( changedDocument, i, ref x, ref y); - } - - if (qh.Count != 0) - distance = item.DistanceTo (qh.Peek ()); - } while (qh.Count != 0); - - int remEnd = System.Math.Min (baseDocument.LineCount, item.RemoveStart + item.Removed + item.Context); - for (int i = item.RemoveStart + item.Removed; i < remEnd; i++) { - MeasureLine (editor, i, ref x, ref y); - } - } - - void MeasureLine (IReadonlyTextDocument document, int lineNumber, ref int x, ref int y) - { - using (var drawingLayout = new Pango.Layout (this.PangoContext)) { + using (var drawingLayout = new Pango.Layout (PangoContext)) { drawingLayout.FontDescription = fontDescription; - var line = document.GetLine (lineNumber); - var indent = line.GetIndentation (document); - var curLineIndent = CalcIndentLength(indent); - if (line.Length == curLineIndent) { + if (!lineResult.XNeedsMeasure) { y += lineHeight; return; } - if (this.indentLength < 0 || this.indentLength > curLineIndent) - this.indentLength = curLineIndent; - drawingLayout.SetText (document.GetTextAt (line)); - int w, h; - drawingLayout.GetPixelSize (out w, out h); + + if (lineResult.LineKind == LineKind.Normal) + drawingLayout.SetMarkup (lineResult.TextOrMarkup); + else + drawingLayout.SetText (lineResult.TextOrMarkup); + + drawingLayout.GetPixelSize (out int w, out int h); x = Math.Max (x, w); y += lineHeight; } } - int CalcIndentLength (string indent) - { - int result = 0; - foreach (var ch in indent) { - if (ch == '\t') { - result = result - result % DefaultSourceEditorOptions.Instance.TabSize + DefaultSourceEditorOptions.Instance.TabSize; - } else { - result++; - } - } - return result; - } - protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context g) { var style = editor.Options.GetEditorTheme (); @@ -254,115 +355,40 @@ namespace MonoDevelop.Refactoring int y = verticalTextSpace / 2; - var qh = new Queue<DiffHunk> (); - var he = diff.GetEnumerator (); - he.MoveNext (); - var current = he.Current; - DiffHunk next; - qh.Enqueue (current); - while (he.MoveNext ()) { - next = he.Current; - - if (current.Overlaps (next)) { - // Change upper bounds. - } else { - WriteHunks (qh, editor, changedTextDocument, g, ref y); - } - qh.Enqueue (next); - - current = next; - } - if (qh.Count != 0) { - WriteHunks (qh, editor, changedTextDocument, g, ref y); - } - } - - void WriteHunks (Queue<DiffHunk> qh, IReadonlyTextDocument baseDocument, IReadonlyTextDocument changedDocument, Cairo.Context g, ref int y) - { - DiffHunk item; - int remStart; - int insStart; - int distance = 0; - - do { - item = qh.Dequeue (); - remStart = System.Math.Max (1, item.RemoveStart - (distance != 0 ? distance : item.Context)); - insStart = System.Math.Max (1, item.InsertStart - (distance != 0 ? distance : item.Context)); - - for (int i = System.Math.Min (remStart, insStart); i < item.RemoveStart; i++) { - DrawLine (g, editor, i, ref y); - } - - for (int i = item.RemoveStart; i < item.RemoveStart + item.Removed; i++) { + foreach (var lineResult in diff.LineResults) { + switch (lineResult.LineKind) { + case LineKind.Normal: + DrawLine (g, lineResult, ref y, isMarkup: true); + break; + case LineKind.Removed: g.Rectangle (0, y, Allocation.Width, lineHeight); - g.SetSourceColor (SyntaxHighlightingService.GetColor (editor.Options.GetEditorTheme (), EditorThemeColors.PreviewDiffRemovedBackground)); + g.SetSourceColor (diff.RemovedBackground); g.Fill (); - g.SetSourceColor (SyntaxHighlightingService.GetColor (editor.Options.GetEditorTheme (), EditorThemeColors.PreviewDiffRemoved)); - DrawTextLine (g, editor, i, ref y); - } - - for (int i = item.InsertStart; i < item.InsertStart + item.Inserted; i++) { + g.SetSourceColor (diff.RemovedForeground); + DrawLine (g, lineResult, ref y, isMarkup: false); + break; + case LineKind.Added: g.Rectangle (0, y, Allocation.Width, lineHeight); - g.SetSourceColor (SyntaxHighlightingService.GetColor (editor.Options.GetEditorTheme (), EditorThemeColors.PreviewDiffAddedBackground)); + g.SetSourceColor (diff.AddedBackground); g.Fill (); - g.SetSourceColor (SyntaxHighlightingService.GetColor (editor.Options.GetEditorTheme (), EditorThemeColors.PreviewDiffAdded)); - DrawTextLine (g, changedDocument, i, ref y); - } - - if (qh.Count != 0) - distance = item.DistanceTo (qh.Peek ()); - } while (qh.Count != 0); - - int remEnd = System.Math.Min (baseDocument.LineCount, item.RemoveStart + item.Removed + item.Context); - for (int i = item.RemoveStart + item.Removed; i < remEnd; i++) { - DrawLine (g, editor, i, ref y); - } - } - - int CorrectIndent (IReadonlyTextDocument document, IDocumentLine line, int indentLength) - { - int result = 0; - int o = line.Offset; - while (indentLength > 0) { - char ch = document [o + result]; - if (ch == '\t') { - indentLength = indentLength + indentLength % DefaultSourceEditorOptions.Instance.TabSize - DefaultSourceEditorOptions.Instance.TabSize; - } else if (ch == ' '){ - indentLength --; - } else { + g.SetSourceColor (diff.AddedForeground); + DrawLine (g, lineResult, ref y, isMarkup: false); break; } - result++; } - return result; } - void DrawLine (Cairo.Context g, TextEditor editor, int lineNumber, ref int y) + void DrawLine (Cairo.Context g, LineResult lineResult, ref int y, bool isMarkup) { - using (var drawingLayout = new Pango.Layout (this.PangoContext)) { + using (var drawingLayout = new Pango.Layout (PangoContext)) { drawingLayout.FontDescription = fontDescription; - var line = editor.GetLine (lineNumber); - var correctedIndentLength = CorrectIndent (editor, line, indentLength); - var offset = line.Offset + Math.Min (correctedIndentLength, line.Length); - var length = Math.Max (0, line.Length - correctedIndentLength); - var markup = editor.GetMarkup (offset, length, new MarkupOptions (MarkupFormat.Pango, false)); - drawingLayout.SetMarkup (markup); - g.Save (); - g.Translate (textBorder, y); - g.ShowLayout (drawingLayout); - g.Restore (); - y += lineHeight; - } - } - void DrawTextLine (Cairo.Context g, IReadonlyTextDocument document, int lineNumber, ref int y) - { - using (var drawingLayout = new Pango.Layout (this.PangoContext)) { - drawingLayout.FontDescription = fontDescription; - var line = document.GetLine (lineNumber); - var correctedIndentLength = CorrectIndent (document, line, indentLength); - drawingLayout.SetText (document.GetTextAt (line.Offset + Math.Min (correctedIndentLength, line.Length), Math.Max (0, line.Length - correctedIndentLength))); + if (isMarkup) + drawingLayout.SetMarkup (lineResult.TextOrMarkup); + else + drawingLayout.SetText (lineResult.TextOrMarkup); + g.Save (); g.Translate (textBorder, y); g.ShowLayout (drawingLayout); diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs index 561db4efe2..1f25e8e4d7 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs @@ -364,6 +364,7 @@ namespace MonoDevelop.Refactoring internal static class Counters { public static TimerCounter FindReferences = InstrumentationService.CreateTimerCounter ("Find references", "Code Navigation", id: "CodeNavigation.FindReferences"); + public static TimerCounter<FixesMenuMetadata> FixesMenu = InstrumentationService.CreateTimerCounter<FixesMenuMetadata> ("Show fixes", "Code Actions", id: "CodeActions.ShowFixes"); public static IDictionary<string, string> CreateFindReferencesMetadata () { @@ -381,5 +382,17 @@ namespace MonoDevelop.Refactoring { metadata ["Result"] = "UserCancel"; } + + public class FixesMenuMetadata : CounterMetadata + { + public FixesMenuMetadata () + { + } + + public bool TriggeredBySmartTag { + get => GetProperty<bool> (); + set => SetProperty (value); + } + } } } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextArea.cs b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextArea.cs index 9fae42b2a5..aeeb48da14 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextArea.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextArea.cs @@ -1722,7 +1722,7 @@ namespace Mono.TextEditor } } - var location = textViewMargin.PointToLocation (x - startPos, y, snapCharacters: true); + var location = textViewMargin.PointToLocation (x - startPos, y); if (oldMargin != margin && oldMargin != null) oldMargin.MouseLeft (); diff --git a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextEditorKeyPressTimings.cs b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextEditorKeyPressTimings.cs index ab4975c190..ff21a242ff 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextEditorKeyPressTimings.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextEditorKeyPressTimings.cs @@ -31,6 +31,7 @@ using Microsoft.VisualStudio.Text.Implementation; using System.Linq; using MonoDevelop.SourceEditor; using MonoDevelop.Ide; +using System.Collections.Immutable; namespace Mono.TextEditor { @@ -53,6 +54,15 @@ namespace Mono.TextEditor int activeCountIndex = 0; int droppedEvents = 0; + const int numberOfBuckets = 9; + readonly int[] buckets = new int[numberOfBuckets]; + + // One less than buckets because the last bucket is everything else. + // This number is the max time a keystroke can take to be placed into this bucket + static readonly ImmutableArray<int> bucketUpperLimit = ImmutableArray.Create<int> ( + 8, 16, 32, 64, 128, 256, 512, 1024 + ); + public void StartTimer (Gdk.EventKey evt) { if (activeCountIndex == numberOfCountSpaces) { @@ -67,6 +77,18 @@ namespace Mono.TextEditor activeCounts[activeCountIndex++] = evt.Time; } + int CalculateBucket (TimeSpan duration) + { + long ms = (long)duration.TotalMilliseconds; + for (var bucket = 0; bucket < bucketUpperLimit.Length; bucket++) { + if (ms <= bucketUpperLimit[bucket]) { + return bucket; + } + } + + return numberOfBuckets - 1; + } + void AddTime (TimeSpan duration) { if (duration > maxTime) { @@ -79,6 +101,9 @@ namespace Mono.TextEditor totalTime += duration; count++; + + var bucketNumber = CalculateBucket (duration); + buckets[bucketNumber]++; } /// <summary> @@ -143,6 +168,11 @@ namespace Mono.TextEditor // Do we want to track the number of dropped events? // If there are any dropped events, something major happened to halt the event loop metadata ["Dropped"] = droppedEvents.ToString (); + + // Add the buckets + for (var bucket = 0; bucket < numberOfBuckets; bucket++) { + metadata [$"Bucket{bucket}"] = buckets[bucket].ToString (); + } MonoDevelop.SourceEditor.Counters.Typing.Inc (metadata); } } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs index 2c4af18636..5ed1770342 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs @@ -361,8 +361,9 @@ namespace MonoDevelop.SourceEditor void OptionsChanged (object sender, EventArgs e) { - var editor = (Mono.TextEditor.MonoTextEditor)scrolledWindow.Child; - + var editor = parent?.TextEditor; + if (editor == null) + return; scrolledBackground.ModifyBg (StateType.Normal, SyntaxHighlightingService.GetColor (editor.EditorTheme, EditorThemeColors.Background)); } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs b/main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs index 018ec7f5dc..3e3f88369a 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/VSEditor/TagBasedSyntaxHighlighting.cs @@ -299,10 +299,7 @@ namespace Microsoft.VisualStudio.Platform styleName = "punctuation.separator.key-value.html";
break;
case "HTML Server-Side Script":
- //styleName = "punctuation.section.embedded.begin"; // suggested by mike, does nothing
- //styleName = "punctuation.section.embedded.begin.cs"; // suggested by mike, does nothing
- styleName = "meta.preprocessor.source.cs"; // TODO: Find a name to use here
- //styleName = style.HtmlServerSideScript.Name;
+ styleName = "source.server.html";
break;
case "HTML Tag Delimiter":
styleName = "punctuation.definition.tag.begin.html";
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestDiscoveryAdapter.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestDiscoveryAdapter.cs index 0214dc7d9b..46c4ceecbc 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestDiscoveryAdapter.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestDiscoveryAdapter.cs @@ -43,17 +43,32 @@ namespace MonoDevelop.UnitTesting.VsTest class VsTestDiscoveryAdapter : VsTestAdapter { ProgressMonitor monitor; - Pad pad; - public VsTestDiscoveryAdapter () + + /// <summary> + /// Creates the progress monitor if it does not already exist. This is done + /// on the UI thread explicitly. The ProgressMonitors is a GuiSyncObject so this + /// will be called on the UI thread implicitly otherwise. The progress monitor + /// should not be created when the static Instance is created since this can + /// result in a UI thread hang if Instance is called by both the UI thread and + /// a background thread at the same time. + /// </summary> + async Task CreateProgressMonitor () { - monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor ( - "TestDiscoveryConsole", - GettextCatalog.GetString ("Test Discovery Console"), - Stock.Console, - false, - true, - false); - pad = IdeApp.Workbench.ProgressMonitors.GetPadForMonitor (monitor); + if (monitor != null) + return; + + await Runtime.RunInMainThread (() => { + if (monitor != null) + return; + + monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor ( + "TestDiscoveryConsole", + GettextCatalog.GetString ("Test Discovery Console"), + Stock.Console, + false, + true, + false); + }); } ConcurrentQueue<DiscoveryJob> discoveryQueue = new ConcurrentQueue<DiscoveryJob> (); @@ -88,6 +103,7 @@ namespace MonoDevelop.UnitTesting.VsTest public async Task<DiscoveredTests> DiscoverTestsAsync (Project project) { + await CreateProgressMonitor (); await Start (); var job = new DiscoveryJob () { project = project }; discoveryQueue.Enqueue (job); diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs index b3e6df0e83..b82de9cb12 100644 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs +++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs @@ -10,15 +10,15 @@ namespace PerformanceDiagnosticsAddIn { protected override void Run () { - if (UIThreadMonitor.Instance.IsListening) - UIThreadMonitor.Instance.Stop (); + if (UIThreadMonitor.Instance.IsSampling) + UIThreadMonitor.Instance.Start (sample: false); else - UIThreadMonitor.Instance.Start (); + UIThreadMonitor.Instance.Start (sample: true); } protected override void Update (CommandInfo info) { - info.Text = UIThreadMonitor.Instance.IsListening ? GettextCatalog.GetString ("Stop monitoring UIThread hangs") : GettextCatalog.GetString ("Start monitoring UIThread hangs"); + info.Text = UIThreadMonitor.Instance.IsSampling ? GettextCatalog.GetString ("Stop monitoring UIThread hangs") : GettextCatalog.GetString ("Start monitoring UIThread hangs"); base.Update (info); } } diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/UIThreadMonitor.cs b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/UIThreadMonitor.cs index 585ae143fc..598049f0c0 100644 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/UIThreadMonitor.cs +++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/UIThreadMonitor.cs @@ -11,39 +11,61 @@ using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Globalization; using System.Collections.Generic; +using System.Text; using System.Threading.Tasks; namespace PerformanceDiagnosticsAddIn { - class UIThreadMonitor + public class UIThreadMonitor { public static UIThreadMonitor Instance { get; } = new UIThreadMonitor (); - UIThreadMonitor () { } + UIThreadMonitor () + { + IdeApp.Exited += IdeAppExited; + } + + void IdeAppExited (object sender, EventArgs e) + { + try { + Instance.Stop (); + } catch (Exception ex) { + LoggingService.LogError ("UIThreadMonitor stop error.", ex); + } + } - Socket socket; Thread tcpLoopThread; Thread dumpsReaderThread; - Thread pumpErrorThread; TcpListener listener; Process process; - void TcpLoop () + void TcpLoop (object param) { - byte [] buffer = new byte [1]; - ManualResetEvent waitUIThread = new ManualResetEvent (false); - var sw = Stopwatch.StartNew (); - while (true) { - sw.Restart (); - var readBytes = socket.Receive (buffer, 1, SocketFlags.None); - if (readBytes != 1) - return; - waitUIThread.Reset (); - Runtime.RunInMainThread (delegate { - waitUIThread.Set (); - }); - waitUIThread.WaitOne (); - socket.Send (buffer); + var connection = (ConnectionInfo)param; + var socket = connection.Socket; + try { + var buffer = new byte [1]; + var waitUIThread = new ManualResetEvent (false); + while (connection.ListenerActive) { + var readBytes = socket.Receive (buffer, 1, SocketFlags.None); + if (readBytes != 1) + return; + waitUIThread.Reset (); + Runtime.RunInMainThread (delegate { + waitUIThread.Set (); + }); + waitUIThread.WaitOne (); + socket.Send (buffer); + } + } catch (Exception ex) { + LoggingService.LogError ("UIThreadMonitor TcpLoop error.", ex); + } finally { + try { + if (connection.ListenerActive) + AcceptClientConnection (connection.Listener); + socket.Close (); + } catch (Exception) { + } } } @@ -86,61 +108,87 @@ namespace PerformanceDiagnosticsAddIn } public bool IsListening { get; private set; } + public bool IsSampling { get; private set; } + public string HangFileName { get; set; } - public void Start () + public void Start (bool sample) { - if (IsListening) - return; - if (!(Environment.GetEnvironmentVariable ("MONO_DEBUG")?.Contains ("disable_omit_fp") ?? false)) { - MessageService.ShowWarning ("Set environment variable", - $@"It is highly recommended to set environment variable ""MONO_DEBUG"" to ""disable_omit_fp"" and restart {BrandingService.ApplicationName} to have better results."); + if (IsListening) { + if (IsSampling == sample) + return; + Stop (); + } + if (sample) { + if (!(Environment.GetEnvironmentVariable ("MONO_DEBUG")?.Contains ("disable_omit_fp") ?? false)) { + MessageService.ShowWarning ("Set environment variable", + $@"It is highly recommended to set environment variable ""MONO_DEBUG"" to ""disable_omit_fp"" and restart {BrandingService.ApplicationName} to have better results."); + } } IsListening = true; + IsSampling = sample; //start listening on random port listener = new TcpListener (IPAddress.Loopback, 0); listener.Start (); - listener.AcceptSocketAsync ().ContinueWith (t => { - if (!t.IsFaulted && !t.IsCanceled) { - socket = t.Result; - tcpLoopThread = new Thread (new ThreadStart (TcpLoop)); - tcpLoopThread.IsBackground = true; - tcpLoopThread.Start (); - listener.Stop (); - } - }); + AcceptClientConnection (listener); //get random port provided by OS var port = ((IPEndPoint)listener.LocalEndpoint).Port; process = new Process (); process.StartInfo.FileName = "mono"; - process.StartInfo.Arguments = $"{typeof (UIThreadMonitorDaemon.MainClass).Assembly.Location} {port} {Process.GetCurrentProcess ().Id}"; + process.StartInfo.Arguments = GetArguments (port, sample); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true;//Ignore it, otherwise it goes to IDE logging process.Start (); - process.StandardError.ReadLine (); - dumpsReaderThread = new Thread (new ThreadStart (DumpsReader)); - dumpsReaderThread.IsBackground = true; - dumpsReaderThread.Start (); - - pumpErrorThread = new Thread (new ThreadStart (PumpErrorStream));//We need to read this... - pumpErrorThread.IsBackground = true; - pumpErrorThread.Start (); + + if (IsSampling) { + dumpsReaderThread = new Thread (new ParameterizedThreadStart (DumpsReader)); + dumpsReaderThread.IsBackground = true; + dumpsReaderThread.Start (process); + Task.Run (() => PumpErrorStream (process)).Ignore (); + } + } + + void AcceptClientConnection (TcpListener tcpListener) + { + tcpListener.AcceptSocketAsync ().ContinueWith (t => { + if (!t.IsFaulted && !t.IsCanceled) { + currentConnection = new ConnectionInfo (t.Result, tcpListener); + tcpLoopThread = new Thread (new ParameterizedThreadStart (TcpLoop)); + tcpLoopThread.IsBackground = true; + tcpLoopThread.Start (currentConnection); + } + }); + } + + string GetArguments (int port, bool sample) + { + var arguments = new StringBuilder (); + arguments.Append ($"{typeof (UIThreadMonitorDaemon.MainClass).Assembly.Location} {port} {Process.GetCurrentProcess ().Id}"); + + if (!sample) + arguments.Append (" --noSample"); + + if (!string.IsNullOrEmpty (HangFileName)) + arguments.Append ($" --hangFile:\"{HangFileName}\""); + + return arguments.ToString (); } [DllImport ("__Internal")] extern static string mono_pmip (long offset); static Dictionary<long, string> methodsCache = new Dictionary<long, string> (); - void PumpErrorStream () + static async Task PumpErrorStream (Process process) { - while (!(process?.HasExited ?? true)) { - process?.StandardError?.ReadLine (); + while (!process.HasExited) { + await process.StandardError.ReadLineAsync ().ConfigureAwait (false); } } - void DumpsReader () + static void DumpsReader (object param) { - while (!(process?.HasExited ?? true)) { + var process = (Process)param; + while (!process.HasExited) { var fileName = process.StandardOutput.ReadLine (); ConvertJITAddressesToMethodNames (fileName, "UIThreadHang"); } @@ -150,11 +198,14 @@ namespace PerformanceDiagnosticsAddIn { if (!IsListening) return; + if (currentConnection != null) + currentConnection.ListenerActive = false; + process.Kill (); + process = null; IsListening = false; + IsSampling = false; listener.Stop (); listener = null; - process.Kill (); - process = null; } internal static void ConvertJITAddressesToMethodNames (string fileName, string profilingType) @@ -184,6 +235,22 @@ namespace PerformanceDiagnosticsAddIn } } } + + ConnectionInfo currentConnection; + + class ConnectionInfo + { + public Socket Socket { get; } + public TcpListener Listener { get; } + public bool ListenerActive { get; set; } + + public ConnectionInfo (Socket socket, TcpListener listener) + { + Socket = socket; + Listener = listener; + ListenerActive = true; + } + } } } diff --git a/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Program.cs b/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Program.cs index bdcde64aeb..596f2c7e0e 100644 --- a/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Program.cs +++ b/main/src/addins/PerformanceDiagnostics/UIThreadMonitorDaemon/Program.cs @@ -26,6 +26,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Linq; using System.Net; using System.Net.Sockets; using System.Threading; @@ -41,37 +42,107 @@ namespace UIThreadMonitorDaemon { static int tcpPort; static int processId; + static bool sample = true; + static string hangFile; + static bool hangFileCreated; + static int sendInterval; + static Process parentProcess; public static int Main (string [] args) { - if (args.Length != 2) - return 1; - if (!int.TryParse (args [0], out tcpPort)) - return 2; - if (!int.TryParse (args [1], out processId)) - return 3; + int result = ParseArguments (args); + if (result != 0) + return result; + + parentProcess = Process.GetProcessById (processId); + + var sendEvents = new WaitHandle[] { sentEvent, parentProcessExitedEvent }; + var events = new WaitHandle[] { responseEvent, disconnectEvent, parentProcessExitedEvent }; var thread = new Thread (new ParameterizedThreadStart (Loop)); thread.Start (tcpPort); var sw = Stopwatch.StartNew (); - while (!disonnected) { - sentEvent.WaitOne (); + while (!parentProcess.HasExited) { + int waitResult = WaitHandle.WaitAny (sendEvents); + if (waitResult == 1) + return 0; // Parent process exited. + sw.Restart (); if (!responseEvent.WaitOne (100)) { - Console.Error.WriteLine ($"Timeout({seq}):" + sw.Elapsed); - StartCollectingStacks (); - if (!responseEvent.WaitOne (10000)) - Console.Error.WriteLine ($"No response({seq}) in 10sec"); - else - Console.Error.WriteLine ($"Response({seq}) in {sw.Elapsed}"); - StopCollectingStacks (); + if (sample) { + Console.Error.WriteLine ($"Timeout({seq}):" + sw.Elapsed); + StartCollectingStacks (); + } + + waitResult = WaitHandle.WaitAny (events, 10000); + if (waitResult == 0) {// Got a response. + if (sample) + Console.Error.WriteLine ($"Response({seq}) in {sw.Elapsed}"); + } else if (waitResult == 1) { // Disconnected + // Do nothing. The while loop will wait for the next send event. + } else if (waitResult == 2) { // Parent process exited + // Do nothing. The while loop checks for an exit. + } else { // Timeout + if (sample) + Console.Error.WriteLine ($"No response({seq}) in 10sec"); + CreateHangFile (); + } + + if (sample) + StopCollectingStacks (); } else { - if (sw.ElapsedMilliseconds > 20) + if (sample && sw.ElapsedMilliseconds > 20) Console.Error.WriteLine ($"In time({seq}):" + sw.Elapsed); + RemoveHangFile (); + } + } + return 0; + } + + static int ParseArguments (string[] args) + { + if (args.Length < 2) + return 1; + if (!int.TryParse (args [0], out tcpPort)) + return 2; + if (!int.TryParse (args [1], out processId)) + return 3; + + sendInterval = 100; // Default time (ms) to wait before sending message to IDE. + + if (args.Length > 2) { + const string hangFileOption = "--hangFile:"; + foreach (string arg in args.Skip (2)) { + if (arg == "--noSample") { + sample = false; + // Increase the send interval if no sampling is being done. + sendInterval = 1000; // 1 second. + } + else if (arg.StartsWith (hangFileOption, StringComparison.OrdinalIgnoreCase)) + hangFile = arg.Substring (hangFileOption.Length); } } + return 0; } + static void CreateHangFile () + { + if (hangFileCreated) + return; + + File.WriteAllText (hangFile, string.Empty); + hangFileCreated = true; + } + + static void RemoveHangFile () + { + if (!hangFileCreated) + return; + + File.Delete (hangFile); + hangFileCreated = false; + } + static Process sampleProcess; static string outputFilePath; static void StartCollectingStacks () @@ -99,29 +170,64 @@ namespace UIThreadMonitorDaemon static AutoResetEvent sentEvent = new AutoResetEvent (false); static ManualResetEvent responseEvent = new ManualResetEvent (false); static ManualResetEvent disconnectEvent = new ManualResetEvent (false); - static bool disonnected; + static ManualResetEvent parentProcessExitedEvent = new ManualResetEvent (false); static byte seq; static void Loop (object portObj) { - var ipe = new IPEndPoint (IPAddress.Loopback, (int)portObj); - var socket = new Socket (ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); - socket.Connect (ipe); + int port = (int)portObj; + Socket socket = Connect (port); var response = new byte [1]; - while (true) { - Thread.Sleep (100); - socket.Send (new byte [1] { ++seq }); - responseEvent.Reset (); - sentEvent.Set (); - var readBytes = socket.Receive (response, 1, SocketFlags.None); - if (readBytes != 1) { - disonnected = true; - disconnectEvent.Set (); - return; + while (!parentProcess.HasExited) { + try { + Thread.Sleep (sendInterval); + socket.Send (new byte [1] { ++seq }); + responseEvent.Reset (); + sentEvent.Set (); + var readBytes = socket.Receive (response, 1, SocketFlags.None); + if (readBytes != 1) { + disconnectEvent.Set (); + throw new ApplicationException ("Disconnected from parent."); + } + if (response [0] != seq) + throw new InvalidOperationException ($"Expected {seq}, got {response [0]}."); + responseEvent.Set (); + } catch (Exception ex) { + if (sample) + Console.Error.WriteLine ($"Error communicating with parent. {ex.Message}"); + try { + socket.Close (); + } catch (Exception) { + // Ignore. + } + socket = Connect (port); + } + } + // Ensure main loop exits if it is waiting for a send event. + parentProcessExitedEvent.Set (); + } + + static int connectRetryInterval = 500; // ms + + static Socket Connect (int port) + { + while (!parentProcess.HasExited) { + try { + var ipe = new IPEndPoint (IPAddress.Loopback, port); + var socket = new Socket (ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + socket.Connect (ipe); + + disconnectEvent.Reset (); + + return socket; + } catch (Exception ex) { + if (sample) + Console.Error.WriteLine ($"Could not connect. {ex.Message}"); + if (!parentProcess.HasExited) { + Thread.Sleep (connectRetryInterval); + } } - if (response [0] != seq) - throw new InvalidOperationException ($"Expected {seq}, got {response [0]}."); - responseEvent.Set (); } + return null; } } } diff --git a/main/src/addins/VBNetBinding/Project/VBProjectExtension.cs b/main/src/addins/VBNetBinding/Project/VBProjectExtension.cs index 01983e4aea..da39219615 100644 --- a/main/src/addins/VBNetBinding/Project/VBProjectExtension.cs +++ b/main/src/addins/VBNetBinding/Project/VBProjectExtension.cs @@ -112,12 +112,10 @@ namespace MonoDevelop.VBNetBinding StockIcon = "md-project"; } - VBBindingCompilerServices compilerServices = new VBBindingCompilerServices(); - + [Obsolete] protected override BuildResult OnCompileSources (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, MonoDevelop.Core.ProgressMonitor monitor) { - Debug.Assert(compilerServices != null); - return compilerServices.Compile (items, configuration, configSelector, monitor); + return VBBindingCompilerServices.InternalCompile (items, configuration, configSelector, monitor); } protected override DotNetCompilerParameters OnCreateCompilationParameters (DotNetProjectConfiguration config, ConfigurationKind kind) diff --git a/main/src/addins/VBNetBinding/VBBindingCompilerServices.cs b/main/src/addins/VBNetBinding/VBBindingCompilerServices.cs index 464b82c151..dbd70e69f1 100644 --- a/main/src/addins/VBNetBinding/VBBindingCompilerServices.cs +++ b/main/src/addins/VBNetBinding/VBBindingCompilerServices.cs @@ -47,9 +47,10 @@ namespace MonoDevelop.VBNetBinding { /// <summary> /// This class controls the compilation of VB.net files and VB.net projects /// </summary> + [Obsolete] public class VBBindingCompilerServices { - string GenerateOptions (DotNetProjectConfiguration configuration, VBCompilerParameters compilerparameters, VBProject projectparameters, string outputFileName) + static string GenerateOptions (DotNetProjectConfiguration configuration, VBCompilerParameters compilerparameters, VBProject projectparameters, string outputFileName) { var project = configuration.ParentItem; StringBuilder sb = new StringBuilder (); @@ -182,9 +183,14 @@ namespace MonoDevelop.VBNetBinding { return sb.ToString(); } - + public BuildResult Compile (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor) { + return InternalCompile (items, configuration, configSelector, monitor); + } + + internal static BuildResult InternalCompile (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor) + { VBCompilerParameters compilerparameters = (VBCompilerParameters) configuration.CompilationParameters; if (compilerparameters == null) compilerparameters = new VBCompilerParameters (); @@ -270,7 +276,7 @@ namespace MonoDevelop.VBNetBinding { } // code duplication: see C# backend : CSharpBindingCompilerManager - void WriteManifestFile(string fileName) + static void WriteManifestFile(string fileName) { string manifestFile = String.Concat(fileName, ".manifest"); if (File.Exists(manifestFile)) { @@ -296,7 +302,7 @@ namespace MonoDevelop.VBNetBinding { sw.Close(); } - BuildResult ParseOutput(TempFileCollection tf, string output) + static BuildResult ParseOutput(TempFileCollection tf, string output) { var result = new BuildResult (output, 1, 0); @@ -336,7 +342,7 @@ namespace MonoDevelop.VBNetBinding { return err; } - private int DoCompilation (string compilerName, string responseFileName, TempFileCollection tf, string working_dir, ExecutionEnvironment envVars, ref string output) + static int DoCompilation (string compilerName, string responseFileName, TempFileCollection tf, string working_dir, ExecutionEnvironment envVars, ref string output) { StringWriter outwr = new StringWriter (); try { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs index cf634cff82..628bc2e0d4 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs @@ -821,7 +821,7 @@ namespace MonoDevelop.VersionControl.Views VersionControlItemList items = new VersionControlItemList (); foreach (string file in files) { Project prj = IdeApp.Workspace.GetProjectsContainingFile (file).FirstOrDefault (); - items.Add (new VersionControlItem (vc, prj, file, Directory.Exists (file), null)); + items.Add (new VersionControlItem (vc, prj, file, Directory.Exists (file), GetVersionInfo (file))); } return items; } @@ -1225,10 +1225,9 @@ namespace MonoDevelop.VersionControl.Views } } - handled = handled || ( - IsClickedNodeSelected ((int)evnt.X, (int)evnt.Y) + handled |= (IsClickedNodeSelected ((int)evnt.X, (int)evnt.Y) && ctxMenu) && this.Selection.GetSelectedRows ().Length > 1 - && (evnt.State & selectionModifiers) == 0); + && (evnt.State & selectionModifiers) == 0; if (!handled) handled = base.OnButtonPressEvent (evnt); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs index 71dfc48d81..b656622faf 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs @@ -245,8 +245,12 @@ namespace MonoDevelop.VersionControl } } } - return detectedVCS == null ? null : detectedVCS.GetRepositoryReference (bestMatch, id); - + try { + return detectedVCS?.GetRepositoryReference (bestMatch, id); + } catch (Exception e) { + LoggingService.LogError ($"Could not query {detectedVCS.Name} repository reference", e); + return null; + } } internal static void SetCommitComment (string file, string comment, bool save) diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs index aca3855241..133db60e95 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs @@ -1,34 +1,34 @@ -//
-// WindowsPlatform.cs
-//
-// Author:
-// Jonathan Pobst <monkey@jpobst.com>
-// Lluis Sanchez Gual <lluis@novell.com>
-// Michael Hutchinson <m.j.hutchinson@gmail.com>
-//
-// Copyright (C) 2007-2011 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2012-2013 Xamarin Inc. (https://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
+// +// WindowsPlatform.cs +// +// Author: +// Jonathan Pobst <monkey@jpobst.com> +// Lluis Sanchez Gual <lluis@novell.com> +// Michael Hutchinson <m.j.hutchinson@gmail.com> +// +// Copyright (C) 2007-2011 Novell, Inc (http://www.novell.com) +// Copyright (C) 2012-2013 Xamarin Inc. (https://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + using System; using System.IO; using System.Drawing; @@ -42,18 +42,18 @@ using MonoDevelop.Ide.Desktop; using System.Diagnostics; using MonoDevelop.Core.Execution; using System.Text; -using MonoDevelop.Core;
+using MonoDevelop.Core; using Microsoft.WindowsAPICodePack.InternetExplorer; using Microsoft.WindowsAPICodePack.Taskbar; using MonoDevelop.Ide; using MonoDevelop.Components.Windows; using WindowsPlatform.MainToolbar; -using MonoDevelop.Components.Commands;
+using MonoDevelop.Components.Commands; using System.Windows.Controls; using System.Collections.ObjectModel; -using System.Windows;
-using System.Windows.Input;
-
+using System.Windows; +using System.Windows.Input; + namespace MonoDevelop.Platform { public class WindowsPlatform : PlatformService @@ -70,8 +70,8 @@ namespace MonoDevelop.Platform public override string Name { get { return "Windows"; } - }
-
+ } + #region Toolbar implementation Components.Commands.CommandManager commandManager; string commandMenuAddinPath; @@ -89,13 +89,13 @@ namespace MonoDevelop.Platform const int WM_SYSCHAR = 0x0106; internal override void AttachMainToolbar (Gtk.VBox parent, Components.MainToolbar.IMainToolbarView toolbar) { - titleBar = new TitleBar ();
- var topMenu = new WPFTitlebar (titleBar);
-
- //commandManager.IncompleteKeyPressed += (sender, e) => {
- // if (e.Key == Gdk.Key.Alt_L) {
- // Keyboard.Focus(titleBar.DockTitle.Children[0]);
- // }
+ titleBar = new TitleBar (); + var topMenu = new WPFTitlebar (titleBar); + + //commandManager.IncompleteKeyPressed += (sender, e) => { + // if (e.Key == Gdk.Key.Alt_L) { + // Keyboard.Focus(titleBar.DockTitle.Children[0]); + // } //}; parent.PackStart (topMenu, false, true, 0); SetupMenu (); @@ -104,20 +104,20 @@ namespace MonoDevelop.Platform } void SetupMenu () - {
- // TODO: Use this?
+ { + // TODO: Use this? CommandEntrySet appCes = commandManager.CreateCommandEntrySet (appMenuAddinPath); CommandEntrySet ces = commandManager.CreateCommandEntrySet (commandMenuAddinPath); - var mainMenu = new Menu {
- IsMainMenu = true,
- FocusVisualStyle = null,
+ var mainMenu = new Menu { + IsMainMenu = true, + FocusVisualStyle = null, }; - foreach (CommandEntrySet ce in ces)
- {
- var item = new TitleMenuItem (commandManager, ce, menu: mainMenu);
- mainMenu.Items.Add(item);
- }
+ foreach (CommandEntrySet ce in ces) + { + var item = new TitleMenuItem (commandManager, ce, menu: mainMenu); + mainMenu.Items.Add(item); + } titleBar.DockTitle.Children.Add (mainMenu); DockPanel.SetDock (mainMenu, Dock.Left); @@ -128,36 +128,25 @@ namespace MonoDevelop.Platform TitleBar titleBar; internal override Components.MainToolbar.IMainToolbarView CreateMainToolbar (Gtk.Window window) - {
- return new WPFToolbar {
- HeightRequest = 40,
+ { + return new WPFToolbar { + HeightRequest = 40, }; - }
+ } #endregion - public override bool GetIsFullscreen (Components.Window window)
+ public override bool GetIsFullscreen (Components.Window window) { - WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT (); - lpwndpl.length = Marshal.SizeOf (lpwndpl); - - Gtk.Window controlWindow = window; - IntPtr handle = GdkWin32.HgdiobjGet (controlWindow.GdkWindow); - Win32.GetWindowPlacement (handle, ref lpwndpl); - return lpwndpl.showCmd == Win32.SW_SHOWMAXIMIZED;
+ //the Fullscreen functionality is broken in GTK on Win7+ + //TODO: implement a workaround. + return false; } - public override void SetIsFullscreen (Components.Window window, bool isFullscreen)
+ public override void SetIsFullscreen (Components.Window window, bool isFullscreen) { - WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT (); - lpwndpl.length = Marshal.SizeOf (lpwndpl); - - Gtk.Window controlWindow = window; - IntPtr handle = GdkWin32.HgdiobjGet (controlWindow.GdkWindow); - Win32.GetWindowPlacement (handle, ref lpwndpl); - lpwndpl.showCmd = isFullscreen ? Win32.SW_SHOWMAXIMIZED : Win32.SW_SHOWNORMAL; - Win32.SetWindowPlacement (handle, ref lpwndpl);
+ //no-op as we have not yet implemented this } -
+ internal static Xwt.Toolkit WPFToolkit; public override void Initialize () @@ -165,8 +154,8 @@ namespace MonoDevelop.Platform // Only initialize elements for Win7+. if (TaskbarManager.IsPlatformSupported) { TaskbarManager.Instance.ApplicationId = BrandingService.ApplicationName; - }
- // Set InternetExplorer emulation mode
+ } + // Set InternetExplorer emulation mode InternetExplorer.EmulationMode = IEEmulationMode.IE11; } @@ -550,8 +539,8 @@ namespace MonoDevelop.Platform try { SHOpenFolderAndSelectItems (dir, (uint)files.Length, files, 0); } finally { - ILFree (dir);
- foreach (var file in files)
+ ILFree (dir); + foreach (var file in files) ILFree (file); } } @@ -573,34 +562,34 @@ namespace MonoDevelop.Platform foreach (string file in files) Process.Start (ExePath, ProcessArgumentBuilder.Quote (file)); } - }
-
- static void ApplyTheme (System.Windows.Window window)
- {
- var color = System.Windows.Media.Color.FromArgb (
- (byte)(MonoDevelop.Ide.Gui.Styles.BackgroundColor.Alpha * 255.0),
- (byte)(MonoDevelop.Ide.Gui.Styles.BackgroundColor.Red * 255.0),
- (byte)(MonoDevelop.Ide.Gui.Styles.BackgroundColor.Green * 255.0),
- (byte)(MonoDevelop.Ide.Gui.Styles.BackgroundColor.Blue * 255.0));
- window.Background = new System.Windows.Media.SolidColorBrush (color);
- }
-
- public class ThemedWpfWindowBackend : Xwt.WPFBackend.WindowBackend
- {
- public override void Initialize ()
- {
- base.Initialize ();
- ApplyTheme (Window);
- }
- }
-
- public class ThemedWpfDialogBackend : Xwt.WPFBackend.DialogBackend
- { - public override void Initialize ()
- {
- base.Initialize ();
- ApplyTheme (Window);
- }
+ } + + static void ApplyTheme (System.Windows.Window window) + { + var color = System.Windows.Media.Color.FromArgb ( + (byte)(MonoDevelop.Ide.Gui.Styles.BackgroundColor.Alpha * 255.0), + (byte)(MonoDevelop.Ide.Gui.Styles.BackgroundColor.Red * 255.0), + (byte)(MonoDevelop.Ide.Gui.Styles.BackgroundColor.Green * 255.0), + (byte)(MonoDevelop.Ide.Gui.Styles.BackgroundColor.Blue * 255.0)); + window.Background = new System.Windows.Media.SolidColorBrush (color); + } + + public class ThemedWpfWindowBackend : Xwt.WPFBackend.WindowBackend + { + public override void Initialize () + { + base.Initialize (); + ApplyTheme (Window); + } + } + + public class ThemedWpfDialogBackend : Xwt.WPFBackend.DialogBackend + { + public override void Initialize () + { + base.Initialize (); + ApplyTheme (Window); + } } } } diff --git a/main/src/addins/Xml/Dom/XAttributeCollection.cs b/main/src/addins/Xml/Dom/XAttributeCollection.cs index 0a906f0ec9..d408f5b63f 100644 --- a/main/src/addins/Xml/Dom/XAttributeCollection.cs +++ b/main/src/addins/Xml/Dom/XAttributeCollection.cs @@ -31,9 +31,11 @@ namespace MonoDevelop.Xml.Dom { public class XAttributeCollection : IEnumerable<XAttribute> { - readonly XObject parent; - XAttribute firstChild; - XAttribute lastChild; + readonly XObject parent;
+
+ public XAttribute Last { get; private set; }
+ public XAttribute First { get; private set; }
+ public int Count { get; private set; } public XAttributeCollection (XObject parent) { @@ -43,7 +45,7 @@ namespace MonoDevelop.Xml.Dom public Dictionary<XName, XAttribute> ToDictionary () { var dict = new Dictionary<XName,XAttribute> (); - XAttribute current = firstChild; + XAttribute current = First; while (current != null) { dict.Add (current.Name, current); current = current.NextSibling; @@ -53,7 +55,7 @@ namespace MonoDevelop.Xml.Dom public XAttribute this [XName name] { get { - XAttribute current = firstChild; + XAttribute current = First; while (current != null) { if (current.Name == name) return current; @@ -65,7 +67,7 @@ namespace MonoDevelop.Xml.Dom public XAttribute this [int index] { get { - XAttribute current = firstChild; + XAttribute current = First; while (current != null) { if (index == 0) return current; @@ -78,7 +80,7 @@ namespace MonoDevelop.Xml.Dom public XAttribute Get (XName name, bool ignoreCase) { - XAttribute current = firstChild; + XAttribute current = First; while (current != null) { if (XName.Equals (current.Name, name, ignoreCase)) return current; @@ -96,17 +98,18 @@ namespace MonoDevelop.Xml.Dom public void AddAttribute (XAttribute newChild) { newChild.Parent = parent; - if (lastChild != null) { - lastChild.NextSibling = newChild; + if (Last != null) { + Last.NextSibling = newChild; } - if (firstChild == null) - firstChild = newChild; - lastChild = newChild; + if (First == null) + First = newChild; + Last = newChild;
+ Count++; } public IEnumerator<XAttribute> GetEnumerator () { - XAttribute current = firstChild; + XAttribute current = First; while (current != null) { yield return current; current = current.NextSibling; diff --git a/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs b/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs index 0c2f3aedc5..6889969c84 100644 --- a/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs +++ b/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs @@ -1268,5 +1268,32 @@ namespace MonoDevelop.Xml.Editor } } } + + [CommandHandler (TextEditorCommands.ExpandSelection)] + public virtual void ExpandSelection () + { + Tracker.UpdateEngine (); + XmlExpandSelectionHandler.ExpandSelection (Editor, Tracker.Engine.GetTreeParser); + } + + [CommandUpdateHandler (TextEditorCommands.ExpandSelection)] + public void UpdateExpandSelection (CommandInfo info) + { + info.Enabled = XmlExpandSelectionHandler.CanExpandSelection (Editor); + + } + + [CommandHandler (TextEditorCommands.ShrinkSelection)] + public virtual void ShrinkSelection () + { + Tracker.UpdateEngine (); + XmlExpandSelectionHandler.ShrinkSelection (Editor, Tracker.Engine.GetTreeParser); + } + + [CommandUpdateHandler (TextEditorCommands.ShrinkSelection)] + public void UpdateShrinkSelection (CommandInfo info) + { + info.Enabled = XmlExpandSelectionHandler.CanShrinkSelection (Editor); + } } } diff --git a/main/src/addins/Xml/Editor/XmlExpandSelectionHandler.cs b/main/src/addins/Xml/Editor/XmlExpandSelectionHandler.cs new file mode 100644 index 0000000000..e4b2e79341 --- /dev/null +++ b/main/src/addins/Xml/Editor/XmlExpandSelectionHandler.cs @@ -0,0 +1,384 @@ +// +// Copyright (c) Microsoft Corp +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Xml.Dom; +using MonoDevelop.Xml.Parser; + +namespace MonoDevelop.Xml.Editor +{ + class XmlExpandSelectionHandler + { + public static bool CanExpandSelection (TextEditor editor) + { + if (!editor.IsSomethingSelected) { + return true; + } + if (editor.Selections.Count () == 1) { + return editor.SelectionRange.Offset > 0 || editor.SelectionRange.Length != editor.Length; + } + return false; + } + + internal static void ExpandSelection (TextEditor editor, Func<XmlParser> getTreeParser) + { + var selectionAnnotation = GetAnnotation (editor, getTreeParser); + if (selectionAnnotation.NodePath.Count == 0) + return; + + var newRegion = selectionAnnotation.Grow (); + if (newRegion.HasValue) { + editor.SetSelection (newRegion.Value.Begin, newRegion.Value.End); + } + } + + public static bool CanShrinkSelection (TextEditor editor) + { + return editor.IsSomethingSelected && editor.Selections.Count () == 1; + } + + internal static void ShrinkSelection (TextEditor editor, Func<XmlParser> getTreeParser) + { + var selectionAnnotation = GetAnnotation (editor, getTreeParser); + if (selectionAnnotation.NodePath.Count == 0) + return; + + var newRegion = selectionAnnotation.Shrink (); + if (newRegion.HasValue) { + editor.SetSelection (newRegion.Value.Begin, newRegion.Value.End); + } else { + editor.ClearSelection (); + } + } + + static XmlExpandSelectionAnnotation GetAnnotation (TextEditor editor, Func<XmlParser> getTreeParser) + { + var result = editor.Annotation<XmlExpandSelectionAnnotation> (); + if (result == null) { + result = new XmlExpandSelectionAnnotation (editor, getTreeParser ()); + editor.AddAnnotation (result); + } + return result; + } + + enum SelectionLevel + { + Self, + Name, + Content, + WithClosing, + Document, + Attributes + } + + class XmlExpandSelectionAnnotation + { + Stack<(int, SelectionLevel)> expansions = new Stack<(int, SelectionLevel)> (); + + readonly IReadonlyTextDocument document; + readonly TextEditor editor; + readonly XmlParser parser; + public List<XObject> NodePath { get; } + public int Index { get; set; } = -1; + public SelectionLevel Level { get; set; } + + public XmlExpandSelectionAnnotation (TextEditor editor, XmlParser parser) + { + this.parser = parser; + this.editor = editor; + document = editor.CreateDocumentSnapshot (); + editor.CaretPositionChanged += Editor_CaretPositionChanged; + NodePath = GetNodePath (parser, document); + } + + void Editor_CaretPositionChanged (object sender, EventArgs e) + { + editor.CaretPositionChanged -= Editor_CaretPositionChanged; + editor.RemoveAnnotations<XmlExpandSelectionAnnotation> (); + } + + DocumentRegion? GetCurrent () + { + if (Index < 0) { + return null; + } + var current = NodePath [Index]; + switch (Level) { + case SelectionLevel.Self: + return current.Region; + case SelectionLevel.WithClosing: + var element = (XElement)current; + return new DocumentRegion (element.Region.Begin, element.ClosingTag.Region.End); + case SelectionLevel.Name: + return current.TryGetNameRegion ().Value; + case SelectionLevel.Content: + if (current is XElement el) { + return new DocumentRegion (el.Region.End, el.ClosingTag.Region.Begin); + } + return ((XAttribute)current).GetAttributeValueRegion (document); + case SelectionLevel.Document: + return new DocumentRegion (new DocumentLocation (1, 1), document.OffsetToLocation (document.Length)); + case SelectionLevel.Attributes: + return ((XElement)current).GetAttributesRegion (); + } + throw new InvalidOperationException (); + } + + public DocumentRegion? Grow () + { + var old = (Index, Level); + if (GrowStateInternal ()) { + expansions.Push (old); + return GetCurrent (); + } + return null; + } + + bool GrowStateInternal () + { + if (Index + 1 == NodePath.Count) { + return false; + } + + //if an index is selected, we may need to transition level rather than transitioning index + if (Index >= 0) { + var current = NodePath [Index]; + if (current is XElement element) { + switch (Level) { + case SelectionLevel.Self: + if (!element.IsSelfClosing) { + Level = SelectionLevel.WithClosing; + return true; + } + break; + case SelectionLevel.Content: + Level = SelectionLevel.WithClosing; + return true; + case SelectionLevel.Name: + Level = SelectionLevel.Self; + return true; + case SelectionLevel.Attributes: + Level = SelectionLevel.Self; + return true; + } + } else if (current is XAttribute att) { + switch (Level) { + case SelectionLevel.Name: + case SelectionLevel.Content: + Level = SelectionLevel.Self; + return true; + } + } else if (Level == SelectionLevel.Name) { + Level = SelectionLevel.Self; + return true; + } else if (Level == SelectionLevel.Document) { + return false; + } + } + + //advance up the node path + Index++; + var newNode = NodePath [Index]; + + //determine the starting selection level for the new node + if (newNode is XDocument) { + Level = SelectionLevel.Document; + return true; + } + + AdvanceUntilClosed (newNode, parser, document); + + if (newNode.Region.ContainsOuter (editor.CaretLocation)) { + var nr = newNode.TryGetNameRegion (); + if (nr != null && nr.Value.ContainsOuter (editor.CaretLocation)) { + Level = SelectionLevel.Name; + return true; + } + if (newNode is XAttribute attribute) { + var valRegion = attribute.GetAttributeValueRegion (document); + if (valRegion.ContainsOuter (editor.CaretLocation)) { + Level = SelectionLevel.Content; + return true; + } + } + if (newNode is XElement xElement && xElement.Attributes.Count > 1) { + var attsRegion = xElement.GetAttributesRegion (); + if (attsRegion.ContainsOuter (editor.CaretLocation)) { + Level = SelectionLevel.Attributes; + return true; + } + } + Level = SelectionLevel.Self; + return true; + } + + if (newNode is XElement el) { + if (el.IsSelfClosing) { + Level = SelectionLevel.Self; + return true; + } + if (el.ClosingTag.Region.ContainsOuter (editor.CaretLocation)) { + Level = SelectionLevel.WithClosing; + return true; + } + Level = SelectionLevel.Content; + return true; + } + + Level = SelectionLevel.Self; + return true; + } + + public DocumentRegion? Shrink () + { + // if we have expansion state, pop it + if (expansions.Count > 0) { + var last = expansions.Pop (); + Index = last.Item1; + Level = last.Item2; + return GetCurrent (); + } + + return null; + } + + //advance the parser in chunks until the given node is complete + static void AdvanceUntilClosed (XObject ob, XmlParser parser, IReadonlyTextDocument document) + { + const int chunk = 200; + var el = ob as XElement; + while (parser.Position < document.Length) { + parser.Parse (document.CreateReader (parser.Position, Math.Min (document.Length - parser.Position, chunk))); + if (el?.IsClosed ?? ob.IsEnded || !parser.Nodes.Contains (ob.Parent)) { + break; + } + } + } + + static List<XObject> GetNodePath (XmlParser parser, IReadonlyTextDocument document) + { + int offset = parser.Position; + var length = document.Length; + int i = offset; + + var nodePath = parser.Nodes.ToList (); + + //if inside body of unclosed element, capture whole body + if (parser.CurrentState is XmlRootState && parser.Nodes.Peek () is XElement unclosedEl) { + while (i < length && InRootOrClosingTagState () && !unclosedEl.IsClosed) { + parser.Push (document.GetCharAt (i++)); + } + } + + //if in potential start of a state, capture it + else if (parser.CurrentState is XmlRootState && GetStateTag() > 0) { + //eat until we figure out whether it's a state transition + while (i < length && GetStateTag () > 0) { + parser.Push (document.GetCharAt (i++)); + } + //if it transitioned to another state, eat until we get a new node on the stack + if (NotInRootState ()) { + var newState = parser.CurrentState; + while (i < length && NotInRootState() && parser.Nodes.Count <= nodePath.Count) { + parser.Push (document.GetCharAt (i++)); + } + if (parser.Nodes.Count > nodePath.Count) { + nodePath.Insert (0, parser.Nodes.Peek ()); + } + } + } + + //ensure any unfinished names are captured + while (i < length && InNameOrAttributeState ()) { + parser.Push (document.GetCharAt (i++)); + } + + //if nodes are incomplete, they won't get connected + //HACK: the only way to reconnect them is reflection + if (nodePath.Count > 1) { + for (int idx = 0; idx < nodePath.Count - 1; idx++) { + var node = nodePath [idx]; + if (node.Parent == null) { + var parent = nodePath [idx + 1]; + node.Parent = parent; + } + } + } + + return nodePath; + + bool InNameOrAttributeState () => + parser.CurrentState is XmlNameState + || parser.CurrentState is XmlAttributeState + || parser.CurrentState is XmlAttributeValueState; + + bool InRootOrClosingTagState () => + parser.CurrentState is XmlRootState + || parser.CurrentState is XmlNameState + || parser.CurrentState is XmlClosingTagState; + + int GetStateTag () => ((IXmlParserContext)parser).StateTag; + + bool NotInRootState () => !(parser.CurrentState is XmlRootState); + } + } + } + + internal static class XmlExtensions + { + public static DocumentRegion? TryGetNameRegion (this XObject xobject) + { + if (xobject is XElement element) { + var r = element.Region; + return new DocumentRegion (r.BeginLine, r.BeginColumn + 1, r.BeginLine, r.BeginColumn + 1 + element.Name.FullName.Length); + } + if (xobject is XClosingTag closingTag) { + var r = closingTag.Region; + return new DocumentRegion (r.BeginLine, r.BeginColumn + 2, r.BeginLine, r.BeginColumn + 2 + closingTag.Name.FullName.Length); + } + if (xobject is XAttribute attribute) { + var r = attribute.Region; + return new DocumentRegion (r.BeginLine, r.BeginColumn, r.BeginLine, r.BeginColumn + attribute.Name.FullName.Length); + } + return null; + } + + public static DocumentRegion GetAttributeValueRegion (this XAttribute att, IReadonlyTextDocument doc) + { + int endOffset = doc.LocationToOffset (att.Region.End) - 1; + int startOffset = endOffset - att.Value.Length; + return new DocumentRegion (doc.OffsetToLocation (startOffset), doc.OffsetToLocation (endOffset)); + } + + public static DocumentRegion GetAttributesRegion (this XElement element) + { + return new DocumentRegion (element.Attributes.First.Region.Begin, element.Attributes.Last.Region.End); + } + + public static bool ContainsOuter (this DocumentRegion region, DocumentLocation location) + { + return region.Begin <= location && location <= region.End; + } + } +} diff --git a/main/src/addins/Xml/MonoDevelop.Xml.csproj b/main/src/addins/Xml/MonoDevelop.Xml.csproj index afc6f69887..6b9df37cdd 100644 --- a/main/src/addins/Xml/MonoDevelop.Xml.csproj +++ b/main/src/addins/Xml/MonoDevelop.Xml.csproj @@ -156,6 +156,7 @@ <Compile Include="Completion\XmlElementPath.cs" /> <Compile Include="Editor\XmlCommands.cs" /> <Compile Include="Editor\EncodedStringWriter.cs" /> + <Compile Include="Editor\XmlExpandSelectionHandler.cs" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> diff --git a/main/src/addins/Xml/Tests/ExpandSelectionTests.cs b/main/src/addins/Xml/Tests/ExpandSelectionTests.cs new file mode 100644 index 0000000000..5cc43fc238 --- /dev/null +++ b/main/src/addins/Xml/Tests/ExpandSelectionTests.cs @@ -0,0 +1,160 @@ +// +// ExpandSelectionTests.cs +// +// Author: +// Mikayla Hutchinson <m.j.hutchinson@gmail.com> +// +// Copyright (c) 2018 Microsoft Corp +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System.Collections.Generic;
+using System.Threading.Tasks;
+using MonoDevelop.Ide; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Ide.Editor.Extension; +using MonoDevelop.Xml.Editor; +using NUnit.Framework; + +namespace MonoDevelop.Xml.Tests +{ + [TestFixture] + public class ExpandSelectionTests : TextEditorExtensionTestBase + { + public static EditorExtensionTestData XmlContentData = new EditorExtensionTestData ( + fileName: "/a.xml", + language: "C#", + mimeType: "application/xml", + projectFileName: "test.csproj" + ); + + const string Document = @"<!-- this is +a comment--> +<foo hello=""hi"" goodbye=""bye""> + this is some text + <bar><baz thing=""done"" /> + <!--another comment--> + </bar> +</foo> +"; + const string CommentDoc = @"<!-- this is +a comment-->"; + + const string ElementFoo = @"<foo hello=""hi"" goodbye=""bye"">"; + + const string ElementWithBodyFoo = @"<foo hello=""hi"" goodbye=""bye""> + this is some text + <bar><baz thing=""done"" /> + <!--another comment--> + </bar> +</foo>"; + + const string AttributesFoo = @"hello=""hi"" goodbye=""bye"""; + + const string AttributeHello = @"hello=""hi"""; + + const string AttributeGoodbye = @"goodbye=""bye"""; + + const string BodyFoo = @" + this is some text + <bar><baz thing=""done"" /> + <!--another comment--> + </bar> +"; + const string ElementBar = @"<bar>"; + + const string ElementWithBodyBar = @"<bar><baz thing=""done"" /> + <!--another comment--> + </bar>"; + + const string BodyBar = @"<baz thing=""done"" /> + <!--another comment--> + "; + + const string ElementBaz= @"<baz thing=""done"" />"; + + const string AttributeThing = @"thing=""done"""; + + const string CommentBar = @"<!--another comment-->"; + + protected override EditorExtensionTestData GetContentData () => XmlContentData; + + protected override IEnumerable<TextEditorExtension> GetEditorExtensions () + { + yield return new XmlTextEditorExtension (); + } + + //args are line, col, then the expected sequence of expansions + [Test] + [TestCase (1, 2, CommentDoc)] + [TestCase (3, 2, "foo", ElementFoo, ElementWithBodyFoo)] + [TestCase (3, 3, "foo", ElementFoo, ElementWithBodyFoo)] + [TestCase (3, 15, "hi", AttributeHello, AttributesFoo, ElementFoo, ElementWithBodyFoo)] + [TestCase (3, 7, "hello", AttributeHello, AttributesFoo, ElementFoo, ElementWithBodyFoo)] + [TestCase (4, 7, BodyFoo, ElementWithBodyFoo)] + [TestCase (5, 22, "done", AttributeThing, ElementBaz, BodyBar, ElementWithBodyBar, BodyFoo, ElementWithBodyFoo)] + [TestCase (6, 12, CommentBar, BodyBar, ElementWithBodyBar, BodyFoo, ElementWithBodyFoo)] + public async Task TestExpandShrink (object[] args) + { + var loc = new DocumentLocation ((int)args [0], (int)args[1]); + using (var testCase = await SetupTestCase (Document)) { + var doc = testCase.Document; + doc.Editor.SetCaretLocation (loc); + var ext = doc.GetContent<BaseXmlEditorExtension> (); + + //check initial state + Assert.IsFalse (doc.Editor.IsSomethingSelected); + Assert.AreEqual (loc, doc.Editor.CaretLocation); + + //check expanding causes correct selections + for (int i = 2; i < args.Length; i++) { + ext.ExpandSelection (); + Assert.AreEqual (args [i], doc.Editor.SelectedText); + } + + //check entire doc is selected + ext.ExpandSelection (); + var sel = doc.Editor.SelectionRange; + Assert.AreEqual (0, sel.Offset); + Assert.AreEqual (Document.Length, sel.Length); + + //check expanding again does not change it + ext.ExpandSelection (); + Assert.AreEqual (0, sel.Offset); + Assert.AreEqual (Document.Length, sel.Length); + + //check shrinking causes correct selections + for (int i = args.Length - 1; i >= 2; i--) { + ext.ShrinkSelection (); + Assert.AreEqual (args [i], doc.Editor.SelectedText); + } + + //final shrink back to a caret + ext.ShrinkSelection (); + Assert.IsFalse (doc.Editor.IsSomethingSelected); + Assert.AreEqual (loc, doc.Editor.CaretLocation); + + //check shrinking again does not change it + ext.ShrinkSelection (); + Assert.IsFalse (doc.Editor.IsSomethingSelected); + Assert.AreEqual (loc, doc.Editor.CaretLocation); + } + } + } +} diff --git a/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj b/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj index 4596126228..361153d7cd 100644 --- a/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj +++ b/main/src/addins/Xml/Tests/MonoDevelop.Xml.Tests.csproj @@ -32,6 +32,14 @@ <Name>MonoDevelop.Xml</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\..\tests\IdeUnitTests\IdeUnitTests.csproj"> + <Project>{F7B2B155-7CF4-42C4-B5AF-63C0667D2E4F}</Project> + <Name>IdeUnitTests</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\..\tests\UnitTests\UnitTests.csproj"> + <Project>{1497D0A8-AFF1-4938-BC22-BE79B358BA5B}</Project> + <Name>UnitTests</Name> + </ProjectReference> </ItemGroup> <ItemGroup> <Reference Include="System" /> @@ -105,6 +113,7 @@ <Compile Include="Formatting\XmlFormatterTests.cs" /> <Compile Include="Schema\SchemaValidationTests.cs" /> <Compile Include="Utils\XsltTransformTest.cs" /> + <Compile Include="ExpandSelectionTests.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="..\schemas\XMLSchema.xsd"> diff --git a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs index 39bba103f8..957ae2c619 100644 --- a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs +++ b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextSegmentMarker.cs @@ -196,11 +196,13 @@ namespace Mono.TextEditor Pango.CairoHelper.ShowErrorUnderline (cr, metrics.TextRenderStartPosition, y + editor.LineHeight - height, editor.Allocation.Width, height);
cr.ResetClip ();
break;
- case MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.DottedLine:
+ case MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.DottedLine: + cr.Save (); cr.MoveTo (@from, y + editor.LineHeight - editor.Options.Zoom - 0.5);
cr.LineTo (to, y + editor.LineHeight - editor.Options.Zoom - 0.5);
cr.SetDash (new double [] { 2 * editor.Options.Zoom, 2 * editor.Options.Zoom }, 0);
cr.Stroke ();
+ cr.Restore ();
break;
case MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.Underline:
cr.MoveTo (@from, y + editor.LineHeight - editor.Options.Zoom - 0.5);
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/TimerCounter.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/TimerCounter.cs index 4852e426f0..26eae0014f 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/TimerCounter.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Instrumentation/TimerCounter.cs @@ -260,8 +260,11 @@ namespace MonoDevelop.Core.Instrumentation protected T GetProperty<T> ([CallerMemberName]string name = null) { - properties.TryGetValue (name, out var result); - return (T) Convert.ChangeType (result, typeof (T), CultureInfo.InvariantCulture); + if (properties.TryGetValue (name, out var result)) { + return (T)Convert.ChangeType (result, typeof (T), CultureInfo.InvariantCulture); + } + + return default (T); } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj index c21eb44fa8..f73a1f78cc 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj @@ -723,6 +723,8 @@ <Compile Include="MonoDevelop.Projects\FileWatcherService.cs" /> <Compile Include="MonoDevelop.Core\SynchronizationContextTaskScheduler.cs" /> <Compile Include="MonoDevelop.Core\ConfigurationProperty.cs" /> + <Compile Include="MonoDevelop.FSW\PathTree.cs" /> + <Compile Include="MonoDevelop.FSW\PathTreeNode.cs" /> </ItemGroup> <ItemGroup> <None Include="BuildVariables.cs.in" /> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs index 57e3fcb4b0..c98222e9e0 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs @@ -55,9 +55,6 @@ namespace MonoDevelop.Core static FileServiceErrorHandler errorHandler; - static FileSystemExtension fileSystemChain; - static readonly FileSystemExtension defaultExtension = new DefaultFileSystemExtension (); - static readonly EventQueue eventQueue = new EventQueue (); static readonly string applicationRootPath = Path.Combine (PropertyService.EntryAssemblyPath, ".."); @@ -67,32 +64,40 @@ namespace MonoDevelop.Core } } - static FileService() + static class FileSystemExtensions { - AddinManager.ExtensionChanged += delegate (object sender, ExtensionEventArgs args) { - if (args.PathChanged (addinFileSystemExtensionPath)) - UpdateExtensions (); - }; - UpdateExtensions (); - } + public static FileSystemExtension Chain => fileSystemChain; - static void UpdateExtensions () - { - if (!Runtime.Initialized) { - fileSystemChain = defaultExtension; - return; - } + static FileSystemExtension fileSystemChain; + static readonly FileSystemExtension defaultExtension = new DefaultFileSystemExtension (); - var extensions = AddinManager.GetExtensionObjects (addinFileSystemExtensionPath, typeof(FileSystemExtension)).Cast<FileSystemExtension> ().ToArray (); - for (int n=0; n<extensions.Length - 1; n++) { - extensions [n].Next = extensions [n + 1]; + static FileSystemExtensions () + { + AddinManager.ExtensionChanged += delegate (object sender, ExtensionEventArgs args) { + if (args.PathChanged (addinFileSystemExtensionPath)) + UpdateExtensions (); + }; + UpdateExtensions (); } - if (extensions.Length > 0) { - extensions [extensions.Length - 1].Next = defaultExtension; - fileSystemChain = extensions [0]; - } else { - fileSystemChain = defaultExtension; + static void UpdateExtensions () + { + if (!Runtime.Initialized) { + fileSystemChain = defaultExtension; + return; + } + + var extensions = AddinManager.GetExtensionObjects (addinFileSystemExtensionPath, typeof (FileSystemExtension)).Cast<FileSystemExtension> ().ToArray (); + for (int n = 0; n < extensions.Length - 1; n++) { + extensions [n].Next = extensions [n + 1]; + } + + if (extensions.Length > 0) { + extensions [extensions.Length - 1].Next = defaultExtension; + fileSystemChain = extensions [0]; + } else { + fileSystemChain = defaultExtension; + } } } @@ -353,7 +358,7 @@ namespace MonoDevelop.Core internal static FileSystemExtension GetFileSystemForPath (string path, bool isDirectory) { Debug.Assert (!String.IsNullOrEmpty (path)); - FileSystemExtension nx = fileSystemChain; + FileSystemExtension nx = FileSystemExtensions.Chain; while (nx != null && !nx.CanHandlePath (path, isDirectory)) nx = nx.Next; return nx; diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Properties.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Properties.cs index 31fc55a1c9..404a37c09e 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Properties.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Properties.cs @@ -50,22 +50,22 @@ namespace MonoDevelop.Core } } - T Convert<T> (object o) + object Convert (object o, Type converterType) { - TypeConverter converter = GetConverter (typeof(T)); - + TypeConverter converter = GetConverter (converterType); + if (o is string) { try { - return (T)converter.ConvertFromInvariantString (o.ToString ()); + return converter.ConvertFromInvariantString (o.ToString ()); } catch (Exception) { - return default(T); + return null; } } - + try { - return (T)converter.ConvertFrom (o); + return converter.ConvertFrom (o); } catch (Exception) { - return default(T); + return null; } } @@ -86,52 +86,65 @@ namespace MonoDevelop.Core } return converter; } - - public T Get<T> (string property, T defaultValue) + + public object Get (string property, object defaultValue, Type type) { if (!defaultValues.ContainsKey (property)) defaultValues = defaultValues.SetItem (property, defaultValue); - if (GetPropertyValue (property, out T value)) + + if (GetPropertyValue (property, out object value, type)) return value; properties = properties.SetItem (property, defaultValue); return defaultValue; } + + + public T Get<T> (string property, T defaultValue) + { + var result = Get (property, defaultValue, typeof (T)); + return result != null ? (T)result : default (T); + } public T Get<T> (string property) { - if (GetPropertyValue (property, out T value)) - return value; + if (GetPropertyValue (property, out object value, typeof(T))) + return (T)value; if (defaultValues.TryGetValue (property, out object defaultValue)) return (T) defaultValue; return default (T); } - bool GetPropertyValue<T> (string property, out T val) + object Get (string property, Type type) + { + return GetPropertyValue (property, out object value, type) ? value : null; + } + + bool GetPropertyValue (string property, out object val, Type type) { if (!properties.TryGetValue (property, out object o)) { - val = default (T); + val = null; return false; } - if (o is T t) { - val = t; + if (o == null) { + val = null; return true; } - if (o == null) { - val = default (T); + if (type.IsInstanceOfType (o)) { + val = o; return true; } if (o is LazyXmlDeserializer ser) { // Deserialize the data and store it in the dictionary, so // following calls return the same object - val = ser.Deserialize<T> (); + val = ser.Deserialize (type); properties = properties.SetItem (property, val); return true; } - val = Convert<T> (o); + val = Convert (o, type); properties = properties.SetItem (property, val); return true; } @@ -151,7 +164,7 @@ namespace MonoDevelop.Core public void Set (string key, object val) { - object old = Get<object> (key); + object old = Get (key, val?.GetType () ?? typeof(object)); if (val == null) { //avoid emitting the event if not necessary if (old == null) @@ -306,23 +319,23 @@ namespace MonoDevelop.Core this.xml = xml; } - public T Deserialize<T> () + public object Deserialize (Type type) { try { - if (typeof(ICustomXmlSerializer).IsAssignableFrom (typeof(T))) { + if (typeof(ICustomXmlSerializer).IsAssignableFrom (type)) { using (XmlReader reader = new XmlTextReader (new MemoryStream (System.Text.Encoding.UTF8.GetBytes ("<" + Properties.SerializedNode + ">" + xml + "</" + Properties.SerializedNode + ">" )))) { - return (T)((ICustomXmlSerializer)typeof(T).Assembly.CreateInstance (typeof(T).FullName)).ReadFrom (reader); + return ((ICustomXmlSerializer)type.Assembly.CreateInstance (type.FullName)).ReadFrom (reader); } } - XmlSerializer serializer = new XmlSerializer (typeof(T)); + XmlSerializer serializer = new XmlSerializer (type); using (StreamReader sr = new StreamReader (new MemoryStream (System.Text.Encoding.UTF8.GetBytes (xml)))) { - return (T)serializer.Deserialize (sr); + return serializer.Deserialize (sr); } - + } catch (Exception e) { - LoggingService.LogWarning ("Caught exception while deserializing:" + typeof(T), e); - return default(T); + LoggingService.LogWarning ("Caught exception while deserializing:" + type, e); + return null; } } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs index 2f49ea6baf..f79ec93bc2 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs @@ -108,6 +108,7 @@ namespace MonoDevelop.Core AddinManager.AddinLoadError += OnLoadError; AddinManager.AddinLoaded += OnLoad; AddinManager.AddinUnloaded += OnUnload; + AddinManager.AddinAssembliesLoaded += OnAssembliesLoaded; try { Counters.RuntimeInitialization.Trace ("Initializing Addin Manager"); @@ -211,16 +212,29 @@ namespace MonoDevelop.Core string msg = "Add-in error (" + args.AddinId + "): " + args.Message; LoggingService.LogError (msg, args.Exception); } - + static void OnLoad (object s, AddinEventArgs args) { - Counters.AddinsLoaded.Inc ("Add-in loaded: " + args.AddinId, new Dictionary<string,string> { { "AddinId", args.AddinId } }); + Counters.AddinsLoaded.Inc ("Add-in loaded: " + args.AddinId, new Dictionary<string, string> { + { "AddinId", args.AddinId }, + { "LoadTrace", Environment.StackTrace }, + }); +#if DEBUG + LoggingService.LogDebug ("Add-in loaded: {0}: {1}", args.AddinId, Environment.StackTrace); +#endif } static void OnUnload (object s, AddinEventArgs args) { Counters.AddinsLoaded.Dec ("Add-in unloaded: " + args.AddinId); } + + static void OnAssembliesLoaded (object s, AddinEventArgs args) + { +#if DEBUG + LoggingService.LogDebug ("Add-in assemblies loaded: {0}: {1}", args.AddinId, Environment.StackTrace); +#endif + } public static bool Initialized { get { return initialized; } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.FSW/PathTree.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.FSW/PathTree.cs new file mode 100644 index 0000000000..e25b4d212d --- /dev/null +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.FSW/PathTree.cs @@ -0,0 +1,252 @@ +// +// PathTree.cs +// +// Author: +// Marius Ungureanu <maungu@microsoft.com> +// +// Copyright (c) 2018 Microsoft Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System.Collections.Generic; +using System.IO; +using MonoDevelop.Core; + +namespace MonoDevelop.FSW +{ + class PathTree + { + internal readonly PathTreeNode rootNode; + + public PathTree () + { + rootNode = new PathTreeNode ("", 0, 1); + if (!Platform.IsWindows) { + rootNode.FirstChild = new PathTreeNode ("/", 0, 0) { + Parent = rootNode, + }; + rootNode.ChildrenCount = 1; + } + } + + public PathTreeNode FindNode (string path) + { + TryFind(path, out var result, out _, out _, out _); + return result; + } + + public IEnumerable<PathTreeNode> Normalize (int maxLeafs) + { + // We want to use an algorithm similar to BFS by using the following logic: + // If the node is live, we can return it + // Otherwise, we keep looking for live nodes in a node's children. + // If the amount of children a node has exceeds the maximum amount of leaves + // we want, we just return the node itself, even if it's not live. + + var queue = new Queue<PathTreeNode>(maxLeafs); + + int yielded = 0; + var child = rootNode.FirstChild; + while (child != null) + { + if (child.IsLive) + { + yielded++; + yield return child; + } else + queue.Enqueue(child); + + child = child.Next; + } + if (queue.Count == 0) + yield break; + + while (yielded <= maxLeafs && queue.Count != 0) + { + var node = queue.Dequeue(); + + if (node.ChildrenCount + yielded - 1 < maxLeafs) + { + child = node.FirstChild; + while (child != null) + { + if (child.IsLive) + { + yielded++; + yield return child; + } + else + queue.Enqueue(child); + child = child.Next; + } + } + else + { + yielded++; + yield return node; + } + } + } + + bool TryFind (string path, out PathTreeNode result, out PathTreeNode parent, out PathTreeNode previousNode, out int lastIndex) + { + lastIndex = 0; + + parent = rootNode; + var currentNode = parent.FirstChild; + previousNode = null; + + while (currentNode != null) + { + int currentIndex = path.IndexOf(Path.DirectorySeparatorChar, lastIndex); + int comparisonResult = string.Compare(currentNode.FullPath, currentNode.Start, path, lastIndex, currentNode.Length); + + // We need to insert in this node's position. + if (comparisonResult > 0) + break; + + // Keep searching. + if (comparisonResult < 0) + { + previousNode = currentNode; + currentNode = currentNode.Next; + continue; + } + + // We found this segment in the tree. + lastIndex = currentIndex + 1; + + // We found the node already, register the ID. + if (currentIndex == -1 || lastIndex == path.Length) + { + result = currentNode; + return true; + } + + // We go to the first child of this segment and repeat the algorithm. + parent = currentNode; + previousNode = null; + currentNode = parent.FirstChild; + } + + result = null; + return false; + } + + public PathTreeNode AddNode (string path, object id) + { + if (TryFind(path, out var result, out var parent, out var previousNode, out var lastIndex)) + { + result.RegisterId(id); + return result; + } + + // At this point, we need to create a new node. + var (first, leaf) = PathTreeNode.CreateSubTree(path, lastIndex); + if (id != null) + leaf.RegisterId(id); + + InsertNode(first, parent, previousNode); + + return leaf; + } + + public PathTreeNode RemoveNode(string path, object id) + { + if (!TryFind (path, out PathTreeNode result, out var parent, out var previousNode, out _)) + return null; + + if (result.UnregisterId(id) && !result.IsLive) + { + var nodeToRemove = result; + var lastToRemove = Platform.IsWindows ? rootNode : rootNode.FirstChild; + + while (nodeToRemove != lastToRemove && IsDeadSubtree (nodeToRemove)) { + parent.ChildrenCount -= 1; + + if (parent.FirstChild == nodeToRemove) + parent.FirstChild = nodeToRemove.Next; + + if (nodeToRemove.Previous != null) + nodeToRemove.Previous.Next = nodeToRemove.Next; + + if (nodeToRemove.Next != null) + nodeToRemove.Next.Previous = nodeToRemove.Previous; + + nodeToRemove.Next = null; + nodeToRemove.Previous = null; + nodeToRemove.Parent = null; + + nodeToRemove = parent; + parent = nodeToRemove.Parent; + } + } + + return result; + } + + bool IsDeadSubtree (PathTreeNode node) + { + // We do a DFS here, looking for any live node in a tree. + // We know that leaves are live, so DFS works better here. + var stack = new Stack<PathTreeNode> (); + stack.Push (node); + + while (stack.Count != 0) { + node = stack.Pop (); + if (node.IsLive) + return false; + + var child = node.FirstChild; + + while (child != null) { + stack.Push (child); + child = child.Next; + } + } + return true; + } + + void InsertNode(PathTreeNode node, PathTreeNode parentNode, PathTreeNode previousNode) + { + parentNode.ChildrenCount += 1; + + node.Parent = parentNode; + if (previousNode == null) + { + // We're inserting at the beginning. + var insertBefore = parentNode.FirstChild; + + node.Next = insertBefore; + if (insertBefore != null) + insertBefore.Previous = node; + parentNode.FirstChild = node; + return; + } + + // We are appending inbetween other nodes + var next = previousNode.Next; + previousNode.Next = node; + node.Previous = previousNode; + + node.Next = next; + if (next != null) + next.Previous = node; + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.FSW/PathTreeNode.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.FSW/PathTreeNode.cs new file mode 100644 index 0000000000..849438d258 --- /dev/null +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.FSW/PathTreeNode.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace MonoDevelop.FSW +{ + sealed class PathTreeNode + { + public PathTreeNode Parent { get; set; } + public PathTreeNode FirstChild { get; set; } + public PathTreeNode Previous { get; set; } + public PathTreeNode Next { get; set; } + public int ChildrenCount { get; set; } + + readonly List<object> ids = new List<object> (); + internal void RegisterId (object id) => ids.Add (id); + internal bool UnregisterId (object id) => ids.Remove (id); + public bool IsLive => ids.Count != 0; + + public string FullPath { get; } + public int Start { get; } + public int Length { get; } + + internal PathTreeNode LastChild { + get { + var child = FirstChild; + while (child != null && child.Next != null) + child = child.Next; + return child; + } + } + internal string Segment => FullPath.Substring (Start, Length); + + public PathTreeNode (string fullPath, int start, int length) + { + FullPath = fullPath; + Start = start; + Length = length; + } + + internal static (PathTreeNode root, PathTreeNode leaf) CreateSubTree (string path, int start) + { + PathTreeNode lastNode = null, rootNode = null; + + while (start < path.Length) { + var nextSep = path.IndexOf (Path.DirectorySeparatorChar, start); + int length = nextSep == -1 ? path.Length - start : nextSep - start; + + if (length != 0) { + var node = new PathTreeNode (path, start, length); + + if (lastNode != null) { + lastNode.FirstChild = node; + node.Parent = lastNode; + lastNode.ChildrenCount = 1; + } else + rootNode = node; + + lastNode = node; + } + + start = start + length + 1; + } + + return (rootNode, lastNode); + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MD1/MD1DotNetProjectHandler.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MD1/MD1DotNetProjectHandler.cs index e161ecd200..37b4f266bd 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MD1/MD1DotNetProjectHandler.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MD1/MD1DotNetProjectHandler.cs @@ -26,19 +26,19 @@ // using System; -using System.IO; -using System.Diagnostics; -using System.Collections.Generic; using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; using System.Text.RegularExpressions; +using System.Threading.Tasks; using MonoDevelop.Core; using MonoDevelop.Core.Execution; -using MonoDevelop.Projects.Extensions; -using System.Threading.Tasks; using MonoDevelop.Projects.MSBuild.Conditions; - + namespace MonoDevelop.Projects.MD1 { + [Obsolete] class MD1DotNetProjectHandler { DotNetProject project; @@ -47,7 +47,7 @@ namespace MonoDevelop.Projects.MD1 { project = entry; } - + public async Task<BuildResult> RunTarget (ProgressMonitor monitor, string target, ConfigurationSelector configuration) { switch (target) @@ -171,7 +171,7 @@ namespace MonoDevelop.Projects.MD1 internal static Task<BuildResult> Compile (ProgressMonitor monitor, DotNetProject project, BuildData buildData) { - return Task<BuildResult>.Run (delegate { + return Task.Run (delegate { ProjectItemCollection items = buildData.Items; BuildResult br = BuildResources (buildData.Configuration, ref items, monitor); if (br != null) @@ -330,7 +330,7 @@ namespace MonoDevelop.Projects.MD1 public static bool IsResgenRequired (string resx_filename, string output_filename) { if (String.Compare (Path.GetExtension (resx_filename), ".resx", true) != 0) - throw new ArgumentException (".resx file expected", "resx_filename"); + throw new ArgumentException (".resx file expected", nameof (resx_filename)); if (File.Exists (output_filename)) return IsFileNewerThan (resx_filename, output_filename); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildFileFormatException.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildFileFormatException.cs index 4881170d82..c6fa08af3f 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildFileFormatException.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildFileFormatException.cs @@ -31,6 +31,10 @@ namespace MonoDevelop.Projects.MSBuild public MSBuildFileFormatException (string message): base (message) { } + + public MSBuildFileFormatException (string message, Exception innerException): base (message, innerException) + { + } } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs index b4c419824e..9d0b6b4375 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProject.cs @@ -232,7 +232,8 @@ namespace MonoDevelop.Projects.MSBuild string xml = File.ReadAllText (file); LoadXml (xml, reader); - + } catch (Exception ex) { + throw new MSBuildFileFormatException (ex.Message + " " + file, ex); } finally { EnableChangeTracking (); } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs index d8efcdfd7f..9852af27b9 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs @@ -607,11 +607,11 @@ namespace MonoDevelop.Projects } } + [Obsolete] internal protected override void PopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration) { base.PopulateOutputFileList (list, configuration); - DotNetProjectConfiguration conf = GetConfiguration (configuration) as DotNetProjectConfiguration; - if (conf == null) + if (!(GetConfiguration (configuration) is DotNetProjectConfiguration conf)) return; // Debug info file @@ -645,6 +645,7 @@ namespace MonoDevelop.Projects [ThreadStatic] static HashSet<DotNetProject> processedProjects; + [Obsolete] internal protected override void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration) { try { @@ -660,6 +661,7 @@ namespace MonoDevelop.Projects } } + [Obsolete] void PopulateSupportFileListInternal (FileCopySet list, ConfigurationSelector configuration) { if (supportReferDistance <= 2) @@ -1192,12 +1194,14 @@ namespace MonoDevelop.Projects return project?.FileName; } + [Obsolete] protected override Task<BuildResult> DoBuild (ProgressMonitor monitor, ConfigurationSelector configuration) { var handler = new MD1DotNetProjectHandler (this); return handler.RunTarget (monitor, "Build", configuration); } + [Obsolete] protected override Task<BuildResult> DoClean (ProgressMonitor monitor, ConfigurationSelector configuration) { var handler = new MD1DotNetProjectHandler (this); @@ -1294,8 +1298,14 @@ namespace MonoDevelop.Projects var config = (DotNetProjectConfiguration) GetConfiguration (configuration); return Files.Any (file => file.BuildAction == BuildAction.EmbeddedResource - && String.Compare (Path.GetExtension (file.FilePath), ".resx", StringComparison.OrdinalIgnoreCase) == 0 - && MD1DotNetProjectHandler.IsResgenRequired (file.FilePath, config.IntermediateOutputDirectory.Combine (file.ResourceId))); + && file.FilePath.HasExtension (".resx") + && IsResourceUpToDate (file.FilePath, config.IntermediateOutputDirectory.Combine (file.ResourceId))); + + bool IsResourceUpToDate (string resxFile, string outputResources) + { + var outInfo = new FileInfo (outputResources); + return !outInfo.Exists || new FileInfo (resxFile).LastWriteTime < outInfo.LastWriteTime; + } } protected internal override DateTime OnGetLastBuildTime (ConfigurationSelector configuration) @@ -1506,11 +1516,13 @@ namespace MonoDevelop.Projects return baseFiles; } + [Obsolete ("Use MSBuild")] internal Task<BuildResult> Compile (ProgressMonitor monitor, BuildData buildData) { return ProjectExtension.OnCompile (monitor, buildData); } + [Obsolete ("Use MSBuild")] protected virtual Task<BuildResult> OnCompile (ProgressMonitor monitor, BuildData buildData) { return MD1DotNetProjectHandler.Compile (monitor, this, buildData); @@ -1680,6 +1692,7 @@ namespace MonoDevelop.Projects protected abstract DotNetCompilerParameters OnCreateCompilationParameters (DotNetProjectConfiguration config, ConfigurationKind kind); + [Obsolete] internal protected virtual BuildResult OnCompileSources (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor) { throw new NotSupportedException (); @@ -2088,6 +2101,7 @@ namespace MonoDevelop.Projects Project.OnReferencedAssembliesChanged (); } + [Obsolete] internal protected override Task<BuildResult> OnCompile (ProgressMonitor monitor, BuildData buildData) { return Project.OnCompile (monitor, buildData); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProjectExtension.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProjectExtension.cs index 62106c0508..29350891a0 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProjectExtension.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProjectExtension.cs @@ -25,12 +25,11 @@ // THE SOFTWARE. using System; using System.Collections.Generic; -using MonoDevelop.Core.Assemblies; -using MonoDevelop.Core.Execution; -using MonoDevelop.Core; using System.Threading; using System.Threading.Tasks; -using MonoDevelop.Projects.MSBuild; +using MonoDevelop.Core; +using MonoDevelop.Core.Assemblies; +using MonoDevelop.Core.Execution; namespace MonoDevelop.Projects { @@ -146,6 +145,7 @@ namespace MonoDevelop.Projects return next.OnGetSupportsFramework (framework); } + [Obsolete ("Use MSBuild")] internal protected virtual Task<BuildResult> OnCompile (ProgressMonitor monitor, BuildData buildData) { return next.OnCompile (monitor, buildData); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/FileWatcherService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/FileWatcherService.cs index 15943f11c0..def67f32fa 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/FileWatcherService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/FileWatcherService.cs @@ -26,151 +26,118 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; +using System.Diagnostics; using System.IO;
using System.Linq; using System.Threading; using System.Threading.Tasks; using MonoDevelop.Core; +using MonoDevelop.FSW; namespace MonoDevelop.Projects { public static class FileWatcherService { + // We don't want more than 8 threads for FileSystemWatchers. + const int maxWatchers = 8; + + static readonly PathTree tree = new PathTree (); static readonly Dictionary<FilePath, FileWatcherWrapper> watchers = new Dictionary<FilePath, FileWatcherWrapper> (); - static readonly List<WorkspaceItem> workspaceItems = new List<WorkspaceItem> (); - static readonly Dictionary<object, List<FilePath>> monitoredDirectories = new Dictionary<object, List<FilePath>> (); + static readonly Dictionary<object, HashSet<FilePath>> monitoredDirectories = new Dictionary<object, HashSet<FilePath>> (); static CancellationTokenSource cancellationTokenSource = new CancellationTokenSource (); public static Task Add (WorkspaceItem item) { lock (watchers) { - workspaceItems.Add (item); item.RootDirectoriesChanged += OnRootDirectoriesChanged; - CancelUpdate (); - return UpdateWatchersAsync (); + return WatchDirectories (item, item.GetRootDirectories ()); } } - static void CancelUpdate () - { - cancellationTokenSource.Cancel (); - cancellationTokenSource = new CancellationTokenSource (); - } - public static Task Remove (WorkspaceItem item) { lock (watchers) { - if (workspaceItems.Remove (item)) { - item.RootDirectoriesChanged -= OnRootDirectoriesChanged; - CancelUpdate (); - return UpdateWatchersAsync (); - } + item.RootDirectoriesChanged -= OnRootDirectoriesChanged; + return WatchDirectories (item, null); } - return Task.CompletedTask; } - static void OnRootDirectoriesChanged (object sender, EventArgs e) + static void OnRootDirectoriesChanged (object sender, EventArgs args) { lock (watchers) { - CancelUpdate (); - UpdateWatchersAsync ().Ignore (); + var item = (WorkspaceItem)sender; + WatchDirectories (item, item.GetRootDirectories ()).Ignore (); } } static Task UpdateWatchersAsync () { + cancellationTokenSource.Cancel (); + cancellationTokenSource = new CancellationTokenSource (); CancellationToken token = cancellationTokenSource.Token; - return Task.Run (() => { - UpdateWatchers (workspaceItems, monitoredDirectories, token); - }); + + return Task.Run (() => UpdateWatchers (token)); } - static void UpdateWatchers ( - List<WorkspaceItem> currentWorkspaceItems, - Dictionary<object, List<FilePath>> currentMonitoredDirectories, - CancellationToken token) + static void UpdateWatchers (CancellationToken token) { - List<FileWatcherWrapper> newWatchers = null; - - HashSet<FilePath> watchedDirectories = GetWatchedDirectories (); - if (token.IsCancellationRequested) return; - foreach (FilePath directory in GetRootDirectories (currentWorkspaceItems, currentMonitoredDirectories)) { - if (!watchedDirectories.Remove (directory)) { - if (Directory.Exists (directory)) { - if (newWatchers == null) - newWatchers = new List<FileWatcherWrapper> (); - var watcher = new FileWatcherWrapper (directory); - newWatchers.Add (watcher); - } - } - } - - if (newWatchers == null && !watchedDirectories.Any ()) { - // Unchanged. - return; - } - lock (watchers) { - if (token.IsCancellationRequested) { - if (newWatchers != null) { - foreach (FileWatcherWrapper watcher in newWatchers) { - watcher.Dispose (); - } - } + if (token.IsCancellationRequested) return; - } - // Remove file watchers no longer needed. - foreach (FilePath directory in watchedDirectories) { - Remove (directory); + var newPathsToWatch = tree.Normalize (maxWatchers).Select (node => (FilePath)node.FullPath); + var newWatchers = new HashSet<FilePath> (newPathsToWatch.Where (dir => Directory.Exists (dir))); + if (newWatchers.Count == 0 && watchers.Count == 0) { + // Unchanged. + return; } - if (newWatchers != null) { - foreach (FileWatcherWrapper watcher in newWatchers) { - watchers.Add (watcher.Path, watcher); - watcher.EnableRaisingEvents = true; + List<FilePath> toRemove; + if (newWatchers.Count == 0) + toRemove = watchers.Keys.ToList (); + else { + toRemove = new List<FilePath> (); + foreach (var kvp in watchers) { + var directory = kvp.Key; + if (!newWatchers.Contains (directory)) + toRemove.Add (directory); } } - } - } - static HashSet<FilePath> GetWatchedDirectories () - { - lock (watchers) { - var directories = new HashSet<FilePath> (); - foreach (FilePath directory in watchers.Keys) { - directories.Add (directory); + // After this point, the watcher update is real and a destructive operation, so do not use the token. + if (token.IsCancellationRequested) + return; + + // First remove the watchers, so we don't spin too many threads. + foreach (var directory in toRemove) { + RemoveWatcher_NoLock (directory); } - return directories; - } - } - static IEnumerable<FilePath> GetRootDirectories ( - List<WorkspaceItem> currentWorkspaceItems, - Dictionary<object, List<FilePath>> currentMonitoredDirectories) - { - var directories = new HashSet<FilePath> (); + // Add the new ones. + if (newWatchers.Count == 0) + return; + + foreach (var path in newWatchers) { + // Don't modify a watcher that already exists. + if (watchers.ContainsKey (path)) { + continue; + } - foreach (WorkspaceItem item in currentWorkspaceItems) { - foreach (FilePath directory in item.GetRootDirectories ()) { - directories.Add (directory); + var watcher = new FileWatcherWrapper (path); + watchers.Add (path, watcher); + watcher.EnableRaisingEvents = true; } - } - foreach (var kvp in currentMonitoredDirectories) { - foreach (var directory in kvp.Value) - directories.Add (directory); } - - return Normalize (directories); } - static void Remove (FilePath directory) + static void RemoveWatcher_NoLock (FilePath directory) { + Debug.Assert (Monitor.IsEntered (watchers)); + if (watchers.TryGetValue (directory, out FileWatcherWrapper watcher)) { watcher.EnableRaisingEvents = false; watcher.Dispose (); @@ -178,28 +145,51 @@ namespace MonoDevelop.Projects } } - internal static IEnumerable<FilePath> Normalize (IEnumerable<FilePath> directories) + public static Task WatchDirectories (object id, IEnumerable<FilePath> directories) { - var directorySet = new HashSet<FilePath> (directories); - - return directorySet.Where (d => { - return directorySet.All (other => !d.IsChildPathOf (other)); - }); + lock (watchers) { + if (RegisterDirectoriesInTree_NoLock (id, directories)) + return UpdateWatchersAsync (); + return Task.CompletedTask; + } } - public static Task WatchDirectories (object id, IEnumerable<FilePath> directories) + static bool RegisterDirectoriesInTree_NoLock (object id, IEnumerable<FilePath> directories) { - lock (watchers) { - if (directories == null) - monitoredDirectories.Remove (id); - else {
- directories = directories.Where (directory => !directory.IsNullOrEmpty);
- monitoredDirectories [id] = new List<FilePath> (directories); + Debug.Assert (Monitor.IsEntered (watchers)); + + // Remove paths subscribed for this id. + // TODO: Only modify those which need to be modified, don't register/unregister with no reason. + + bool modified = false; + + if (monitoredDirectories.TryGetValue (id, out var oldDirectories)) { + foreach (var dir in oldDirectories) { + var node = tree.RemoveNode (dir, id); + + bool wasRemoved = node != null && !node.IsLive; + modified |= wasRemoved; } + } - CancelUpdate (); - return UpdateWatchersAsync (); + // Remove the current registered directories + monitoredDirectories.Remove (id); + if (directories == null) + return modified; + + // Apply new ones if we have any + var set = new HashSet<FilePath> (directories.Where(x => !x.IsNullOrEmpty)); + + if (set.Count > 0) { + monitoredDirectories [id] = set; + foreach (var path in set) { + tree.AddNode (path, id); + } + + // If we reached here, we have added at least 1 node, and the tree has changed. + modified = true; } + return modified; } /// <summary> @@ -208,7 +198,6 @@ namespace MonoDevelop.Projects internal static Task Update () { lock (watchers) { - CancelUpdate (); return UpdateWatchersAsync (); } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index a50e937eb3..96ab37d1f0 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -1224,107 +1224,114 @@ namespace MonoDevelop.Projects async Task<TargetEvaluationResult> RunMSBuildTarget (ProgressMonitor monitor, string target, ConfigurationSelector configuration, TargetEvaluationContext context) { - if (MSBuildProject.UseMSBuildEngine) { - var includeReferencedProjects = context != null ? context.LoadReferencedProjects : false; - var configs = GetConfigurations (configuration, includeReferencedProjects); - - string [] evaluateItems = context != null ? context.ItemsToEvaluate.ToArray () : new string [0]; - string [] evaluateProperties = context != null ? context.PropertiesToEvaluate.ToArray () : new string [0]; - - var globalProperties = CreateGlobalProperties (); - if (context != null) { - var md = (ProjectItemMetadata)context.GlobalProperties; - md.SetProject (sourceProject); - foreach (var p in md.GetProperties ()) - globalProperties [p.Name] = p.Value; - } - - MSBuildResult result = null; - await Task.Run (async delegate { - - bool operationRequiresExclusiveLock = context.BuilderQueue == BuilderQueue.LongOperations; - TimerCounter buildTimer = null; - switch (target) { - case "Build": buildTimer = Counters.BuildMSBuildProjectTimer; break; - case "Clean": buildTimer = Counters.CleanMSBuildProjectTimer; break; - } + if (!MSBuildProject.UseMSBuildEngine) { + #pragma warning disable CS0612 // obsolete + return await DeprecatedRunMSBuildTarget (monitor, target, configuration); + #pragma warning restore CS0612 + } - var metadata = GetProjectEventMetadata (configuration); - var t1 = Counters.RunMSBuildTargetTimer.BeginTiming (metadata); - var t2 = buildTimer != null ? buildTimer.BeginTiming (metadata) : null; + var includeReferencedProjects = context?.LoadReferencedProjects ?? false; + var configs = GetConfigurations (configuration, includeReferencedProjects); - IRemoteProjectBuilder builder = await GetProjectBuilder (monitor.CancellationToken, context, setBusy:operationRequiresExclusiveLock).ConfigureAwait (false); + string [] evaluateItems = context != null ? context.ItemsToEvaluate.ToArray () : new string [0]; + string [] evaluateProperties = context != null ? context.PropertiesToEvaluate.ToArray () : new string [0]; - string [] targets; - if (target.IndexOf (';') != -1) - targets = target.Split (new [] { ';' }, StringSplitOptions.RemoveEmptyEntries); - else - targets = new string [] { target }; + var globalProperties = CreateGlobalProperties (); + if (context != null) { + var md = (ProjectItemMetadata)context.GlobalProperties; + md.SetProject (sourceProject); + foreach (var p in md.GetProperties ()) + globalProperties [p.Name] = p.Value; + } - var logger = context.Loggers.Count != 1 ? new ProxyLogger (this, context.Loggers) : context.Loggers.First (); - - try { - result = await builder.Run (configs, monitor.Log, logger, context.LogVerbosity, targets, evaluateItems, evaluateProperties, globalProperties, monitor.CancellationToken).ConfigureAwait (false); - } finally { - builder.Dispose (); - t1.End (); - if (t2 != null) { - AddRunMSBuildTargetTimerMetadata (metadata, result, target, configuration); - t2.End (); - if (IsFirstBuild && target == "Build") { - await Runtime.RunInMainThread (() => IsFirstBuild = false); - } - } - } - }); + MSBuildResult result = null; + await Task.Run (async delegate { - var br = new BuildResult (); - foreach (var err in result.Errors) { - FilePath file = null; - if (err.File != null) - file = Path.Combine (Path.GetDirectoryName (err.ProjectFile ?? ItemDirectory.ToString ()), err.File); - - br.Append (new BuildError (file, err.LineNumber, err.ColumnNumber, err.Code, err.Message) { - Subcategory = err.Subcategory, - EndLine = err.EndLineNumber, - EndColumn = err.EndColumnNumber, - IsWarning = err.IsWarning, - HelpKeyword = err.HelpKeyword, - }); + bool operationRequiresExclusiveLock = context.BuilderQueue == BuilderQueue.LongOperations; + TimerCounter buildTimer = null; + switch (target) { + case "Build": buildTimer = Counters.BuildMSBuildProjectTimer; break; + case "Clean": buildTimer = Counters.CleanMSBuildProjectTimer; break; } - // Get the evaluated properties + var metadata = GetProjectEventMetadata (configuration); + var t1 = Counters.RunMSBuildTargetTimer.BeginTiming (metadata); + var t2 = buildTimer?.BeginTiming (metadata); - var properties = new Dictionary<string, IMSBuildPropertyEvaluated> (); - foreach (var p in result.Properties) - properties [p.Key] = new MSBuildPropertyEvaluated (sourceProject, p.Key, p.Value, p.Value); + IRemoteProjectBuilder builder = await GetProjectBuilder (monitor.CancellationToken, context, setBusy: operationRequiresExclusiveLock).ConfigureAwait (false); - var props = new MSBuildPropertyGroupEvaluated (sourceProject); - props.SetProperties (properties); + string [] targets; + if (target.IndexOf (';') != -1) + targets = target.Split (new [] { ';' }, StringSplitOptions.RemoveEmptyEntries); + else + targets = new string [] { target }; - // Get the evaluated items + var logger = context.Loggers.Count != 1 ? new ProxyLogger (this, context.Loggers) : context.Loggers.First (); - var evItems = new List<IMSBuildItemEvaluated> (); - foreach (var it in result.Items.SelectMany (d => d.Value)) { - var eit = new MSBuildItemEvaluated (sourceProject, it.Name, it.ItemSpec, it.ItemSpec); - if (it.Metadata.Count > 0) { - var imd = (MSBuildPropertyGroupEvaluated)eit.Metadata; - properties = new Dictionary<string, IMSBuildPropertyEvaluated> (); - foreach (var m in it.Metadata) - properties [m.Key] = new MSBuildPropertyEvaluated (sourceProject, m.Key, m.Value, m.Value); - imd.SetProperties (properties); + try { + result = await builder.Run (configs, monitor.Log, logger, context.LogVerbosity, targets, evaluateItems, evaluateProperties, globalProperties, monitor.CancellationToken).ConfigureAwait (false); + } finally { + builder.Dispose (); + t1.End (); + if (t2 != null) { + AddRunMSBuildTargetTimerMetadata (metadata, result, target, configuration); + t2.End (); + if (IsFirstBuild && target == "Build") { + await Runtime.RunInMainThread (() => IsFirstBuild = false); + } } - evItems.Add (eit); } + }); - return new TargetEvaluationResult (br, evItems, props); + var br = new BuildResult (); + foreach (var err in result.Errors) { + FilePath file = null; + if (err.File != null) + file = Path.Combine (Path.GetDirectoryName (err.ProjectFile ?? ItemDirectory.ToString ()), err.File); + + br.Append (new BuildError (file, err.LineNumber, err.ColumnNumber, err.Code, err.Message) { + Subcategory = err.Subcategory, + EndLine = err.EndLineNumber, + EndColumn = err.EndColumnNumber, + IsWarning = err.IsWarning, + HelpKeyword = err.HelpKeyword, + }); } - else { - RemoteBuildEngineManager.UnloadProject (FileName).Ignore (); - if (this is DotNetProject) { - var handler = new MonoDevelop.Projects.MD1.MD1DotNetProjectHandler ((DotNetProject)this); - return new TargetEvaluationResult (await handler.RunTarget (monitor, target, configuration)); + + // Get the evaluated properties + + var properties = new Dictionary<string, IMSBuildPropertyEvaluated> (); + foreach (var p in result.Properties) + properties [p.Key] = new MSBuildPropertyEvaluated (sourceProject, p.Key, p.Value, p.Value); + + var props = new MSBuildPropertyGroupEvaluated (sourceProject); + props.SetProperties (properties); + + // Get the evaluated items + + var evItems = new List<IMSBuildItemEvaluated> (); + foreach (var it in result.Items.SelectMany (d => d.Value)) { + var eit = new MSBuildItemEvaluated (sourceProject, it.Name, it.ItemSpec, it.ItemSpec); + if (it.Metadata.Count > 0) { + var imd = (MSBuildPropertyGroupEvaluated)eit.Metadata; + properties = new Dictionary<string, IMSBuildPropertyEvaluated> (); + foreach (var m in it.Metadata) + properties [m.Key] = new MSBuildPropertyEvaluated (sourceProject, m.Key, m.Value, m.Value); + imd.SetProperties (properties); } + evItems.Add (eit); + } + + return new TargetEvaluationResult (br, evItems, props); + } + + [Obsolete] + async Task<TargetEvaluationResult> DeprecatedRunMSBuildTarget (ProgressMonitor monitor, string target, ConfigurationSelector configuration) + { + RemoteBuildEngineManager.UnloadProject (FileName).Ignore (); + if (this is DotNetProject dnp) { + var handler = new MD1.MD1DotNetProjectHandler (dnp); + return new TargetEvaluationResult (await handler.RunTarget (monitor, target, configuration)); } return null; } @@ -1729,28 +1736,34 @@ namespace MonoDevelop.Projects async Task<TargetEvaluationResult> RunBuildTarget (ProgressMonitor monitor, ConfigurationSelector configuration, TargetEvaluationContext context) { - // create output directory, if not exists - ProjectConfiguration conf = GetConfiguration (configuration) as ProjectConfiguration; - if (conf == null) { - BuildResult cres = new BuildResult (); + if (!(GetConfiguration (configuration) is ProjectConfiguration conf)) { + var cres = new BuildResult (); cres.AddError (GettextCatalog.GetString ("Configuration '{0}' not found in project '{1}'", configuration.ToString (), Name)); return new TargetEvaluationResult (cres); } - + StringParserService.Properties["Project"] = Name; - - if (MSBuildProject.UseMSBuildEngine) { - // Build is always a long operation. Make sure we build the project in the right builder. - context.BuilderQueue = BuilderQueue.LongOperations; - var result = await RunMSBuildTarget (monitor, "Build", configuration, context); - if (!result.BuildResult.Failed) - SetFastBuildCheckClean (configuration, context); - return result; + + if (!MSBuildProject.UseMSBuildEngine) { + #pragma warning disable CS0612 // obsolete + return await RunDeprecatedBuildTarget (monitor, configuration, conf); + #pragma warning restore CS0612 } - + + // Build is always a long operation. Make sure we build the project in the right builder. + context.BuilderQueue = BuilderQueue.LongOperations; + var result = await RunMSBuildTarget (monitor, "Build", configuration, context); + if (!result.BuildResult.Failed) + SetFastBuildCheckClean (configuration, context); + return result; + } + + [Obsolete] + async Task<TargetEvaluationResult> RunDeprecatedBuildTarget (ProgressMonitor monitor, ConfigurationSelector configuration, ProjectConfiguration conf) + { string outputDir = conf.OutputDirectory; try { - DirectoryInfo directoryInfo = new DirectoryInfo (outputDir); + var directoryInfo = new DirectoryInfo (outputDir); if (!directoryInfo.Exists) { directoryInfo.Create (); } @@ -1760,9 +1773,9 @@ namespace MonoDevelop.Projects //copy references and files marked to "CopyToOutputDirectory" CopySupportFiles (monitor, configuration); - + monitor.Log.WriteLine (GettextCatalog.GetString ("Performing main compilation…")); - + BuildResult res = await DoBuild (monitor, configuration); if (res != null) { @@ -1885,6 +1898,7 @@ namespace MonoDevelop.Projects /// Copies all support files to the output directory of the given configuration. Support files /// include: assembly references with the Local Copy flag, data files with the Copy to Output option, etc. /// </remarks> + [Obsolete ("Use MSBuild")] public void CopySupportFiles (ProgressMonitor monitor, ConfigurationSelector configuration) { ProjectConfiguration config = (ProjectConfiguration) GetConfiguration (configuration); @@ -1936,6 +1950,7 @@ namespace MonoDevelop.Projects /// Deletes all support files from the output directory of the given configuration. Support files /// include: assembly references with the Local Copy flag, data files with the Copy to Output option, etc. /// </remarks> + [Obsolete ("Use MSBuild")] public async Task DeleteSupportFiles (ProgressMonitor monitor, ConfigurationSelector configuration) { ProjectConfiguration config = (ProjectConfiguration) GetConfiguration (configuration); @@ -1968,6 +1983,7 @@ namespace MonoDevelop.Projects /// Returns a list of all files that are required to use the project output binary, for example: data files with /// the Copy to Output option, debug information files, generated resource files, etc. /// </remarks> + [Obsolete ("Use MSBuild")] public FileCopySet GetSupportFileList (ConfigurationSelector configuration) { var list = new FileCopySet (); @@ -1988,6 +2004,7 @@ namespace MonoDevelop.Projects /// Returns a list of all files that are required to use the project output binary, for example: data files with /// the Copy to Output option, debug information files, generated resource files, etc. /// </remarks> + [Obsolete("Use MSBuild")] internal protected virtual void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration) { ProjectExtension.OnPopulateSupportFileList (list, configuration); @@ -2014,12 +2031,13 @@ namespace MonoDevelop.Projects /// Returns a list of all files that are generated when this project is built, including: the generated binary, /// debug information files, satellite assemblies. /// </remarks> + [Obsolete ("Use MSBuild")] public List<FilePath> GetOutputFiles (ConfigurationSelector configuration) { if (configuration == null) { throw new ArgumentNullException ("configuration"); } - List<FilePath> list = new List<FilePath> (); + var list = new List<FilePath> (); PopulateOutputFileList (list, configuration); return list; } @@ -2037,10 +2055,12 @@ namespace MonoDevelop.Projects /// Returns a list of all files that are required to use the project output binary, for example: data files with /// the Copy to Output option, debug information files, generated resource files, etc. /// </remarks> + [Obsolete("Use MSBuild")] internal protected virtual void PopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration) { ProjectExtension.OnPopulateOutputFileList (list, configuration); } + [Obsolete] void DoPopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration) { string file = GetOutputFileName (configuration); @@ -2087,31 +2107,39 @@ namespace MonoDevelop.Projects /// This method is invoked to build the project. Support files such as files with the Copy to Output flag will /// be copied before calling this method. /// </remarks> + [Obsolete("Use MSBuild")] protected virtual Task<BuildResult> DoBuild (ProgressMonitor monitor, ConfigurationSelector configuration) { return Task.FromResult (BuildResult.CreateSuccess ()); } - protected override async Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) + protected override async Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext buildSession) { - var newContext = operationContext as TargetEvaluationContext ?? new TargetEvaluationContext (operationContext); + var newContext = buildSession as TargetEvaluationContext ?? new TargetEvaluationContext (buildSession); return (await RunTarget (monitor, "Clean", configuration, newContext)).BuildResult; } - async Task<TargetEvaluationResult> RunCleanTarget (ProgressMonitor monitor, ConfigurationSelector configuration, TargetEvaluationContext context) + Task<TargetEvaluationResult> RunCleanTarget (ProgressMonitor monitor, ConfigurationSelector configuration, TargetEvaluationContext context) { - ProjectConfiguration config = GetConfiguration (configuration) as ProjectConfiguration; - if (config == null) { + if (!(GetConfiguration (configuration) is ProjectConfiguration config)) { monitor.ReportError (GettextCatalog.GetString ("Configuration '{0}' not found in project '{1}'", configuration, Name), null); - return new TargetEvaluationResult (BuildResult.CreateSuccess ()); + return Task.FromResult (new TargetEvaluationResult (BuildResult.CreateSuccess ())); } - - if (MSBuildProject.UseMSBuildEngine) { - // Clean is considered a long operation. Make sure we build the project in the right builder. - context.BuilderQueue = BuilderQueue.LongOperations; - return await RunMSBuildTarget (monitor, "Clean", configuration, context); + + if (!MSBuildProject.UseMSBuildEngine) { + #pragma warning disable CS0612 // obsolete + return RunDeprecatedCleanTarget (monitor, configuration, config); + #pragma warning restore CS0612 } - + + // Clean is considered a long operation. Make sure we build the project in the right builder. + context.BuilderQueue = BuilderQueue.LongOperations; + return RunMSBuildTarget (monitor, "Clean", configuration, context); + } + + [Obsolete] + async Task<TargetEvaluationResult> RunDeprecatedCleanTarget (ProgressMonitor monitor, ConfigurationSelector configuration, ProjectConfiguration config) + { monitor.Log.WriteLine ("Removing output files..."); var filesToDelete = GetOutputFiles (configuration).ToArray (); @@ -2134,6 +2162,7 @@ namespace MonoDevelop.Projects return new TargetEvaluationResult (res); } + [Obsolete("Use MSBuild")] protected virtual Task<BuildResult> DoClean (ProgressMonitor monitor, ConfigurationSelector configuration) { return Task.FromResult (BuildResult.CreateSuccess ()); @@ -4506,11 +4535,13 @@ namespace MonoDevelop.Projects return Project.OnCreateProjectItem (item); } + [Obsolete] internal protected override void OnPopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration) { Project.DoPopulateSupportFileList (list, configuration); } + [Obsolete] internal protected override void OnPopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration) { Project.DoPopulateOutputFileList (list, configuration); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs index afcb6f622f..0b755c6ce3 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs @@ -217,11 +217,13 @@ namespace MonoDevelop.Projects return next.OnCreateProjectItem (item); } + [Obsolete ("Use MSBuild")] internal protected virtual void OnPopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration) { next.OnPopulateSupportFileList (list, configuration); } + [Obsolete ("Use MSBuild")] internal protected virtual void OnPopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration) { next.OnPopulateOutputFileList (list, configuration); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs index cb17ac467e..1e4a7ebbb2 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs @@ -199,7 +199,7 @@ namespace MonoDevelop.Projects /// <summary> /// Returns the root directories associated that should be watched by the file watcher. /// </summary> - internal IEnumerable<FilePath> GetRootDirectories () + internal HashSet<FilePath> GetRootDirectories () { if (rootDirectories != null) return rootDirectories; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs index bf3fa70a7f..0f9aea5c68 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs @@ -70,7 +70,7 @@ namespace MonoDevelop.Components.Commands Hashtable handlerInfo = new Hashtable (); List<ICommandBar> toolbars = new List<ICommandBar> (); CommandTargetChain globalHandlerChain; - ArrayList commandUpdateErrors = new ArrayList (); + List<object> commandUpdateErrors = new List<object> (); List<ICommandTargetVisitor> visitors = new List<ICommandTargetVisitor> (); LinkedList<Gtk.Window> topLevelWindows = new LinkedList<Gtk.Window> (); Stack delegatorStack = new Stack (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenuItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenuItem.cs index c3fffe75cc..896dc4d573 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenuItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenuItem.cs @@ -28,6 +28,7 @@ using System; using System.Collections; +using System.Collections.Generic; using MonoDevelop.Core; namespace MonoDevelop.Components.Commands @@ -39,7 +40,7 @@ namespace MonoDevelop.Components.Commands bool isArray; bool isArrayItem; object arrayDataItem; - ArrayList itemArray; + List<Gtk.MenuItem> itemArray; IconId lastIcon; string overrideLabel; bool wasButtonActivation; @@ -170,7 +171,7 @@ namespace MonoDevelop.Components.Commands menu.Remove (item); } - itemArray = new ArrayList (); + itemArray = new List<Gtk.MenuItem> (); int i = Array.IndexOf (menu.Children, this); if (cmdInfo.ArrayInfo != null) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs index 721faff88e..bcfecd1ebe 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs @@ -643,11 +643,20 @@ namespace MonoDevelop.Components.MainToolbar if (popup == null) return; + popup.IgnoreRepositionWindow = false; + + var anchor = ToolbarView.PopupAnchor; if (IdeApp.Workbench.RootWindow.Visible) - popup.ShowPopup (ToolbarView.PopupAnchor, PopupPosition.TopRight); + popup.ShowPopup (anchor, PopupPosition.TopRight); + + if (anchor.GdkWindow == null) { + var location = new Xwt.Point (anchor.Allocation.Width - popup.Size.Width, anchor.Allocation.Y); - if (ToolbarView.PopupAnchor.GdkWindow == null) - popup.Location = new Xwt.Point (ToolbarView.PopupAnchor.Allocation.Width - popup.Size.Width, ToolbarView.PopupAnchor.Allocation.Y); + // Need to hard lock the location because Xwt doesn't know that the allocation might be coming from a + // Cocoa control and thus has been changed to take macOS monitor layout into consideration + popup.IgnoreRepositionWindow = true; + popup.Location = location; + } } void DestroyPopup () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Xwt/XwtThemedPopup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Xwt/XwtThemedPopup.cs index 304d50851d..4d2ae9b298 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Xwt/XwtThemedPopup.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Xwt/XwtThemedPopup.cs @@ -129,8 +129,13 @@ namespace MonoDevelop.Components return false; } + internal bool IgnoreRepositionWindow { get; set; } public override void RepositionWindow (Rectangle? newTargetRect = default (Rectangle?)) { + if (IgnoreRepositionWindow) { + return; + } + if (!HasParent) return; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.BuildOutputView/BuildOutputTreeCellView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.BuildOutputView/BuildOutputTreeCellView.cs index b58f9f93e9..3178eea9dd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.BuildOutputView/BuildOutputTreeCellView.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.BuildOutputView/BuildOutputTreeCellView.cs @@ -519,8 +519,16 @@ namespace MonoDevelop.Ide.BuildOutputView status.TaskLinkRenderRectangle.X = lastErrorPanelStartX + 5;
status.TaskLinkRenderRectangle.Y = cellArea.Y + padding;
- var layout = DrawText (ctx, cellArea, status.TaskLinkRenderRectangle.X, text, padding, font: defaultFont, trimming: TextTrimming.Word, underline: true);
+ //TODO: we can do a cache of the text layout and only resize
+ //Our link text layoud needs to be created with real size
+ var layout = CreateTextLayout (cellArea, text, defaultFont, trimming: TextTrimming.WordElipsis, underline: true);
status.TaskLinkRenderRectangle.Size = layout.GetSize ();
+
+ //Now we calculate if fits the content and readjust
+ var maxSize = cellArea.Width + cellArea.X + padding - status.TaskLinkRenderRectangle.X;
+ status.TaskLinkRenderRectangle.Width = layout.Width = maxSize;
+
+ DrawText (ctx, layout, cellArea, status.TaskLinkRenderRectangle.X, padding);
return;
}
return;
@@ -569,32 +577,43 @@ namespace MonoDevelop.Ide.BuildOutputView }
}
- TextLayout DrawText (Context ctx, Xwt.Rectangle cellArea, double x, string text, double padding, Font font, double width = 0, TextTrimming trimming = TextTrimming.WordElipsis, bool underline = false)
+ static TextLayout CreateTextLayout (Xwt.Rectangle cellArea, string text, Font font, TextTrimming trimming = TextTrimming.WordElipsis, bool underline = false, double width = 0)
{
- if (width < 0) {
- throw new Exception ("width cannot be negative");
- }
+ var descriptionTextLayout = new TextLayout { + Font = font, + Text = text, + Trimming = trimming + };
- var descriptionTextLayout = new TextLayout ();
-
- descriptionTextLayout.Font = font;
- descriptionTextLayout.Text = text;
- descriptionTextLayout.Trimming = trimming;
-
if (underline) {
descriptionTextLayout.SetUnderline (0, text.Length);
}
-
+
if (width != 0) {
descriptionTextLayout.Width = width;
}
descriptionTextLayout.Height = cellArea.Height;
- ctx.DrawTextLayout (descriptionTextLayout, x, cellArea.Y + padding);
return descriptionTextLayout;
}
+ static TextLayout DrawText (Context ctx, Xwt.Rectangle cellArea, double x, string text, double padding, Font font, double width = 0, TextTrimming trimming = TextTrimming.WordElipsis, bool underline = false)
+ {
+ if (width < 0) {
+ throw new Exception ("width cannot be negative");
+ }
+
+ var textLayout = CreateTextLayout (cellArea, text, font, trimming, underline);
+ DrawText (ctx, textLayout, cellArea, x, padding);
+ return textLayout;
+ }
+
+ static void DrawText (Context ctx, TextLayout textLayout, Xwt.Rectangle cellArea, double x, double padding)
+ {
+ ctx.DrawTextLayout (textLayout, x, cellArea.Y + padding);
+ }
+
void DrawImage (Context ctx, Xwt.Rectangle cellArea, Image image, double x, int imageSize, bool isSelected, double topPadding = 0)
{
ctx.DrawImage (isSelected ? image.WithStyles ("sel") : image, x, cellArea.Top + (cellArea.Height / 2 - imageSize / 2), imageSize, imageSize);
@@ -673,7 +692,8 @@ namespace MonoDevelop.Ide.BuildOutputView var node = GetValue (BuildOutputNodeField);
var status = GetViewStatus (node);
- if (status.TaskLinkRenderRectangle.Contains (args.Position) || status.ErrorsRectangle.Contains (args.Position) || status.WarningsRectangle.Contains (args.Position)) {
+ var containsClickableElement = status.TaskLinkRenderRectangle.Contains (args.Position) || status.ErrorsRectangle.Contains (args.Position) || status.WarningsRectangle.Contains (args.Position);
+ if (containsClickableElement) {
ParentWidget.Cursor = CursorType.Hand;
} else {
ParentWidget.Cursor = CursorType.Arrow;
@@ -688,10 +708,8 @@ namespace MonoDevelop.Ide.BuildOutputView selectionEnd = pos;
QueueDraw ();
}
- } else {
- if (insideText) {
- ParentWidget.Cursor = CursorType.IBeam;
- }
+ } else if (insideText && !containsClickableElement) {
+ ParentWidget.Cursor = CursorType.IBeam;
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/SolutionPadCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/SolutionPadCodon.cs index 4c1bd3c34a..39747e63aa 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/SolutionPadCodon.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/SolutionPadCodon.cs @@ -31,6 +31,7 @@ using System; using System.Collections; +using System.Collections.Generic; using MonoDevelop.Core; using Mono.Addins; using MonoDevelop.Ide.Gui; @@ -56,8 +57,8 @@ namespace MonoDevelop.Ide.Codons void BuildChildren () { - ArrayList bs = new ArrayList (); - ArrayList ops = new ArrayList (); + List<NodeBuilder> bs = new List<NodeBuilder> (); + List<TreePadOption> ops = new List<TreePadOption> (); foreach (ExtensionNode ob in ChildNodes) { NodeBuilderCodon nbc = ob as NodeBuilderCodon; @@ -69,8 +70,8 @@ namespace MonoDevelop.Ide.Codons } else if (ob is PadContextMenuExtensionNode) contextMenuPath = ((PadContextMenuExtensionNode) ob).MenuPath; } - builders = (NodeBuilder[]) bs.ToArray (typeof(NodeBuilder)); - options = (TreePadOption[]) ops.ToArray (typeof(TreePadOption)); + builders = bs.ToArray (); + options = ops.ToArray (); } protected override PadContent CreatePad () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/WorkbenchContextCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/WorkbenchContextCodon.cs index 6529dec3a1..dc9da0389e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/WorkbenchContextCodon.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/WorkbenchContextCodon.cs @@ -30,7 +30,7 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using Mono.Addins; @@ -44,13 +44,13 @@ namespace MonoDevelop.Ide.Codons public ContextPadCodon[] Pads { get { if (pads == null) { - ArrayList bs = new ArrayList (); + var bs = new List<ContextPadCodon> (); foreach (ExtensionNode ob in ChildNodes) { ContextPadCodon spad = ob as ContextPadCodon; if (spad != null) bs.Add (spad); } - pads = (ContextPadCodon[]) bs.ToArray (typeof(ContextPadCodon)); + pads = bs.ToArray (); } return pads; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs index 7a1eca14b3..18eb5d3f9f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs @@ -220,6 +220,9 @@ namespace MonoDevelop.Ide.Commands info.Text = IdeApp.Workbench.FullScreen ? GettextCatalog.GetString ("Exit Full Screen") : GettextCatalog.GetString ("Enter Full Screen"); + } else if (Platform.IsWindows) { + //this is currently a no-op on Windows as it's broken, so hide it + info.Visible = info.Enabled = false; } else { info.Checked = IdeApp.Workbench.FullScreen; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Composition/CompositionManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Composition/CompositionManager.cs index 4d38bec572..94a5a8ce2e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Composition/CompositionManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Composition/CompositionManager.cs @@ -84,23 +84,27 @@ namespace MonoDevelop.Ide.Composition } return creationTask; - }
-
+ } + /// <summary> /// Returns an instance of type T that is exported by some composition part. The instance is shared (singleton). /// </summary> - public static T GetExportedValue<T> () - { - return Instance.ExportProvider.GetExportedValue<T> (); - }
+ public static T GetExportedValue<T> () => Instance.ExportProvider.GetExportedValue<T> ();
/// <summary>
- /// Returns all instance of type T that are exported by some composition part. The instances are shared (singletons).
+ /// Returns all instances of type T that are exported by some composition part. The instances are shared (singletons).
/// </summary>
- public static IEnumerable<T> GetExportedValues<T> ()
- {
- return Instance.ExportProvider.GetExportedValues<T> ();
- } + public static IEnumerable<T> GetExportedValues<T> () => Instance.ExportProvider.GetExportedValues<T> (); + + /// <summary>
+ /// Returns a lazy holding the instance of type T that is exported by some composition part. The instance is shared (singleton).
+ /// </summary>
+ public static Lazy<T> GetExport<T> () => Instance.ExportProvider.GetExport<T> (); + + /// <summary>
+ /// Returns lazies holding all instances of type T that are exported by some composition part. The instances are shared (singletons).
+ /// </summary>
+ public static IEnumerable<Lazy<T>> GetExports<T> () => Instance.ExportProvider.GetExports<T> (); public RuntimeComposition RuntimeComposition { get; private set; } public IExportProviderFactory ExportProviderFactory { get; private set; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs index df0b23ff61..271081f9ed 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs @@ -175,7 +175,7 @@ namespace MonoDevelop.Ide.Desktop public string GetMimeTypeForRoslynLanguage (string language) { - foreach (MimeTypeNode mt in mimeTypeNodes) { + foreach (MimeTypeNode mt in MimeTypeNodes.All) { if (mt.RoslynName == language) return mt.Id; } @@ -276,29 +276,35 @@ namespace MonoDevelop.Ide.Desktop return null; } - static List<MimeTypeNode> mimeTypeNodes = new List<MimeTypeNode> (); - static PlatformService () + static class MimeTypeNodes { - if (AddinManager.IsInitialized) { - AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Core/MimeTypes", delegate (object sender, ExtensionNodeEventArgs args) { - var newList = new List<MimeTypeNode> (mimeTypeNodes); - var mimeTypeNode = (MimeTypeNode)args.ExtensionNode; - switch (args.Change) { - case ExtensionChange.Add: - // initialize child nodes. - mimeTypeNode.ChildNodes.GetEnumerator (); - newList.Add (mimeTypeNode); - break; - case ExtensionChange.Remove: - newList.Remove (mimeTypeNode); - break; - } - mimeTypeNodes = newList; - }); + public static List<MimeTypeNode> All => mimeTypeNodes; + + static List<MimeTypeNode> mimeTypeNodes = new List<MimeTypeNode> (); + + static MimeTypeNodes () + { + if (AddinManager.IsInitialized) { + AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Core/MimeTypes", delegate (object sender, ExtensionNodeEventArgs args) { + var newList = new List<MimeTypeNode> (mimeTypeNodes); + var mimeTypeNode = (MimeTypeNode)args.ExtensionNode; + switch (args.Change) { + case ExtensionChange.Add: + // initialize child nodes. + mimeTypeNode.ChildNodes.GetEnumerator (); + newList.Add (mimeTypeNode); + break; + case ExtensionChange.Remove: + newList.Remove (mimeTypeNode); + break; + } + mimeTypeNodes = newList; + }); + } } } - static Lazy<IFilePathRegistryService> filePathRegistryService = new Lazy<IFilePathRegistryService> (() => CompositionManager.GetExportedValue<IFilePathRegistryService> ()); + static Lazy<IFilePathRegistryService> filePathRegistryService = CompositionManager.GetExport<IFilePathRegistryService> (); MimeTypeNode FindMimeTypeForFile (string fileName) { try { @@ -316,7 +322,7 @@ namespace MonoDevelop.Ide.Desktop LoggingService.LogError ("IFilePathRegistryService query failed", ex); }
- foreach (MimeTypeNode mt in mimeTypeNodes) { + foreach (MimeTypeNode mt in MimeTypeNodes.All) { if (mt.SupportsFile (fileName)) return mt; } @@ -325,7 +331,7 @@ namespace MonoDevelop.Ide.Desktop MimeTypeNode FindMimeType (string type) { - foreach (MimeTypeNode mt in mimeTypeNodes) { + foreach (MimeTypeNode mt in MimeTypeNodes.All) { if (mt.Id == type) return mt; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs index 766a9c54ff..6cfc9d46f1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs @@ -185,8 +185,10 @@ namespace MonoDevelop.Ide.Editor.Extension var token = src.Token; if (LinksShown) { var lineNumber = Editor.PointToLocation (x, y).Line; + if (lineNumber < 1 || lineNumber > Editor.LineCount) + return; var line = Editor.GetLine (lineNumber); - if (visibleLines.Any (line.Equals)) { + if (line == null || visibleLines.Any (line.Equals)) { return; } visibleLines.Add (line); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/Formats/OldFormat.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/Formats/OldFormat.cs index 5bf159f6bf..53c1211825 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/Formats/OldFormat.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/Formats/OldFormat.cs @@ -76,6 +76,9 @@ namespace MonoDevelop.Ide.Editor.Highlighting var result = new Dictionary<string, string> { { "foreground", style.Foreground.ToPangoString () } }; + if (!style.TransparentBackground) { + result.Add ("background", style.Background.ToPangoString ()); + } if (style.FontStyle != Xwt.Drawing.FontStyle.Normal || style.FontWeight != Xwt.Drawing.FontWeight.Normal) { var fontStyle = StringBuilderCache.Allocate (); @@ -282,6 +285,7 @@ namespace MonoDevelop.Ide.Editor.Highlighting settings.Add (new ThemeSetting ("HTML Comment", new List<string> { "comment.block.html" }, ConvertChunkStyle (colorScheme.HtmlComment))); settings.Add (new ThemeSetting ("HTML Element Name", new List<string> { "entity.name.tag.html" }, ConvertChunkStyle (colorScheme.HtmlElementName))); settings.Add (new ThemeSetting ("HTML Entity", new List<string> { "constant.character.entity.html" }, ConvertChunkStyle (colorScheme.HtmlEntity))); + settings.Add (new ThemeSetting ("HTML Server-Side Script", new List<string> { "source.server.html" }, ConvertChunkStyle (colorScheme.HtmlServerSideScript))); var style = ConvertChunkStyle (colorScheme.PlainText); style ["fontStyle"] = "bold"; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/LanguageBundle.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/LanguageBundle.cs index e54e307ff5..ea54e1f33f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/LanguageBundle.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/LanguageBundle.cs @@ -63,6 +63,8 @@ namespace MonoDevelop.Ide.Editor.Highlighting public string FileName { get; private set; } + internal bool BuiltInBundle { get; set; } + public LanguageBundle (string name, string fileName) { Name = name; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RegexEngine/Regex.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RegexEngine/Regex.cs index 9acfd7bae1..01b09b5233 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RegexEngine/Regex.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RegexEngine/Regex.cs @@ -8,7 +8,8 @@ // expression. using MonoDevelop.Core.Text; -namespace MonoDevelop.Ide.Editor.Highlighting.RegexEngine { +namespace MonoDevelop.Ide.Editor.Highlighting.RegexEngine +{ using System; using System.Threading; @@ -825,31 +826,24 @@ namespace MonoDevelop.Ide.Editor.Highlighting.RegexEngine { return Run(false, -1, input, 0, input.Length, startat, internalMatchTimeout); } - /* + /* * Finds the first match, restricting the search to the specified interval of * the char array. */ - /// <devdoc> - /// <para> - /// Matches a - /// regular expression with a string and returns the precise result as a - /// RegexMatch object. - /// </para> - /// </devdoc> - public Match Match (string input, int beginning, int length) - { - if (input == null) - throw new ArgumentNullException ("input"); - - return Run (false, -1, input, beginning, length, UseOptionR () ? beginning + length : beginning, internalMatchTimeout); - } + /// <devdoc> + /// <para> + /// Matches a + /// regular expression with a string and returns the precise result as a + /// RegexMatch object. + /// </para> + /// </devdoc> + public Match Match (string input, int beginning, int length) => Match (input, beginning, length, internalMatchTimeout); public Match Match (string input, int beginning, int length, TimeSpan matchTimeout) { if (input == null) - throw new ArgumentNullException ("input"); - - return Run (false, -1, input, beginning, length, UseOptionR () ? beginning + length : beginning, matchTimeout); + throw new ArgumentNullException (nameof (input)); + return Run (false, -1, input, 0, input.Length, UseOptionR () ? beginning + length : beginning, matchTimeout); } /* diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RegexEngine/RegexMatchCollection.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RegexEngine/RegexMatchCollection.cs index 4f96d64e0b..6156791c88 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RegexEngine/RegexMatchCollection.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RegexEngine/RegexMatchCollection.cs @@ -27,16 +27,10 @@ namespace MonoDevelop.Ide.Editor.Highlighting.RegexEngine { /// names in a regular expression. /// </para> /// </devdoc> -#if !SILVERLIGHT [ Serializable() ] -#endif class MatchCollection : ICollection { internal Regex _regex; -#if SILVERLIGHT internal List<Match> _matches; -#else - internal ArrayList _matches; -#endif internal bool _done; internal string _input; internal int _beginning; @@ -59,11 +53,8 @@ namespace MonoDevelop.Ide.Editor.Highlighting.RegexEngine { _length = length; _startat = startat; _prevlen = -1; -#if SILVERLIGHT + _matches = new List<Match>(); -#else - _matches = new ArrayList(); -#endif _done = false; } @@ -176,12 +167,8 @@ namespace MonoDevelop.Ide.Editor.Highlighting.RegexEngine { int count = Count; try { -#if SILVERLIGHT // Array.Copy will check for null. Array.Copy(_matches.ToArray(), 0, array, arrayIndex, count); -#else - _matches.CopyTo(array, arrayIndex); -#endif } catch (ArrayTypeMismatchException) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs index 9df810fec0..a1989f6bf0 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxHighlightingService.cs @@ -47,9 +47,9 @@ namespace MonoDevelop.Ide.Editor.Highlighting public static class SyntaxHighlightingService { - static LanguageBundle builtInBundle = new LanguageBundle ("default", null); - static LanguageBundle extensionBundle = new LanguageBundle ("extensions", null); - internal static LanguageBundle userThemeBundle = new LanguageBundle ("userThemes", null); + static LanguageBundle builtInBundle = new LanguageBundle ("default", null) { BuiltInBundle = true }; + static LanguageBundle extensionBundle = new LanguageBundle ("extensions", null) { BuiltInBundle = true }; + internal static LanguageBundle userThemeBundle = new LanguageBundle ("userThemes", null) { BuiltInBundle = true }; static List<LanguageBundle> languageBundles = new List<LanguageBundle> (); internal static IEnumerable<LanguageBundle> AllBundles { @@ -58,12 +58,6 @@ namespace MonoDevelop.Ide.Editor.Highlighting } } - internal static IEnumerable<LanguageBundle> LanguageBundles { - get { - return languageBundles.Skip (1); - } - } - public static string[] Styles { get { var result = new List<string> (); @@ -357,9 +351,9 @@ namespace MonoDevelop.Ide.Editor.Highlighting static System.Text.RegularExpressions.Regex fileTypesRegex = new System.Text.RegularExpressions.Regex ("\\s*\"fileTypes\""); static System.Text.RegularExpressions.Regex fileTypesEndRegex = new System.Text.RegularExpressions.Regex ("\\],"); - enum JSonFormat { Unknown, OldSyntaxTheme, TextMateJsonSyntax } + internal enum JSonFormat { Unknown, OldSyntaxTheme, TextMateJsonSyntax } - static bool TryScanJSonStyle (Stream stream, out string name, out JSonFormat format, out List<string> fileTypes, out string scopeName) + internal static bool TryScanJSonStyle (Stream stream, out string name, out JSonFormat format, out List<string> fileTypes, out string scopeName) { name = null; scopeName = null; @@ -405,11 +399,9 @@ namespace MonoDevelop.Ide.Editor.Highlighting if (readFileTypes && fileTypesEndRegex.Match (line).Success) break; if (readFileTypes) { - line = line.Trim (); - if (line.Length > 3) { - var fileType = line.Substring (1, line.Length - 3); + string fileType = ParseFileType (line); + if (!string.IsNullOrEmpty(fileType)) fileTypes.Add (fileType); - } } } if (fileTypes == null) @@ -425,6 +417,19 @@ namespace MonoDevelop.Ide.Editor.Highlighting return false; } + internal static string ParseFileType (string line) + { + var idx1 = line.IndexOf ('"'); + var idx2 = line.LastIndexOf ('"'); + if (idx1 < 0 || idx1 + 1 >= idx2) + return null; + // the . is optional, some extensions mention it and some don't + if (line [idx1 + 1] == '.') + idx1++; + idx1++; // skip " + return line.Substring (idx1, idx2 - idx1); + + } static bool TryScanTextMateSyntax (Stream stream, out List<string> fileTypes, out string name, out string scopeName) { fileTypes = null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/JavaScript.tmLanguage.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/JavaScript.tmLanguage.json index 57c071374c..f81ff34d38 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/JavaScript.tmLanguage.json +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/JavaScript.tmLanguage.json @@ -4,7 +4,7 @@ "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/3a70fab1b03520774fa236f1f7e7a0939463739f", + "version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/7bf8960f7042474b10b519f39339fc527907ce16", "name": "JavaScript (with React support)", "scopeName": "source.js", "fileTypes": [ @@ -13,7 +13,6 @@ ".es6", ".mjs" ], - "uuid": "805375ec-d614-41f5-8993-5843fe63ea82", "patterns": [ { "include": "#directives" @@ -47,31 +46,249 @@ "include": "#declaration" }, { + "include": "#control-statement" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#label" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-semicolon" + } + ] + }, + "declaration": { + "patterns": [ + { + "include": "#decorator" + }, + { + "include": "#var-expr" + }, + { + "include": "#function-declaration" + }, + { + "include": "#class-declaration" + }, + { + "include": "#interface-declaration" + }, + { + "include": "#enum-declaration" + }, + { + "include": "#namespace-declaration" + }, + { + "include": "#type-alias-declaration" + }, + { + "include": "#import-equals-declaration" + }, + { + "include": "#import-declaration" + }, + { + "include": "#export-declaration" + } + ] + }, + "control-statement": { + "patterns": [ + { "include": "#switch-statement" }, { "include": "#for-loop" }, { - "include": "#after-operator-block" + "name": "keyword.control.trycatch.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#decl-block" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|goto)\\s+([_$[:alpha:]][_$[:alnum:]]*)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "captures": { + "1": { + "name": "keyword.control.loop.js" + }, + "2": { + "name": "entity.name.label.js" + } + } }, { - "include": "#control-statement" + "name": "keyword.control.loop.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#expression" + "name": "keyword.control.flow.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(return)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#punctuation-semicolon" + "name": "keyword.control.switch.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.conditional.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(else|if)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.with.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(with)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.other.debugger.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(debugger)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "storage.modifier.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(declare)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + } + ] + }, + "label": { + "patterns": [ + { + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)(?=\\s*\\{)", + "beginCaptures": { + "1": { + "name": "entity.name.label.js" + }, + "2": { + "name": "punctuation.separator.label.js" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#decl-block" + } + ] + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)", + "captures": { + "1": { + "name": "entity.name.label.js" + }, + "2": { + "name": "punctuation.separator.label.js" + } + } + } + ] + }, + "expression": { + "patterns": [ + { + "include": "#expressionWithoutIdentifiers" + }, + { + "include": "#identifiers" + }, + { + "include": "#expressionPunctuations" + } + ] + }, + "expressionWithoutIdentifiers": { + "patterns": [ + { + "include": "#jsx" + }, + { + "include": "#string" + }, + { + "include": "#regex" + }, + { + "include": "#template" + }, + { + "include": "#comment" + }, + { + "include": "#function-expression" + }, + { + "include": "#class-expression" + }, + { + "include": "#arrow-function" + }, + { + "include": "#paren-expression-possibly-arrow" + }, + { + "include": "#cast" + }, + { + "include": "#ternary-expression" + }, + { + "include": "#new-expr" + }, + { + "include": "#instanceof-expr" + }, + { + "include": "#object-literal" + }, + { + "include": "#expression-operators" + }, + { + "include": "#function-call" + }, + { + "include": "#literal" + }, + { + "include": "#support-objects" + }, + { + "include": "#paren-expression" + } + ] + }, + "expressionPunctuations": { + "patterns": [ + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-accessor" + } + ] + }, + "decorator": { + "name": "meta.decorator.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))\\@", + "beginCaptures": { + "0": { + "name": "punctuation.decorator.js" + } + }, + "end": "(?=\\s)", + "patterns": [ + { + "include": "#expression" } ] }, "var-expr": { "name": "meta.var.expr.js", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(var|let|const(?!\\s+enum\\b))\\b(?!\\$|\\.)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(var|let|const(?!\\s+enum\\b))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { "name": "keyword.control.export.js" @@ -95,6 +312,29 @@ "include": "#comment" }, { + "begin": "(,)\\s*(?!\\S)", + "beginCaptures": { + "1": { + "name": "punctuation.separator.comma.js" + } + }, + "end": "(?<!,)((?==|;|}|(\\s+(of|in)\\s+)|^\\s*$))|((?<=\\S)(?=\\s*$))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#destructuring-variable" + }, + { + "include": "#var-single-variable" + }, + { + "include": "#punctuation-comma" + } + ] + }, + { "include": "#punctuation-comma" } ] @@ -103,7 +343,7 @@ "patterns": [ { "name": "meta.var-single-variable.expr.js", - "begin": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)", + "begin": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", "beginCaptures": { "1": { "name": "meta.definition.variable.js entity.name.function.js" @@ -165,7 +405,7 @@ "patterns": [ { "name": "meta.object-binding-pattern-variable.js", - "begin": "(?<!=|:|of|in)\\s*(?=\\{)", + "begin": "(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\{)", "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", "patterns": [ { @@ -181,7 +421,7 @@ }, { "name": "meta.array-binding-pattern-variable.js", - "begin": "(?<!=|:|of|in)\\s*(?=\\[)", + "begin": "(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\[)", "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", "patterns": [ { @@ -203,7 +443,7 @@ "include": "#comment" }, { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", "end": "(?=,|\\})", "patterns": [ { @@ -229,7 +469,7 @@ ] }, "object-binding-element-propertyName": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", "end": "(:)", "endCaptures": { "0": { @@ -244,6 +484,9 @@ "include": "#array-literal" }, { + "include": "#numeric-literal" + }, + { "name": "variable.object.property.js", "match": "([_$[:alpha:]][_$[:alnum:]]*)" } @@ -255,6 +498,9 @@ "include": "#comment" }, { + "include": "#string" + }, + { "include": "#object-binding-pattern" }, { @@ -326,212 +572,941 @@ } ] }, - "ternary-expression": { - "begin": "(\\?)", - "beginCaptures": { - "0": { - "name": "keyword.operator.ternary.js" + "parameter-name": { + "patterns": [ + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|protected|private|readonly)\\s+(?=(public|protected|private|readonly)\\s+)", + "captures": { + "1": { + "name": "storage.modifier.js" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "storage.modifier.js" + }, + "2": { + "name": "keyword.operator.rest.js" + }, + "3": { + "name": "entity.name.function.js variable.language.this.js" + }, + "4": { + "name": "entity.name.function.js" + }, + "5": { + "name": "keyword.operator.optional.js" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)", + "captures": { + "1": { + "name": "storage.modifier.js" + }, + "2": { + "name": "keyword.operator.rest.js" + }, + "3": { + "name": "variable.parameter.js variable.language.this.js" + }, + "4": { + "name": "variable.parameter.js" + }, + "5": { + "name": "keyword.operator.optional.js" + } + } } - }, - "end": "(:)", - "endCaptures": { - "0": { - "name": "keyword.operator.ternary.js" + ] + }, + "destructuring-parameter": { + "patterns": [ + { + "name": "meta.parameter.object-binding-pattern.js", + "begin": "(?<!=|:)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.binding-pattern.object.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.object.js" + } + }, + "patterns": [ + { + "include": "#parameter-object-binding-element" + } + ] + }, + { + "name": "meta.paramter.array-binding-pattern.js", + "begin": "(?<!=|:)\\s*(\\[)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.binding-pattern.array.js" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.js" + } + }, + "patterns": [ + { + "include": "#parameter-binding-element" + }, + { + "include": "#punctuation-comma" + } + ] } - }, + ] + }, + "parameter-object-binding-element": { "patterns": [ { - "include": "#expression" + "include": "#comment" + }, + { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "end": "(?=,|\\})", + "patterns": [ + { + "include": "#object-binding-element-propertyName" + }, + { + "include": "#parameter-binding-element" + } + ] + }, + { + "include": "#parameter-object-binding-pattern" + }, + { + "include": "#destructuring-parameter-rest" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#punctuation-comma" } ] }, - "expression": { + "parameter-binding-element": { "patterns": [ { - "include": "#jsx" + "include": "#comment" }, { "include": "#string" }, { - "include": "#regex" + "include": "#parameter-object-binding-pattern" }, { - "include": "#template" + "include": "#parameter-array-binding-pattern" }, { - "include": "#comment" + "include": "#destructuring-parameter-rest" }, { - "include": "#function-expression" + "include": "#variable-initializer" + } + ] + }, + "destructuring-parameter-rest": { + "match": "(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "keyword.operator.rest.js" + }, + "2": { + "name": "variable.parameter.js" + } + } + }, + "parameter-object-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\{)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.js" }, + "2": { + "name": "punctuation.definition.binding-pattern.object.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.object.js" + } + }, + "patterns": [ { - "include": "#class-or-interface-declaration" + "include": "#parameter-object-binding-element" + } + ] + }, + "parameter-array-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\[)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.js" }, + "2": { + "name": "punctuation.definition.binding-pattern.array.js" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.js" + } + }, + "patterns": [ { - "include": "#arrow-function" + "include": "#parameter-binding-element" }, { - "include": "#cast" + "include": "#punctuation-comma" + } + ] + }, + "field-declaration": { + "name": "meta.field.declaration.js", + "begin": "(?x)(?<!\\()(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(readonly)\\s+)?(?=\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", + "beginCaptures": { + "1": { + "name": "storage.modifier.js" + } + }, + "end": "(?x)(?=\\}|;|,|$|(^(?!\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "patterns": [ + { + "include": "#variable-initializer" }, { - "include": "#ternary-expression" + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", + "end": "(?x)(?=[};,=]|$|(^(?!\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "patterns": [ + { + "include": "#type-annotation" + }, + { + "include": "#string" + }, + { + "include": "#array-literal" + }, + { + "include": "#numeric-literal" + }, + { + "include": "#comment" + }, + { + "match": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(\\?)?(?=(\\?\\s*)?\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "meta.definition.property.js entity.name.function.js" + }, + "2": { + "name": "keyword.operator.optional.js" + } + } + }, + { + "name": "meta.definition.property.js variable.object.property.js", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + { + "name": "keyword.operator.optional.js", + "match": "\\?" + } + ] + } + ] + }, + "variable-initializer": { + "patterns": [ + { + "begin": "(?<!=|!)(=)(?!=)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.js" + } + }, + "end": "(?=$|^|[,);}\\]])", + "patterns": [ + { + "include": "#expression" + } + ] }, { - "include": "#new-expr" + "begin": "(?<!=|!)(=)(?!=)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.js" + } + }, + "end": "(?=[,);}\\]])|(?=^\\s*$)|(?<=\\S)(?<!=)(?=\\s*$)", + "patterns": [ + { + "include": "#expression" + } + ] + } + ] + }, + "function-declaration": { + "name": "meta.function.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js" + }, + "2": { + "name": "storage.modifier.async.js" }, + "3": { + "name": "storage.type.function.js" + }, + "4": { + "name": "keyword.generator.asterisk.js" + }, + "5": { + "name": "meta.definition.function.js entity.name.function.js" + } + }, + "end": "(?=$|^|;)|(?<=\\})", + "patterns": [ { - "include": "#object-literal" + "include": "#function-name" }, { - "include": "#expression-operators" + "include": "#function-body" + } + ] + }, + "function-expression": { + "name": "meta.function.expression.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js" + }, + "2": { + "name": "storage.type.function.js" + }, + "3": { + "name": "keyword.generator.asterisk.js" }, + "4": { + "name": "meta.definition.function.js entity.name.function.js" + } + }, + "end": "(?<=\\})", + "patterns": [ { - "include": "#function-call" + "include": "#function-name" }, { - "include": "#literal" + "include": "#function-body" + } + ] + }, + "function-name": { + "name": "meta.definition.function.js entity.name.function.js", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + "function-body": { + "patterns": [ + { + "include": "#comment" }, { - "include": "#support-objects" + "include": "#type-parameters" }, { - "include": "#identifiers" + "include": "#function-parameters" }, { - "include": "#paren-expression" + "include": "#return-type" }, { - "include": "#punctuation-comma" + "include": "#decl-block" }, { - "include": "#punctuation-accessor" + "name": "keyword.generator.asterisk.js", + "match": "\\*" } ] }, - "control-statement": { + "method-declaration": { "patterns": [ { - "name": "keyword.control.trycatch.js", - "match": "(?<!\\.|\\$)\\b(catch|finally|throw|try)\\b(?!\\$|\\.)" + "name": "meta.method.declaration.js", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?\\s*\\b(constructor)\\b(?!:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "storage.modifier.js" + }, + "2": { + "name": "storage.modifier.js" + }, + "3": { + "name": "storage.modifier.async.js" + }, + "4": { + "name": "storage.type.js" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] }, { - "name": "keyword.control.loop.js", - "match": "(?<!\\.|\\$)\\b(break|continue|do|goto|while)\\b(?!\\$|\\.)" + "name": "meta.method.declaration.js", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:(?:\\s*\\b(new)\\b(?!:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|(?:(\\*)\\s*)?)(?=\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.js" + }, + "2": { + "name": "storage.modifier.js" + }, + "3": { + "name": "storage.modifier.async.js" + }, + "4": { + "name": "keyword.operator.new.js" + }, + "5": { + "name": "keyword.generator.asterisk.js" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] }, { - "name": "keyword.control.flow.js", - "match": "(?<!\\.|\\$)\\b(return)\\b(?!\\$|\\.)" + "name": "meta.method.declaration.js", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.js" + }, + "2": { + "name": "storage.modifier.js" + }, + "3": { + "name": "storage.modifier.async.js" + }, + "4": { + "name": "storage.type.property.js" + }, + "5": { + "name": "keyword.generator.asterisk.js" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] + } + ] + }, + "object-literal-method-declaration": { + "name": "meta.method.declaration.js", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js" }, + "2": { + "name": "storage.type.property.js" + }, + "3": { + "name": "keyword.generator.asterisk.js" + } + }, + "end": "(?=\\}|;|,)|(?<=\\})", + "patterns": [ { - "name": "keyword.control.switch.js", - "match": "(?<!\\.|\\$)\\b(case|default|switch)\\b(?!\\$|\\.)" + "include": "#method-declaration-name" }, { - "name": "keyword.control.conditional.js", - "match": "(?<!\\.|\\$)\\b(else|if)\\b(?!\\$|\\.)" + "include": "#function-body" }, { - "name": "keyword.control.with.js", - "match": "(?<!\\.|\\$)\\b(with)\\b(?!\\$|\\.)" + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js" + }, + "2": { + "name": "storage.type.property.js" + }, + "3": { + "name": "keyword.generator.asterisk.js" + } + }, + "end": "(?=\\(|\\<)", + "patterns": [ + { + "include": "#method-declaration-name" + } + ] + } + ] + }, + "method-declaration-name": { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??)\\s*[\\(\\<])", + "end": "(?=\\(|\\<)", + "patterns": [ + { + "include": "#string" }, { - "name": "keyword.other.debugger.js", - "match": "(?<!\\.|\\$)\\b(debugger)\\b(?!\\$|\\.)" + "include": "#array-literal" }, { - "name": "storage.modifier.js", - "match": "(?<!\\.|\\$)\\b(declare)\\b(?!\\$|\\.)" + "include": "#numeric-literal" + }, + { + "name": "meta.definition.method.js entity.name.function.js", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + { + "name": "keyword.operator.optional.js", + "match": "\\?" } ] }, - "declaration": { + "arrow-function": { "patterns": [ { - "include": "#decorator" + "name": "meta.arrow.js", + "match": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\\s+)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)", + "captures": { + "1": { + "name": "storage.modifier.async.js" + }, + "2": { + "name": "variable.parameter.js" + } + } }, { - "include": "#var-expr" + "name": "meta.arrow.js", + "begin": "(?x) (?:\n (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\n)? ((?<![})!\\]])\\s*\n (?=\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n )\n)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "include": "#function-parameters" + }, + { + "include": "#arrow-return-type" + } + ] }, { - "include": "#function-declaration" + "name": "meta.arrow.js", + "begin": "=>", + "beginCaptures": { + "0": { + "name": "storage.type.function.arrow.js" + } + }, + "end": "(?<=\\}|\\S)(?<!=>)|((?!\\{)(?=\\S))", + "patterns": [ + { + "include": "#decl-block" + }, + { + "include": "#expression" + } + ] + } + ] + }, + "indexer-declaration": { + "name": "meta.indexer.declaration.js", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(readonly)\\s*)?\\s*(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "beginCaptures": { + "1": { + "name": "storage.modifier.js" + }, + "2": { + "name": "meta.brace.square.js" + }, + "3": { + "name": "variable.parameter.js" + } + }, + "end": "(\\])\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.js" }, + "2": { + "name": "keyword.operator.optional.js" + } + }, + "patterns": [ { - "include": "#class-or-interface-declaration" + "include": "#type-annotation" + } + ] + }, + "indexer-mapped-type-declaration": { + "name": "meta.indexer.mappedtype.declaration.js", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))([+-])?(readonly)\\s*)?\\s*(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s+(in)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.modifier.js" + }, + "2": { + "name": "storage.modifier.js" + }, + "3": { + "name": "meta.brace.square.js" + }, + "4": { + "name": "entity.name.type.js" }, + "5": { + "name": "keyword.operator.expression.in.js" + } + }, + "end": "(\\])([+-])?\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.js" + }, + "2": { + "name": "keyword.operator.type.modifier.js" + }, + "3": { + "name": "keyword.operator.optional.js" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + "function-parameters": { + "name": "meta.parameters.js", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.definition.parameters.begin.js" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.parameters.end.js" + } + }, + "patterns": [ + { + "include": "#function-parameters-body" + } + ] + }, + "function-parameters-body": { + "patterns": [ { - "include": "#type-declaration" + "include": "#comment" }, { - "include": "#enum-declaration" + "include": "#decorator" }, { - "include": "#namespace-declaration" + "include": "#destructuring-parameter" }, { - "include": "#import-equals-declaration" + "include": "#parameter-name" }, { - "include": "#import-declaration" + "include": "#type-annotation" }, { - "include": "#export-declaration" + "include": "#variable-initializer" + }, + { + "name": "punctuation.separator.parameter.js", + "match": "," } ] }, - "decorator": { - "name": "meta.decorator.js", - "begin": "(?<!\\.|\\$)\\@", + "class-declaration": { + "name": "meta.class.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(class)\\b(?=\\s+|/[/*])", "beginCaptures": { - "0": { - "name": "punctuation.decorator.js" + "1": { + "name": "keyword.control.export.js" + }, + "2": { + "name": "storage.modifier.js" + }, + "3": { + "name": "storage.type.class.js" } }, - "end": "(?=\\s)", + "end": "(?<=\\})", "patterns": [ { - "include": "#expression" + "include": "#class-declaration-or-expression-patterns" } ] }, - "type-declaration": { - "name": "meta.type.declaration.js", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(type)\\b\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*", + "class-expression": { + "name": "meta.class.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(class)\\b(?=\\s+|[<{]|\\/[\\/*])", + "beginCaptures": { + "1": { + "name": "storage.type.class.js" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#class-declaration-or-expression-patterns" + } + ] + }, + "class-declaration-or-expression-patterns": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" + }, + { + "match": "[_$[:alpha:]][_$[:alnum:]]*", + "captures": { + "0": { + "name": "entity.name.type.class.js" + } + } + }, + { + "include": "#type-parameters" + }, + { + "include": "#class-or-interface-body" + } + ] + }, + "interface-declaration": { + "name": "meta.interface.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(interface)\\b(?=\\s+|/[/*])", "beginCaptures": { "1": { "name": "keyword.control.export.js" }, "2": { - "name": "storage.type.type.js" + "name": "storage.modifier.js" }, "3": { - "name": "entity.name.type.alias.js" + "name": "storage.type.interface.js" } }, - "end": "(?=[};]|\\bvar\\b|\\blet\\b|\\bconst\\b|\\btype\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\bnamespace\\b|\\bmodule\\b|\\bimport\\b|\\benum\\b|\\bdeclare\\b|\\bexport\\b|\\babstract\\b|\\basync\\b)", + "end": "(?<=\\})", "patterns": [ { "include": "#comment" }, { + "include": "#class-or-interface-heritage" + }, + { + "match": "[_$[:alpha:]][_$[:alnum:]]*", + "captures": { + "0": { + "name": "entity.name.type.interface.js" + } + } + }, + { "include": "#type-parameters" }, { - "include": "#type" + "include": "#class-or-interface-body" + } + ] + }, + "class-or-interface-heritage": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(extends|implements)\\b)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "storage.modifier.js" + } + }, + "end": "(?=\\{)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" }, { - "match": "(=)\\s*", + "include": "#type-parameters" + }, + { + "include": "#expressionWithoutIdentifiers" + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*)", "captures": { "1": { - "name": "keyword.operator.assignment.js" + "name": "entity.name.type.module.js" + }, + "2": { + "name": "punctuation.accessor.js" + }, + "3": { + "name": "punctuation.accessor.optional.js" } } + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "entity.other.inherited-class.js" + } + } + }, + { + "include": "#expressionPunctuations" } ] }, + "class-or-interface-body": { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#decorator" + }, + { + "include": "#method-declaration" + }, + { + "include": "#indexer-declaration" + }, + { + "include": "#field-declaration" + }, + { + "include": "#string" + }, + { + "include": "#type-annotation" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#access-modifier" + }, + { + "include": "#property-accessor" + }, + { + "include": "#async-modifier" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-semicolon" + } + ] + }, + "access-modifier": { + "name": "storage.modifier.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(abstract|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "property-accessor": { + "name": "storage.type.property.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(get|set)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "async-modifier": { + "name": "storage.modifier.async.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(async)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, "enum-declaration": { "name": "meta.enum.declaration.js", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)", "beginCaptures": { "1": { "name": "keyword.control.export.js" @@ -586,7 +1561,7 @@ ] }, { - "begin": "(?=((\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))", + "begin": "(?=((\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))", "end": "(?=,|\\}|$)", "patterns": [ { @@ -612,7 +1587,7 @@ }, "namespace-declaration": { "name": "meta.namespace.declaration.js", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+(?=[_$[:alpha:]\"'`])", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+(?=[_$[:alpha:]\"'`]))", "beginCaptures": { "1": { "name": "keyword.control.export.js" @@ -621,7 +1596,7 @@ "name": "storage.type.namespace.js" } }, - "end": "(?<=\\})", + "end": "(?<=\\})|(?=;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#comment" @@ -641,11 +1616,49 @@ } ] }, + "type-alias-declaration": { + "name": "meta.type.declaration.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(type)\\b\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js" + }, + "2": { + "name": "storage.type.type.js" + }, + "3": { + "name": "entity.name.type.alias.js" + } + }, + "end": "(?=\\}|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "begin": "(=)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.js" + } + }, + "end": "(?=\\}|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, "import-equals-declaration": { "patterns": [ { "name": "meta.import-equals.external.js", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(require)\\s*(\\()", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(require)\\s*(\\()", "beginCaptures": { "1": { "name": "keyword.control.export.js" @@ -683,7 +1696,7 @@ }, { "name": "meta.import-equals.internal.js", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(?!require\\b)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(?!require\\b)", "beginCaptures": { "1": { "name": "keyword.control.export.js" @@ -698,19 +1711,22 @@ "name": "keyword.operator.assignment.js" } }, - "end": "(?=;|$)", + "end": "(?=;|$|^)", "patterns": [ { "include": "#comment" }, { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", "captures": { "1": { "name": "entity.name.type.module.js" }, "2": { "name": "punctuation.accessor.js" + }, + "3": { + "name": "punctuation.accessor.optional.js" } } }, @@ -724,7 +1740,7 @@ }, "import-declaration": { "name": "meta.import.js", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)(?!(\\s*:)|(\\$|\\.))\\b", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)(?!\\s*[:\\(])(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { "name": "keyword.control.export.js" @@ -733,9 +1749,29 @@ "name": "keyword.control.import.js" } }, - "end": "(?=;|$)", + "end": "(?<!^import|[^\\._$[:alnum:]]import)(?=;|$|^)", "patterns": [ { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "begin": "(?<=^import|[^\\._$[:alnum:]]import)(?!\\s*[\"'])", + "end": "\\bfrom\\b", + "endCaptures": { + "0": { + "name": "keyword.control.from.js" + } + }, + "patterns": [ + { + "include": "#import-export-declaration" + } + ] + }, + { "include": "#import-export-declaration" } ] @@ -743,7 +1779,7 @@ "export-declaration": { "patterns": [ { - "match": "(?<!\\.|\\$)\\b(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "keyword.control.export.js" @@ -761,7 +1797,7 @@ }, { "name": "meta.export.default.js", - "begin": "(?<!\\.|\\$)\\b(export)(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))", "beginCaptures": { "1": { "name": "keyword.control.export.js" @@ -773,7 +1809,7 @@ "name": "keyword.control.default.js" } }, - "end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)", + "end": "(?=$|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#expression" @@ -782,13 +1818,13 @@ }, { "name": "meta.export.js", - "begin": "(?<!\\.|\\$)\\b(export)(?!(\\s*:)|(\\$))\\b", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?!\\s*:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "0": { "name": "keyword.control.export.js" } }, - "end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)", + "end": "(?=$|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#import-export-declaration" @@ -843,8 +1879,7 @@ "include": "#comment" }, { - "comment": "(default|*|name) as alias", - "match": "(?x) (?: \\b(default)\\b | (\\*) | ([_$[:alpha:]][_$[:alnum:]]*)) \\s+ \n (as) \\s+ (?: (\\b default \\b | \\*) | ([_$[:alpha:]][_$[:alnum:]]*))", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bdefault)|(\\*)|(\\b[_$[:alpha:]][_$[:alnum:]]*))\\s+(as)\\s+(?:(\\bdefault(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|(\\b[_$[:alpha:]][_$[:alnum:]]*))", "captures": { "1": { "name": "keyword.control.default.js" @@ -859,7 +1894,7 @@ "name": "keyword.control.as.js" }, "5": { - "name": "invalid.illegal.js" + "name": "keyword.control.default.js" }, "6": { "name": "variable.other.readwrite.alias.js" @@ -883,147 +1918,170 @@ } ] }, - "class-or-interface-declaration": { + "switch-statement": { + "name": "switch-statement.expr.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?=\\bswitch\\s*\\()", + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js" + } + }, "patterns": [ { - "name": "meta.class.js", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(class)\\b(?=\\s+|/[/*])", + "name": "switch-expression.expr.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(switch)\\s*(\\()", "beginCaptures": { "1": { - "name": "keyword.control.export.js" + "name": "keyword.control.switch.js" }, "2": { - "name": "storage.modifier.js" - }, - "3": { - "name": "storage.type.class.js" + "name": "meta.brace.round.js" } }, - "end": "(?<=\\})", + "end": "\\)", "endCaptures": { - "1": { + "0": { + "name": "meta.brace.round.js" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "name": "switch-block.expr.js", + "begin": "\\{", + "beginCaptures": { + "0": { "name": "punctuation.definition.block.js" } }, + "end": "(?=\\})", "patterns": [ { - "include": "#comment" + "name": "case-clause.expr.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default(?=:))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "keyword.control.switch.js" + } + }, + "end": "(?=:)", + "patterns": [ + { + "include": "#expression" + } + ] }, { - "include": "#class-or-interface-heritage" + "begin": "(:)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "case-clause.expr.js punctuation.definition.section.case-statement.js" + }, + "2": { + "name": "meta.block.js punctuation.definition.block.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "meta.block.js punctuation.definition.block.js" + } + }, + "contentName": "meta.block.js", + "patterns": [ + { + "include": "#statements" + } + ] }, { - "match": "[_$[:alpha:]][_$[:alnum:]]*", + "match": "(:)", "captures": { "0": { - "name": "entity.name.type.class.js" + "name": "case-clause.expr.js punctuation.definition.section.case-statement.js" } } }, { - "include": "#type-parameters" - }, - { - "include": "#class-or-interface-body" + "include": "#statements" } ] + } + ] + }, + "for-loop": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))for(?=((\\s+|(\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*))await)?\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)?(\\())", + "beginCaptures": { + "0": { + "name": "keyword.control.loop.js" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#comment" + }, + { + "name": "keyword.control.loop.js", + "match": "await" }, { - "name": "meta.interface.js", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(interface)\\b(?=\\s+|/[/*])", + "begin": "\\(", "beginCaptures": { - "1": { - "name": "keyword.control.export.js" - }, - "2": { - "name": "storage.modifier.js" - }, - "3": { - "name": "storage.type.interface.js" + "0": { + "name": "meta.brace.round.js" } }, - "end": "(?<=\\})", + "end": "\\)", "endCaptures": { - "1": { - "name": "punctuation.definition.block.js" + "0": { + "name": "meta.brace.round.js" } }, "patterns": [ { - "include": "#comment" - }, - { - "include": "#class-or-interface-heritage" - }, - { - "match": "[_$[:alpha:]][_$[:alnum:]]*", - "captures": { - "0": { - "name": "entity.name.type.interface.js" - } - } + "include": "#var-expr" }, { - "include": "#type-parameters" + "include": "#expression" }, { - "include": "#class-or-interface-body" + "include": "#punctuation-semicolon" } ] } ] }, - "class-or-interface-heritage": { - "begin": "(?<!\\.|\\$)(?:\\b(extends|implements)\\b)(?!\\$|\\.)", + "decl-block": { + "name": "meta.block.js", + "begin": "\\{", "beginCaptures": { - "1": { - "name": "storage.modifier.js" + "0": { + "name": "punctuation.definition.block.js" } }, - "end": "(?=\\{)", + "end": "\\}", "endCaptures": { - "1": { + "0": { "name": "punctuation.definition.block.js" } }, "patterns": [ { - "include": "#comment" - }, - { - "include": "#class-or-interface-heritage" - }, - { - "include": "#type-parameters" - }, - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*([,<{]|extends|implements|//|/\\*))", - "captures": { - "1": { - "name": "entity.name.type.module.js" - }, - "2": { - "name": "punctuation.accessor.js" - } - } - }, - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*([,<{]|extends|implements|//|/\\*))", - "captures": { - "1": { - "name": "entity.other.inherited-class.js" - } - } - }, - { - "include": "#expression" + "include": "#statements" } ] }, - "class-or-interface-body": { - "begin": "\\{", + "after-operator-block-as-object-literal": { + "name": "meta.objectliteral.js", + "begin": "(?<!\\+\\+|--)(?<=[:=(,\\[?+!>]|^await|[^\\._$[:alnum:]]await|^return|[^\\._$[:alnum:]]return|^yield|[^\\._$[:alnum:]]yield|^throw|[^\\._$[:alnum:]]throw|^in|[^\\._$[:alnum:]]in|^of|[^\\._$[:alnum:]]of|^typeof|[^\\._$[:alnum:]]typeof|&&|\\|\\||\\*)\\s*(\\{)", "beginCaptures": { - "0": { + "1": { "name": "punctuation.definition.block.js" } }, @@ -1035,54 +2093,12 @@ }, "patterns": [ { - "include": "#string" - }, - { - "include": "#comment" - }, - { - "include": "#decorator" - }, - { - "include": "#method-declaration" - }, - { - "include": "#indexer-declaration" - }, - { - "include": "#field-declaration" - }, - { - "include": "#type-annotation" - }, - { - "include": "#variable-initializer" - }, - { - "include": "#access-modifier" - }, - { - "include": "#property-accessor" - }, - { - "include": "#after-operator-block" - }, - { - "include": "#decl-block" - }, - { - "include": "#expression" - }, - { - "include": "#punctuation-comma" - }, - { - "include": "#punctuation-semicolon" + "include": "#object-member" } ] }, - "type-object": { - "name": "meta.object.type.js", + "object-literal": { + "name": "meta.objectliteral.js", "begin": "\\{", "beginCaptures": { "0": { @@ -1097,938 +2113,565 @@ }, "patterns": [ { - "include": "#comment" - }, - { - "include": "#method-declaration" - }, + "include": "#object-member" + } + ] + }, + "object-member": { + "patterns": [ { - "include": "#indexer-declaration" + "include": "#comment" }, { - "include": "#indexer-mapped-type-declaration" + "include": "#object-literal-method-declaration" }, { - "include": "#field-declaration" + "name": "meta.object.member.js meta.object-literal.key.js", + "begin": "(?=\\[)", + "end": "(?=:)|((?<=[\\]])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#array-literal" + } + ] }, { - "include": "#type-annotation" + "name": "meta.object.member.js meta.object-literal.key.js", + "begin": "(?=[\\'\\\"])", + "end": "(?=:)|((?<=[\\'\\\"])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#string" + } + ] }, { - "begin": "\\.\\.\\.", - "beginCaptures": { - "0": { - "name": "keyword.operator.spread.js" - } - }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + "name": "meta.method.declaration.js", + "begin": "(?<=[\\]\\'\\\"])(?=\\s*[\\(\\<])", + "end": "(?=\\}|;|,)|(?<=\\})", "patterns": [ { - "include": "#type" + "include": "#function-body" } ] }, { - "include": "#punctuation-comma" + "name": "meta.object.member.js", + "match": "(?![_$[:alpha:]])([[:digit:]]+)\\s*(?=:)", + "captures": { + "0": { + "name": "meta.object-literal.key.js" + }, + "1": { + "name": "constant.numeric.decimal.js" + } + } }, { - "include": "#punctuation-semicolon" + "name": "meta.object.member.js", + "match": "(?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "0": { + "name": "meta.object-literal.key.js" + }, + "1": { + "name": "entity.name.function.js" + } + } }, { - "include": "#type" - } - ] - }, - "field-declaration": { - "name": "meta.field.declaration.js", - "begin": "(?<!\\()(?:(?<!\\.|\\$)\\b(readonly)\\s+)?(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", - "beginCaptures": { - "1": { - "name": "storage.modifier.js" - } - }, - "end": "(?=\\}|;|,|$|(^(?!(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", - "patterns": [ - { - "include": "#variable-initializer" + "name": "meta.object.member.js", + "match": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "captures": { + "0": { + "name": "meta.object-literal.key.js" + } + } }, { - "begin": "(?=((?:[_$[:alpha:]][_$[:alnum:]]*)|(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", - "end": "(?=[};,=]|$|(^(?!(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "name": "meta.object.member.js", + "begin": "\\.\\.\\.", + "beginCaptures": { + "0": { + "name": "keyword.operator.spread.js" + } + }, + "end": "(?=,|\\})", "patterns": [ { - "include": "#type-annotation" - }, - { - "include": "#string" - }, - { - "include": "#array-literal" - }, - { - "include": "#comment" - }, - { - "name": "meta.definition.property.js entity.name.function.js", - "match": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=(\\?\\s*)?\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)" - }, - { - "name": "meta.definition.property.js variable.object.property.js", - "match": "[_$[:alpha:]][_$[:alnum:]]*" - }, - { - "name": "keyword.operator.optional.js", - "match": "\\?" + "include": "#expression" } ] - } - ] - }, - "method-declaration": { - "patterns": [ + }, { - "name": "meta.method.declaration.js", - "begin": "(?<!\\.|\\$)(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", - "beginCaptures": { + "name": "meta.object.member.js", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$)", + "captures": { "1": { - "name": "storage.modifier.js" - }, - "2": { - "name": "storage.modifier.js" - }, - "3": { - "name": "storage.modifier.async.js" - }, - "4": { - "name": "storage.type.property.js" - }, - "5": { - "name": "keyword.generator.asterisk.js" + "name": "variable.other.readwrite.js" } - }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + } + }, + { + "name": "meta.object.member.js", + "begin": "(?=[_$[:alpha:]][_$[:alnum:]]*\\s*=)", + "end": "(?=,|\\}|$)", "patterns": [ { - "include": "#method-declaration-name" - }, - { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" - }, - { - "include": "#return-type" - }, - { - "include": "#decl-block" + "include": "#expression" } ] }, { - "name": "meta.method.declaration.js", - "begin": "(?<!\\.|\\$)(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:(?:\\b(?:(new)|(constructor))\\b(?!\\$|\\.|:))|(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))?\\s*[\\(\\<]))", + "name": "meta.object.member.js", + "begin": ":", "beginCaptures": { - "1": { - "name": "storage.modifier.js" - }, - "2": { - "name": "storage.modifier.js" - }, - "3": { - "name": "storage.modifier.async.js" - }, - "4": { - "name": "keyword.operator.new.js" - }, - "5": { - "name": "storage.type.js" - }, - "6": { - "name": "keyword.generator.asterisk.js" + "0": { + "name": "meta.object-literal.key.js punctuation.separator.key-value.js" } }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + "end": "(?=,|\\})", "patterns": [ { - "include": "#method-declaration-name" - }, - { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" + "begin": "(?<=:)\\s*(async)?(?=\\s*(<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)\\(\\s*([\\{\\[]\\s*)?$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#type-parameters" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.js" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + } + ] }, { - "include": "#return-type" + "begin": "(?<=:)\\s*(async)?\\s*(\\()(?=\\s*([\\{\\[]\\s*)?$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js" + }, + "2": { + "name": "meta.brace.round.js" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] }, { - "include": "#decl-block" + "include": "#expression" } ] - } - ] - }, - "method-declaration-name": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??)\\s*[\\(\\<])", - "end": "(?=\\(|\\<)", - "patterns": [ - { - "include": "#string" - }, - { - "include": "#array-literal" - }, - { - "name": "meta.definition.method.js entity.name.function.js", - "match": "[_$[:alpha:]][_$[:alnum:]]*" - }, - { - "name": "keyword.operator.optional.js", - "match": "\\?" - } - ] - }, - "object-literal-method-declaration": { - "name": "meta.method.declaration.js", - "begin": "(?<!\\.|\\$)(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", - "beginCaptures": { - "1": { - "name": "storage.modifier.async.js" - }, - "2": { - "name": "storage.type.property.js" - }, - "3": { - "name": "keyword.generator.asterisk.js" - } - }, - "end": "(?=\\}|;|,)|(?<=\\})", - "patterns": [ - { - "include": "#method-declaration-name" - }, - { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" - }, - { - "include": "#return-type" - }, - { - "include": "#object-literal-method-overload-declaration" - }, - { - "include": "#decl-block" - } - ] - }, - "object-literal-method-overload-declaration": { - "begin": "(?<!\\.|\\$)(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", - "beginCaptures": { - "1": { - "name": "storage.modifier.async.js" - }, - "2": { - "name": "storage.type.property.js" }, - "3": { - "name": "keyword.generator.asterisk.js" - } - }, - "end": "(?=\\(|\\<)", - "patterns": [ { - "include": "#method-declaration-name" + "include": "#punctuation-comma" } ] }, - "indexer-declaration": { - "name": "meta.indexer.declaration.js", - "begin": "(?:(?<!\\.|\\$)\\b(readonly)\\s*)?(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "ternary-expression": { + "begin": "(?!\\?\\.\\s*[^[:digit:]])(\\?)", "beginCaptures": { "1": { - "name": "storage.modifier.js" - }, - "2": { - "name": "meta.brace.square.js" - }, - "3": { - "name": "variable.parameter.js" + "name": "keyword.operator.ternary.js" } }, - "end": "(\\])\\s*(\\?\\s*)?|$", + "end": "\\s*(:)", "endCaptures": { "1": { - "name": "meta.brace.square.js" - }, - "2": { - "name": "keyword.operator.optional.js" + "name": "keyword.operator.ternary.js" } }, "patterns": [ { - "include": "#type-annotation" + "include": "#expression" } ] }, - "indexer-mapped-type-declaration": { - "name": "meta.indexer.mappedtype.declaration.js", - "begin": "(?:(?<!\\.|\\$)\\b(readonly)\\s*)?(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s+(in)\\s+", - "beginCaptures": { - "1": { - "name": "storage.modifier.js" - }, - "2": { - "name": "meta.brace.square.js" - }, - "3": { - "name": "entity.name.type.js" - }, - "4": { - "name": "keyword.operator.expression.in.js" - } - }, - "end": "(\\])\\s*(\\?\\s*)?|$", - "endCaptures": { - "1": { - "name": "meta.brace.square.js" - }, - "2": { - "name": "keyword.operator.optional.js" - } - }, + "function-call": { + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "end": "(?<=\\))(?!(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", "patterns": [ { - "include": "#type" - } - ] - }, - "function-declaration": { - "name": "meta.function.js", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", - "beginCaptures": { - "1": { - "name": "keyword.control.export.js" - }, - "2": { - "name": "storage.modifier.async.js" - }, - "3": { - "name": "storage.type.function.js" - }, - "4": { - "name": "keyword.generator.asterisk.js" + "name": "meta.function-call.js", + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*))", + "end": "(?=\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "patterns": [ + { + "include": "#literal" + }, + { + "include": "#support-objects" + }, + { + "include": "#object-identifiers" + }, + { + "include": "#punctuation-accessor" + }, + { + "name": "keyword.operator.expression.import.js", + "match": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))import(?=\\s*[\\(]\\s*[\\\"\\'\\`]))" + }, + { + "name": "entity.name.function.js", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" + } + ] }, - "5": { - "name": "meta.definition.function.js entity.name.function.js" - } - }, - "end": "(?=$|^|;)|(?<=\\})", - "patterns": [ { "include": "#comment" }, { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" + "name": "meta.function-call.js punctuation.accessor.optional.js", + "match": "\\?\\." }, { - "include": "#return-type" + "include": "#type-arguments" }, { - "include": "#decl-block" + "include": "#paren-expression" } ] }, - "function-expression": { - "name": "meta.function.expression.js", - "begin": "(?<!\\.|\\$)\\b(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "new-expr": { + "name": "new.expr.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { - "name": "storage.modifier.async.js" - }, - "2": { - "name": "storage.type.function.js" - }, - "3": { - "name": "keyword.generator.asterisk.js" - }, - "4": { - "name": "meta.definition.function.js entity.name.function.js" + "name": "keyword.operator.new.js" } }, - "end": "(?<=\\})", + "end": "(?<=\\))|(?=[;),}\\]:]|\\|\\||\\&\\&|$|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))new(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))function((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", "patterns": [ { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" + "include": "#paren-expression" }, { - "include": "#return-type" + "include": "#class-declaration" }, { - "include": "#decl-block" - } - ] - }, - "object-literal": { - "name": "meta.objectliteral.js", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.js" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.js" - } - }, - "patterns": [ - { - "include": "#object-member" - } - ] - }, - "decl-block": { - "name": "meta.block.js", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.js" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.js" - } - }, - "patterns": [ - { - "include": "#statements" + "include": "#type" } ] }, - "after-operator-block": { - "name": "meta.objectliteral.js", - "begin": "(?<=[=(,\\[?+!]|await|return|yield|throw|in|of|typeof|&&|\\|\\||\\*)\\s*(\\{)", + "instanceof-expr": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(instanceof)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { - "name": "punctuation.definition.block.js" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.js" + "name": "keyword.operator.expression.instanceof.js" } }, + "end": "(?<=\\))|(?=[;),}\\]:?]|\\|\\||\\&\\&|$|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))function((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", "patterns": [ { - "include": "#object-member" - } - ] - }, - "parameter-name": { - "patterns": [ - { - "match": "\\s*\\b(public|protected|private|readonly)(?=\\s+(public|protected|private|readonly)\\s+)", - "captures": { - "1": { - "name": "storage.modifier.js" - } - } - }, - { - "match": "(?x)(?:\\s*\\b(public|private|protected|readonly)\\s+)?(\\.\\.\\.)?\\s*(?<!=|:)(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)", - "captures": { - "1": { - "name": "storage.modifier.js" - }, - "2": { - "name": "keyword.operator.rest.js" - }, - "3": { - "name": "entity.name.function.js variable.language.this.js" - }, - "4": { - "name": "entity.name.function.js" - }, - "5": { - "name": "keyword.operator.optional.js" - } - } - }, - { - "match": "(?:\\s*\\b(public|private|protected|readonly)\\s+)?(\\.\\.\\.)?\\s*(?<!=|:)(?:((?<!\\.|\\$)\\bthis\\b(?!\\.|\\$))|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)", - "captures": { - "1": { - "name": "storage.modifier.js" - }, - "2": { - "name": "keyword.operator.rest.js" - }, - "3": { - "name": "variable.parameter.js variable.language.this.js" - }, - "4": { - "name": "variable.parameter.js" - }, - "5": { - "name": "keyword.operator.optional.js" - } - } + "include": "#type" } ] }, - "destructuring-parameter": { + "paren-expression-possibly-arrow": { "patterns": [ { - "name": "meta.parameter.object-binding-pattern.js", - "begin": "(?<!=|:)\\s*(\\{)", + "begin": "(?<=[(=,])\\s*(async)?(?=\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*))?\\(\\s*[\\{\\[]\\s*$)", "beginCaptures": { "1": { - "name": "punctuation.definition.binding-pattern.object.js" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.object.js" + "name": "storage.modifier.async.js" } }, + "end": "(?<=\\))", "patterns": [ { - "include": "#parameter-object-binding-element" + "include": "#paren-expression-possibly-arrow-with-typeparameters" } ] }, { - "name": "meta.paramter.array-binding-pattern.js", - "begin": "(?<!=|:)\\s*(\\[)", + "begin": "(?<=[(=,]|=>)\\s*(async)?(?=\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*))?\\(\\s*$)", "beginCaptures": { "1": { - "name": "punctuation.definition.binding-pattern.array.js" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.array.js" + "name": "storage.modifier.async.js" } }, + "end": "(?<=\\))", "patterns": [ { - "include": "#parameter-binding-element" - }, - { - "include": "#punctuation-comma" + "include": "#paren-expression-possibly-arrow-with-typeparameters" } ] + }, + { + "include": "#possibly-arrow-return-type" } ] }, - "parameter-object-binding-element": { + "paren-expression-possibly-arrow-with-typeparameters": { "patterns": [ { - "include": "#comment" + "include": "#type-parameters" }, { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", - "end": "(?=,|\\})", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.js" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js" + } + }, "patterns": [ { - "include": "#object-binding-element-propertyName" - }, - { - "include": "#parameter-binding-element" + "include": "#expression-inside-possibly-arrow-parens" } ] - }, - { - "include": "#parameter-object-binding-pattern" - }, - { - "include": "#destructuring-parameter-rest" - }, - { - "include": "#variable-initializer" - }, - { - "include": "#punctuation-comma" } ] }, - "parameter-binding-element": { + "expression-inside-possibly-arrow-parens": { "patterns": [ { - "include": "#comment" - }, - { - "include": "#parameter-object-binding-pattern" + "include": "#expressionWithoutIdentifiers" }, { - "include": "#parameter-array-binding-pattern" + "include": "#function-parameters-body" }, { - "include": "#destructuring-parameter-rest" + "include": "#identifiers" }, { - "include": "#variable-initializer" + "include": "#expressionPunctuations" } ] }, - "destructuring-parameter-rest": { - "match": "(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)", - "captures": { - "1": { - "name": "keyword.operator.rest.js" - }, - "2": { - "name": "variable.parameter.js" - } - } - }, - "parameter-object-binding-pattern": { - "begin": "(?:(\\.\\.\\.)\\s*)?(\\{)", + "paren-expression": { + "begin": "\\(", "beginCaptures": { - "1": { - "name": "keyword.operator.rest.js" - }, - "2": { - "name": "punctuation.definition.binding-pattern.object.js" + "0": { + "name": "meta.brace.round.js" } }, - "end": "\\}", + "end": "\\)", "endCaptures": { "0": { - "name": "punctuation.definition.binding-pattern.object.js" + "name": "meta.brace.round.js" } }, "patterns": [ { - "include": "#parameter-object-binding-element" + "include": "#expression" } ] }, - "parameter-array-binding-pattern": { - "begin": "(?:(\\.\\.\\.)\\s*)?(\\[)", - "beginCaptures": { - "1": { - "name": "keyword.operator.rest.js" - }, - "2": { - "name": "punctuation.definition.binding-pattern.array.js" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.array.js" - } - }, + "cast": { "patterns": [ { - "include": "#parameter-binding-element" - }, - { - "include": "#punctuation-comma" + "include": "#jsx" } ] }, - "return-type": { - "name": "meta.return.type.js", - "begin": "(?<=\\))\\s*(:)", - "beginCaptures": { - "1": { - "name": "keyword.operator.type.annotation.js" - } - }, - "end": "(?<![:|&])(?=$|^|[{};,]|//)", + "expression-operators": { "patterns": [ { - "include": "#comment" + "name": "keyword.control.flow.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(await)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "begin": "(?<=[:])(?=\\s*\\{)", - "end": "(?<=\\})", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?=\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*\\*)", + "beginCaptures": { + "1": { + "name": "keyword.control.flow.js" + } + }, + "end": "\\*", + "endCaptures": { + "0": { + "name": "keyword.generator.asterisk.js" + } + }, "patterns": [ { - "include": "#type-object" + "include": "#comment" } ] }, { - "include": "#type-predicate-operator" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?:\\s*(\\*))?", + "captures": { + "1": { + "name": "keyword.control.flow.js" + }, + "2": { + "name": "keyword.generator.asterisk.js" + } + } }, { - "include": "#type" - } - ] - }, - "type-predicate-operator": { - "name": "keyword.operator.expression.is.js", - "match": "(?<!\\.|\\$)\\bis\\b(?!\\$|\\.)" - }, - "type-annotation": { - "name": "meta.type.annotation.js", - "begin": ":", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.annotation.js" - } - }, - "end": "(?=$|^|[,);\\}\\]]|//)|(?==[^>])|(?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)", - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.expression.delete.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))delete(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#type" - } - ] - }, - "type": { - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.expression.in.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))in(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()" }, { - "include": "#string" + "name": "keyword.operator.expression.of.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))of(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()" }, { - "include": "#numeric-literal" + "name": "keyword.operator.expression.instanceof.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))instanceof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#type-primitive" + "name": "keyword.operator.new.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))new(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#type-builtin-literals" + "include": "#typeof-operator" }, { - "include": "#type-parameters" + "name": "keyword.operator.expression.void.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))void(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#type-tuple" + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(as)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.control.as.js" + } + }, + "end": "(?=$|^|[;,:})\\]]|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(as)\\s+))", + "patterns": [ + { + "include": "#type" + } + ] }, { - "include": "#type-object" + "name": "keyword.operator.spread.js", + "match": "\\.\\.\\." }, { - "include": "#type-operators" + "name": "keyword.operator.assignment.compound.js", + "match": "\\*=|(?<!\\()/=|%=|\\+=|\\-=" }, { - "include": "#type-fn-type-parameters" + "name": "keyword.operator.assignment.compound.bitwise.js", + "match": "\\&=|\\^=|<<=|>>=|>>>=|\\|=" }, { - "include": "#type-paren-or-function-parameters" + "name": "keyword.operator.bitwise.shift.js", + "match": "<<|>>>|>>" }, { - "include": "#type-function-return-type" + "name": "keyword.operator.comparison.js", + "match": "===|!==|==|!=" }, { - "include": "#type-name" - } - ] - }, - "function-parameters": { - "name": "meta.parameters.js", - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "punctuation.definition.parameters.begin.js" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.parameters.end.js" - } - }, - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.relational.js", + "match": "<=|>=|<>|<|>" }, { - "include": "#decorator" + "name": "keyword.operator.logical.js", + "match": "\\!|&&|\\|\\|" }, { - "include": "#destructuring-parameter" + "name": "keyword.operator.bitwise.js", + "match": "\\&|~|\\^|\\|" }, { - "include": "#parameter-name" + "name": "keyword.operator.assignment.js", + "match": "\\=" }, { - "include": "#type-annotation" + "name": "keyword.operator.decrement.js", + "match": "--" }, { - "include": "#variable-initializer" + "name": "keyword.operator.increment.js", + "match": "\\+\\+" }, { - "name": "punctuation.separator.parameter.js", - "match": "," - } - ] - }, - "type-primitive": { - "name": "support.type.primitive.js", - "match": "(?<!\\.|\\$)\\b(string|number|boolean|symbol|any|void|never)\\b(?!\\$|\\.)" - }, - "type-builtin-literals": { - "name": "support.type.builtin.js", - "match": "(?<!\\.|\\$)\\b(this|true|false|undefined|null|object)\\b(?!\\$|\\.)" - }, - "type-paren-or-function-parameters": { - "name": "meta.type.paren.cover.js", - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "meta.brace.round.js" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.js" - } - }, - "patterns": [ - { - "include": "#type" + "name": "keyword.operator.arithmetic.js", + "match": "%|\\*|/|-|\\+" }, { - "include": "#function-parameters" - } - ] - }, - "type-fn-type-parameters": { - "patterns": [ - { - "name": "meta.type.constructor.js", - "match": "(?<!\\.|\\$)\\b(new)\\b(?=\\s*\\<)", + "match": "(?<=[_$[:alnum:])\\]])\\s*(/)(?![/*])", "captures": { "1": { - "name": "keyword.control.new.js" + "name": "keyword.operator.arithmetic.js" } } - }, - { - "name": "meta.type.constructor.js", - "begin": "(?<!\\.|\\$)\\b(new)\\b\\s*(?=\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.new.js" - } - }, - "end": "(?<=\\))", - "patterns": [ - { - "include": "#function-parameters" - } - ] - }, - { - "name": "meta.type.function.js", - "begin": "(?x)(\n (?=\n [(]\\s*(\n ([)]) | \n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n )\n )\n)", - "end": "(?<=\\))", - "patterns": [ - { - "include": "#function-parameters" - } - ] } ] }, - "type-operators": { + "typeof-operator": { + "name": "keyword.operator.expression.typeof.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))typeof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "literal": { "patterns": [ { - "include": "#typeof-operator" + "include": "#numeric-literal" }, { - "begin": "([&|])(?=\\s*\\{)", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.js" - } - }, - "end": "(?<=\\})", - "patterns": [ - { - "include": "#type-object" - } - ] + "include": "#boolean-literal" }, { - "begin": "[&|]", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.js" - } - }, - "end": "(?=\\S)" + "include": "#null-literal" }, { - "name": "keyword.operator.expression.keyof.js", - "match": "(?<!\\.|\\$)\\bkeyof\\b(?!\\$|\\.)" - } - ] - }, - "type-function-return-type": { - "name": "meta.type.function.return.js", - "begin": "=>", - "beginCaptures": { - "0": { - "name": "storage.type.function.arrow.js" - } - }, - "end": "(?<!=>)(?<![|&])(?=[,\\]\\)\\{\\}=;>]|//|$)", - "patterns": [ + "include": "#undefined-literal" + }, { - "include": "#comment" + "include": "#numericConstant-literal" }, { - "begin": "(?<==>)(?=\\s*\\{)", - "end": "(?<=\\})", - "patterns": [ - { - "include": "#type-object" - } - ] + "include": "#array-literal" }, { - "include": "#type-predicate-operator" + "include": "#this-literal" }, { - "include": "#type" + "include": "#super-literal" } ] }, - "type-tuple": { - "name": "meta.type.tuple.js", - "begin": "\\[", + "array-literal": { + "name": "meta.array.literal.js", + "begin": "\\s*(\\[)", "beginCaptures": { - "0": { + "1": { "name": "meta.brace.square.js" } }, @@ -2040,205 +2683,92 @@ }, "patterns": [ { - "include": "#type" + "include": "#expression" }, { "include": "#punctuation-comma" } ] }, - "type-name": { - "patterns": [ - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)", - "captures": { - "1": { - "name": "entity.name.type.module.js" - }, - "2": { - "name": "punctuation.accessor.js" - } - } - }, - { - "name": "entity.name.type.js", - "match": "[_$[:alpha:]][_$[:alnum:]]*" - } - ] - }, - "type-parameters": { - "name": "meta.type.parameters.js", - "begin": "(<)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.typeparameters.begin.js" - } - }, - "end": "(>)", - "endCaptures": { - "1": { - "name": "punctuation.definition.typeparameters.end.js" - } - }, + "numeric-literal": { "patterns": [ { - "include": "#comment" - }, - { - "name": "storage.modifier.js", - "match": "(?<!\\.|\\$)\\b(extends)\\b(?!\\$)" - }, - { - "name": "keyword.operator.assignment.js", - "match": "\\=(?!>)" + "name": "constant.numeric.hex.js", + "match": "\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$)" }, { - "include": "#type" + "name": "constant.numeric.binary.js", + "match": "\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$)" }, { - "include": "#punctuation-comma" - } - ] - }, - "variable-initializer": { - "patterns": [ - { - "begin": "(?<!=|!)(=)(?!=)(?=\\s*\\S)", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.js" - } - }, - "end": "(?=$|^|[,);}\\]])", - "patterns": [ - { - "include": "#expression" - } - ] + "name": "constant.numeric.octal.js", + "match": "\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$)" }, { - "begin": "(?<!=|!)(=)(?!=)", - "beginCaptures": { + "match": "(?x)\n(?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$)", + "captures": { + "0": { + "name": "constant.numeric.decimal.js" + }, "1": { - "name": "keyword.operator.assignment.js" - } - }, - "end": "(?=[,);}\\]])|(?=^\\s*$)|(?<=\\S)(?<!=)", - "patterns": [ - { - "include": "#expression" + "name": "meta.delimiter.decimal.period.js" + }, + "2": { + "name": "meta.delimiter.decimal.period.js" + }, + "3": { + "name": "meta.delimiter.decimal.period.js" + }, + "4": { + "name": "meta.delimiter.decimal.period.js" + }, + "5": { + "name": "meta.delimiter.decimal.period.js" + }, + "6": { + "name": "meta.delimiter.decimal.period.js" } - ] + } } ] }, - "for-loop": { - "begin": "(?<!\\.|\\$)\\b(for)(?:\\s+(await))?\\s*(\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.loop.js" - }, - "2": { - "name": "keyword.control.loop.js" - }, - "3": { - "name": "meta.brace.round.js" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.js" - } - }, + "boolean-literal": { "patterns": [ { - "include": "#var-expr" - }, - { - "include": "#expression" + "name": "constant.language.boolean.true.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))true(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#punctuation-semicolon" + "name": "constant.language.boolean.false.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))false(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" } ] }, - "switch-expression": { - "name": "switch-expression.expr.js", - "begin": "(?<!\\.|\\$)\\b(switch)\\s*(\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.switch.js" - }, - "2": { - "name": "meta.brace.round.js" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.js" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] + "null-literal": { + "name": "constant.language.null.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))null(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, - "switch-block": { - "name": "switch-block.expr.js", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.js" - } - }, - "end": "(?=\\})", - "patterns": [ - { - "include": "#case-clause" - }, - { - "include": "#statements" - } - ] + "this-literal": { + "name": "variable.language.this.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))this\\b(?!\\$)" }, - "case-clause": { - "name": "case-clause.expr.js", - "begin": "(?<!\\.|\\$)\\b(case|default(?=:))\\b(?!\\$|\\.)", - "beginCaptures": { - "1": { - "name": "keyword.control.switch.js" - } - }, - "end": ":", - "endCaptures": { - "0": { - "name": "punctuation.definition.section.case-statement.js" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] + "super-literal": { + "name": "variable.language.super.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))super\\b(?!\\$)" }, - "switch-statement": { - "name": "switch-statement.expr.js", - "begin": "(?<!\\.|\\$)(?=\\bswitch\\s*\\()", - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.js" - } - }, + "undefined-literal": { + "name": "constant.language.undefined.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))undefined(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "numericConstant-literal": { "patterns": [ { - "include": "#switch-expression" + "name": "constant.language.nan.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))NaN(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#switch-block" + "name": "constant.language.infinity.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))Infinity(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" } ] }, @@ -2246,22 +2776,26 @@ "patterns": [ { "name": "variable.language.arguments.js", - "match": "(?<!\\.|\\$)\\b(arguments)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(arguments)\\b(?!\\$)" }, { "name": "support.class.builtin.js", - "match": "(?x)(?<!\\.|\\$)\\b(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator\n |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Promise|Proxy\n |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray\n |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\\b(?!\\$)" + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator\n |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Proxy\n |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray\n |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\\b(?!\\$)" }, { "name": "support.class.error.js", - "match": "(?<!\\.|\\$)\\b((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\\b(?!\\$)" + }, + { + "name": "support.class.promise.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Promise)\\b(?!\\$)" }, { "name": "support.function.js", - "match": "(?x)(?<!\\.|\\$)\\b(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|\n isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\\s*\\() " + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|\n isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\\s*\\()" }, { - "match": "(?x)(?<!\\.|\\$)\\b(Math)(?:\\s*(\\.)\\s*(?:\n (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|\n expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|\n round|sign|sin|sinh|sqrt|tan|tanh|trunc)\n |\n (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Math)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|\n expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|\n round|sign|sin|sinh|sqrt|tan|tanh|trunc)\n |\n (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\\b(?!\\$)", "captures": { "1": { "name": "support.constant.math.js" @@ -2270,15 +2804,18 @@ "name": "punctuation.accessor.js" }, "3": { - "name": "support.function.math.js" + "name": "punctuation.accessor.optional.js" }, "4": { + "name": "support.function.math.js" + }, + "5": { "name": "support.constant.property.math.js" } } }, { - "match": "(?x)(?<!\\.|\\$)\\b(console)(?:\\s*(\\.)\\s*(\n assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log\n |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(console)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(\n assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log\n |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\\b(?!\\$)", "captures": { "1": { "name": "support.class.console.js" @@ -2287,12 +2824,15 @@ "name": "punctuation.accessor.js" }, "3": { + "name": "punctuation.accessor.optional.js" + }, + "4": { "name": "support.function.console.js" } } }, { - "match": "(?<!\\.|\\$)\\b(JSON)(?:\\s*(\\.)\\s*(parse|stringify))?\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(JSON)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(parse|stringify))?\\b(?!\\$)", "captures": { "1": { "name": "support.constant.json.js" @@ -2301,26 +2841,66 @@ "name": "punctuation.accessor.js" }, "3": { + "name": "punctuation.accessor.optional.js" + }, + "4": { "name": "support.function.json.js" } } }, { - "match": "(?x) (\\.) \\s* (?:\n (constructor|length|prototype|__proto__) \n |\n (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(import)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(meta)\\b(?!\\$)", + "captures": { + "1": { + "name": "keyword.control.import.js" + }, + "2": { + "name": "punctuation.accessor.js" + }, + "3": { + "name": "punctuation.accessor.optional.js" + }, + "4": { + "name": "support.variable.property.importmeta.js" + } + } + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(target)\\b(?!\\$)", + "captures": { + "1": { + "name": "keyword.operator.new.js" + }, + "2": { + "name": "punctuation.accessor.js" + }, + "3": { + "name": "punctuation.accessor.optional.js" + }, + "4": { + "name": "support.variable.property.target.js" + } + } + }, + { + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s* (?:\n (constructor|length|prototype|__proto__)\n |\n (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\\b(?!\\$)", "captures": { "1": { "name": "punctuation.accessor.js" }, "2": { - "name": "support.variable.property.js" + "name": "punctuation.accessor.optional.js" }, "3": { + "name": "support.variable.property.js" + }, + "4": { "name": "support.constant.js" } } }, { - "match": "(?x) (?<!\\.|\\$) \\b (?:\n (document|event|navigator|performance|screen|window) \n |\n (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener\n |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule\n |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration\n |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern\n |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent\n |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException\n |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer\n |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry\n |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent\n |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential\n |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync\n |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement\n |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement\n |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement\n |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement\n |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement\n |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement\n |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement\n |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement\n |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement\n |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement\n |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement\n |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase\n |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction\n |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities\n |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess\n |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent\n |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream\n |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent\n |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID\n |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification\n |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential\n |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark\n |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList\n |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent\n |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList\n |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager\n |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource\n |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement\n |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength\n |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio\n |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement\n |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement\n |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement\n |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength\n |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement\n |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio\n |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList\n |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement\n |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement\n |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState\n |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet\n |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable\n |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer\n |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat\n |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES\n |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope\n |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult\n |XSLTProcessor))\\b(?!\\$)", + "match": "(?x) (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.)) \\b (?:\n (document|event|navigator|performance|screen|window)\n |\n (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener\n |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule\n |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration\n |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern\n |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent\n |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException\n |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer\n |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry\n |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent\n |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential\n |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync\n |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement\n |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement\n |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement\n |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement\n |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement\n |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement\n |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement\n |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement\n |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement\n |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement\n |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement\n |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase\n |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction\n |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities\n |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess\n |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent\n |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream\n |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent\n |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID\n |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification\n |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential\n |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark\n |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList\n |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent\n |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList\n |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager\n |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource\n |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement\n |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength\n |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio\n |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement\n |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement\n |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement\n |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength\n |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement\n |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio\n |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList\n |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement\n |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement\n |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState\n |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet\n |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable\n |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer\n |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat\n |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES\n |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope\n |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult\n |XSLTProcessor))\\b(?!\\$)", "captures": { "1": { "name": "support.variable.dom.js" @@ -2331,25 +2911,28 @@ } }, { - "match": "(?x) (\\.) \\s* (?:\n (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE\n |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR\n |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR\n |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)\n |\n (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName\n |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop\n |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor\n |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption\n |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear\n |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete\n |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset\n |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight\n |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds\n |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize\n |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host\n |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth\n |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext\n |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom\n |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple\n |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName\n |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight\n |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer\n |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling\n |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText\n |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts\n |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove\n |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary\n |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead\n |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile\n |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\\b(?!\\$|\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s* (?:\n (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE\n |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR\n |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR\n |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)\n |\n (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName\n |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop\n |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor\n |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption\n |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear\n |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete\n |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset\n |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight\n |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds\n |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize\n |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host\n |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth\n |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext\n |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom\n |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple\n |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName\n |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight\n |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer\n |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling\n |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText\n |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts\n |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove\n |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary\n |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead\n |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile\n |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\\b(?!\\$|\\s*(<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\\()", "captures": { "1": { "name": "punctuation.accessor.js" }, "2": { - "name": "support.constant.dom.js" + "name": "punctuation.accessor.optional.js" }, "3": { + "name": "support.constant.dom.js" + }, + "4": { "name": "support.variable.property.dom.js" } } }, { "name": "support.class.node.js", - "match": "(?x)(?<!\\.|\\$)\\b(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)" + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)" }, { - "match": "(?x)(?<!\\.|\\$)\\b(process)(?:(\\.)(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(process)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)", "captures": { "1": { "name": "support.variable.object.process.js" @@ -2358,15 +2941,18 @@ "name": "punctuation.accessor.js" }, "3": { - "name": "support.variable.property.process.js" + "name": "punctuation.accessor.optional.js" }, "4": { + "name": "support.variable.property.process.js" + }, + "5": { "name": "support.function.process.js" } } }, { - "match": "(?<!\\.|\\$)\\b(?:(exports)|(module)(?:(\\.)(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(exports)|(module)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)", "captures": { "1": { "name": "support.type.object.module.js" @@ -2378,88 +2964,39 @@ "name": "punctuation.accessor.js" }, "4": { + "name": "punctuation.accessor.optional.js" + }, + "5": { "name": "support.type.object.module.js" } } }, { "name": "support.variable.object.node.js", - "match": "(?<!\\.|\\$)\\b(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)" }, { - "match": "(?x) (\\.) \\s* \n(?:\n (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|\n Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|\n Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|\n Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|\n Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|\n Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|\n Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|\n Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\n ) |\n (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|\n scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|\n sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|\n Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|\n Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|\n savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|\n contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|\n createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|\n test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|\n untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|\n print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|\n fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|\n forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|\n abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|\n releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|\n Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|\n Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|\n moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back\n ) |\n (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|\n appendChild|appendData|before|blur|canPlayType|captureStream|\n caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|\n cloneContents|cloneNode|cloneRange|close|closest|collapse|\n compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|\n convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|\n createAttributeNS|createCaption|createCDATASection|createComment|\n createContextualFragment|createDocument|createDocumentFragment|\n createDocumentType|createElement|createElementNS|createEntityReference|\n createEvent|createExpression|createHTMLDocument|createNodeIterator|\n createNSResolver|createProcessingInstruction|createRange|createShadowRoot|\n createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|\n deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|\n deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|\n enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|\n exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|\n getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|\n getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|\n getClientRects|getContext|getDestinationInsertionPoints|getElementById|\n getElementsByClassName|getElementsByName|getElementsByTagName|\n getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|\n getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|\n hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|\n insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|\n insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|\n isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|\n lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|\n moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|\n parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|\n previousSibling|probablySupportsContext|queryCommandEnabled|\n queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|\n querySelector|querySelectorAll|registerContentHandler|registerElement|\n registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|\n removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|\n removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|\n requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|\n scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|\n setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|\n setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|\n setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|\n slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|\n submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|\n toDataURL|toggle|toString|values|write|writeln\n )\n)(?=\\s*\\()", + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s*\n(?:\n (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|\n Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|\n Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|\n Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|\n Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|\n Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|\n Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|\n Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\n ) |\n (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|\n scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|\n sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|\n Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|\n Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|\n savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|\n contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|\n createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|\n test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|\n untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|\n print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|\n fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|\n forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|\n abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|\n releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|\n Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|\n Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|\n moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back\n ) |\n (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|\n appendChild|appendData|before|blur|canPlayType|captureStream|\n caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|\n cloneContents|cloneNode|cloneRange|close|closest|collapse|\n compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|\n convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|\n createAttributeNS|createCaption|createCDATASection|createComment|\n createContextualFragment|createDocument|createDocumentFragment|\n createDocumentType|createElement|createElementNS|createEntityReference|\n createEvent|createExpression|createHTMLDocument|createNodeIterator|\n createNSResolver|createProcessingInstruction|createRange|createShadowRoot|\n createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|\n deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|\n deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|\n enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|\n exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|\n getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|\n getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|\n getClientRects|getContext|getDestinationInsertionPoints|getElementById|\n getElementsByClassName|getElementsByName|getElementsByTagName|\n getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|\n getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|\n hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|\n insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|\n insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|\n isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|\n lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|\n moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|\n parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|\n previousSibling|probablySupportsContext|queryCommandEnabled|\n queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|\n querySelector|querySelectorAll|registerContentHandler|registerElement|\n registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|\n removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|\n removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|\n requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|\n scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|\n setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|\n setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|\n setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|\n slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|\n submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|\n toDataURL|toggle|toString|values|write|writeln\n ) |\n (all|catch|finally|race|reject|resolve|then\n )\n)(?=\\s*\\()", "captures": { "1": { "name": "punctuation.accessor.js" }, "2": { - "name": "support.function.event-handler.js" + "name": "punctuation.accessor.optional.js" }, "3": { - "name": "support.function.js" + "name": "support.function.event-handler.js" }, "4": { - "name": "support.function.dom.js" - } - } - } - ] - }, - "function-call": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "end": "(?<=\\))(?!(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "patterns": [ - { - "name": "meta.function-call.js", - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*))", - "end": "(?=\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "patterns": [ - { - "include": "#literal" - }, - { - "include": "#support-objects" - }, - { - "include": "#object-identifiers" - }, - { - "include": "#punctuation-accessor" + "name": "support.function.js" }, - { - "name": "entity.name.function.js", - "match": "([_$[:alpha:]][_$[:alnum:]]*)" - } - ] - }, - { - "include": "#comment" - }, - { - "name": "meta.type.parameters.js", - "begin": "\\<", - "beginCaptures": { - "0": { - "name": "punctuation.definition.typeparameters.begin.js" - } - }, - "end": "\\>", - "endCaptures": { - "0": { - "name": "punctuation.definition.typeparameters.end.js" - } - }, - "patterns": [ - { - "include": "#type" + "5": { + "name": "support.function.dom.js" }, - { - "include": "#punctuation-comma" + "6": { + "name": "support.function.promise.js" } - ] - }, - { - "include": "#paren-expression" + } } ] }, @@ -2469,34 +3006,43 @@ "include": "#object-identifiers" }, { - "match": "(?x)(?:(\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n))", + "match": "(?x)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n))", "captures": { "1": { "name": "punctuation.accessor.js" }, "2": { + "name": "punctuation.accessor.optional.js" + }, + "3": { "name": "entity.name.function.js" } } }, { - "match": "(\\.)\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", "captures": { "1": { "name": "punctuation.accessor.js" }, "2": { + "name": "punctuation.accessor.optional.js" + }, + "3": { "name": "variable.other.constant.property.js" } } }, { - "match": "(\\.)\\s*([_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*([_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "punctuation.accessor.js" }, "2": { + "name": "punctuation.accessor.optional.js" + }, + "3": { "name": "variable.other.property.js" } } @@ -2515,24 +3061,27 @@ "patterns": [ { "name": "support.class.js", - "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\.\\s*prototype\\b(?!\\$))" + "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\??\\.\\s*prototype\\b(?!\\$))" }, { - "match": "(?x)(\\.)\\s*(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?x)(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "punctuation.accessor.js" }, "2": { - "name": "variable.other.constant.object.property.js" + "name": "punctuation.accessor.optional.js" }, "3": { + "name": "variable.other.constant.object.property.js" + }, + "4": { "name": "variable.other.object.property.js" } } }, { - "match": "(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "variable.other.constant.object.js" @@ -2544,349 +3093,519 @@ } ] }, - "cast": { - "patterns": [ - { - "include": "#jsx" - } - ] - }, - "new-expr": { - "name": "new.expr.js", - "begin": "(?<!\\.|\\$)\\b(new)\\b(?!\\$|\\.)", - "beginCaptures": { - "1": { - "name": "keyword.operator.new.js" - } - }, - "end": "(?<=\\))|(?=[;),}]|$|((?<!\\.|\\$)\\bnew\\b(?!\\$|\\.))|((?<!\\.|\\$)\\bfunction((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", - "patterns": [ - { - "include": "#paren-expression" - }, - { - "include": "#class-or-interface-declaration" - }, - { - "include": "#type" - } - ] - }, - "object-member": { + "type-annotation": { "patterns": [ { - "include": "#comment" - }, - { - "include": "#object-literal-method-declaration" - }, - { - "name": "meta.object.member.js", - "begin": "(?=(?:(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(?:\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*:)", - "end": "(?=,|\\})", + "name": "meta.type.annotation.js", + "begin": "(:)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.js" + } + }, + "end": "(?<![:|&])((?=$|^|[,);\\}\\]]|//)|(?==[^>])|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", "patterns": [ { - "name": "meta.object-literal.key.js", - "begin": "(?=(?:(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(?:\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*:)", - "end": ":", - "endCaptures": { - "0": { - "name": "punctuation.separator.key-value.js" - } - }, - "patterns": [ - { - "include": "#string" - }, - { - "include": "#array-literal" - } - ] - }, - { - "include": "#expression" + "include": "#type" } ] }, { - "name": "meta.object.member.js", - "begin": "(?![_$[:alpha:]])([[:digit:]]+)\\s*(:)", + "name": "meta.type.annotation.js", + "begin": "(:)", "beginCaptures": { - "0": { - "name": "meta.object-literal.key.js" - }, "1": { - "name": "constant.numeric.decimal.js" - }, - "2": { - "name": "punctuation.separator.key-value.js" + "name": "keyword.operator.type.annotation.js" } }, - "end": "(?=,|\\})", + "end": "(?<![:|&])((?=[,);\\}\\]]|//)|(?==[^>])|(?=^\\s*$)|((?<=\\S)(?=\\s*$))|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", "patterns": [ { - "include": "#expression" + "include": "#type" } ] - }, + } + ] + }, + "return-type": { + "patterns": [ { - "name": "meta.object.member.js", - "begin": "(?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)(?=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n)))", + "name": "meta.return.type.js", + "begin": "(?<=\\))\\s*(:)(?=\\s*\\S)", "beginCaptures": { - "0": { - "name": "meta.object-literal.key.js" - }, "1": { - "name": "entity.name.function.js" - }, - "2": { - "name": "punctuation.separator.key-value.js" + "name": "keyword.operator.type.annotation.js" } }, - "end": "(?=,|\\})", + "end": "(?<![:|&])(?=$|^|[{};,]|//)", "patterns": [ { - "include": "#expression" + "include": "#return-type-core" } ] }, { - "name": "meta.object.member.js", - "begin": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(:)", + "name": "meta.return.type.js", + "begin": "(?<=\\))\\s*(:)", "beginCaptures": { - "0": { - "name": "meta.object-literal.key.js" - }, "1": { - "name": "punctuation.separator.key-value.js" + "name": "keyword.operator.type.annotation.js" } }, - "end": "(?=,|\\})", + "end": "(?<![:|&])((?=[{};,]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", "patterns": [ { - "include": "#expression" + "include": "#return-type-core" } ] + } + ] + }, + "return-type-core": { + "patterns": [ + { + "include": "#comment" }, { - "name": "meta.object.member.js", - "begin": "\\.\\.\\.", - "beginCaptures": { - "0": { - "name": "keyword.operator.spread.js" - } - }, - "end": "(?=,|\\})", + "begin": "(?<=[:|&])(?=\\s*\\{)", + "end": "(?<=\\})", "patterns": [ { - "include": "#expression" + "include": "#type-object" } ] }, { - "name": "meta.object.member.js", - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$)", - "captures": { - "1": { - "name": "variable.other.readwrite.js" + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "arrow-return-type": { + "name": "meta.return.type.arrow.js", + "begin": "(?<=\\))\\s*(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.js" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "possibly-arrow-return-type": { + "begin": "(?<=\\))\\s*(:)(?=\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+\\s*=>)", + "beginCaptures": { + "1": { + "name": "meta.arrow.js meta.return.type.arrow.js keyword.operator.type.annotation.js" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "contentName": "meta.arrow.js meta.return.type.arrow.js", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "arrow-return-type-body": { + "patterns": [ + { + "begin": "(?<=[:])(?=\\s*\\{)", + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" } - } + ] + }, + { + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "type-parameters": { + "name": "meta.type.parameters.js", + "begin": "(<)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.begin.js" + } + }, + "end": "(>)", + "endCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.end.js" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "name": "storage.modifier.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(extends)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "include": "#type" }, { "include": "#punctuation-comma" } ] }, - "expression-operators": { + "type-arguments": { + "name": "meta.type.parameters.js", + "begin": "\\<", + "beginCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.begin.js" + } + }, + "end": "\\>", + "endCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.end.js" + } + }, "patterns": [ { - "name": "keyword.control.flow.js", - "match": "(?<!\\.|\\$)\\b(await)\\b(?!\\$|\\.)" + "include": "#type" }, { - "match": "(?<!\\.|\\$)\\b(yield)\\b(?!\\$|\\.)(?:\\s*(\\*))?", - "captures": { - "1": { - "name": "keyword.control.flow.js" - }, - "2": { - "name": "keyword.generator.asterisk.js" - } - } + "include": "#punctuation-comma" + } + ] + }, + "type": { + "patterns": [ + { + "include": "#comment" }, { - "name": "keyword.operator.expression.delete.js", - "match": "(?<!\\.|\\$)\\bdelete\\b(?!\\$|\\.)" + "include": "#string" }, { - "name": "keyword.operator.expression.in.js", - "match": "(?<!\\.|\\$)\\bin\\b(?!\\$|\\.)" + "include": "#numeric-literal" }, { - "name": "keyword.operator.expression.of.js", - "match": "(?<!\\.|\\$)\\bof\\b(?!\\$|\\.)" + "include": "#type-primitive" }, { - "name": "keyword.operator.expression.instanceof.js", - "match": "(?<!\\.|\\$)\\binstanceof\\b(?!\\$|\\.)" + "include": "#type-builtin-literals" }, { - "name": "keyword.operator.new.js", - "match": "(?<!\\.|\\$)\\bnew\\b(?!\\$|\\.)" + "include": "#type-parameters" }, { - "include": "#typeof-operator" + "include": "#type-tuple" }, { - "name": "keyword.operator.expression.void.js", - "match": "(?<!\\.|\\$)\\bvoid\\b(?!\\$|\\.)" + "include": "#type-object" }, { - "begin": "(?<!\\.|\\$)\\b(as)\\s+", - "beginCaptures": { - "1": { - "name": "keyword.control.as.js" - } - }, - "end": "(?=$|^|[;,:})\\]])", - "patterns": [ - { - "include": "#type" - } - ] + "include": "#type-conditional" }, { - "name": "keyword.operator.spread.js", - "match": "\\.\\.\\." + "include": "#type-operators" }, { - "name": "keyword.operator.assignment.compound.js", - "match": "\\*=|(?<!\\()/=|%=|\\+=|\\-=" + "include": "#type-fn-type-parameters" }, { - "name": "keyword.operator.assignment.compound.bitwise.js", - "match": "\\&=|\\^=|<<=|>>=|>>>=|\\|=" + "include": "#type-paren-or-function-parameters" }, { - "name": "keyword.operator.bitwise.shift.js", - "match": "<<|>>>|>>" + "include": "#type-function-return-type" }, { - "name": "keyword.operator.comparison.js", - "match": "===|!==|==|!=" + "include": "#type-name" + } + ] + }, + "type-primitive": { + "name": "support.type.primitive.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(string|number|boolean|symbol|any|void|never)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-builtin-literals": { + "name": "support.type.builtin.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(this|true|false|undefined|null|object)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-tuple": { + "name": "meta.type.tuple.js", + "begin": "\\[", + "beginCaptures": { + "0": { + "name": "meta.brace.square.js" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "meta.brace.square.js" + } + }, + "patterns": [ + { + "include": "#type" }, { - "name": "keyword.operator.relational.js", - "match": "<=|>=|<>|<|>" + "include": "#punctuation-comma" + } + ] + }, + "type-object": { + "name": "meta.object.type.js", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js" + } + }, + "patterns": [ + { + "include": "#comment" }, { - "name": "keyword.operator.logical.js", - "match": "\\!|&&|\\|\\|" + "include": "#method-declaration" }, { - "name": "keyword.operator.bitwise.js", - "match": "\\&|~|\\^|\\|" + "include": "#indexer-declaration" }, { - "name": "keyword.operator.assignment.js", - "match": "\\=" + "include": "#indexer-mapped-type-declaration" }, { - "name": "keyword.operator.decrement.js", - "match": "--" + "include": "#field-declaration" }, { - "name": "keyword.operator.increment.js", - "match": "\\+\\+" + "include": "#type-annotation" }, { - "name": "keyword.operator.arithmetic.js", - "match": "%|\\*|/|-|\\+" + "begin": "\\.\\.\\.", + "beginCaptures": { + "0": { + "name": "keyword.operator.spread.js" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#type" + } + ] }, { - "match": "(?<=[_$[:alnum:])])\\s*(/)(?![/*])", - "captures": { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-semicolon" + }, + { + "include": "#type" + } + ] + }, + "type-conditional": { + "patterns": [ + { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(extends)\\s+", + "beginCaptures": { "1": { - "name": "keyword.operator.arithmetic.js" + "name": "storage.modifier.js" } - } + }, + "end": "(?<=:)", + "patterns": [ + { + "begin": "\\?", + "beginCaptures": { + "0": { + "name": "keyword.operator.ternary.js" + } + }, + "end": ":", + "endCaptures": { + "0": { + "name": "keyword.operator.ternary.js" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "include": "#type" + } + ] } ] }, - "typeof-operator": { - "name": "keyword.operator.expression.typeof.js", - "match": "(?<!\\.|\\$)\\btypeof\\b(?!\\$|\\.)" - }, - "arrow-function": { + "type-paren-or-function-parameters": { + "name": "meta.type.paren.cover.js", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.js" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js" + } + }, "patterns": [ { - "name": "meta.arrow.js", - "match": "(?:(?<!\\.|\\$)(\\basync)\\s+)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)", + "include": "#destructuring-parameter" + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=\\s*(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)))", "captures": { "1": { - "name": "storage.modifier.async.js" + "name": "storage.modifier.js" + }, + "2": { + "name": "keyword.operator.rest.js" + }, + "3": { + "name": "entity.name.function.js variable.language.this.js" + }, + "4": { + "name": "entity.name.function.js" + }, + "5": { + "name": "keyword.operator.optional.js" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=:)", + "captures": { + "1": { + "name": "storage.modifier.js" }, "2": { + "name": "keyword.operator.rest.js" + }, + "3": { + "name": "variable.parameter.js variable.language.this.js" + }, + "4": { "name": "variable.parameter.js" + }, + "5": { + "name": "keyword.operator.optional.js" } } }, { - "name": "meta.arrow.js", - "begin": "(?x) (?:\n (?<!\\.|\\$)(\\basync)\n)? ((?<![})!\\]])\\s*\n (?=\n # sure shot arrow functions even if => is on new line\n (\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n ) |\n (\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends \n ) |\n # arrow function possible to detect only with => on same line\n (\n (<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)? # typeparameters\n \\(([^()]|\\([^()]*\\))*\\) # parameteres\n (\\s*:\\s*(.)*)? # return type\n \\s*=> # arrow operator\n )\n )\n)", + "include": "#type-annotation" + }, + { + "name": "punctuation.separator.parameter.js", + "match": "," + }, + { + "include": "#type" + } + ] + }, + "type-fn-type-parameters": { + "patterns": [ + { + "name": "meta.type.constructor.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\b(?=\\s*\\<)", + "captures": { + "1": { + "name": "keyword.control.new.js" + } + } + }, + { + "name": "meta.type.constructor.js", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\b\\s*(?=\\()", "beginCaptures": { "1": { - "name": "storage.modifier.async.js" + "name": "keyword.control.new.js" } }, - "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "end": "(?<=\\))", "patterns": [ { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, + "include": "#function-parameters" + } + ] + }, + { + "name": "meta.type.function.js", + "begin": "(?x)(\n (?=\n [(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n )\n )\n)", + "end": "(?<=\\))", + "patterns": [ { "include": "#function-parameters" - }, + } + ] + } + ] + }, + "type-function-return-type": { + "patterns": [ + { + "name": "meta.type.function.return.js", + "begin": "(=>)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "storage.type.function.arrow.js" + } + }, + "end": "(?<!=>)(?<![|&])(?=[,\\]\\)\\{\\}=;>:\\?]|//|$)", + "patterns": [ { - "include": "#arrow-return-type" + "include": "#type-function-return-type-core" } ] }, { - "name": "meta.arrow.js", + "name": "meta.type.function.return.js", "begin": "=>", "beginCaptures": { "0": { "name": "storage.type.function.arrow.js" } }, - "end": "(?<=\\}|\\S)(?<!=>)|((?!\\{)(?=\\S))", + "end": "(?<!=>)(?<![|&])((?=[,\\]\\)\\{\\}=;:\\?>]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", "patterns": [ { - "include": "#decl-block" - }, - { - "include": "#expression" + "include": "#type-function-return-type-core" } ] } ] }, - "arrow-return-type": { - "name": "meta.return.type.arrow.js", - "begin": "(?<=\\))\\s*(:)", - "beginCaptures": { - "1": { - "name": "keyword.operator.type.annotation.js" - } - }, - "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "type-function-return-type-core": { "patterns": [ { - "begin": "(?<=[:])(?=\\s*\\{)", + "include": "#comment" + }, + { + "begin": "(?<==>)(?=\\s*\\{)", "end": "(?<=\\})", "patterns": [ { @@ -2902,6 +3621,84 @@ } ] }, + "type-operators": { + "patterns": [ + { + "include": "#typeof-operator" + }, + { + "begin": "(?:([&|])|(=(?!>)))(?=\\s*\\{)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.js" + }, + "2": { + "name": "keyword.operator.assignment.js" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "begin": "([&|])|(=(?!>))", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.js" + }, + "2": { + "name": "keyword.operator.assignment.js" + } + }, + "end": "(?=\\S)" + }, + { + "name": "keyword.operator.expression.keyof.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))keyof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.operator.ternary.js", + "match": "(\\?|\\:)" + }, + { + "name": "keyword.operator.expression.infer.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))infer(?=\\s+[_$[:alpha:]])" + }, + { + "name": "keyword.operator.expression.import.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))import(?=\\s*\\()" + } + ] + }, + "type-predicate-operator": { + "name": "keyword.operator.expression.is.js", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))is(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-name": { + "patterns": [ + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "entity.name.type.module.js" + }, + "2": { + "name": "punctuation.accessor.js" + }, + "3": { + "name": "punctuation.accessor.optional.js" + } + } + }, + { + "name": "entity.name.type.js", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + } + ] + }, "punctuation-comma": { "name": "punctuation.separator.comma.js", "match": "," @@ -2911,28 +3708,23 @@ "match": ";" }, "punctuation-accessor": { - "name": "punctuation.accessor.js", - "match": "\\." - }, - "paren-expression": { - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "meta.brace.round.js" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.js" + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "punctuation.accessor.js" + }, + "2": { + "name": "punctuation.accessor.optional.js" } - }, + } + }, + "string": { "patterns": [ { - "include": "#expression" + "include": "#qstring-single" }, { - "include": "#punctuation-comma" + "include": "#qstring-double" } ] }, @@ -2982,17 +3774,87 @@ } ] }, + "string-character-escape": { + "name": "constant.character.escape.js", + "match": "\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" + }, + "template": { + "patterns": [ + { + "name": "string.template.js", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.js" + } + }, + "end": "(?=`)", + "patterns": [ + { + "include": "#type-arguments" + } + ] + }, + { + "name": "string.template.js", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.js" + }, + "2": { + "name": "punctuation.definition.string.template.begin.js" + } + }, + "end": "`", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.template.end.js" + } + }, + "patterns": [ + { + "include": "#template-substitution-element" + }, + { + "include": "#string-character-escape" + } + ] + } + ] + }, + "template-substitution-element": { + "name": "meta.template.expression.js", + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.template-expression.begin.js" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.template-expression.end.js" + } + }, + "patterns": [ + { + "include": "#expression" + } + ], + "contentName": "meta.embedded.line.js" + }, "regex": { "patterns": [ { "name": "string.regexp.js", - "begin": "(?<=[=(:,\\[?+!]|return|case|=>|&&|\\|\\||\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/(?![\\/*])[gimy]*(?!\\s*[a-zA-Z0-9_$]))", + "begin": "(?<!\\+\\+|--)(?<=[=(:,\\[?+!]|^return|[^\\._$[:alnum:]]return|^case|[^\\._$[:alnum:]]case|=>|&&|\\|\\||\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))", "beginCaptures": { "1": { "name": "punctuation.definition.string.begin.js" } }, - "end": "(/)([gimuy]*)", + "end": "(/)([gimsuy]*)", "endCaptures": { "1": { "name": "punctuation.definition.string.end.js" @@ -3009,13 +3871,13 @@ }, { "name": "string.regexp.js", - "begin": "(?<![_$[:alnum:])])\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/(?![\\/*])[gimy]*(?!\\s*[a-zA-Z0-9_$]))", + "begin": "(?<![_$[:alnum:])\\]]|\\+\\+|--)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.js" } }, - "end": "(/)([gimuy]*)", + "end": "(/)([gimsuy]*)", "endCaptures": { "1": { "name": "punctuation.definition.string.end.js" @@ -3039,8 +3901,15 @@ "match": "\\\\[bB]|\\^|\\$" }, { - "name": "keyword.other.back-reference.regexp", - "match": "\\\\[1-9]\\d*" + "match": "\\\\[1-9]\\d*|\\\\k<([a-zA-Z_$][\\w$]*)>", + "captures": { + "0": { + "name": "keyword.other.back-reference.regexp" + }, + "1": { + "name": "variable.other.regexp" + } + } }, { "name": "keyword.operator.quantifier.regexp", @@ -3052,7 +3921,7 @@ }, { "name": "meta.group.assertion.regexp", - "begin": "(\\()((\\?=)|(\\?!))", + "begin": "(\\()((\\?=)|(\\?!)|(\\?<=)|(\\?<!))", "beginCaptures": { "1": { "name": "punctuation.definition.group.regexp" @@ -3065,6 +3934,12 @@ }, "4": { "name": "meta.assertion.negative-look-ahead.regexp" + }, + "5": { + "name": "meta.assertion.look-behind.regexp" + }, + "6": { + "name": "meta.assertion.negative-look-behind.regexp" } }, "end": "(\\))", @@ -3081,13 +3956,16 @@ }, { "name": "meta.group.regexp", - "begin": "\\((\\?:)?", + "begin": "\\((?:(\\?:)|(?:\\?<([a-zA-Z_$][\\w$]*)>))?", "beginCaptures": { "0": { "name": "punctuation.definition.group.regexp" }, "1": { - "name": "punctuation.definition.group.capture.regexp" + "name": "punctuation.definition.group.no-capture.regexp" + }, + "2": { + "name": "variable.other.regexp" } }, "end": "\\)", @@ -3122,7 +4000,7 @@ "patterns": [ { "name": "constant.other.character-class.range.regexp", - "match": "(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))", + "match": "(?:.|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))", "captures": { "1": { "name": "constant.character.numeric.regexp" @@ -3162,7 +4040,7 @@ }, { "name": "constant.character.numeric.regexp", - "match": "\\\\([0-7]{3}|x\\h\\h|u\\h\\h\\h\\h)" + "match": "\\\\([0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4})" }, { "name": "constant.character.control.regexp", @@ -3174,207 +4052,6 @@ } ] }, - "string": { - "patterns": [ - { - "include": "#qstring-single" - }, - { - "include": "#qstring-double" - } - ] - }, - "template": { - "name": "string.template.js", - "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", - "beginCaptures": { - "1": { - "name": "entity.name.function.tagged-template.js" - }, - "2": { - "name": "punctuation.definition.string.template.begin.js" - } - }, - "end": "`", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.template.end.js" - } - }, - "patterns": [ - { - "include": "#template-substitution-element" - }, - { - "include": "#string-character-escape" - } - ] - }, - "string-character-escape": { - "name": "constant.character.escape.js", - "match": "\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" - }, - "template-substitution-element": { - "name": "meta.template.expression.js", - "begin": "\\$\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.template-expression.begin.js" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.template-expression.end.js" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] - }, - "literal": { - "patterns": [ - { - "include": "#numeric-literal" - }, - { - "include": "#boolean-literal" - }, - { - "include": "#null-literal" - }, - { - "include": "#undefined-literal" - }, - { - "include": "#numericConstant-literal" - }, - { - "include": "#array-literal" - }, - { - "include": "#this-literal" - }, - { - "include": "#super-literal" - } - ] - }, - "array-literal": { - "name": "meta.array.literal.js", - "begin": "\\[", - "beginCaptures": { - "0": { - "name": "meta.brace.square.js" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "meta.brace.square.js" - } - }, - "patterns": [ - { - "include": "#expression" - }, - { - "include": "#punctuation-comma" - } - ] - }, - "numeric-literal": { - "patterns": [ - { - "name": "constant.numeric.hex.js", - "match": "\\b(?<!\\$)0(x|X)[0-9a-fA-F]+\\b(?!\\$)" - }, - { - "name": "constant.numeric.binary.js", - "match": "\\b(?<!\\$)0(b|B)[01]+\\b(?!\\$)" - }, - { - "name": "constant.numeric.octal.js", - "match": "\\b(?<!\\$)0(o|O)?[0-7]+\\b(?!\\$)" - }, - { - "match": "(?x)\n(?<!\\$)(?:\n (?:\\b[0-9]+(\\.)[0-9]+[eE][+-]?[0-9]+\\b)| # 1.1E+3\n (?:\\b[0-9]+(\\.)[eE][+-]?[0-9]+\\b)| # 1.E+3\n (?:\\B(\\.)[0-9]+[eE][+-]?[0-9]+\\b)| # .1E+3\n (?:\\b[0-9]+[eE][+-]?[0-9]+\\b)| # 1E+3\n (?:\\b[0-9]+(\\.)[0-9]+\\b)| # 1.1\n (?:\\b[0-9]+(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9]+\\b)| # .1\n (?:\\b[0-9]+\\b(?!\\.)) # 1\n)(?!\\$)", - "captures": { - "0": { - "name": "constant.numeric.decimal.js" - }, - "1": { - "name": "meta.delimiter.decimal.period.js" - }, - "2": { - "name": "meta.delimiter.decimal.period.js" - }, - "3": { - "name": "meta.delimiter.decimal.period.js" - }, - "4": { - "name": "meta.delimiter.decimal.period.js" - }, - "5": { - "name": "meta.delimiter.decimal.period.js" - }, - "6": { - "name": "meta.delimiter.decimal.period.js" - } - } - } - ] - }, - "boolean-literal": { - "patterns": [ - { - "name": "constant.language.boolean.true.js", - "match": "(?<!\\.|\\$)\\btrue\\b(?!\\$)" - }, - { - "name": "constant.language.boolean.false.js", - "match": "(?<!\\.|\\$)\\bfalse\\b(?!\\$)" - } - ] - }, - "null-literal": { - "name": "constant.language.null.js", - "match": "(?<!\\.|\\$)\\bnull\\b(?!\\$)" - }, - "this-literal": { - "name": "variable.language.this.js", - "match": "(?<!\\.|\\$)\\bthis\\b(?!\\$)" - }, - "super-literal": { - "name": "variable.language.super.js", - "match": "(?<!\\.|\\$)\\bsuper\\b(?!\\$)" - }, - "undefined-literal": { - "name": "constant.language.undefined.js", - "match": "(?<!\\.|\\$)\\bundefined\\b(?!\\$)" - }, - "numericConstant-literal": { - "patterns": [ - { - "name": "constant.language.nan.js", - "match": "(?<!\\.|\\$)\\bNaN\\b(?!\\$)" - }, - { - "name": "constant.language.infinity.js", - "match": "(?<!\\.|\\$)\\bInfinity\\b(?!\\$)" - } - ] - }, - "access-modifier": { - "name": "storage.modifier.js", - "match": "(?<!\\.|\\$)\\b(abstract|public|protected|private|readonly|static)\\b(?!\\$|\\.)" - }, - "property-accessor": { - "name": "storage.type.property.js", - "match": "(?<!\\.|\\$)\\b(get|set)\\b(?!\\$|\\.)" - }, "comment": { "patterns": [ { @@ -3399,10 +4076,16 @@ }, { "name": "comment.block.js", - "begin": "/\\*", + "begin": "(/\\*)(?:\\s*((@)internal)(?=\\s|(\\*/)))?", "beginCaptures": { - "0": { + "1": { "name": "punctuation.definition.comment.js" + }, + "2": { + "name": "storage.type.internaldeclaration.js" + }, + "3": { + "name": "punctuation.decorator.internaldeclaration.js" } }, "end": "\\*/", @@ -3413,23 +4096,32 @@ } }, { - "begin": "(^[ \\t]+)?(//)", + "begin": "(^[ \\t]+)?((//)(?:\\s*((@)internal)(?=\\s|$))?)", "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.js" }, "2": { - "name": "comment.line.double-slash.js punctuation.definition.comment.js" + "name": "comment.line.double-slash.js" + }, + "3": { + "name": "punctuation.definition.comment.js" + }, + "4": { + "name": "storage.type.internaldeclaration.js" + }, + "5": { + "name": "punctuation.decorator.internaldeclaration.js" } }, "end": "(?=^)", - "contentName": "comment.line.double-slash.tsx" + "contentName": "comment.line.double-slash.js" } ] }, "directives": { "name": "comment.line.triple-slash.directive.js", - "begin": "^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|name)\\s*=\\s*((\\'[^']*\\')|(\\\"[^\"]*\\\")))+\\s*/>\\s*$)", + "begin": "^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|name)\\s*=\\s*((\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")))+\\s*/>\\s*$)", "beginCaptures": { "1": { "name": "punctuation.definition.comment.js" @@ -3473,7 +4165,7 @@ "docblock": { "patterns": [ { - "match": "(?x)\n((@)access)\n\\s+\n(private|protected|public)\n\\b", + "match": "(?x)\n((@)(?:access|api))\n\\s+\n(private|protected|public)\n\\b", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3597,7 +4289,7 @@ } }, { - "match": "(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!https?://)\n (?:[^@\\s*/]|\\*[^/])+\n )\n)", + "match": "(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!\n # Avoid matching bare URIs (also acceptable as links)\n https?://\n |\n # Avoid matching {@inline tags}; we match those below\n (?:\\[[^\\[\\]]*\\])? # Possible description [preceding]{@tag}\n {@(?:link|linkcode|linkplain|tutorial)\\b\n )\n # Matched namepath\n (?:[^@\\s*/]|\\*[^/])+\n )\n)", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3614,7 +4306,7 @@ } }, { - "match": "(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(?:\n ([A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]*) # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* (,) \\s*\n ([A-Za-z_$]\n [\\w$.\\[\\]]*)\n )*\n)", + "match": "(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(\n [A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]* # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* , \\s*\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n )*\n)", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3624,12 +4316,6 @@ }, "3": { "name": "variable.other.jsdoc" - }, - "4": { - "name": "punctuation.delimiter.object.comma.jsdoc" - }, - "5": { - "name": "variable.other.jsdoc" } } }, @@ -3689,32 +4375,29 @@ }, { "name": "variable.other.jsdoc", - "begin": "\\[", - "end": "\\]|(?=\\*/)", - "patterns": [ - { - "match": "(=)((?:[^\\]*]|\\*[^/])*)", - "captures": { - "1": { - "name": "keyword.operator.assignment.jsdoc" - }, - "2": { - "name": "source.embedded.js" - } - } + "match": "(?x)\n(\\[)\\s*\n[\\w$]+\n(?:\n (?:\\[\\])? # Foo[ ].bar properties within an array\n \\. # Foo.Bar namespaced parameter\n [\\w$]+\n)*\n(?:\n \\s*\n (=) # [foo=bar] Default parameter value\n \\s*\n (\n # The inner regexes are to stop the match early at */ and to not stop at escaped quotes\n (?>\n \"(?:(?:\\*(?!/))|(?:\\\\(?!\"))|[^*\\\\])*?\" | # [foo=\"bar\"] Double-quoted\n '(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted\n \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal\n (?:(?:\\*(?!/))|\\s(?!\\s*\\])|\\[.*?(?:\\]|(?=\\*/))|[^*\\s\\[\\]])* # Everything else\n )*\n )\n)?\n\\s*(?:(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/))", + "captures": { + "1": { + "name": "punctuation.definition.optional-value.begin.bracket.square.jsdoc" }, - { - "include": "#brackets" + "2": { + "name": "keyword.operator.assignment.jsdoc" }, - { - "include": "#quotes" + "3": { + "name": "source.embedded.js" + }, + "4": { + "name": "punctuation.definition.optional-value.end.bracket.square.jsdoc" + }, + "5": { + "name": "invalid.illegal.syntax.jsdoc" } - ] + } } ] }, { - "begin": "((@)(?:define|enum|exception|implements|modifies|namespace|private|protected|returns?|suppress|throws|type))\\s+(?={)", + "begin": "(?x)\n(\n (@)\n (?:define|enum|exception|export|extends|lends|implements|modifies\n |namespace|private|protected|returns?|suppress|this|throws|type\n |yields?)\n)\n\\s+(?={)", "beginCaptures": { "1": { "name": "storage.type.class.jsdoc" @@ -3787,7 +4470,7 @@ }, { "name": "storage.type.class.jsdoc", - "match": "(?x) (@) (?:abstract|access|alias|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|global|host|ignore|implements|implicitCast|inherit[Dd]oc|inner|instance|interface|kind |lends|license|listens|main|member|memberof!?|method|mixes|mixins?|modifies|module|name|namespace |noalias|nocollapse|nocompile|nosideeffects|override|overview|package|param|preserve|private|prop |property|protected|public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule |summary|suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce) \\b", + "match": "(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \\b", "captures": { "1": { "name": "punctuation.definition.block.tag.jsdoc" @@ -3882,28 +4565,6 @@ } ] }, - "quotes": { - "patterns": [ - { - "begin": "'", - "end": "'|(?=\\*/)", - "patterns": [ - { - "include": "#quotes" - } - ] - }, - { - "begin": "\"", - "end": "\"|(?=\\*/)", - "patterns": [ - { - "include": "#quotes" - } - ] - } - ] - }, "jsdoctype": { "patterns": [ { @@ -3938,136 +4599,46 @@ } ] }, - "jsx-tag-attributes": { - "patterns": [ - { - "include": "#jsx-tag-attribute-name" - }, - { - "include": "#jsx-tag-attribute-assignment" - }, - { - "include": "#jsx-string-double-quoted" - }, - { - "include": "#jsx-string-single-quoted" - }, - { - "include": "#jsx-evaluated-code" - } - ] - }, - "jsx-tag-attribute-name": { - "match": "(?x)\n \\s*\n ([_$a-zA-Z][-$\\w]*)\n (?=\\s|=|/?>|/\\*|//)", - "captures": { - "1": { - "name": "entity.other.attribute-name.js" - } - } - }, - "jsx-tag-attribute-assignment": { - "name": "keyword.operator.assignment.js", - "match": "=(?=\\s*(?:'|\"|{|/\\*|//|\\n))" - }, - "jsx-string-double-quoted": { - "name": "string.quoted.double.js", - "begin": "\"", - "end": "\"", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.js" - } - }, - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.js" - } - }, - "patterns": [ - { - "include": "#jsx-entities" - } - ] - }, - "jsx-string-single-quoted": { - "name": "string.quoted.single.js", - "begin": "'", - "end": "'", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.js" - } - }, - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.js" - } - }, - "patterns": [ - { - "include": "#jsx-entities" - } - ] - }, - "jsx-entities": { + "jsx": { "patterns": [ { - "name": "constant.character.entity.js", - "match": "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)", - "captures": { - "1": { - "name": "punctuation.definition.entity.js" - }, - "3": { - "name": "punctuation.definition.entity.js" - } - } + "include": "#jsx-tag-without-attributes-in-expression" }, { - "name": "invalid.illegal.bad-ampersand.js", - "match": "&" + "include": "#jsx-tag-in-expression" } ] }, - "jsx-evaluated-code": { - "name": "meta.embedded.expression.js", - "begin": "\\{", - "end": "\\}", - "beginCaptures": { - "0": { - "name": "punctuation.section.embedded.begin.js" - } - }, - "endCaptures": { - "0": { - "name": "punctuation.section.embedded.end.js" - } - }, + "jsx-tag-without-attributes-in-expression": { + "begin": "(?<!\\+\\+|--)(?<=[({\\[,?=>:*]|&&|\\|\\||\\?|^return|[^\\._$[:alnum:]]return|^default|[^\\._$[:alnum:]]default|^)\\s*(?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", + "end": "(?!(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", "patterns": [ { - "include": "#expression" + "include": "#jsx-tag-without-attributes" } ] }, - "jsx-tag-attributes-illegal": { - "name": "invalid.illegal.attribute.js", - "match": "\\S+" - }, "jsx-tag-without-attributes": { "name": "meta.tag.without-attributes.js", - "begin": "(<)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\\s*(>)", - "end": "(</)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\\s*(>)", + "begin": "(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>)", + "end": "(</)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>)", "beginCaptures": { "1": { "name": "punctuation.definition.tag.begin.js" }, "2": { - "name": "entity.name.tag.js" + "name": "entity.name.tag.namespace.js" }, "3": { - "name": "support.class.component.js" + "name": "punctuation.separator.namespace.js" }, "4": { + "name": "entity.name.tag.js" + }, + "5": { + "name": "support.class.component.js" + }, + "6": { "name": "punctuation.definition.tag.end.js" } }, @@ -4076,16 +4647,22 @@ "name": "punctuation.definition.tag.begin.js" }, "2": { - "name": "entity.name.tag.js" + "name": "entity.name.tag.namespace.js" }, "3": { - "name": "support.class.component.js" + "name": "punctuation.separator.namespace.js" }, "4": { + "name": "entity.name.tag.js" + }, + "5": { + "name": "support.class.component.js" + }, + "6": { "name": "punctuation.definition.tag.end.js" } }, - "contentName": "meta.jsx.children.tsx", + "contentName": "meta.jsx.children.js", "patterns": [ { "include": "#jsx-children" @@ -4093,41 +4670,19 @@ ] }, "jsx-tag-in-expression": { - "begin": "(?x)\n (?<=[({\\[,?=>:*]|&&|\\|\\||\\?|\\Wreturn|^return|\\Wdefault|^)\\s*\n (?!(<)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>)) #look ahead is not start of tag without attributes\n (?!<\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=>])|,)) # look ahead is not type parameter of arrow\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))", - "end": "(/>)|(?:(</)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\\s*(>))", - "endCaptures": { - "0": { - "name": "meta.tag.js" - }, - "1": { - "name": "punctuation.definition.tag.end.js" - }, - "2": { - "name": "punctuation.definition.tag.begin.js" - }, - "3": { - "name": "entity.name.tag.js" - }, - "4": { - "name": "support.class.component.js" - }, - "5": { - "name": "punctuation.definition.tag.end.js" - } - }, + "begin": "(?x)\n (?<!\\+\\+|--)(?<=[({\\[,?=>:*]|&&|\\|\\||\\?|^return|[^\\._$[:alnum:]]return|^default|[^\\._$[:alnum:]]default|^)\\s*\n (?!<\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=>])|,)) # look ahead is not type parameter of arrow\n (?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", + "end": "(?!(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", "patterns": [ { "include": "#jsx-tag" } ] }, - "jsx-child-tag": { - "begin": "(?x)\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))", - "end": "(/>)|(?:(</)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\\s*(>))", + "jsx-tag": { + "name": "meta.tag.js", + "begin": "(?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", + "end": "(/>)|(?:(</)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", "endCaptures": { - "0": { - "name": "meta.tag.js" - }, "1": { "name": "punctuation.definition.tag.end.js" }, @@ -4135,36 +4690,38 @@ "name": "punctuation.definition.tag.begin.js" }, "3": { - "name": "entity.name.tag.js" + "name": "entity.name.tag.namespace.js" }, "4": { - "name": "support.class.component.js" + "name": "punctuation.separator.namespace.js" }, "5": { + "name": "entity.name.tag.js" + }, + "6": { + "name": "support.class.component.js" + }, + "7": { "name": "punctuation.definition.tag.end.js" } }, "patterns": [ { - "include": "#jsx-tag" - } - ] - }, - "jsx-tag": { - "name": "meta.tag.js", - "begin": "(?x)\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))", - "end": "(?=(/>)|(?:(</)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>)))", - "patterns": [ - { - "begin": "(?x)\n (<)\\s*\n ((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>)", + "begin": "(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>)", "beginCaptures": { "1": { "name": "punctuation.definition.tag.begin.js" }, "2": { - "name": "entity.name.tag.js" + "name": "entity.name.tag.namespace.js" }, "3": { + "name": "punctuation.separator.namespace.js" + }, + "4": { + "name": "entity.name.tag.js" + }, + "5": { "name": "support.class.component.js" } }, @@ -4174,10 +4731,10 @@ "include": "#comment" }, { - "include": "#jsx-tag-attributes" + "include": "#type-arguments" }, { - "include": "#jsx-tag-attributes-illegal" + "include": "#jsx-tag-attributes" } ] }, @@ -4189,7 +4746,7 @@ } }, "end": "(?=</)", - "contentName": "meta.jsx.children.tsx", + "contentName": "meta.jsx.children.js", "patterns": [ { "include": "#jsx-children" @@ -4198,20 +4755,13 @@ } ] }, - "jsx-tag-invalid": { - "name": "invalid.illegal.tag.incomplete.js", - "match": "<\\s*>" - }, "jsx-children": { "patterns": [ { "include": "#jsx-tag-without-attributes" }, { - "include": "#jsx-child-tag" - }, - { - "include": "#jsx-tag-invalid" + "include": "#jsx-tag" }, { "include": "#jsx-evaluated-code" @@ -4221,18 +4771,135 @@ } ] }, - "jsx": { + "jsx-evaluated-code": { + "name": "meta.embedded.expression.js", + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.js" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.js" + } + }, "patterns": [ { - "include": "#jsx-tag-without-attributes" + "include": "#expression" + } + ] + }, + "jsx-entities": { + "patterns": [ + { + "name": "constant.character.entity.js", + "match": "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)", + "captures": { + "1": { + "name": "punctuation.definition.entity.js" + }, + "3": { + "name": "punctuation.definition.entity.js" + } + } }, { - "include": "#jsx-tag-in-expression" + "name": "invalid.illegal.bad-ampersand.js", + "match": "&" + } + ] + }, + "jsx-tag-attributes": { + "name": "meta.tag.attributes.js", + "begin": "\\s+", + "end": "(?=[/]?>)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#jsx-tag-attribute-name" + }, + { + "include": "#jsx-tag-attribute-assignment" + }, + { + "include": "#jsx-string-double-quoted" + }, + { + "include": "#jsx-string-single-quoted" + }, + { + "include": "#jsx-evaluated-code" + }, + { + "include": "#jsx-tag-attributes-illegal" + } + ] + }, + "jsx-tag-attribute-name": { + "match": "(?x)\n \\s*\n (?:([_$a-zA-Z][-$\\w.]*)(:))?\n ([_$a-zA-Z][-$\\w]*)\n (?=\\s|=|/?>|/\\*|//)", + "captures": { + "1": { + "name": "entity.other.attribute-name.namespace.js" + }, + "2": { + "name": "punctuation.separator.namespace.js" }, + "3": { + "name": "entity.other.attribute-name.js" + } + } + }, + "jsx-tag-attribute-assignment": { + "name": "keyword.operator.assignment.js", + "match": "=(?=\\s*(?:'|\"|{|/\\*|//|\\n))" + }, + "jsx-string-double-quoted": { + "name": "string.quoted.double.js", + "begin": "\"", + "end": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.js" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.js" + } + }, + "patterns": [ + { + "include": "#jsx-entities" + } + ] + }, + "jsx-string-single-quoted": { + "name": "string.quoted.single.js", + "begin": "'", + "end": "'", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.js" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.js" + } + }, + "patterns": [ { - "include": "#jsx-tag-invalid" + "include": "#jsx-entities" } ] + }, + "jsx-tag-attributes-illegal": { + "name": "invalid.illegal.attribute.js", + "match": "\\S+" } } }
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/JavaScriptReact.tmLanguage.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/JavaScriptReact.tmLanguage.json new file mode 100644 index 0000000000..d9d8c93e8b --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/JavaScriptReact.tmLanguage.json @@ -0,0 +1,4902 @@ +{ + "information_for_contributors": [ + "This file has been converted from https://github.com/Microsoft/TypeScript-TmLanguage/blob/master/TypeScriptReact.tmLanguage", + "If you want to provide a fix or improvement, please create a pull request against the original repository.", + "Once accepted there, we are happy to receive an update request." + ], + "version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/7bf8960f7042474b10b519f39339fc527907ce16", + "name": "JavaScript (with React support)", + "scopeName": "source.js.jsx", + "fileTypes": [ + "jsx" + ], + "patterns": [ + { + "include": "#directives" + }, + { + "include": "#statements" + }, + { + "name": "comment.line.shebang.ts", + "match": "\\A(#!).*(?=$)", + "captures": { + "1": { + "name": "punctuation.definition.comment.ts" + } + } + } + ], + "repository": { + "statements": { + "patterns": [ + { + "include": "#string" + }, + { + "include": "#template" + }, + { + "include": "#comment" + }, + { + "include": "#declaration" + }, + { + "include": "#control-statement" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#label" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-semicolon" + } + ] + }, + "declaration": { + "patterns": [ + { + "include": "#decorator" + }, + { + "include": "#var-expr" + }, + { + "include": "#function-declaration" + }, + { + "include": "#class-declaration" + }, + { + "include": "#interface-declaration" + }, + { + "include": "#enum-declaration" + }, + { + "include": "#namespace-declaration" + }, + { + "include": "#type-alias-declaration" + }, + { + "include": "#import-equals-declaration" + }, + { + "include": "#import-declaration" + }, + { + "include": "#export-declaration" + } + ] + }, + "control-statement": { + "patterns": [ + { + "include": "#switch-statement" + }, + { + "include": "#for-loop" + }, + { + "name": "keyword.control.trycatch.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|goto)\\s+([_$[:alpha:]][_$[:alnum:]]*)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "captures": { + "1": { + "name": "keyword.control.loop.js.jsx" + }, + "2": { + "name": "entity.name.label.js.jsx" + } + } + }, + { + "name": "keyword.control.loop.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.flow.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(return)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.switch.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.conditional.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(else|if)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.with.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(with)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.other.debugger.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(debugger)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "storage.modifier.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(declare)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + } + ] + }, + "label": { + "patterns": [ + { + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)(?=\\s*\\{)", + "beginCaptures": { + "1": { + "name": "entity.name.label.js.jsx" + }, + "2": { + "name": "punctuation.separator.label.js.jsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#decl-block" + } + ] + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)", + "captures": { + "1": { + "name": "entity.name.label.js.jsx" + }, + "2": { + "name": "punctuation.separator.label.js.jsx" + } + } + } + ] + }, + "expression": { + "patterns": [ + { + "include": "#expressionWithoutIdentifiers" + }, + { + "include": "#identifiers" + }, + { + "include": "#expressionPunctuations" + } + ] + }, + "expressionWithoutIdentifiers": { + "patterns": [ + { + "include": "#jsx" + }, + { + "include": "#string" + }, + { + "include": "#regex" + }, + { + "include": "#template" + }, + { + "include": "#comment" + }, + { + "include": "#function-expression" + }, + { + "include": "#class-expression" + }, + { + "include": "#arrow-function" + }, + { + "include": "#paren-expression-possibly-arrow" + }, + { + "include": "#cast" + }, + { + "include": "#ternary-expression" + }, + { + "include": "#new-expr" + }, + { + "include": "#instanceof-expr" + }, + { + "include": "#object-literal" + }, + { + "include": "#expression-operators" + }, + { + "include": "#function-call" + }, + { + "include": "#literal" + }, + { + "include": "#support-objects" + }, + { + "include": "#paren-expression" + } + ] + }, + "expressionPunctuations": { + "patterns": [ + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-accessor" + } + ] + }, + "decorator": { + "name": "meta.decorator.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))\\@", + "beginCaptures": { + "0": { + "name": "punctuation.decorator.js.jsx" + } + }, + "end": "(?=\\s)", + "patterns": [ + { + "include": "#expression" + } + ] + }, + "var-expr": { + "name": "meta.var.expr.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(var|let|const(?!\\s+enum\\b))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "storage.type.js.jsx" + } + }, + "end": "(?=$|^|;|}|(\\s+(of|in)\\s+))", + "patterns": [ + { + "include": "#destructuring-variable" + }, + { + "include": "#var-single-variable" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#comment" + }, + { + "begin": "(,)\\s*(?!\\S)", + "beginCaptures": { + "1": { + "name": "punctuation.separator.comma.js.jsx" + } + }, + "end": "(?<!,)((?==|;|}|(\\s+(of|in)\\s+)|^\\s*$))|((?<=\\S)(?=\\s*$))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#destructuring-variable" + }, + { + "include": "#var-single-variable" + }, + { + "include": "#punctuation-comma" + } + ] + }, + { + "include": "#punctuation-comma" + } + ] + }, + "var-single-variable": { + "patterns": [ + { + "name": "meta.var-single-variable.expr.js.jsx", + "begin": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "beginCaptures": { + "1": { + "name": "meta.definition.variable.js.jsx entity.name.function.js.jsx" + } + }, + "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", + "patterns": [ + { + "include": "#var-single-variable-type-annotation" + } + ] + }, + { + "name": "meta.var-single-variable.expr.js.jsx", + "begin": "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", + "beginCaptures": { + "1": { + "name": "meta.definition.variable.js.jsx variable.other.constant.js.jsx" + } + }, + "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", + "patterns": [ + { + "include": "#var-single-variable-type-annotation" + } + ] + }, + { + "name": "meta.var-single-variable.expr.js.jsx", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)", + "beginCaptures": { + "1": { + "name": "meta.definition.variable.js.jsx variable.other.readwrite.js.jsx" + } + }, + "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", + "patterns": [ + { + "include": "#var-single-variable-type-annotation" + } + ] + } + ] + }, + "var-single-variable-type-annotation": { + "patterns": [ + { + "include": "#type-annotation" + }, + { + "include": "#string" + }, + { + "include": "#comment" + } + ] + }, + "destructuring-variable": { + "patterns": [ + { + "name": "meta.object-binding-pattern-variable.js.jsx", + "begin": "(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\{)", + "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", + "patterns": [ + { + "include": "#object-binding-pattern" + }, + { + "include": "#type-annotation" + }, + { + "include": "#comment" + } + ] + }, + { + "name": "meta.array-binding-pattern-variable.js.jsx", + "begin": "(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\[)", + "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", + "patterns": [ + { + "include": "#array-binding-pattern" + }, + { + "include": "#type-annotation" + }, + { + "include": "#comment" + } + ] + } + ] + }, + "object-binding-element": { + "patterns": [ + { + "include": "#comment" + }, + { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "end": "(?=,|\\})", + "patterns": [ + { + "include": "#object-binding-element-propertyName" + }, + { + "include": "#binding-element" + } + ] + }, + { + "include": "#object-binding-pattern" + }, + { + "include": "#destructuring-variable-rest" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "object-binding-element-propertyName": { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "end": "(:)", + "endCaptures": { + "0": { + "name": "punctuation.destructuring.js.jsx" + } + }, + "patterns": [ + { + "include": "#string" + }, + { + "include": "#array-literal" + }, + { + "include": "#numeric-literal" + }, + { + "name": "variable.object.property.js.jsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" + } + ] + }, + "binding-element": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#object-binding-pattern" + }, + { + "include": "#array-binding-pattern" + }, + { + "include": "#destructuring-variable-rest" + }, + { + "include": "#variable-initializer" + } + ] + }, + "destructuring-variable-rest": { + "match": "(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "keyword.operator.rest.js.jsx" + }, + "2": { + "name": "meta.definition.variable.js.jsx variable.other.readwrite.js.jsx" + } + } + }, + "object-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\{)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.js.jsx" + }, + "2": { + "name": "punctuation.definition.binding-pattern.object.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.object.js.jsx" + } + }, + "patterns": [ + { + "include": "#object-binding-element" + } + ] + }, + "array-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\[)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.js.jsx" + }, + "2": { + "name": "punctuation.definition.binding-pattern.array.js.jsx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.js.jsx" + } + }, + "patterns": [ + { + "include": "#binding-element" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "parameter-name": { + "patterns": [ + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|protected|private|readonly)\\s+(?=(public|protected|private|readonly)\\s+)", + "captures": { + "1": { + "name": "storage.modifier.js.jsx" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "storage.modifier.js.jsx" + }, + "2": { + "name": "keyword.operator.rest.js.jsx" + }, + "3": { + "name": "entity.name.function.js.jsx variable.language.this.js.jsx" + }, + "4": { + "name": "entity.name.function.js.jsx" + }, + "5": { + "name": "keyword.operator.optional.js.jsx" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)", + "captures": { + "1": { + "name": "storage.modifier.js.jsx" + }, + "2": { + "name": "keyword.operator.rest.js.jsx" + }, + "3": { + "name": "variable.parameter.js.jsx variable.language.this.js.jsx" + }, + "4": { + "name": "variable.parameter.js.jsx" + }, + "5": { + "name": "keyword.operator.optional.js.jsx" + } + } + } + ] + }, + "destructuring-parameter": { + "patterns": [ + { + "name": "meta.parameter.object-binding-pattern.js.jsx", + "begin": "(?<!=|:)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.binding-pattern.object.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.object.js.jsx" + } + }, + "patterns": [ + { + "include": "#parameter-object-binding-element" + } + ] + }, + { + "name": "meta.paramter.array-binding-pattern.js.jsx", + "begin": "(?<!=|:)\\s*(\\[)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.binding-pattern.array.js.jsx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.js.jsx" + } + }, + "patterns": [ + { + "include": "#parameter-binding-element" + }, + { + "include": "#punctuation-comma" + } + ] + } + ] + }, + "parameter-object-binding-element": { + "patterns": [ + { + "include": "#comment" + }, + { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "end": "(?=,|\\})", + "patterns": [ + { + "include": "#object-binding-element-propertyName" + }, + { + "include": "#parameter-binding-element" + } + ] + }, + { + "include": "#parameter-object-binding-pattern" + }, + { + "include": "#destructuring-parameter-rest" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "parameter-binding-element": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#parameter-object-binding-pattern" + }, + { + "include": "#parameter-array-binding-pattern" + }, + { + "include": "#destructuring-parameter-rest" + }, + { + "include": "#variable-initializer" + } + ] + }, + "destructuring-parameter-rest": { + "match": "(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "keyword.operator.rest.js.jsx" + }, + "2": { + "name": "variable.parameter.js.jsx" + } + } + }, + "parameter-object-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\{)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.js.jsx" + }, + "2": { + "name": "punctuation.definition.binding-pattern.object.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.object.js.jsx" + } + }, + "patterns": [ + { + "include": "#parameter-object-binding-element" + } + ] + }, + "parameter-array-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\[)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.js.jsx" + }, + "2": { + "name": "punctuation.definition.binding-pattern.array.js.jsx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.js.jsx" + } + }, + "patterns": [ + { + "include": "#parameter-binding-element" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "field-declaration": { + "name": "meta.field.declaration.js.jsx", + "begin": "(?x)(?<!\\()(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(readonly)\\s+)?(?=\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", + "beginCaptures": { + "1": { + "name": "storage.modifier.js.jsx" + } + }, + "end": "(?x)(?=\\}|;|,|$|(^(?!\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "patterns": [ + { + "include": "#variable-initializer" + }, + { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", + "end": "(?x)(?=[};,=]|$|(^(?!\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "patterns": [ + { + "include": "#type-annotation" + }, + { + "include": "#string" + }, + { + "include": "#array-literal" + }, + { + "include": "#numeric-literal" + }, + { + "include": "#comment" + }, + { + "match": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(\\?)?(?=(\\?\\s*)?\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "meta.definition.property.js.jsx entity.name.function.js.jsx" + }, + "2": { + "name": "keyword.operator.optional.js.jsx" + } + } + }, + { + "name": "meta.definition.property.js.jsx variable.object.property.js.jsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + { + "name": "keyword.operator.optional.js.jsx", + "match": "\\?" + } + ] + } + ] + }, + "variable-initializer": { + "patterns": [ + { + "begin": "(?<!=|!)(=)(?!=)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.js.jsx" + } + }, + "end": "(?=$|^|[,);}\\]])", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "begin": "(?<!=|!)(=)(?!=)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.js.jsx" + } + }, + "end": "(?=[,);}\\]])|(?=^\\s*$)|(?<=\\S)(?<!=)(?=\\s*$)", + "patterns": [ + { + "include": "#expression" + } + ] + } + ] + }, + "function-declaration": { + "name": "meta.function.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "storage.modifier.async.js.jsx" + }, + "3": { + "name": "storage.type.function.js.jsx" + }, + "4": { + "name": "keyword.generator.asterisk.js.jsx" + }, + "5": { + "name": "meta.definition.function.js.jsx entity.name.function.js.jsx" + } + }, + "end": "(?=$|^|;)|(?<=\\})", + "patterns": [ + { + "include": "#function-name" + }, + { + "include": "#function-body" + } + ] + }, + "function-expression": { + "name": "meta.function.expression.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js.jsx" + }, + "2": { + "name": "storage.type.function.js.jsx" + }, + "3": { + "name": "keyword.generator.asterisk.js.jsx" + }, + "4": { + "name": "meta.definition.function.js.jsx entity.name.function.js.jsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#function-name" + }, + { + "include": "#function-body" + } + ] + }, + "function-name": { + "name": "meta.definition.function.js.jsx entity.name.function.js.jsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + "function-body": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "include": "#function-parameters" + }, + { + "include": "#return-type" + }, + { + "include": "#decl-block" + }, + { + "name": "keyword.generator.asterisk.js.jsx", + "match": "\\*" + } + ] + }, + "method-declaration": { + "patterns": [ + { + "name": "meta.method.declaration.js.jsx", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?\\s*\\b(constructor)\\b(?!:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "storage.modifier.js.jsx" + }, + "2": { + "name": "storage.modifier.js.jsx" + }, + "3": { + "name": "storage.modifier.async.js.jsx" + }, + "4": { + "name": "storage.type.js.jsx" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] + }, + { + "name": "meta.method.declaration.js.jsx", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:(?:\\s*\\b(new)\\b(?!:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|(?:(\\*)\\s*)?)(?=\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.js.jsx" + }, + "2": { + "name": "storage.modifier.js.jsx" + }, + "3": { + "name": "storage.modifier.async.js.jsx" + }, + "4": { + "name": "keyword.operator.new.js.jsx" + }, + "5": { + "name": "keyword.generator.asterisk.js.jsx" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] + }, + { + "name": "meta.method.declaration.js.jsx", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.js.jsx" + }, + "2": { + "name": "storage.modifier.js.jsx" + }, + "3": { + "name": "storage.modifier.async.js.jsx" + }, + "4": { + "name": "storage.type.property.js.jsx" + }, + "5": { + "name": "keyword.generator.asterisk.js.jsx" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] + } + ] + }, + "object-literal-method-declaration": { + "name": "meta.method.declaration.js.jsx", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js.jsx" + }, + "2": { + "name": "storage.type.property.js.jsx" + }, + "3": { + "name": "keyword.generator.asterisk.js.jsx" + } + }, + "end": "(?=\\}|;|,)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + }, + { + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js.jsx" + }, + "2": { + "name": "storage.type.property.js.jsx" + }, + "3": { + "name": "keyword.generator.asterisk.js.jsx" + } + }, + "end": "(?=\\(|\\<)", + "patterns": [ + { + "include": "#method-declaration-name" + } + ] + } + ] + }, + "method-declaration-name": { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??)\\s*[\\(\\<])", + "end": "(?=\\(|\\<)", + "patterns": [ + { + "include": "#string" + }, + { + "include": "#array-literal" + }, + { + "include": "#numeric-literal" + }, + { + "name": "meta.definition.method.js.jsx entity.name.function.js.jsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + { + "name": "keyword.operator.optional.js.jsx", + "match": "\\?" + } + ] + }, + "arrow-function": { + "patterns": [ + { + "name": "meta.arrow.js.jsx", + "match": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\\s+)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)", + "captures": { + "1": { + "name": "storage.modifier.async.js.jsx" + }, + "2": { + "name": "variable.parameter.js.jsx" + } + } + }, + { + "name": "meta.arrow.js.jsx", + "begin": "(?x) (?:\n (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\n)? ((?<![})!\\]])\\s*\n (?=\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n )\n)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js.jsx" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "include": "#function-parameters" + }, + { + "include": "#arrow-return-type" + } + ] + }, + { + "name": "meta.arrow.js.jsx", + "begin": "=>", + "beginCaptures": { + "0": { + "name": "storage.type.function.arrow.js.jsx" + } + }, + "end": "(?<=\\}|\\S)(?<!=>)|((?!\\{)(?=\\S))", + "patterns": [ + { + "include": "#decl-block" + }, + { + "include": "#expression" + } + ] + } + ] + }, + "indexer-declaration": { + "name": "meta.indexer.declaration.js.jsx", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(readonly)\\s*)?\\s*(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "beginCaptures": { + "1": { + "name": "storage.modifier.js.jsx" + }, + "2": { + "name": "meta.brace.square.js.jsx" + }, + "3": { + "name": "variable.parameter.js.jsx" + } + }, + "end": "(\\])\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.js.jsx" + }, + "2": { + "name": "keyword.operator.optional.js.jsx" + } + }, + "patterns": [ + { + "include": "#type-annotation" + } + ] + }, + "indexer-mapped-type-declaration": { + "name": "meta.indexer.mappedtype.declaration.js.jsx", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))([+-])?(readonly)\\s*)?\\s*(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s+(in)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.modifier.js.jsx" + }, + "2": { + "name": "storage.modifier.js.jsx" + }, + "3": { + "name": "meta.brace.square.js.jsx" + }, + "4": { + "name": "entity.name.type.js.jsx" + }, + "5": { + "name": "keyword.operator.expression.in.js.jsx" + } + }, + "end": "(\\])([+-])?\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.js.jsx" + }, + "2": { + "name": "keyword.operator.type.modifier.js.jsx" + }, + "3": { + "name": "keyword.operator.optional.js.jsx" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + "function-parameters": { + "name": "meta.parameters.js.jsx", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.definition.parameters.begin.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.parameters.end.js.jsx" + } + }, + "patterns": [ + { + "include": "#function-parameters-body" + } + ] + }, + "function-parameters-body": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#decorator" + }, + { + "include": "#destructuring-parameter" + }, + { + "include": "#parameter-name" + }, + { + "include": "#type-annotation" + }, + { + "include": "#variable-initializer" + }, + { + "name": "punctuation.separator.parameter.js.jsx", + "match": "," + } + ] + }, + "class-declaration": { + "name": "meta.class.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(class)\\b(?=\\s+|/[/*])", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "storage.modifier.js.jsx" + }, + "3": { + "name": "storage.type.class.js.jsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#class-declaration-or-expression-patterns" + } + ] + }, + "class-expression": { + "name": "meta.class.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(class)\\b(?=\\s+|[<{]|\\/[\\/*])", + "beginCaptures": { + "1": { + "name": "storage.type.class.js.jsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#class-declaration-or-expression-patterns" + } + ] + }, + "class-declaration-or-expression-patterns": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" + }, + { + "match": "[_$[:alpha:]][_$[:alnum:]]*", + "captures": { + "0": { + "name": "entity.name.type.class.js.jsx" + } + } + }, + { + "include": "#type-parameters" + }, + { + "include": "#class-or-interface-body" + } + ] + }, + "interface-declaration": { + "name": "meta.interface.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(interface)\\b(?=\\s+|/[/*])", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "storage.modifier.js.jsx" + }, + "3": { + "name": "storage.type.interface.js.jsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" + }, + { + "match": "[_$[:alpha:]][_$[:alnum:]]*", + "captures": { + "0": { + "name": "entity.name.type.interface.js.jsx" + } + } + }, + { + "include": "#type-parameters" + }, + { + "include": "#class-or-interface-body" + } + ] + }, + "class-or-interface-heritage": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(extends|implements)\\b)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "storage.modifier.js.jsx" + } + }, + "end": "(?=\\{)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" + }, + { + "include": "#type-parameters" + }, + { + "include": "#expressionWithoutIdentifiers" + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*)", + "captures": { + "1": { + "name": "entity.name.type.module.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + } + } + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "entity.other.inherited-class.js.jsx" + } + } + }, + { + "include": "#expressionPunctuations" + } + ] + }, + "class-or-interface-body": { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#decorator" + }, + { + "include": "#method-declaration" + }, + { + "include": "#indexer-declaration" + }, + { + "include": "#field-declaration" + }, + { + "include": "#string" + }, + { + "include": "#type-annotation" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#access-modifier" + }, + { + "include": "#property-accessor" + }, + { + "include": "#async-modifier" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-semicolon" + } + ] + }, + "access-modifier": { + "name": "storage.modifier.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(abstract|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "property-accessor": { + "name": "storage.type.property.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(get|set)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "async-modifier": { + "name": "storage.modifier.async.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(async)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "enum-declaration": { + "name": "meta.enum.declaration.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "storage.modifier.js.jsx" + }, + "3": { + "name": "storage.type.enum.js.jsx" + }, + "4": { + "name": "entity.name.type.enum.js.jsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#comment" + }, + { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "begin": "([_$[:alpha:]][_$[:alnum:]]*)", + "beginCaptures": { + "0": { + "name": "variable.other.enummember.js.jsx" + } + }, + "end": "(?=,|\\}|$)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#variable-initializer" + } + ] + }, + { + "begin": "(?=((\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))", + "end": "(?=,|\\}|$)", + "patterns": [ + { + "include": "#string" + }, + { + "include": "#array-literal" + }, + { + "include": "#comment" + }, + { + "include": "#variable-initializer" + } + ] + }, + { + "include": "#punctuation-comma" + } + ] + } + ] + }, + "namespace-declaration": { + "name": "meta.namespace.declaration.js.jsx", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+(?=[_$[:alpha:]\"'`]))", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "storage.type.namespace.js.jsx" + } + }, + "end": "(?<=\\})|(?=;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "name": "entity.name.type.module.js.jsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" + }, + { + "include": "#punctuation-accessor" + }, + { + "include": "#decl-block" + } + ] + }, + "type-alias-declaration": { + "name": "meta.type.declaration.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(type)\\b\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "storage.type.type.js.jsx" + }, + "3": { + "name": "entity.name.type.alias.js.jsx" + } + }, + "end": "(?=\\}|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "begin": "(=)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.js.jsx" + } + }, + "end": "(?=\\}|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, + "import-equals-declaration": { + "patterns": [ + { + "name": "meta.import-equals.external.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(require)\\s*(\\()", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "keyword.control.import.js.jsx" + }, + "3": { + "name": "variable.other.readwrite.alias.js.jsx" + }, + "4": { + "name": "keyword.operator.assignment.js.jsx" + }, + "5": { + "name": "keyword.control.require.js.jsx" + }, + "6": { + "name": "meta.brace.round.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + } + ] + }, + { + "name": "meta.import-equals.internal.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(?!require\\b)", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "keyword.control.import.js.jsx" + }, + "3": { + "name": "variable.other.readwrite.alias.js.jsx" + }, + "4": { + "name": "keyword.operator.assignment.js.jsx" + } + }, + "end": "(?=;|$|^)", + "patterns": [ + { + "include": "#comment" + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "entity.name.type.module.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + } + } + }, + { + "name": "variable.other.readwrite.js.jsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" + } + ] + } + ] + }, + "import-declaration": { + "name": "meta.import.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)(?!\\s*[:\\(])(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "keyword.control.import.js.jsx" + } + }, + "end": "(?<!^import|[^\\._$[:alnum:]]import)(?=;|$|^)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "begin": "(?<=^import|[^\\._$[:alnum:]]import)(?!\\s*[\"'])", + "end": "\\bfrom\\b", + "endCaptures": { + "0": { + "name": "keyword.control.from.js.jsx" + } + }, + "patterns": [ + { + "include": "#import-export-declaration" + } + ] + }, + { + "include": "#import-export-declaration" + } + ] + }, + "export-declaration": { + "patterns": [ + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "keyword.control.as.js.jsx" + }, + "3": { + "name": "storage.type.namespace.js.jsx" + }, + "4": { + "name": "entity.name.type.module.js.jsx" + } + } + }, + { + "name": "meta.export.default.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))", + "beginCaptures": { + "1": { + "name": "keyword.control.export.js.jsx" + }, + "2": { + "name": "keyword.operator.assignment.js.jsx" + }, + "3": { + "name": "keyword.control.default.js.jsx" + } + }, + "end": "(?=$|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "name": "meta.export.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?!\\s*:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "0": { + "name": "keyword.control.export.js.jsx" + } + }, + "end": "(?=$|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#import-export-declaration" + } + ] + } + ] + }, + "import-export-declaration": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#import-export-block" + }, + { + "name": "keyword.control.from.js.jsx", + "match": "\\bfrom\\b" + }, + { + "include": "#import-export-clause" + } + ] + }, + "import-export-block": { + "name": "meta.block.js.jsx", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "patterns": [ + { + "include": "#import-export-clause" + } + ] + }, + "import-export-clause": { + "patterns": [ + { + "include": "#comment" + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bdefault)|(\\*)|(\\b[_$[:alpha:]][_$[:alnum:]]*))\\s+(as)\\s+(?:(\\bdefault(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|(\\b[_$[:alpha:]][_$[:alnum:]]*))", + "captures": { + "1": { + "name": "keyword.control.default.js.jsx" + }, + "2": { + "name": "constant.language.import-export-all.js.jsx" + }, + "3": { + "name": "variable.other.readwrite.js.jsx" + }, + "4": { + "name": "keyword.control.as.js.jsx" + }, + "5": { + "name": "keyword.control.default.js.jsx" + }, + "6": { + "name": "variable.other.readwrite.alias.js.jsx" + } + } + }, + { + "include": "#punctuation-comma" + }, + { + "name": "constant.language.import-export-all.js.jsx", + "match": "\\*" + }, + { + "name": "keyword.control.default.js.jsx", + "match": "\\b(default)\\b" + }, + { + "name": "variable.other.readwrite.alias.js.jsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" + } + ] + }, + "switch-statement": { + "name": "switch-statement.expr.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?=\\bswitch\\s*\\()", + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "patterns": [ + { + "name": "switch-expression.expr.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(switch)\\s*(\\()", + "beginCaptures": { + "1": { + "name": "keyword.control.switch.js.jsx" + }, + "2": { + "name": "meta.brace.round.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "name": "switch-block.expr.js.jsx", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "end": "(?=\\})", + "patterns": [ + { + "name": "case-clause.expr.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default(?=:))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "keyword.control.switch.js.jsx" + } + }, + "end": "(?=:)", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "begin": "(:)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "case-clause.expr.js.jsx punctuation.definition.section.case-statement.js.jsx" + }, + "2": { + "name": "meta.block.js.jsx punctuation.definition.block.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "meta.block.js.jsx punctuation.definition.block.js.jsx" + } + }, + "contentName": "meta.block.js.jsx", + "patterns": [ + { + "include": "#statements" + } + ] + }, + { + "match": "(:)", + "captures": { + "0": { + "name": "case-clause.expr.js.jsx punctuation.definition.section.case-statement.js.jsx" + } + } + }, + { + "include": "#statements" + } + ] + } + ] + }, + "for-loop": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))for(?=((\\s+|(\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*))await)?\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)?(\\())", + "beginCaptures": { + "0": { + "name": "keyword.control.loop.js.jsx" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#comment" + }, + { + "name": "keyword.control.loop.js.jsx", + "match": "await" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "patterns": [ + { + "include": "#var-expr" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-semicolon" + } + ] + } + ] + }, + "decl-block": { + "name": "meta.block.js.jsx", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "patterns": [ + { + "include": "#statements" + } + ] + }, + "after-operator-block-as-object-literal": { + "name": "meta.objectliteral.js.jsx", + "begin": "(?<!\\+\\+|--)(?<=[:=(,\\[?+!>]|^await|[^\\._$[:alnum:]]await|^return|[^\\._$[:alnum:]]return|^yield|[^\\._$[:alnum:]]yield|^throw|[^\\._$[:alnum:]]throw|^in|[^\\._$[:alnum:]]in|^of|[^\\._$[:alnum:]]of|^typeof|[^\\._$[:alnum:]]typeof|&&|\\|\\||\\*)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "patterns": [ + { + "include": "#object-member" + } + ] + }, + "object-literal": { + "name": "meta.objectliteral.js.jsx", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "patterns": [ + { + "include": "#object-member" + } + ] + }, + "object-member": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#object-literal-method-declaration" + }, + { + "name": "meta.object.member.js.jsx meta.object-literal.key.js.jsx", + "begin": "(?=\\[)", + "end": "(?=:)|((?<=[\\]])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#array-literal" + } + ] + }, + { + "name": "meta.object.member.js.jsx meta.object-literal.key.js.jsx", + "begin": "(?=[\\'\\\"])", + "end": "(?=:)|((?<=[\\'\\\"])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#string" + } + ] + }, + { + "name": "meta.method.declaration.js.jsx", + "begin": "(?<=[\\]\\'\\\"])(?=\\s*[\\(\\<])", + "end": "(?=\\}|;|,)|(?<=\\})", + "patterns": [ + { + "include": "#function-body" + } + ] + }, + { + "name": "meta.object.member.js.jsx", + "match": "(?![_$[:alpha:]])([[:digit:]]+)\\s*(?=:)", + "captures": { + "0": { + "name": "meta.object-literal.key.js.jsx" + }, + "1": { + "name": "constant.numeric.decimal.js.jsx" + } + } + }, + { + "name": "meta.object.member.js.jsx", + "match": "(?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "0": { + "name": "meta.object-literal.key.js.jsx" + }, + "1": { + "name": "entity.name.function.js.jsx" + } + } + }, + { + "name": "meta.object.member.js.jsx", + "match": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "captures": { + "0": { + "name": "meta.object-literal.key.js.jsx" + } + } + }, + { + "name": "meta.object.member.js.jsx", + "begin": "\\.\\.\\.", + "beginCaptures": { + "0": { + "name": "keyword.operator.spread.js.jsx" + } + }, + "end": "(?=,|\\})", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "name": "meta.object.member.js.jsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$)", + "captures": { + "1": { + "name": "variable.other.readwrite.js.jsx" + } + } + }, + { + "name": "meta.object.member.js.jsx", + "begin": "(?=[_$[:alpha:]][_$[:alnum:]]*\\s*=)", + "end": "(?=,|\\}|$)", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "name": "meta.object.member.js.jsx", + "begin": ":", + "beginCaptures": { + "0": { + "name": "meta.object-literal.key.js.jsx punctuation.separator.key-value.js.jsx" + } + }, + "end": "(?=,|\\})", + "patterns": [ + { + "begin": "(?<=:)\\s*(async)?(?=\\s*(<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)\\(\\s*([\\{\\[]\\s*)?$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js.jsx" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#type-parameters" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + } + ] + }, + { + "begin": "(?<=:)\\s*(async)?\\s*(\\()(?=\\s*([\\{\\[]\\s*)?$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js.jsx" + }, + "2": { + "name": "meta.brace.round.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + }, + { + "include": "#expression" + } + ] + }, + { + "include": "#punctuation-comma" + } + ] + }, + "ternary-expression": { + "begin": "(?!\\?\\.\\s*[^[:digit:]])(\\?)", + "beginCaptures": { + "1": { + "name": "keyword.operator.ternary.js.jsx" + } + }, + "end": "\\s*(:)", + "endCaptures": { + "1": { + "name": "keyword.operator.ternary.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + "function-call": { + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "end": "(?<=\\))(?!(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "patterns": [ + { + "name": "meta.function-call.js.jsx", + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*))", + "end": "(?=\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "patterns": [ + { + "include": "#literal" + }, + { + "include": "#support-objects" + }, + { + "include": "#object-identifiers" + }, + { + "include": "#punctuation-accessor" + }, + { + "name": "keyword.operator.expression.import.js.jsx", + "match": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))import(?=\\s*[\\(]\\s*[\\\"\\'\\`]))" + }, + { + "name": "entity.name.function.js.jsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" + } + ] + }, + { + "include": "#comment" + }, + { + "name": "meta.function-call.js.jsx punctuation.accessor.optional.js.jsx", + "match": "\\?\\." + }, + { + "include": "#type-arguments" + }, + { + "include": "#paren-expression" + } + ] + }, + "new-expr": { + "name": "new.expr.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "keyword.operator.new.js.jsx" + } + }, + "end": "(?<=\\))|(?=[;),}\\]:]|\\|\\||\\&\\&|$|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))new(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))function((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", + "patterns": [ + { + "include": "#paren-expression" + }, + { + "include": "#class-declaration" + }, + { + "include": "#type" + } + ] + }, + "instanceof-expr": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(instanceof)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "keyword.operator.expression.instanceof.js.jsx" + } + }, + "end": "(?<=\\))|(?=[;),}\\]:?]|\\|\\||\\&\\&|$|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))function((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", + "patterns": [ + { + "include": "#type" + } + ] + }, + "paren-expression-possibly-arrow": { + "patterns": [ + { + "begin": "(?<=[(=,])\\s*(async)?(?=\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*))?\\(\\s*[\\{\\[]\\s*$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js.jsx" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#paren-expression-possibly-arrow-with-typeparameters" + } + ] + }, + { + "begin": "(?<=[(=,]|=>)\\s*(async)?(?=\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*))?\\(\\s*$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.js.jsx" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#paren-expression-possibly-arrow-with-typeparameters" + } + ] + }, + { + "include": "#possibly-arrow-return-type" + } + ] + }, + "paren-expression-possibly-arrow-with-typeparameters": { + "patterns": [ + { + "include": "#type-parameters" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + } + ] + }, + "expression-inside-possibly-arrow-parens": { + "patterns": [ + { + "include": "#expressionWithoutIdentifiers" + }, + { + "include": "#function-parameters-body" + }, + { + "include": "#identifiers" + }, + { + "include": "#expressionPunctuations" + } + ] + }, + "paren-expression": { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + "cast": { + "patterns": [ + { + "include": "#jsx" + } + ] + }, + "expression-operators": { + "patterns": [ + { + "name": "keyword.control.flow.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(await)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?=\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*\\*)", + "beginCaptures": { + "1": { + "name": "keyword.control.flow.js.jsx" + } + }, + "end": "\\*", + "endCaptures": { + "0": { + "name": "keyword.generator.asterisk.js.jsx" + } + }, + "patterns": [ + { + "include": "#comment" + } + ] + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?:\\s*(\\*))?", + "captures": { + "1": { + "name": "keyword.control.flow.js.jsx" + }, + "2": { + "name": "keyword.generator.asterisk.js.jsx" + } + } + }, + { + "name": "keyword.operator.expression.delete.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))delete(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.operator.expression.in.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))in(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()" + }, + { + "name": "keyword.operator.expression.of.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))of(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()" + }, + { + "name": "keyword.operator.expression.instanceof.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))instanceof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.operator.new.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))new(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "include": "#typeof-operator" + }, + { + "name": "keyword.operator.expression.void.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))void(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(as)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.control.as.js.jsx" + } + }, + "end": "(?=$|^|[;,:})\\]]|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(as)\\s+))", + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "name": "keyword.operator.spread.js.jsx", + "match": "\\.\\.\\." + }, + { + "name": "keyword.operator.assignment.compound.js.jsx", + "match": "\\*=|(?<!\\()/=|%=|\\+=|\\-=" + }, + { + "name": "keyword.operator.assignment.compound.bitwise.js.jsx", + "match": "\\&=|\\^=|<<=|>>=|>>>=|\\|=" + }, + { + "name": "keyword.operator.bitwise.shift.js.jsx", + "match": "<<|>>>|>>" + }, + { + "name": "keyword.operator.comparison.js.jsx", + "match": "===|!==|==|!=" + }, + { + "name": "keyword.operator.relational.js.jsx", + "match": "<=|>=|<>|<|>" + }, + { + "name": "keyword.operator.logical.js.jsx", + "match": "\\!|&&|\\|\\|" + }, + { + "name": "keyword.operator.bitwise.js.jsx", + "match": "\\&|~|\\^|\\|" + }, + { + "name": "keyword.operator.assignment.js.jsx", + "match": "\\=" + }, + { + "name": "keyword.operator.decrement.js.jsx", + "match": "--" + }, + { + "name": "keyword.operator.increment.js.jsx", + "match": "\\+\\+" + }, + { + "name": "keyword.operator.arithmetic.js.jsx", + "match": "%|\\*|/|-|\\+" + }, + { + "match": "(?<=[_$[:alnum:])\\]])\\s*(/)(?![/*])", + "captures": { + "1": { + "name": "keyword.operator.arithmetic.js.jsx" + } + } + } + ] + }, + "typeof-operator": { + "name": "keyword.operator.expression.typeof.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))typeof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "literal": { + "patterns": [ + { + "include": "#numeric-literal" + }, + { + "include": "#boolean-literal" + }, + { + "include": "#null-literal" + }, + { + "include": "#undefined-literal" + }, + { + "include": "#numericConstant-literal" + }, + { + "include": "#array-literal" + }, + { + "include": "#this-literal" + }, + { + "include": "#super-literal" + } + ] + }, + "array-literal": { + "name": "meta.array.literal.js.jsx", + "begin": "\\s*(\\[)", + "beginCaptures": { + "1": { + "name": "meta.brace.square.js.jsx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "meta.brace.square.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "numeric-literal": { + "patterns": [ + { + "name": "constant.numeric.hex.js.jsx", + "match": "\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$)" + }, + { + "name": "constant.numeric.binary.js.jsx", + "match": "\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$)" + }, + { + "name": "constant.numeric.octal.js.jsx", + "match": "\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$)" + }, + { + "match": "(?x)\n(?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$)", + "captures": { + "0": { + "name": "constant.numeric.decimal.js.jsx" + }, + "1": { + "name": "meta.delimiter.decimal.period.js.jsx" + }, + "2": { + "name": "meta.delimiter.decimal.period.js.jsx" + }, + "3": { + "name": "meta.delimiter.decimal.period.js.jsx" + }, + "4": { + "name": "meta.delimiter.decimal.period.js.jsx" + }, + "5": { + "name": "meta.delimiter.decimal.period.js.jsx" + }, + "6": { + "name": "meta.delimiter.decimal.period.js.jsx" + } + } + } + ] + }, + "boolean-literal": { + "patterns": [ + { + "name": "constant.language.boolean.true.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))true(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "constant.language.boolean.false.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))false(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + } + ] + }, + "null-literal": { + "name": "constant.language.null.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))null(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "this-literal": { + "name": "variable.language.this.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))this\\b(?!\\$)" + }, + "super-literal": { + "name": "variable.language.super.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))super\\b(?!\\$)" + }, + "undefined-literal": { + "name": "constant.language.undefined.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))undefined(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "numericConstant-literal": { + "patterns": [ + { + "name": "constant.language.nan.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))NaN(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "constant.language.infinity.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))Infinity(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + } + ] + }, + "support-objects": { + "patterns": [ + { + "name": "variable.language.arguments.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(arguments)\\b(?!\\$)" + }, + { + "name": "support.class.builtin.js.jsx", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator\n |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Proxy\n |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray\n |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\\b(?!\\$)" + }, + { + "name": "support.class.error.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\\b(?!\\$)" + }, + { + "name": "support.class.promise.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Promise)\\b(?!\\$)" + }, + { + "name": "support.function.js.jsx", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|\n isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\\s*\\()" + }, + { + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Math)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|\n expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|\n round|sign|sin|sinh|sqrt|tan|tanh|trunc)\n |\n (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\\b(?!\\$)", + "captures": { + "1": { + "name": "support.constant.math.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "4": { + "name": "support.function.math.js.jsx" + }, + "5": { + "name": "support.constant.property.math.js.jsx" + } + } + }, + { + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(console)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(\n assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log\n |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\\b(?!\\$)", + "captures": { + "1": { + "name": "support.class.console.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "4": { + "name": "support.function.console.js.jsx" + } + } + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(JSON)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(parse|stringify))?\\b(?!\\$)", + "captures": { + "1": { + "name": "support.constant.json.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "4": { + "name": "support.function.json.js.jsx" + } + } + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(import)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(meta)\\b(?!\\$)", + "captures": { + "1": { + "name": "keyword.control.import.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "4": { + "name": "support.variable.property.importmeta.js.jsx" + } + } + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(target)\\b(?!\\$)", + "captures": { + "1": { + "name": "keyword.operator.new.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "4": { + "name": "support.variable.property.target.js.jsx" + } + } + }, + { + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s* (?:\n (constructor|length|prototype|__proto__)\n |\n (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\\b(?!\\$)", + "captures": { + "1": { + "name": "punctuation.accessor.js.jsx" + }, + "2": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "3": { + "name": "support.variable.property.js.jsx" + }, + "4": { + "name": "support.constant.js.jsx" + } + } + }, + { + "match": "(?x) (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.)) \\b (?:\n (document|event|navigator|performance|screen|window)\n |\n (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener\n |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule\n |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration\n |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern\n |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent\n |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException\n |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer\n |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry\n |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent\n |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential\n |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync\n |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement\n |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement\n |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement\n |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement\n |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement\n |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement\n |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement\n |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement\n |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement\n |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement\n |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement\n |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase\n |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction\n |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities\n |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess\n |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent\n |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream\n |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent\n |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID\n |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification\n |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential\n |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark\n |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList\n |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent\n |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList\n |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager\n |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource\n |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement\n |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength\n |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio\n |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement\n |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement\n |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement\n |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength\n |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement\n |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio\n |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList\n |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement\n |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement\n |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState\n |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet\n |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable\n |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer\n |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat\n |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES\n |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope\n |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult\n |XSLTProcessor))\\b(?!\\$)", + "captures": { + "1": { + "name": "support.variable.dom.js.jsx" + }, + "2": { + "name": "support.class.dom.js.jsx" + } + } + }, + { + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s* (?:\n (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE\n |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR\n |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR\n |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)\n |\n (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName\n |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop\n |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor\n |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption\n |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear\n |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete\n |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset\n |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight\n |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds\n |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize\n |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host\n |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth\n |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext\n |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom\n |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple\n |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName\n |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight\n |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer\n |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling\n |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText\n |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts\n |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove\n |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary\n |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead\n |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile\n |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\\b(?!\\$|\\s*(<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\\()", + "captures": { + "1": { + "name": "punctuation.accessor.js.jsx" + }, + "2": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "3": { + "name": "support.constant.dom.js.jsx" + }, + "4": { + "name": "support.variable.property.dom.js.jsx" + } + } + }, + { + "name": "support.class.node.js.jsx", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)" + }, + { + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(process)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)", + "captures": { + "1": { + "name": "support.variable.object.process.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "4": { + "name": "support.variable.property.process.js.jsx" + }, + "5": { + "name": "support.function.process.js.jsx" + } + } + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(exports)|(module)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)", + "captures": { + "1": { + "name": "support.type.object.module.js.jsx" + }, + "2": { + "name": "support.type.object.module.js.jsx" + }, + "3": { + "name": "punctuation.accessor.js.jsx" + }, + "4": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "5": { + "name": "support.type.object.module.js.jsx" + } + } + }, + { + "name": "support.variable.object.node.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)" + }, + { + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s*\n(?:\n (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|\n Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|\n Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|\n Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|\n Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|\n Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|\n Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|\n Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\n ) |\n (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|\n scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|\n sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|\n Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|\n Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|\n savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|\n contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|\n createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|\n test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|\n untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|\n print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|\n fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|\n forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|\n abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|\n releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|\n Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|\n Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|\n moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back\n ) |\n (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|\n appendChild|appendData|before|blur|canPlayType|captureStream|\n caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|\n cloneContents|cloneNode|cloneRange|close|closest|collapse|\n compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|\n convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|\n createAttributeNS|createCaption|createCDATASection|createComment|\n createContextualFragment|createDocument|createDocumentFragment|\n createDocumentType|createElement|createElementNS|createEntityReference|\n createEvent|createExpression|createHTMLDocument|createNodeIterator|\n createNSResolver|createProcessingInstruction|createRange|createShadowRoot|\n createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|\n deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|\n deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|\n enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|\n exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|\n getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|\n getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|\n getClientRects|getContext|getDestinationInsertionPoints|getElementById|\n getElementsByClassName|getElementsByName|getElementsByTagName|\n getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|\n getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|\n hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|\n insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|\n insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|\n isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|\n lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|\n moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|\n parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|\n previousSibling|probablySupportsContext|queryCommandEnabled|\n queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|\n querySelector|querySelectorAll|registerContentHandler|registerElement|\n registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|\n removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|\n removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|\n requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|\n scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|\n setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|\n setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|\n setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|\n slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|\n submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|\n toDataURL|toggle|toString|values|write|writeln\n ) |\n (all|catch|finally|race|reject|resolve|then\n )\n)(?=\\s*\\()", + "captures": { + "1": { + "name": "punctuation.accessor.js.jsx" + }, + "2": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "3": { + "name": "support.function.event-handler.js.jsx" + }, + "4": { + "name": "support.function.js.jsx" + }, + "5": { + "name": "support.function.dom.js.jsx" + }, + "6": { + "name": "support.function.promise.js.jsx" + } + } + } + ] + }, + "identifiers": { + "patterns": [ + { + "include": "#object-identifiers" + }, + { + "match": "(?x)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n))", + "captures": { + "1": { + "name": "punctuation.accessor.js.jsx" + }, + "2": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "3": { + "name": "entity.name.function.js.jsx" + } + } + }, + { + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", + "captures": { + "1": { + "name": "punctuation.accessor.js.jsx" + }, + "2": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "3": { + "name": "variable.other.constant.property.js.jsx" + } + } + }, + { + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "punctuation.accessor.js.jsx" + }, + "2": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "3": { + "name": "variable.other.property.js.jsx" + } + } + }, + { + "name": "variable.other.constant.js.jsx", + "match": "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" + }, + { + "name": "variable.other.readwrite.js.jsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + } + ] + }, + "object-identifiers": { + "patterns": [ + { + "name": "support.class.js.jsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\??\\.\\s*prototype\\b(?!\\$))" + }, + { + "match": "(?x)(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "punctuation.accessor.js.jsx" + }, + "2": { + "name": "punctuation.accessor.optional.js.jsx" + }, + "3": { + "name": "variable.other.constant.object.property.js.jsx" + }, + "4": { + "name": "variable.other.object.property.js.jsx" + } + } + }, + { + "match": "(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "variable.other.constant.object.js.jsx" + }, + "2": { + "name": "variable.other.object.js.jsx" + } + } + } + ] + }, + "type-annotation": { + "patterns": [ + { + "name": "meta.type.annotation.js.jsx", + "begin": "(:)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.js.jsx" + } + }, + "end": "(?<![:|&])((?=$|^|[,);\\}\\]]|//)|(?==[^>])|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "name": "meta.type.annotation.js.jsx", + "begin": "(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.js.jsx" + } + }, + "end": "(?<![:|&])((?=[,);\\}\\]]|//)|(?==[^>])|(?=^\\s*$)|((?<=\\S)(?=\\s*$))|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, + "return-type": { + "patterns": [ + { + "name": "meta.return.type.js.jsx", + "begin": "(?<=\\))\\s*(:)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.js.jsx" + } + }, + "end": "(?<![:|&])(?=$|^|[{};,]|//)", + "patterns": [ + { + "include": "#return-type-core" + } + ] + }, + { + "name": "meta.return.type.js.jsx", + "begin": "(?<=\\))\\s*(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.js.jsx" + } + }, + "end": "(?<![:|&])((?=[{};,]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", + "patterns": [ + { + "include": "#return-type-core" + } + ] + } + ] + }, + "return-type-core": { + "patterns": [ + { + "include": "#comment" + }, + { + "begin": "(?<=[:|&])(?=\\s*\\{)", + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "arrow-return-type": { + "name": "meta.return.type.arrow.js.jsx", + "begin": "(?<=\\))\\s*(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.js.jsx" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "possibly-arrow-return-type": { + "begin": "(?<=\\))\\s*(:)(?=\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+\\s*=>)", + "beginCaptures": { + "1": { + "name": "meta.arrow.js.jsx meta.return.type.arrow.js.jsx keyword.operator.type.annotation.js.jsx" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "contentName": "meta.arrow.js.jsx meta.return.type.arrow.js.jsx", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "arrow-return-type-body": { + "patterns": [ + { + "begin": "(?<=[:])(?=\\s*\\{)", + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "type-parameters": { + "name": "meta.type.parameters.js.jsx", + "begin": "(<)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.begin.js.jsx" + } + }, + "end": "(>)", + "endCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.end.js.jsx" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "name": "storage.modifier.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(extends)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "include": "#type" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "type-arguments": { + "name": "meta.type.parameters.js.jsx", + "begin": "\\<", + "beginCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.begin.js.jsx" + } + }, + "end": "\\>", + "endCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.end.js.jsx" + } + }, + "patterns": [ + { + "include": "#type" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "type": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#numeric-literal" + }, + { + "include": "#type-primitive" + }, + { + "include": "#type-builtin-literals" + }, + { + "include": "#type-parameters" + }, + { + "include": "#type-tuple" + }, + { + "include": "#type-object" + }, + { + "include": "#type-conditional" + }, + { + "include": "#type-operators" + }, + { + "include": "#type-fn-type-parameters" + }, + { + "include": "#type-paren-or-function-parameters" + }, + { + "include": "#type-function-return-type" + }, + { + "include": "#type-name" + } + ] + }, + "type-primitive": { + "name": "support.type.primitive.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(string|number|boolean|symbol|any|void|never)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-builtin-literals": { + "name": "support.type.builtin.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(this|true|false|undefined|null|object)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-tuple": { + "name": "meta.type.tuple.js.jsx", + "begin": "\\[", + "beginCaptures": { + "0": { + "name": "meta.brace.square.js.jsx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "meta.brace.square.js.jsx" + } + }, + "patterns": [ + { + "include": "#type" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "type-object": { + "name": "meta.object.type.js.jsx", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.js.jsx" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#method-declaration" + }, + { + "include": "#indexer-declaration" + }, + { + "include": "#indexer-mapped-type-declaration" + }, + { + "include": "#field-declaration" + }, + { + "include": "#type-annotation" + }, + { + "begin": "\\.\\.\\.", + "beginCaptures": { + "0": { + "name": "keyword.operator.spread.js.jsx" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-semicolon" + }, + { + "include": "#type" + } + ] + }, + "type-conditional": { + "patterns": [ + { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(extends)\\s+", + "beginCaptures": { + "1": { + "name": "storage.modifier.js.jsx" + } + }, + "end": "(?<=:)", + "patterns": [ + { + "begin": "\\?", + "beginCaptures": { + "0": { + "name": "keyword.operator.ternary.js.jsx" + } + }, + "end": ":", + "endCaptures": { + "0": { + "name": "keyword.operator.ternary.js.jsx" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "include": "#type" + } + ] + } + ] + }, + "type-paren-or-function-parameters": { + "name": "meta.type.paren.cover.js.jsx", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.js.jsx" + } + }, + "patterns": [ + { + "include": "#destructuring-parameter" + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=\\s*(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)))", + "captures": { + "1": { + "name": "storage.modifier.js.jsx" + }, + "2": { + "name": "keyword.operator.rest.js.jsx" + }, + "3": { + "name": "entity.name.function.js.jsx variable.language.this.js.jsx" + }, + "4": { + "name": "entity.name.function.js.jsx" + }, + "5": { + "name": "keyword.operator.optional.js.jsx" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=:)", + "captures": { + "1": { + "name": "storage.modifier.js.jsx" + }, + "2": { + "name": "keyword.operator.rest.js.jsx" + }, + "3": { + "name": "variable.parameter.js.jsx variable.language.this.js.jsx" + }, + "4": { + "name": "variable.parameter.js.jsx" + }, + "5": { + "name": "keyword.operator.optional.js.jsx" + } + } + }, + { + "include": "#type-annotation" + }, + { + "name": "punctuation.separator.parameter.js.jsx", + "match": "," + }, + { + "include": "#type" + } + ] + }, + "type-fn-type-parameters": { + "patterns": [ + { + "name": "meta.type.constructor.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\b(?=\\s*\\<)", + "captures": { + "1": { + "name": "keyword.control.new.js.jsx" + } + } + }, + { + "name": "meta.type.constructor.js.jsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\b\\s*(?=\\()", + "beginCaptures": { + "1": { + "name": "keyword.control.new.js.jsx" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#function-parameters" + } + ] + }, + { + "name": "meta.type.function.js.jsx", + "begin": "(?x)(\n (?=\n [(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n )\n )\n)", + "end": "(?<=\\))", + "patterns": [ + { + "include": "#function-parameters" + } + ] + } + ] + }, + "type-function-return-type": { + "patterns": [ + { + "name": "meta.type.function.return.js.jsx", + "begin": "(=>)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "storage.type.function.arrow.js.jsx" + } + }, + "end": "(?<!=>)(?<![|&])(?=[,\\]\\)\\{\\}=;>:\\?]|//|$)", + "patterns": [ + { + "include": "#type-function-return-type-core" + } + ] + }, + { + "name": "meta.type.function.return.js.jsx", + "begin": "=>", + "beginCaptures": { + "0": { + "name": "storage.type.function.arrow.js.jsx" + } + }, + "end": "(?<!=>)(?<![|&])((?=[,\\]\\)\\{\\}=;:\\?>]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", + "patterns": [ + { + "include": "#type-function-return-type-core" + } + ] + } + ] + }, + "type-function-return-type-core": { + "patterns": [ + { + "include": "#comment" + }, + { + "begin": "(?<==>)(?=\\s*\\{)", + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "type-operators": { + "patterns": [ + { + "include": "#typeof-operator" + }, + { + "begin": "(?:([&|])|(=(?!>)))(?=\\s*\\{)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.js.jsx" + }, + "2": { + "name": "keyword.operator.assignment.js.jsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "begin": "([&|])|(=(?!>))", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.js.jsx" + }, + "2": { + "name": "keyword.operator.assignment.js.jsx" + } + }, + "end": "(?=\\S)" + }, + { + "name": "keyword.operator.expression.keyof.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))keyof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.operator.ternary.js.jsx", + "match": "(\\?|\\:)" + }, + { + "name": "keyword.operator.expression.infer.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))infer(?=\\s+[_$[:alpha:]])" + }, + { + "name": "keyword.operator.expression.import.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))import(?=\\s*\\()" + } + ] + }, + "type-predicate-operator": { + "name": "keyword.operator.expression.is.js.jsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))is(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-name": { + "patterns": [ + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "entity.name.type.module.js.jsx" + }, + "2": { + "name": "punctuation.accessor.js.jsx" + }, + "3": { + "name": "punctuation.accessor.optional.js.jsx" + } + } + }, + { + "name": "entity.name.type.js.jsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + } + ] + }, + "punctuation-comma": { + "name": "punctuation.separator.comma.js.jsx", + "match": "," + }, + "punctuation-semicolon": { + "name": "punctuation.terminator.statement.js.jsx", + "match": ";" + }, + "punctuation-accessor": { + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "punctuation.accessor.js.jsx" + }, + "2": { + "name": "punctuation.accessor.optional.js.jsx" + } + } + }, + "string": { + "patterns": [ + { + "include": "#qstring-single" + }, + { + "include": "#qstring-double" + } + ] + }, + "qstring-double": { + "name": "string.quoted.double.js.jsx", + "begin": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.js.jsx" + } + }, + "end": "(\")|((?:[^\\\\\\n])$)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.js.jsx" + }, + "2": { + "name": "invalid.illegal.newline.js.jsx" + } + }, + "patterns": [ + { + "include": "#string-character-escape" + } + ] + }, + "qstring-single": { + "name": "string.quoted.single.js.jsx", + "begin": "'", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.js.jsx" + } + }, + "end": "(\\')|((?:[^\\\\\\n])$)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.js.jsx" + }, + "2": { + "name": "invalid.illegal.newline.js.jsx" + } + }, + "patterns": [ + { + "include": "#string-character-escape" + } + ] + }, + "string-character-escape": { + "name": "constant.character.escape.js.jsx", + "match": "\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" + }, + "template": { + "patterns": [ + { + "name": "string.template.js.jsx", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.js.jsx" + } + }, + "end": "(?=`)", + "patterns": [ + { + "include": "#type-arguments" + } + ] + }, + { + "name": "string.template.js.jsx", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.js.jsx" + }, + "2": { + "name": "punctuation.definition.string.template.begin.js.jsx" + } + }, + "end": "`", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.template.end.js.jsx" + } + }, + "patterns": [ + { + "include": "#template-substitution-element" + }, + { + "include": "#string-character-escape" + } + ] + } + ] + }, + "template-substitution-element": { + "name": "meta.template.expression.js.jsx", + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.template-expression.begin.js.jsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.template-expression.end.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression" + } + ], + "contentName": "meta.embedded.line.js.jsx" + }, + "regex": { + "patterns": [ + { + "name": "string.regexp.js.jsx", + "begin": "(?<!\\+\\+|--)(?<=[=(:,\\[?+!]|^return|[^\\._$[:alnum:]]return|^case|[^\\._$[:alnum:]]case|=>|&&|\\|\\||\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))", + "beginCaptures": { + "1": { + "name": "punctuation.definition.string.begin.js.jsx" + } + }, + "end": "(/)([gimsuy]*)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.js.jsx" + }, + "2": { + "name": "keyword.other.js.jsx" + } + }, + "patterns": [ + { + "include": "#regexp" + } + ] + }, + { + "name": "string.regexp.js.jsx", + "begin": "(?<![_$[:alnum:])\\]]|\\+\\+|--)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.js.jsx" + } + }, + "end": "(/)([gimsuy]*)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.js.jsx" + }, + "2": { + "name": "keyword.other.js.jsx" + } + }, + "patterns": [ + { + "include": "#regexp" + } + ] + } + ] + }, + "regexp": { + "patterns": [ + { + "name": "keyword.control.anchor.regexp", + "match": "\\\\[bB]|\\^|\\$" + }, + { + "match": "\\\\[1-9]\\d*|\\\\k<([a-zA-Z_$][\\w$]*)>", + "captures": { + "0": { + "name": "keyword.other.back-reference.regexp" + }, + "1": { + "name": "variable.other.regexp" + } + } + }, + { + "name": "keyword.operator.quantifier.regexp", + "match": "[?+*]|\\{(\\d+,\\d+|\\d+,|,\\d+|\\d+)\\}\\??" + }, + { + "name": "keyword.operator.or.regexp", + "match": "\\|" + }, + { + "name": "meta.group.assertion.regexp", + "begin": "(\\()((\\?=)|(\\?!)|(\\?<=)|(\\?<!))", + "beginCaptures": { + "1": { + "name": "punctuation.definition.group.regexp" + }, + "2": { + "name": "punctuation.definition.group.assertion.regexp" + }, + "3": { + "name": "meta.assertion.look-ahead.regexp" + }, + "4": { + "name": "meta.assertion.negative-look-ahead.regexp" + }, + "5": { + "name": "meta.assertion.look-behind.regexp" + }, + "6": { + "name": "meta.assertion.negative-look-behind.regexp" + } + }, + "end": "(\\))", + "endCaptures": { + "1": { + "name": "punctuation.definition.group.regexp" + } + }, + "patterns": [ + { + "include": "#regexp" + } + ] + }, + { + "name": "meta.group.regexp", + "begin": "\\((?:(\\?:)|(?:\\?<([a-zA-Z_$][\\w$]*)>))?", + "beginCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + }, + "1": { + "name": "punctuation.definition.group.no-capture.regexp" + }, + "2": { + "name": "variable.other.regexp" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + } + }, + "patterns": [ + { + "include": "#regexp" + } + ] + }, + { + "name": "constant.other.character-class.set.regexp", + "begin": "(\\[)(\\^)?", + "beginCaptures": { + "1": { + "name": "punctuation.definition.character-class.regexp" + }, + "2": { + "name": "keyword.operator.negation.regexp" + } + }, + "end": "(\\])", + "endCaptures": { + "1": { + "name": "punctuation.definition.character-class.regexp" + } + }, + "patterns": [ + { + "name": "constant.other.character-class.range.regexp", + "match": "(?:.|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))", + "captures": { + "1": { + "name": "constant.character.numeric.regexp" + }, + "2": { + "name": "constant.character.control.regexp" + }, + "3": { + "name": "constant.character.escape.backslash.regexp" + }, + "4": { + "name": "constant.character.numeric.regexp" + }, + "5": { + "name": "constant.character.control.regexp" + }, + "6": { + "name": "constant.character.escape.backslash.regexp" + } + } + }, + { + "include": "#regex-character-class" + } + ] + }, + { + "include": "#regex-character-class" + } + ] + }, + "regex-character-class": { + "patterns": [ + { + "name": "constant.other.character-class.regexp", + "match": "\\\\[wWsSdDtrnvf]|\\." + }, + { + "name": "constant.character.numeric.regexp", + "match": "\\\\([0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4})" + }, + { + "name": "constant.character.control.regexp", + "match": "\\\\c[A-Z]" + }, + { + "name": "constant.character.escape.backslash.regexp", + "match": "\\\\." + } + ] + }, + "comment": { + "patterns": [ + { + "name": "comment.block.documentation.js.jsx", + "begin": "/\\*\\*(?!/)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.js.jsx" + } + }, + "end": "\\*/", + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.js.jsx" + } + }, + "patterns": [ + { + "include": "#docblock" + } + ] + }, + { + "name": "comment.block.js.jsx", + "begin": "(/\\*)(?:\\s*((@)internal)(?=\\s|(\\*/)))?", + "beginCaptures": { + "1": { + "name": "punctuation.definition.comment.js.jsx" + }, + "2": { + "name": "storage.type.internaldeclaration.js.jsx" + }, + "3": { + "name": "punctuation.decorator.internaldeclaration.js.jsx" + } + }, + "end": "\\*/", + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.js.jsx" + } + } + }, + { + "begin": "(^[ \\t]+)?((//)(?:\\s*((@)internal)(?=\\s|$))?)", + "beginCaptures": { + "1": { + "name": "punctuation.whitespace.comment.leading.js.jsx" + }, + "2": { + "name": "comment.line.double-slash.js.jsx" + }, + "3": { + "name": "punctuation.definition.comment.js.jsx" + }, + "4": { + "name": "storage.type.internaldeclaration.js.jsx" + }, + "5": { + "name": "punctuation.decorator.internaldeclaration.js.jsx" + } + }, + "end": "(?=^)", + "contentName": "comment.line.double-slash.js.jsx" + } + ] + }, + "directives": { + "name": "comment.line.triple-slash.directive.js.jsx", + "begin": "^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|name)\\s*=\\s*((\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")))+\\s*/>\\s*$)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.comment.js.jsx" + } + }, + "end": "(?=^)", + "patterns": [ + { + "name": "meta.tag.js.jsx", + "begin": "(<)(reference|amd-dependency|amd-module)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.directive.js.jsx" + }, + "2": { + "name": "entity.name.tag.directive.js.jsx" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.directive.js.jsx" + } + }, + "patterns": [ + { + "name": "entity.other.attribute-name.directive.js.jsx", + "match": "path|types|no-default-lib|name" + }, + { + "name": "keyword.operator.assignment.js.jsx", + "match": "=" + }, + { + "include": "#string" + } + ] + } + ] + }, + "docblock": { + "patterns": [ + { + "match": "(?x)\n((@)(?:access|api))\n\\s+\n(private|protected|public)\n\\b", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "constant.language.access-type.jsdoc" + } + } + }, + { + "match": "(?x)\n((@)author)\n\\s+\n(\n [^@\\s<>*/]\n (?:[^@<>*/]|\\*[^/])*\n)\n(?:\n \\s*\n (<)\n ([^>\\s]+)\n (>)\n)?", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "entity.name.type.instance.jsdoc" + }, + "4": { + "name": "punctuation.definition.bracket.angle.begin.jsdoc" + }, + "5": { + "name": "constant.other.email.link.underline.jsdoc" + }, + "6": { + "name": "punctuation.definition.bracket.angle.end.jsdoc" + } + } + }, + { + "match": "(?x)\n((@)borrows) \\s+\n((?:[^@\\s*/]|\\*[^/])+) # <that namepath>\n\\s+ (as) \\s+ # as\n((?:[^@\\s*/]|\\*[^/])+) # <this namepath>", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "entity.name.type.instance.jsdoc" + }, + "4": { + "name": "keyword.operator.control.jsdoc" + }, + "5": { + "name": "entity.name.type.instance.jsdoc" + } + } + }, + { + "name": "meta.example.jsdoc", + "begin": "((@)example)\\s+", + "end": "(?=@|\\*/)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "patterns": [ + { + "match": "^\\s\\*\\s+" + }, + { + "contentName": "constant.other.description.jsdoc", + "begin": "\\G(<)caption(>)", + "beginCaptures": { + "0": { + "name": "entity.name.tag.inline.jsdoc" + }, + "1": { + "name": "punctuation.definition.bracket.angle.begin.jsdoc" + }, + "2": { + "name": "punctuation.definition.bracket.angle.end.jsdoc" + } + }, + "end": "(</)caption(>)|(?=\\*/)", + "endCaptures": { + "0": { + "name": "entity.name.tag.inline.jsdoc" + }, + "1": { + "name": "punctuation.definition.bracket.angle.begin.jsdoc" + }, + "2": { + "name": "punctuation.definition.bracket.angle.end.jsdoc" + } + } + }, + { + "match": "[^\\s@*](?:[^*]|\\*[^/])*", + "captures": { + "0": { + "name": "source.embedded.js.jsx" + } + } + } + ] + }, + { + "match": "(?x) ((@)kind) \\s+ (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) \\b", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "constant.language.symbol-type.jsdoc" + } + } + }, + { + "match": "(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!\n # Avoid matching bare URIs (also acceptable as links)\n https?://\n |\n # Avoid matching {@inline tags}; we match those below\n (?:\\[[^\\[\\]]*\\])? # Possible description [preceding]{@tag}\n {@(?:link|linkcode|linkplain|tutorial)\\b\n )\n # Matched namepath\n (?:[^@\\s*/]|\\*[^/])+\n )\n)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.link.underline.jsdoc" + }, + "4": { + "name": "entity.name.type.instance.jsdoc" + } + } + }, + { + "match": "(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(\n [A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]* # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* , \\s*\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n )*\n)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.jsdoc" + } + } + }, + { + "match": "(?x)\n(\n (@)\n (?:arg|argument|const|constant|member|namespace|param|var)\n)\n\\s+\n(\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.jsdoc" + } + } + }, + { + "begin": "((@)typedef)\\s+(?={)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "end": "(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])", + "patterns": [ + { + "include": "#jsdoctype" + }, + { + "name": "entity.name.type.instance.jsdoc", + "match": "(?:[^@\\s*/]|\\*[^/])+" + } + ] + }, + { + "begin": "((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\\s+(?={)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "end": "(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])", + "patterns": [ + { + "include": "#jsdoctype" + }, + { + "name": "variable.other.jsdoc", + "match": "([A-Za-z_$][\\w$.\\[\\]]*)" + }, + { + "name": "variable.other.jsdoc", + "match": "(?x)\n(\\[)\\s*\n[\\w$]+\n(?:\n (?:\\[\\])? # Foo[ ].bar properties within an array\n \\. # Foo.Bar namespaced parameter\n [\\w$]+\n)*\n(?:\n \\s*\n (=) # [foo=bar] Default parameter value\n \\s*\n (\n # The inner regexes are to stop the match early at */ and to not stop at escaped quotes\n (?>\n \"(?:(?:\\*(?!/))|(?:\\\\(?!\"))|[^*\\\\])*?\" | # [foo=\"bar\"] Double-quoted\n '(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted\n \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal\n (?:(?:\\*(?!/))|\\s(?!\\s*\\])|\\[.*?(?:\\]|(?=\\*/))|[^*\\s\\[\\]])* # Everything else\n )*\n )\n)?\n\\s*(?:(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/))", + "captures": { + "1": { + "name": "punctuation.definition.optional-value.begin.bracket.square.jsdoc" + }, + "2": { + "name": "keyword.operator.assignment.jsdoc" + }, + "3": { + "name": "source.embedded.js.jsx" + }, + "4": { + "name": "punctuation.definition.optional-value.end.bracket.square.jsdoc" + }, + "5": { + "name": "invalid.illegal.syntax.jsdoc" + } + } + } + ] + }, + { + "begin": "(?x)\n(\n (@)\n (?:define|enum|exception|export|extends|lends|implements|modifies\n |namespace|private|protected|returns?|suppress|this|throws|type\n |yields?)\n)\n\\s+(?={)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "end": "(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])", + "patterns": [ + { + "include": "#jsdoctype" + } + ] + }, + { + "match": "(?x)\n(\n (@)\n (?:alias|augments|callback|constructs|emits|event|fires|exports?\n |extends|external|function|func|host|lends|listens|interface|memberof!?\n |method|module|mixes|mixin|name|requires|see|this|typedef|uses)\n)\n\\s+\n(\n (?:\n [^{}@\\s*] | \\*[^/]\n )+\n)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "entity.name.type.instance.jsdoc" + } + } + }, + { + "contentName": "variable.other.jsdoc", + "begin": "((@)(?:default(?:value)?|license|version))\\s+(([''\"]))", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.jsdoc" + }, + "4": { + "name": "punctuation.definition.string.begin.jsdoc" + } + }, + "end": "(\\3)|(?=$|\\*/)", + "endCaptures": { + "0": { + "name": "variable.other.jsdoc" + }, + "1": { + "name": "punctuation.definition.string.end.jsdoc" + } + } + }, + { + "match": "((@)(?:default(?:value)?|license|tutorial|variation|version))\\s+([^\\s*]+)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.jsdoc" + } + } + }, + { + "name": "storage.type.class.jsdoc", + "match": "(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \\b", + "captures": { + "1": { + "name": "punctuation.definition.block.tag.jsdoc" + } + } + }, + { + "include": "#inline-tags" + } + ] + }, + "brackets": { + "patterns": [ + { + "begin": "{", + "end": "}|(?=\\*/)", + "patterns": [ + { + "include": "#brackets" + } + ] + }, + { + "begin": "\\[", + "end": "\\]|(?=\\*/)", + "patterns": [ + { + "include": "#brackets" + } + ] + } + ] + }, + "inline-tags": { + "patterns": [ + { + "name": "constant.other.description.jsdoc", + "match": "(\\[)[^\\]]+(\\])(?={@(?:link|linkcode|linkplain|tutorial))", + "captures": { + "1": { + "name": "punctuation.definition.bracket.square.begin.jsdoc" + }, + "2": { + "name": "punctuation.definition.bracket.square.end.jsdoc" + } + } + }, + { + "name": "entity.name.type.instance.jsdoc", + "begin": "({)((@)(?:link(?:code|plain)?|tutorial))\\s*", + "beginCaptures": { + "1": { + "name": "punctuation.definition.bracket.curly.begin.jsdoc" + }, + "2": { + "name": "storage.type.class.jsdoc" + }, + "3": { + "name": "punctuation.definition.inline.tag.jsdoc" + } + }, + "end": "}|(?=\\*/)", + "endCaptures": { + "0": { + "name": "punctuation.definition.bracket.curly.end.jsdoc" + } + }, + "patterns": [ + { + "match": "\\G((?=https?://)(?:[^|}\\s*]|\\*[/])+)(\\|)?", + "captures": { + "1": { + "name": "variable.other.link.underline.jsdoc" + }, + "2": { + "name": "punctuation.separator.pipe.jsdoc" + } + } + }, + { + "match": "\\G((?:[^{}@\\s|*]|\\*[^/])+)(\\|)?", + "captures": { + "1": { + "name": "variable.other.description.jsdoc" + }, + "2": { + "name": "punctuation.separator.pipe.jsdoc" + } + } + } + ] + } + ] + }, + "jsdoctype": { + "patterns": [ + { + "name": "invalid.illegal.type.jsdoc", + "match": "\\G{(?:[^}*]|\\*[^/}])+$" + }, + { + "contentName": "entity.name.type.instance.jsdoc", + "begin": "\\G({)", + "beginCaptures": { + "0": { + "name": "entity.name.type.instance.jsdoc" + }, + "1": { + "name": "punctuation.definition.bracket.curly.begin.jsdoc" + } + }, + "end": "((}))\\s*|(?=\\*/)", + "endCaptures": { + "1": { + "name": "entity.name.type.instance.jsdoc" + }, + "2": { + "name": "punctuation.definition.bracket.curly.end.jsdoc" + } + }, + "patterns": [ + { + "include": "#brackets" + } + ] + } + ] + }, + "jsx": { + "patterns": [ + { + "include": "#jsx-tag-without-attributes-in-expression" + }, + { + "include": "#jsx-tag-in-expression" + } + ] + }, + "jsx-tag-without-attributes-in-expression": { + "begin": "(?<!\\+\\+|--)(?<=[({\\[,?=>:*]|&&|\\|\\||\\?|^return|[^\\._$[:alnum:]]return|^default|[^\\._$[:alnum:]]default|^)\\s*(?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", + "end": "(?!(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", + "patterns": [ + { + "include": "#jsx-tag-without-attributes" + } + ] + }, + "jsx-tag-without-attributes": { + "name": "meta.tag.without-attributes.js.jsx", + "begin": "(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>)", + "end": "(</)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.js.jsx" + }, + "2": { + "name": "entity.name.tag.namespace.js.jsx" + }, + "3": { + "name": "punctuation.separator.namespace.js.jsx" + }, + "4": { + "name": "entity.name.tag.js.jsx" + }, + "5": { + "name": "support.class.component.js.jsx" + }, + "6": { + "name": "punctuation.definition.tag.end.js.jsx" + } + }, + "endCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.js.jsx" + }, + "2": { + "name": "entity.name.tag.namespace.js.jsx" + }, + "3": { + "name": "punctuation.separator.namespace.js.jsx" + }, + "4": { + "name": "entity.name.tag.js.jsx" + }, + "5": { + "name": "support.class.component.js.jsx" + }, + "6": { + "name": "punctuation.definition.tag.end.js.jsx" + } + }, + "contentName": "meta.jsx.children.js.jsx", + "patterns": [ + { + "include": "#jsx-children" + } + ] + }, + "jsx-tag-in-expression": { + "begin": "(?x)\n (?<!\\+\\+|--)(?<=[({\\[,?=>:*]|&&|\\|\\||\\?|^return|[^\\._$[:alnum:]]return|^default|[^\\._$[:alnum:]]default|^)\\s*\n (?!<\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=>])|,)) # look ahead is not type parameter of arrow\n (?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", + "end": "(?!(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", + "patterns": [ + { + "include": "#jsx-tag" + } + ] + }, + "jsx-tag": { + "name": "meta.tag.js.jsx", + "begin": "(?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", + "end": "(/>)|(?:(</)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", + "endCaptures": { + "1": { + "name": "punctuation.definition.tag.end.js.jsx" + }, + "2": { + "name": "punctuation.definition.tag.begin.js.jsx" + }, + "3": { + "name": "entity.name.tag.namespace.js.jsx" + }, + "4": { + "name": "punctuation.separator.namespace.js.jsx" + }, + "5": { + "name": "entity.name.tag.js.jsx" + }, + "6": { + "name": "support.class.component.js.jsx" + }, + "7": { + "name": "punctuation.definition.tag.end.js.jsx" + } + }, + "patterns": [ + { + "begin": "(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.js.jsx" + }, + "2": { + "name": "entity.name.tag.namespace.js.jsx" + }, + "3": { + "name": "punctuation.separator.namespace.js.jsx" + }, + "4": { + "name": "entity.name.tag.js.jsx" + }, + "5": { + "name": "support.class.component.js.jsx" + } + }, + "end": "(?=[/]?>)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-arguments" + }, + { + "include": "#jsx-tag-attributes" + } + ] + }, + { + "begin": "(>)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.end.js.jsx" + } + }, + "end": "(?=</)", + "contentName": "meta.jsx.children.js.jsx", + "patterns": [ + { + "include": "#jsx-children" + } + ] + } + ] + }, + "jsx-children": { + "patterns": [ + { + "include": "#jsx-tag-without-attributes" + }, + { + "include": "#jsx-tag" + }, + { + "include": "#jsx-evaluated-code" + }, + { + "include": "#jsx-entities" + } + ] + }, + "jsx-evaluated-code": { + "name": "meta.embedded.expression.js.jsx", + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.js.jsx" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.js.jsx" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + "jsx-entities": { + "patterns": [ + { + "name": "constant.character.entity.js.jsx", + "match": "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)", + "captures": { + "1": { + "name": "punctuation.definition.entity.js.jsx" + }, + "3": { + "name": "punctuation.definition.entity.js.jsx" + } + } + }, + { + "name": "invalid.illegal.bad-ampersand.js.jsx", + "match": "&" + } + ] + }, + "jsx-tag-attributes": { + "name": "meta.tag.attributes.js.jsx", + "begin": "\\s+", + "end": "(?=[/]?>)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#jsx-tag-attribute-name" + }, + { + "include": "#jsx-tag-attribute-assignment" + }, + { + "include": "#jsx-string-double-quoted" + }, + { + "include": "#jsx-string-single-quoted" + }, + { + "include": "#jsx-evaluated-code" + }, + { + "include": "#jsx-tag-attributes-illegal" + } + ] + }, + "jsx-tag-attribute-name": { + "match": "(?x)\n \\s*\n (?:([_$a-zA-Z][-$\\w.]*)(:))?\n ([_$a-zA-Z][-$\\w]*)\n (?=\\s|=|/?>|/\\*|//)", + "captures": { + "1": { + "name": "entity.other.attribute-name.namespace.js.jsx" + }, + "2": { + "name": "punctuation.separator.namespace.js.jsx" + }, + "3": { + "name": "entity.other.attribute-name.js.jsx" + } + } + }, + "jsx-tag-attribute-assignment": { + "name": "keyword.operator.assignment.js.jsx", + "match": "=(?=\\s*(?:'|\"|{|/\\*|//|\\n))" + }, + "jsx-string-double-quoted": { + "name": "string.quoted.double.js.jsx", + "begin": "\"", + "end": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.js.jsx" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.js.jsx" + } + }, + "patterns": [ + { + "include": "#jsx-entities" + } + ] + }, + "jsx-string-single-quoted": { + "name": "string.quoted.single.js.jsx", + "begin": "'", + "end": "'", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.js.jsx" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.js.jsx" + } + }, + "patterns": [ + { + "include": "#jsx-entities" + } + ] + }, + "jsx-tag-attributes-illegal": { + "name": "invalid.illegal.attribute.js.jsx", + "match": "\\S+" + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/Regular Expressions (JavaScript).tmLanguage b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/Regular Expressions (JavaScript).tmLanguage new file mode 100644 index 0000000000..1dda780649 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/javascript/syntaxes/Regular Expressions (JavaScript).tmLanguage @@ -0,0 +1,237 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>fileTypes</key> + <array/> + <key>hideFromUser</key> + <true/> + <key>name</key> + <string>Regular Expressions (JavaScript)</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#regexp</string> + </dict> + </array> + <key>repository</key> + <dict> + <key>regex-character-class</key> + <dict> + <key>patterns</key> + <array> + <dict> + <key>match</key> + <string>\\[wWsSdD]|\.</string> + <key>name</key> + <string>constant.character.character-class.regexp</string> + </dict> + <dict> + <key>match</key> + <string>\\([0-7]{3}|x\h\h|u\h\h\h\h)</string> + <key>name</key> + <string>constant.character.numeric.regexp</string> + </dict> + <dict> + <key>match</key> + <string>\\c[A-Z]</string> + <key>name</key> + <string>constant.character.control.regexp</string> + </dict> + <dict> + <key>match</key> + <string>\\.</string> + <key>name</key> + <string>constant.character.escape.backslash.regexp</string> + </dict> + </array> + </dict> + <key>regexp</key> + <dict> + <key>patterns</key> + <array> + <dict> + <key>match</key> + <string>\\[bB]|\^|\$</string> + <key>name</key> + <string>keyword.control.anchor.regexp</string> + </dict> + <dict> + <key>match</key> + <string>\\[1-9]\d*</string> + <key>name</key> + <string>keyword.other.back-reference.regexp</string> + </dict> + <dict> + <key>match</key> + <string>[?+*]|\{(\d+,\d+|\d+,|,\d+|\d+)\}\??</string> + <key>name</key> + <string>keyword.operator.quantifier.regexp</string> + </dict> + <dict> + <key>match</key> + <string>\|</string> + <key>name</key> + <string>keyword.operator.or.regexp</string> + </dict> + <dict> + <key>begin</key> + <string>(\()((\?=)|(\?!))</string> + <key>beginCaptures</key> + <dict> + <key>1</key> + <dict> + <key>name</key> + <string>punctuation.definition.group.regexp</string> + </dict> + <key>3</key> + <dict> + <key>name</key> + <string>meta.assertion.look-ahead.regexp</string> + </dict> + <key>4</key> + <dict> + <key>name</key> + <string>meta.assertion.negative-look-ahead.regexp</string> + </dict> + </dict> + <key>end</key> + <string>(\))</string> + <key>endCaptures</key> + <dict> + <key>1</key> + <dict> + <key>name</key> + <string>punctuation.definition.group.regexp</string> + </dict> + </dict> + <key>name</key> + <string>meta.group.assertion.regexp</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#regexp</string> + </dict> + </array> + </dict> + <dict> + <key>begin</key> + <string>\((\?:)?</string> + <key>beginCaptures</key> + <dict> + <key>0</key> + <dict> + <key>name</key> + <string>punctuation.definition.group.regexp</string> + </dict> + </dict> + <key>end</key> + <string>\)</string> + <key>endCaptures</key> + <dict> + <key>0</key> + <dict> + <key>name</key> + <string>punctuation.definition.group.regexp</string> + </dict> + </dict> + <key>name</key> + <string>meta.group.regexp</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#regexp</string> + </dict> + </array> + </dict> + <dict> + <key>begin</key> + <string>(\[)(\^)?</string> + <key>beginCaptures</key> + <dict> + <key>1</key> + <dict> + <key>name</key> + <string>punctuation.definition.character-class.regexp</string> + </dict> + <key>2</key> + <dict> + <key>name</key> + <string>keyword.operator.negation.regexp</string> + </dict> + </dict> + <key>end</key> + <string>(\])</string> + <key>endCaptures</key> + <dict> + <key>1</key> + <dict> + <key>name</key> + <string>punctuation.definition.character-class.regexp</string> + </dict> + </dict> + <key>name</key> + <string>constant.other.character-class.set.regexp</string> + <key>patterns</key> + <array> + <dict> + <key>captures</key> + <dict> + <key>1</key> + <dict> + <key>name</key> + <string>constant.character.numeric.regexp</string> + </dict> + <key>2</key> + <dict> + <key>name</key> + <string>constant.character.control.regexp</string> + </dict> + <key>3</key> + <dict> + <key>name</key> + <string>constant.character.escape.backslash.regexp</string> + </dict> + <key>4</key> + <dict> + <key>name</key> + <string>constant.character.numeric.regexp</string> + </dict> + <key>5</key> + <dict> + <key>name</key> + <string>constant.character.control.regexp</string> + </dict> + <key>6</key> + <dict> + <key>name</key> + <string>constant.character.escape.backslash.regexp</string> + </dict> + </dict> + <key>match</key> + <string>(?:.|(\\(?:[0-7]{3}|x\h\h|u\h\h\h\h))|(\\c[A-Z])|(\\.))\-(?:[^\]\\]|(\\(?:[0-7]{3}|x\h\h|u\h\h\h\h))|(\\c[A-Z])|(\\.))</string> + <key>name</key> + <string>constant.other.character-class.range.regexp</string> + </dict> + <dict> + <key>include</key> + <string>#regex-character-class</string> + </dict> + </array> + </dict> + <dict> + <key>include</key> + <string>#regex-character-class</string> + </dict> + </array> + </dict> + </dict> + <key>scopeName</key> + <string>source.js.regexp</string> + <key>uuid</key> + <string>AC8679DE-3AC7-4056-84F9-69A7ADC29DDD</string> +</dict> +</plist> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/typescript/syntaxes/TypeScript.tmLanguage.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/typescript/syntaxes/TypeScript.tmLanguage.json index 90c14f0fc9..cdb64b65cc 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/typescript/syntaxes/TypeScript.tmLanguage.json +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/typescript/syntaxes/TypeScript.tmLanguage.json @@ -4,13 +4,12 @@ "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/3a70fab1b03520774fa236f1f7e7a0939463739f", + "version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/7bf8960f7042474b10b519f39339fc527907ce16", "name": "TypeScript", "scopeName": "source.ts", "fileTypes": [ "ts" ], - "uuid": "ef98eb90-bf9b-11e4-bb52-0800200c9a66", "patterns": [ { "include": "#directives" @@ -44,31 +43,246 @@ "include": "#declaration" }, { + "include": "#control-statement" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#label" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-semicolon" + } + ] + }, + "declaration": { + "patterns": [ + { + "include": "#decorator" + }, + { + "include": "#var-expr" + }, + { + "include": "#function-declaration" + }, + { + "include": "#class-declaration" + }, + { + "include": "#interface-declaration" + }, + { + "include": "#enum-declaration" + }, + { + "include": "#namespace-declaration" + }, + { + "include": "#type-alias-declaration" + }, + { + "include": "#import-equals-declaration" + }, + { + "include": "#import-declaration" + }, + { + "include": "#export-declaration" + } + ] + }, + "control-statement": { + "patterns": [ + { "include": "#switch-statement" }, { "include": "#for-loop" }, { - "include": "#after-operator-block" + "name": "keyword.control.trycatch.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#decl-block" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|goto)\\s+([_$[:alpha:]][_$[:alnum:]]*)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "captures": { + "1": { + "name": "keyword.control.loop.ts" + }, + "2": { + "name": "entity.name.label.ts" + } + } }, { - "include": "#control-statement" + "name": "keyword.control.loop.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#expression" + "name": "keyword.control.flow.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(return)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#punctuation-semicolon" + "name": "keyword.control.switch.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.conditional.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(else|if)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.with.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(with)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.other.debugger.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(debugger)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "storage.modifier.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(declare)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + } + ] + }, + "label": { + "patterns": [ + { + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)(?=\\s*\\{)", + "beginCaptures": { + "1": { + "name": "entity.name.label.ts" + }, + "2": { + "name": "punctuation.separator.label.ts" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#decl-block" + } + ] + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)", + "captures": { + "1": { + "name": "entity.name.label.ts" + }, + "2": { + "name": "punctuation.separator.label.ts" + } + } + } + ] + }, + "expression": { + "patterns": [ + { + "include": "#expressionWithoutIdentifiers" + }, + { + "include": "#identifiers" + }, + { + "include": "#expressionPunctuations" + } + ] + }, + "expressionWithoutIdentifiers": { + "patterns": [ + { + "include": "#string" + }, + { + "include": "#regex" + }, + { + "include": "#template" + }, + { + "include": "#comment" + }, + { + "include": "#function-expression" + }, + { + "include": "#class-expression" + }, + { + "include": "#arrow-function" + }, + { + "include": "#paren-expression-possibly-arrow" + }, + { + "include": "#cast" + }, + { + "include": "#ternary-expression" + }, + { + "include": "#new-expr" + }, + { + "include": "#instanceof-expr" + }, + { + "include": "#object-literal" + }, + { + "include": "#expression-operators" + }, + { + "include": "#function-call" + }, + { + "include": "#literal" + }, + { + "include": "#support-objects" + }, + { + "include": "#paren-expression" + } + ] + }, + "expressionPunctuations": { + "patterns": [ + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-accessor" + } + ] + }, + "decorator": { + "name": "meta.decorator.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))\\@", + "beginCaptures": { + "0": { + "name": "punctuation.decorator.ts" + } + }, + "end": "(?=\\s)", + "patterns": [ + { + "include": "#expression" } ] }, "var-expr": { "name": "meta.var.expr.ts", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(var|let|const(?!\\s+enum\\b))\\b(?!\\$|\\.)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(var|let|const(?!\\s+enum\\b))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { "name": "keyword.control.export.ts" @@ -92,6 +306,29 @@ "include": "#comment" }, { + "begin": "(,)\\s*(?!\\S)", + "beginCaptures": { + "1": { + "name": "punctuation.separator.comma.ts" + } + }, + "end": "(?<!,)((?==|;|}|(\\s+(of|in)\\s+)|^\\s*$))|((?<=\\S)(?=\\s*$))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#destructuring-variable" + }, + { + "include": "#var-single-variable" + }, + { + "include": "#punctuation-comma" + } + ] + }, + { "include": "#punctuation-comma" } ] @@ -100,7 +337,7 @@ "patterns": [ { "name": "meta.var-single-variable.expr.ts", - "begin": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)", + "begin": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", "beginCaptures": { "1": { "name": "meta.definition.variable.ts entity.name.function.ts" @@ -162,7 +399,7 @@ "patterns": [ { "name": "meta.object-binding-pattern-variable.ts", - "begin": "(?<!=|:|of|in)\\s*(?=\\{)", + "begin": "(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\{)", "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", "patterns": [ { @@ -178,7 +415,7 @@ }, { "name": "meta.array-binding-pattern-variable.ts", - "begin": "(?<!=|:|of|in)\\s*(?=\\[)", + "begin": "(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\[)", "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", "patterns": [ { @@ -200,7 +437,7 @@ "include": "#comment" }, { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", "end": "(?=,|\\})", "patterns": [ { @@ -226,7 +463,7 @@ ] }, "object-binding-element-propertyName": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", "end": "(:)", "endCaptures": { "0": { @@ -241,6 +478,9 @@ "include": "#array-literal" }, { + "include": "#numeric-literal" + }, + { "name": "variable.object.property.ts", "match": "([_$[:alpha:]][_$[:alnum:]]*)" } @@ -252,6 +492,9 @@ "include": "#comment" }, { + "include": "#string" + }, + { "include": "#object-binding-pattern" }, { @@ -323,209 +566,941 @@ } ] }, - "ternary-expression": { - "begin": "(\\?)", + "parameter-name": { + "patterns": [ + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|protected|private|readonly)\\s+(?=(public|protected|private|readonly)\\s+)", + "captures": { + "1": { + "name": "storage.modifier.ts" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "keyword.operator.rest.ts" + }, + "3": { + "name": "entity.name.function.ts variable.language.this.ts" + }, + "4": { + "name": "entity.name.function.ts" + }, + "5": { + "name": "keyword.operator.optional.ts" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)", + "captures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "keyword.operator.rest.ts" + }, + "3": { + "name": "variable.parameter.ts variable.language.this.ts" + }, + "4": { + "name": "variable.parameter.ts" + }, + "5": { + "name": "keyword.operator.optional.ts" + } + } + } + ] + }, + "destructuring-parameter": { + "patterns": [ + { + "name": "meta.parameter.object-binding-pattern.ts", + "begin": "(?<!=|:)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.binding-pattern.object.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.object.ts" + } + }, + "patterns": [ + { + "include": "#parameter-object-binding-element" + } + ] + }, + { + "name": "meta.paramter.array-binding-pattern.ts", + "begin": "(?<!=|:)\\s*(\\[)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.binding-pattern.array.ts" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.ts" + } + }, + "patterns": [ + { + "include": "#parameter-binding-element" + }, + { + "include": "#punctuation-comma" + } + ] + } + ] + }, + "parameter-object-binding-element": { + "patterns": [ + { + "include": "#comment" + }, + { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "end": "(?=,|\\})", + "patterns": [ + { + "include": "#object-binding-element-propertyName" + }, + { + "include": "#parameter-binding-element" + } + ] + }, + { + "include": "#parameter-object-binding-pattern" + }, + { + "include": "#destructuring-parameter-rest" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "parameter-binding-element": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#parameter-object-binding-pattern" + }, + { + "include": "#parameter-array-binding-pattern" + }, + { + "include": "#destructuring-parameter-rest" + }, + { + "include": "#variable-initializer" + } + ] + }, + "destructuring-parameter-rest": { + "match": "(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "keyword.operator.rest.ts" + }, + "2": { + "name": "variable.parameter.ts" + } + } + }, + "parameter-object-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\{)", "beginCaptures": { - "0": { - "name": "keyword.operator.ternary.ts" + "1": { + "name": "keyword.operator.rest.ts" + }, + "2": { + "name": "punctuation.definition.binding-pattern.object.ts" } }, - "end": "(:)", + "end": "\\}", "endCaptures": { "0": { - "name": "keyword.operator.ternary.ts" + "name": "punctuation.definition.binding-pattern.object.ts" } }, "patterns": [ { - "include": "#expression" + "include": "#parameter-object-binding-element" } ] }, - "expression": { + "parameter-array-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\[)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.ts" + }, + "2": { + "name": "punctuation.definition.binding-pattern.array.ts" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.ts" + } + }, "patterns": [ { - "include": "#string" + "include": "#parameter-binding-element" }, { - "include": "#regex" - }, + "include": "#punctuation-comma" + } + ] + }, + "field-declaration": { + "name": "meta.field.declaration.ts", + "begin": "(?x)(?<!\\()(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(readonly)\\s+)?(?=\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", + "beginCaptures": { + "1": { + "name": "storage.modifier.ts" + } + }, + "end": "(?x)(?=\\}|;|,|$|(^(?!\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "patterns": [ { - "include": "#template" + "include": "#variable-initializer" }, { - "include": "#comment" + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", + "end": "(?x)(?=[};,=]|$|(^(?!\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "patterns": [ + { + "include": "#type-annotation" + }, + { + "include": "#string" + }, + { + "include": "#array-literal" + }, + { + "include": "#numeric-literal" + }, + { + "include": "#comment" + }, + { + "match": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(\\?)?(?=(\\?\\s*)?\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "meta.definition.property.ts entity.name.function.ts" + }, + "2": { + "name": "keyword.operator.optional.ts" + } + } + }, + { + "name": "meta.definition.property.ts variable.object.property.ts", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + { + "name": "keyword.operator.optional.ts", + "match": "\\?" + } + ] + } + ] + }, + "variable-initializer": { + "patterns": [ + { + "begin": "(?<!=|!)(=)(?!=)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.ts" + } + }, + "end": "(?=$|^|[,);}\\]])", + "patterns": [ + { + "include": "#expression" + } + ] }, { - "include": "#function-expression" + "begin": "(?<!=|!)(=)(?!=)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.ts" + } + }, + "end": "(?=[,);}\\]])|(?=^\\s*$)|(?<=\\S)(?<!=)(?=\\s*$)", + "patterns": [ + { + "include": "#expression" + } + ] + } + ] + }, + "function-declaration": { + "name": "meta.function.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.export.ts" }, + "2": { + "name": "storage.modifier.async.ts" + }, + "3": { + "name": "storage.type.function.ts" + }, + "4": { + "name": "keyword.generator.asterisk.ts" + }, + "5": { + "name": "meta.definition.function.ts entity.name.function.ts" + } + }, + "end": "(?=$|^|;)|(?<=\\})", + "patterns": [ { - "include": "#class-or-interface-declaration" + "include": "#function-name" }, { - "include": "#arrow-function" + "include": "#function-body" + } + ] + }, + "function-expression": { + "name": "meta.function.expression.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" }, + "2": { + "name": "storage.type.function.ts" + }, + "3": { + "name": "keyword.generator.asterisk.ts" + }, + "4": { + "name": "meta.definition.function.ts entity.name.function.ts" + } + }, + "end": "(?<=\\})", + "patterns": [ { - "include": "#cast" + "include": "#function-name" }, { - "include": "#ternary-expression" + "include": "#function-body" + } + ] + }, + "function-name": { + "name": "meta.definition.function.ts entity.name.function.ts", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + "function-body": { + "patterns": [ + { + "include": "#comment" }, { - "include": "#new-expr" + "include": "#type-parameters" }, { - "include": "#object-literal" + "include": "#function-parameters" }, { - "include": "#expression-operators" + "include": "#return-type" }, { - "include": "#function-call" + "include": "#decl-block" }, { - "include": "#literal" + "name": "keyword.generator.asterisk.ts", + "match": "\\*" + } + ] + }, + "method-declaration": { + "patterns": [ + { + "name": "meta.method.declaration.ts", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?\\s*\\b(constructor)\\b(?!:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "storage.modifier.ts" + }, + "3": { + "name": "storage.modifier.async.ts" + }, + "4": { + "name": "storage.type.ts" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] }, { - "include": "#support-objects" + "name": "meta.method.declaration.ts", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:(?:\\s*\\b(new)\\b(?!:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|(?:(\\*)\\s*)?)(?=\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "storage.modifier.ts" + }, + "3": { + "name": "storage.modifier.async.ts" + }, + "4": { + "name": "keyword.operator.new.ts" + }, + "5": { + "name": "keyword.generator.asterisk.ts" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] }, { - "include": "#identifiers" + "name": "meta.method.declaration.ts", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "storage.modifier.ts" + }, + "3": { + "name": "storage.modifier.async.ts" + }, + "4": { + "name": "storage.type.property.ts" + }, + "5": { + "name": "keyword.generator.asterisk.ts" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] + } + ] + }, + "object-literal-method-declaration": { + "name": "meta.method.declaration.ts", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" }, + "2": { + "name": "storage.type.property.ts" + }, + "3": { + "name": "keyword.generator.asterisk.ts" + } + }, + "end": "(?=\\}|;|,)|(?<=\\})", + "patterns": [ { - "include": "#paren-expression" + "include": "#method-declaration-name" }, { - "include": "#punctuation-comma" + "include": "#function-body" }, { - "include": "#punctuation-accessor" + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + }, + "2": { + "name": "storage.type.property.ts" + }, + "3": { + "name": "keyword.generator.asterisk.ts" + } + }, + "end": "(?=\\(|\\<)", + "patterns": [ + { + "include": "#method-declaration-name" + } + ] } ] }, - "control-statement": { + "method-declaration-name": { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??)\\s*[\\(\\<])", + "end": "(?=\\(|\\<)", "patterns": [ { - "name": "keyword.control.trycatch.ts", - "match": "(?<!\\.|\\$)\\b(catch|finally|throw|try)\\b(?!\\$|\\.)" + "include": "#string" }, { - "name": "keyword.control.loop.ts", - "match": "(?<!\\.|\\$)\\b(break|continue|do|goto|while)\\b(?!\\$|\\.)" + "include": "#array-literal" }, { - "name": "keyword.control.flow.ts", - "match": "(?<!\\.|\\$)\\b(return)\\b(?!\\$|\\.)" + "include": "#numeric-literal" }, { - "name": "keyword.control.switch.ts", - "match": "(?<!\\.|\\$)\\b(case|default|switch)\\b(?!\\$|\\.)" + "name": "meta.definition.method.ts entity.name.function.ts", + "match": "[_$[:alpha:]][_$[:alnum:]]*" }, { - "name": "keyword.control.conditional.ts", - "match": "(?<!\\.|\\$)\\b(else|if)\\b(?!\\$|\\.)" - }, + "name": "keyword.operator.optional.ts", + "match": "\\?" + } + ] + }, + "arrow-function": { + "patterns": [ { - "name": "keyword.control.with.ts", - "match": "(?<!\\.|\\$)\\b(with)\\b(?!\\$|\\.)" + "name": "meta.arrow.ts", + "match": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\\s+)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)", + "captures": { + "1": { + "name": "storage.modifier.async.ts" + }, + "2": { + "name": "variable.parameter.ts" + } + } }, { - "name": "keyword.other.debugger.ts", - "match": "(?<!\\.|\\$)\\b(debugger)\\b(?!\\$|\\.)" + "name": "meta.arrow.ts", + "begin": "(?x) (?:\n (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\n)? ((?<![})!\\]])\\s*\n (?=\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n )\n)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "include": "#function-parameters" + }, + { + "include": "#arrow-return-type" + } + ] }, { - "name": "storage.modifier.ts", - "match": "(?<!\\.|\\$)\\b(declare)\\b(?!\\$|\\.)" + "name": "meta.arrow.ts", + "begin": "=>", + "beginCaptures": { + "0": { + "name": "storage.type.function.arrow.ts" + } + }, + "end": "(?<=\\}|\\S)(?<!=>)|((?!\\{)(?=\\S))", + "patterns": [ + { + "include": "#decl-block" + }, + { + "include": "#expression" + } + ] } ] }, - "declaration": { + "indexer-declaration": { + "name": "meta.indexer.declaration.ts", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(readonly)\\s*)?\\s*(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "beginCaptures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "meta.brace.square.ts" + }, + "3": { + "name": "variable.parameter.ts" + } + }, + "end": "(\\])\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.ts" + }, + "2": { + "name": "keyword.operator.optional.ts" + } + }, "patterns": [ { - "include": "#decorator" + "include": "#type-annotation" + } + ] + }, + "indexer-mapped-type-declaration": { + "name": "meta.indexer.mappedtype.declaration.ts", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))([+-])?(readonly)\\s*)?\\s*(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s+(in)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.modifier.ts" }, - { - "include": "#var-expr" + "2": { + "name": "storage.modifier.ts" + }, + "3": { + "name": "meta.brace.square.ts" + }, + "4": { + "name": "entity.name.type.ts" }, + "5": { + "name": "keyword.operator.expression.in.ts" + } + }, + "end": "(\\])([+-])?\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.ts" + }, + "2": { + "name": "keyword.operator.type.modifier.ts" + }, + "3": { + "name": "keyword.operator.optional.ts" + } + }, + "patterns": [ { - "include": "#function-declaration" + "include": "#type" + } + ] + }, + "function-parameters": { + "name": "meta.parameters.ts", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.definition.parameters.begin.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.parameters.end.ts" + } + }, + "patterns": [ + { + "include": "#function-parameters-body" + } + ] + }, + "function-parameters-body": { + "patterns": [ + { + "include": "#comment" }, { - "include": "#class-or-interface-declaration" + "include": "#decorator" }, { - "include": "#type-declaration" + "include": "#destructuring-parameter" }, { - "include": "#enum-declaration" + "include": "#parameter-name" }, { - "include": "#namespace-declaration" + "include": "#type-annotation" }, { - "include": "#import-equals-declaration" + "include": "#variable-initializer" }, { - "include": "#import-declaration" + "name": "punctuation.separator.parameter.ts", + "match": "," + } + ] + }, + "class-declaration": { + "name": "meta.class.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(class)\\b(?=\\s+|/[/*])", + "beginCaptures": { + "1": { + "name": "keyword.control.export.ts" }, + "2": { + "name": "storage.modifier.ts" + }, + "3": { + "name": "storage.type.class.ts" + } + }, + "end": "(?<=\\})", + "patterns": [ { - "include": "#export-declaration" + "include": "#class-declaration-or-expression-patterns" } ] }, - "decorator": { - "name": "meta.decorator.ts", - "begin": "(?<!\\.|\\$)\\@", + "class-expression": { + "name": "meta.class.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(class)\\b(?=\\s+|[<{]|\\/[\\/*])", "beginCaptures": { - "0": { - "name": "punctuation.decorator.ts" + "1": { + "name": "storage.type.class.ts" } }, - "end": "(?=\\s)", + "end": "(?<=\\})", "patterns": [ { - "include": "#expression" + "include": "#class-declaration-or-expression-patterns" } ] }, - "type-declaration": { - "name": "meta.type.declaration.ts", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(type)\\b\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*", + "class-declaration-or-expression-patterns": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" + }, + { + "match": "[_$[:alpha:]][_$[:alnum:]]*", + "captures": { + "0": { + "name": "entity.name.type.class.ts" + } + } + }, + { + "include": "#type-parameters" + }, + { + "include": "#class-or-interface-body" + } + ] + }, + "interface-declaration": { + "name": "meta.interface.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(interface)\\b(?=\\s+|/[/*])", "beginCaptures": { "1": { "name": "keyword.control.export.ts" }, "2": { - "name": "storage.type.type.ts" + "name": "storage.modifier.ts" }, "3": { - "name": "entity.name.type.alias.ts" + "name": "storage.type.interface.ts" } }, - "end": "(?=[};]|\\bvar\\b|\\blet\\b|\\bconst\\b|\\btype\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\bnamespace\\b|\\bmodule\\b|\\bimport\\b|\\benum\\b|\\bdeclare\\b|\\bexport\\b|\\babstract\\b|\\basync\\b)", + "end": "(?<=\\})", "patterns": [ { "include": "#comment" }, { + "include": "#class-or-interface-heritage" + }, + { + "match": "[_$[:alpha:]][_$[:alnum:]]*", + "captures": { + "0": { + "name": "entity.name.type.interface.ts" + } + } + }, + { "include": "#type-parameters" }, { - "include": "#type" + "include": "#class-or-interface-body" + } + ] + }, + "class-or-interface-heritage": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(extends|implements)\\b)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "storage.modifier.ts" + } + }, + "end": "(?=\\{)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" + }, + { + "include": "#type-parameters" + }, + { + "include": "#expressionWithoutIdentifiers" }, { - "match": "(=)\\s*", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*)", "captures": { "1": { - "name": "keyword.operator.assignment.ts" + "name": "entity.name.type.module.ts" + }, + "2": { + "name": "punctuation.accessor.ts" + }, + "3": { + "name": "punctuation.accessor.optional.ts" + } + } + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "entity.other.inherited-class.ts" } } + }, + { + "include": "#expressionPunctuations" + } + ] + }, + "class-or-interface-body": { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.ts" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#decorator" + }, + { + "include": "#method-declaration" + }, + { + "include": "#indexer-declaration" + }, + { + "include": "#field-declaration" + }, + { + "include": "#string" + }, + { + "include": "#type-annotation" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#access-modifier" + }, + { + "include": "#property-accessor" + }, + { + "include": "#async-modifier" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-semicolon" } ] }, + "access-modifier": { + "name": "storage.modifier.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(abstract|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "property-accessor": { + "name": "storage.type.property.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(get|set)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "async-modifier": { + "name": "storage.modifier.async.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(async)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, "enum-declaration": { "name": "meta.enum.declaration.ts", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)", "beginCaptures": { "1": { "name": "keyword.control.export.ts" @@ -580,7 +1555,7 @@ ] }, { - "begin": "(?=((\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))", + "begin": "(?=((\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))", "end": "(?=,|\\}|$)", "patterns": [ { @@ -606,7 +1581,7 @@ }, "namespace-declaration": { "name": "meta.namespace.declaration.ts", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+(?=[_$[:alpha:]\"'`])", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+(?=[_$[:alpha:]\"'`]))", "beginCaptures": { "1": { "name": "keyword.control.export.ts" @@ -615,7 +1590,7 @@ "name": "storage.type.namespace.ts" } }, - "end": "(?<=\\})", + "end": "(?<=\\})|(?=;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#comment" @@ -635,11 +1610,49 @@ } ] }, + "type-alias-declaration": { + "name": "meta.type.declaration.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(type)\\b\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.export.ts" + }, + "2": { + "name": "storage.type.type.ts" + }, + "3": { + "name": "entity.name.type.alias.ts" + } + }, + "end": "(?=\\}|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "begin": "(=)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.ts" + } + }, + "end": "(?=\\}|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, "import-equals-declaration": { "patterns": [ { "name": "meta.import-equals.external.ts", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(require)\\s*(\\()", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(require)\\s*(\\()", "beginCaptures": { "1": { "name": "keyword.control.export.ts" @@ -677,7 +1690,7 @@ }, { "name": "meta.import-equals.internal.ts", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(?!require\\b)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(?!require\\b)", "beginCaptures": { "1": { "name": "keyword.control.export.ts" @@ -692,19 +1705,22 @@ "name": "keyword.operator.assignment.ts" } }, - "end": "(?=;|$)", + "end": "(?=;|$|^)", "patterns": [ { "include": "#comment" }, { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", "captures": { "1": { "name": "entity.name.type.module.ts" }, "2": { "name": "punctuation.accessor.ts" + }, + "3": { + "name": "punctuation.accessor.optional.ts" } } }, @@ -718,7 +1734,7 @@ }, "import-declaration": { "name": "meta.import.ts", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)(?!(\\s*:)|(\\$|\\.))\\b", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)(?!\\s*[:\\(])(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { "name": "keyword.control.export.ts" @@ -727,9 +1743,29 @@ "name": "keyword.control.import.ts" } }, - "end": "(?=;|$)", + "end": "(?<!^import|[^\\._$[:alnum:]]import)(?=;|$|^)", "patterns": [ { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "begin": "(?<=^import|[^\\._$[:alnum:]]import)(?!\\s*[\"'])", + "end": "\\bfrom\\b", + "endCaptures": { + "0": { + "name": "keyword.control.from.ts" + } + }, + "patterns": [ + { + "include": "#import-export-declaration" + } + ] + }, + { "include": "#import-export-declaration" } ] @@ -737,7 +1773,7 @@ "export-declaration": { "patterns": [ { - "match": "(?<!\\.|\\$)\\b(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "keyword.control.export.ts" @@ -755,7 +1791,7 @@ }, { "name": "meta.export.default.ts", - "begin": "(?<!\\.|\\$)\\b(export)(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))", "beginCaptures": { "1": { "name": "keyword.control.export.ts" @@ -767,7 +1803,7 @@ "name": "keyword.control.default.ts" } }, - "end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)", + "end": "(?=$|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#expression" @@ -776,13 +1812,13 @@ }, { "name": "meta.export.ts", - "begin": "(?<!\\.|\\$)\\b(export)(?!(\\s*:)|(\\$))\\b", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?!\\s*:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "0": { "name": "keyword.control.export.ts" } }, - "end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)", + "end": "(?=$|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#import-export-declaration" @@ -837,8 +1873,7 @@ "include": "#comment" }, { - "comment": "(default|*|name) as alias", - "match": "(?x) (?: \\b(default)\\b | (\\*) | ([_$[:alpha:]][_$[:alnum:]]*)) \\s+ \n (as) \\s+ (?: (\\b default \\b | \\*) | ([_$[:alpha:]][_$[:alnum:]]*))", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bdefault)|(\\*)|(\\b[_$[:alpha:]][_$[:alnum:]]*))\\s+(as)\\s+(?:(\\bdefault(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|(\\b[_$[:alpha:]][_$[:alnum:]]*))", "captures": { "1": { "name": "keyword.control.default.ts" @@ -853,7 +1888,7 @@ "name": "keyword.control.as.ts" }, "5": { - "name": "invalid.illegal.ts" + "name": "keyword.control.default.ts" }, "6": { "name": "variable.other.readwrite.alias.ts" @@ -877,147 +1912,170 @@ } ] }, - "class-or-interface-declaration": { + "switch-statement": { + "name": "switch-statement.expr.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?=\\bswitch\\s*\\()", + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.ts" + } + }, "patterns": [ { - "name": "meta.class.ts", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(class)\\b(?=\\s+|/[/*])", + "name": "switch-expression.expr.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(switch)\\s*(\\()", "beginCaptures": { "1": { - "name": "keyword.control.export.ts" + "name": "keyword.control.switch.ts" }, "2": { - "name": "storage.modifier.ts" - }, - "3": { - "name": "storage.type.class.ts" + "name": "meta.brace.round.ts" } }, - "end": "(?<=\\})", + "end": "\\)", "endCaptures": { - "1": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "name": "switch-block.expr.ts", + "begin": "\\{", + "beginCaptures": { + "0": { "name": "punctuation.definition.block.ts" } }, + "end": "(?=\\})", "patterns": [ { - "include": "#comment" + "name": "case-clause.expr.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default(?=:))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "keyword.control.switch.ts" + } + }, + "end": "(?=:)", + "patterns": [ + { + "include": "#expression" + } + ] }, { - "include": "#class-or-interface-heritage" + "begin": "(:)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "case-clause.expr.ts punctuation.definition.section.case-statement.ts" + }, + "2": { + "name": "meta.block.ts punctuation.definition.block.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "meta.block.ts punctuation.definition.block.ts" + } + }, + "contentName": "meta.block.ts", + "patterns": [ + { + "include": "#statements" + } + ] }, { - "match": "[_$[:alpha:]][_$[:alnum:]]*", + "match": "(:)", "captures": { "0": { - "name": "entity.name.type.class.ts" + "name": "case-clause.expr.ts punctuation.definition.section.case-statement.ts" } } }, { - "include": "#type-parameters" - }, - { - "include": "#class-or-interface-body" + "include": "#statements" } ] + } + ] + }, + "for-loop": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))for(?=((\\s+|(\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*))await)?\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)?(\\())", + "beginCaptures": { + "0": { + "name": "keyword.control.loop.ts" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#comment" + }, + { + "name": "keyword.control.loop.ts", + "match": "await" }, { - "name": "meta.interface.ts", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(interface)\\b(?=\\s+|/[/*])", + "begin": "\\(", "beginCaptures": { - "1": { - "name": "keyword.control.export.ts" - }, - "2": { - "name": "storage.modifier.ts" - }, - "3": { - "name": "storage.type.interface.ts" + "0": { + "name": "meta.brace.round.ts" } }, - "end": "(?<=\\})", + "end": "\\)", "endCaptures": { - "1": { - "name": "punctuation.definition.block.ts" + "0": { + "name": "meta.brace.round.ts" } }, "patterns": [ { - "include": "#comment" + "include": "#var-expr" }, { - "include": "#class-or-interface-heritage" - }, - { - "match": "[_$[:alpha:]][_$[:alnum:]]*", - "captures": { - "0": { - "name": "entity.name.type.interface.ts" - } - } - }, - { - "include": "#type-parameters" + "include": "#expression" }, { - "include": "#class-or-interface-body" + "include": "#punctuation-semicolon" } ] } ] }, - "class-or-interface-heritage": { - "begin": "(?<!\\.|\\$)(?:\\b(extends|implements)\\b)(?!\\$|\\.)", + "decl-block": { + "name": "meta.block.ts", + "begin": "\\{", "beginCaptures": { - "1": { - "name": "storage.modifier.ts" + "0": { + "name": "punctuation.definition.block.ts" } }, - "end": "(?=\\{)", + "end": "\\}", "endCaptures": { - "1": { + "0": { "name": "punctuation.definition.block.ts" } }, "patterns": [ { - "include": "#comment" - }, - { - "include": "#class-or-interface-heritage" - }, - { - "include": "#type-parameters" - }, - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*([,<{]|extends|implements|//|/\\*))", - "captures": { - "1": { - "name": "entity.name.type.module.ts" - }, - "2": { - "name": "punctuation.accessor.ts" - } - } - }, - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*([,<{]|extends|implements|//|/\\*))", - "captures": { - "1": { - "name": "entity.other.inherited-class.ts" - } - } - }, - { - "include": "#expression" + "include": "#statements" } ] }, - "class-or-interface-body": { - "begin": "\\{", + "after-operator-block-as-object-literal": { + "name": "meta.objectliteral.ts", + "begin": "(?<!\\+\\+|--)(?<=[:=(,\\[?+!>]|^await|[^\\._$[:alnum:]]await|^return|[^\\._$[:alnum:]]return|^yield|[^\\._$[:alnum:]]yield|^throw|[^\\._$[:alnum:]]throw|^in|[^\\._$[:alnum:]]in|^of|[^\\._$[:alnum:]]of|^typeof|[^\\._$[:alnum:]]typeof|&&|\\|\\||\\*)\\s*(\\{)", "beginCaptures": { - "0": { + "1": { "name": "punctuation.definition.block.ts" } }, @@ -1029,54 +2087,12 @@ }, "patterns": [ { - "include": "#string" - }, - { - "include": "#comment" - }, - { - "include": "#decorator" - }, - { - "include": "#method-declaration" - }, - { - "include": "#indexer-declaration" - }, - { - "include": "#field-declaration" - }, - { - "include": "#type-annotation" - }, - { - "include": "#variable-initializer" - }, - { - "include": "#access-modifier" - }, - { - "include": "#property-accessor" - }, - { - "include": "#after-operator-block" - }, - { - "include": "#decl-block" - }, - { - "include": "#expression" - }, - { - "include": "#punctuation-comma" - }, - { - "include": "#punctuation-semicolon" + "include": "#object-member" } ] }, - "type-object": { - "name": "meta.object.type.ts", + "object-literal": { + "name": "meta.objectliteral.ts", "begin": "\\{", "beginCaptures": { "0": { @@ -1091,938 +2107,602 @@ }, "patterns": [ { + "include": "#object-member" + } + ] + }, + "object-member": { + "patterns": [ + { "include": "#comment" }, { - "include": "#method-declaration" + "include": "#object-literal-method-declaration" }, { - "include": "#indexer-declaration" + "name": "meta.object.member.ts meta.object-literal.key.ts", + "begin": "(?=\\[)", + "end": "(?=:)|((?<=[\\]])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#array-literal" + } + ] }, { - "include": "#indexer-mapped-type-declaration" + "name": "meta.object.member.ts meta.object-literal.key.ts", + "begin": "(?=[\\'\\\"])", + "end": "(?=:)|((?<=[\\'\\\"])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#string" + } + ] }, { - "include": "#field-declaration" + "name": "meta.method.declaration.ts", + "begin": "(?<=[\\]\\'\\\"])(?=\\s*[\\(\\<])", + "end": "(?=\\}|;|,)|(?<=\\})", + "patterns": [ + { + "include": "#function-body" + } + ] }, { - "include": "#type-annotation" + "name": "meta.object.member.ts", + "match": "(?![_$[:alpha:]])([[:digit:]]+)\\s*(?=:)", + "captures": { + "0": { + "name": "meta.object-literal.key.ts" + }, + "1": { + "name": "constant.numeric.decimal.ts" + } + } }, { + "name": "meta.object.member.ts", + "match": "(?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "0": { + "name": "meta.object-literal.key.ts" + }, + "1": { + "name": "entity.name.function.ts" + } + } + }, + { + "name": "meta.object.member.ts", + "match": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "captures": { + "0": { + "name": "meta.object-literal.key.ts" + } + } + }, + { + "name": "meta.object.member.ts", "begin": "\\.\\.\\.", "beginCaptures": { "0": { "name": "keyword.operator.spread.ts" } }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + "end": "(?=,|\\})", "patterns": [ { - "include": "#type" + "include": "#expression" } ] }, { - "include": "#punctuation-comma" - }, - { - "include": "#punctuation-semicolon" - }, - { - "include": "#type" - } - ] - }, - "field-declaration": { - "name": "meta.field.declaration.ts", - "begin": "(?<!\\()(?:(?<!\\.|\\$)\\b(readonly)\\s+)?(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", - "beginCaptures": { - "1": { - "name": "storage.modifier.ts" - } - }, - "end": "(?=\\}|;|,|$|(^(?!(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", - "patterns": [ - { - "include": "#variable-initializer" + "name": "meta.object.member.ts", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$)", + "captures": { + "1": { + "name": "variable.other.readwrite.ts" + } + } }, { - "begin": "(?=((?:[_$[:alpha:]][_$[:alnum:]]*)|(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", - "end": "(?=[};,=]|$|(^(?!(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "name": "meta.object.member.ts", + "begin": "(?=[_$[:alpha:]][_$[:alnum:]]*\\s*=)", + "end": "(?=,|\\}|$)", "patterns": [ { - "include": "#type-annotation" - }, - { - "include": "#string" - }, - { - "include": "#array-literal" - }, - { - "include": "#comment" - }, - { - "name": "meta.definition.property.ts entity.name.function.ts", - "match": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=(\\?\\s*)?\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)" - }, - { - "name": "meta.definition.property.ts variable.object.property.ts", - "match": "[_$[:alpha:]][_$[:alnum:]]*" - }, - { - "name": "keyword.operator.optional.ts", - "match": "\\?" + "include": "#expression" } ] - } - ] - }, - "method-declaration": { - "patterns": [ + }, { - "name": "meta.method.declaration.ts", - "begin": "(?<!\\.|\\$)(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "name": "meta.object.member.ts", + "begin": ":", "beginCaptures": { - "1": { - "name": "storage.modifier.ts" - }, - "2": { - "name": "storage.modifier.ts" - }, - "3": { - "name": "storage.modifier.async.ts" - }, - "4": { - "name": "storage.type.property.ts" - }, - "5": { - "name": "keyword.generator.asterisk.ts" + "0": { + "name": "meta.object-literal.key.ts punctuation.separator.key-value.ts" } }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + "end": "(?=,|\\})", "patterns": [ { - "include": "#method-declaration-name" - }, - { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" + "begin": "(?<=:)\\s*(async)?(?=\\s*(<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)\\(\\s*([\\{\\[]\\s*)?$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#type-parameters" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + } + ] }, { - "include": "#return-type" + "begin": "(?<=:)\\s*(async)?\\s*(\\()(?=\\s*([\\{\\[]\\s*)?$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + }, + "2": { + "name": "meta.brace.round.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] }, { - "include": "#decl-block" + "include": "#expression" } ] }, { - "name": "meta.method.declaration.ts", - "begin": "(?<!\\.|\\$)(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:(?:\\b(?:(new)|(constructor))\\b(?!\\$|\\.|:))|(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))?\\s*[\\(\\<]))", - "beginCaptures": { - "1": { - "name": "storage.modifier.ts" - }, - "2": { - "name": "storage.modifier.ts" - }, - "3": { - "name": "storage.modifier.async.ts" - }, - "4": { - "name": "keyword.operator.new.ts" - }, - "5": { - "name": "storage.type.ts" - }, - "6": { - "name": "keyword.generator.asterisk.ts" - } - }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + "include": "#punctuation-comma" + } + ] + }, + "ternary-expression": { + "begin": "(?!\\?\\.\\s*[^[:digit:]])(\\?)", + "beginCaptures": { + "1": { + "name": "keyword.operator.ternary.ts" + } + }, + "end": "\\s*(:)", + "endCaptures": { + "1": { + "name": "keyword.operator.ternary.ts" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + "function-call": { + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "end": "(?<=\\))(?!(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "patterns": [ + { + "name": "meta.function-call.ts", + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*))", + "end": "(?=\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", "patterns": [ { - "include": "#method-declaration-name" + "include": "#literal" }, { - "include": "#comment" + "include": "#support-objects" }, { - "include": "#type-parameters" + "include": "#object-identifiers" }, { - "include": "#function-parameters" + "include": "#punctuation-accessor" }, { - "include": "#return-type" + "name": "keyword.operator.expression.import.ts", + "match": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))import(?=\\s*[\\(]\\s*[\\\"\\'\\`]))" }, { - "include": "#decl-block" + "name": "entity.name.function.ts", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" } ] - } - ] - }, - "method-declaration-name": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??)\\s*[\\(\\<])", - "end": "(?=\\(|\\<)", - "patterns": [ + }, { - "include": "#string" + "include": "#comment" }, { - "include": "#array-literal" + "name": "meta.function-call.ts punctuation.accessor.optional.ts", + "match": "\\?\\." }, { - "name": "meta.definition.method.ts entity.name.function.ts", - "match": "[_$[:alpha:]][_$[:alnum:]]*" + "include": "#type-arguments" }, { - "name": "keyword.operator.optional.ts", - "match": "\\?" + "include": "#paren-expression" } ] }, - "object-literal-method-declaration": { - "name": "meta.method.declaration.ts", - "begin": "(?<!\\.|\\$)(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "new-expr": { + "name": "new.expr.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { - "name": "storage.modifier.async.ts" - }, - "2": { - "name": "storage.type.property.ts" - }, - "3": { - "name": "keyword.generator.asterisk.ts" + "name": "keyword.operator.new.ts" } }, - "end": "(?=\\}|;|,)|(?<=\\})", + "end": "(?<=\\))|(?=[;),}\\]:]|\\|\\||\\&\\&|$|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))new(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))function((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", "patterns": [ { - "include": "#method-declaration-name" - }, - { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" - }, - { - "include": "#return-type" + "include": "#paren-expression" }, { - "include": "#object-literal-method-overload-declaration" + "include": "#class-declaration" }, { - "include": "#decl-block" + "include": "#type" } ] }, - "object-literal-method-overload-declaration": { - "begin": "(?<!\\.|\\$)(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "instanceof-expr": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(instanceof)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { - "name": "storage.modifier.async.ts" - }, - "2": { - "name": "storage.type.property.ts" - }, - "3": { - "name": "keyword.generator.asterisk.ts" + "name": "keyword.operator.expression.instanceof.ts" } }, - "end": "(?=\\(|\\<)", + "end": "(?<=\\))|(?=[;),}\\]:?]|\\|\\||\\&\\&|$|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))function((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", "patterns": [ { - "include": "#method-declaration-name" + "include": "#type" } ] }, - "indexer-declaration": { - "name": "meta.indexer.declaration.ts", - "begin": "(?:(?<!\\.|\\$)\\b(readonly)\\s*)?(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", - "beginCaptures": { - "1": { - "name": "storage.modifier.ts" - }, - "2": { - "name": "meta.brace.square.ts" - }, - "3": { - "name": "variable.parameter.ts" - } - }, - "end": "(\\])\\s*(\\?\\s*)?|$", - "endCaptures": { - "1": { - "name": "meta.brace.square.ts" - }, - "2": { - "name": "keyword.operator.optional.ts" - } - }, + "paren-expression-possibly-arrow": { "patterns": [ { - "include": "#type-annotation" - } - ] - }, - "indexer-mapped-type-declaration": { - "name": "meta.indexer.mappedtype.declaration.ts", - "begin": "(?:(?<!\\.|\\$)\\b(readonly)\\s*)?(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s+(in)\\s+", - "beginCaptures": { - "1": { - "name": "storage.modifier.ts" - }, - "2": { - "name": "meta.brace.square.ts" - }, - "3": { - "name": "entity.name.type.ts" + "begin": "(?<=[(=,])\\s*(async)?(?=\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*))?\\(\\s*[\\{\\[]\\s*$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#paren-expression-possibly-arrow-with-typeparameters" + } + ] }, - "4": { - "name": "keyword.operator.expression.in.ts" - } - }, - "end": "(\\])\\s*(\\?\\s*)?|$", - "endCaptures": { - "1": { - "name": "meta.brace.square.ts" + { + "begin": "(?<=[(=,]|=>)\\s*(async)?(?=\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*))?\\(\\s*$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#paren-expression-possibly-arrow-with-typeparameters" + } + ] }, - "2": { - "name": "keyword.operator.optional.ts" - } - }, - "patterns": [ { - "include": "#type" + "include": "#possibly-arrow-return-type" } ] }, - "function-declaration": { - "name": "meta.function.ts", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", - "beginCaptures": { - "1": { - "name": "keyword.control.export.ts" - }, - "2": { - "name": "storage.modifier.async.ts" - }, - "3": { - "name": "storage.type.function.ts" - }, - "4": { - "name": "keyword.generator.asterisk.ts" - }, - "5": { - "name": "meta.definition.function.ts entity.name.function.ts" - } - }, - "end": "(?=$|^|;)|(?<=\\})", + "paren-expression-possibly-arrow-with-typeparameters": { "patterns": [ { - "include": "#comment" - }, - { "include": "#type-parameters" }, { - "include": "#function-parameters" - }, - { - "include": "#return-type" - }, - { - "include": "#decl-block" + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] } ] }, - "function-expression": { - "name": "meta.function.expression.ts", - "begin": "(?<!\\.|\\$)\\b(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", - "beginCaptures": { - "1": { - "name": "storage.modifier.async.ts" - }, - "2": { - "name": "storage.type.function.ts" - }, - "3": { - "name": "keyword.generator.asterisk.ts" - }, - "4": { - "name": "meta.definition.function.ts entity.name.function.ts" - } - }, - "end": "(?<=\\})", + "expression-inside-possibly-arrow-parens": { "patterns": [ { - "include": "#comment" + "include": "#expressionWithoutIdentifiers" }, { - "include": "#type-parameters" + "include": "#function-parameters-body" }, { - "include": "#function-parameters" - }, - { - "include": "#return-type" + "include": "#identifiers" }, { - "include": "#decl-block" - } - ] - }, - "object-literal": { - "name": "meta.objectliteral.ts", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.ts" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.ts" - } - }, - "patterns": [ - { - "include": "#object-member" + "include": "#expressionPunctuations" } ] }, - "decl-block": { - "name": "meta.block.ts", - "begin": "\\{", + "paren-expression": { + "begin": "\\(", "beginCaptures": { "0": { - "name": "punctuation.definition.block.ts" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.ts" - } - }, - "patterns": [ - { - "include": "#statements" - } - ] - }, - "after-operator-block": { - "name": "meta.objectliteral.ts", - "begin": "(?<=[=(,\\[?+!]|await|return|yield|throw|in|of|typeof|&&|\\|\\||\\*)\\s*(\\{)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.block.ts" + "name": "meta.brace.round.ts" } }, - "end": "\\}", + "end": "\\)", "endCaptures": { "0": { - "name": "punctuation.definition.block.ts" + "name": "meta.brace.round.ts" } }, "patterns": [ { - "include": "#object-member" - } - ] - }, - "parameter-name": { - "patterns": [ - { - "match": "\\s*\\b(public|protected|private|readonly)(?=\\s+(public|protected|private|readonly)\\s+)", - "captures": { - "1": { - "name": "storage.modifier.ts" - } - } - }, - { - "match": "(?x)(?:\\s*\\b(public|private|protected|readonly)\\s+)?(\\.\\.\\.)?\\s*(?<!=|:)(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)", - "captures": { - "1": { - "name": "storage.modifier.ts" - }, - "2": { - "name": "keyword.operator.rest.ts" - }, - "3": { - "name": "entity.name.function.ts variable.language.this.ts" - }, - "4": { - "name": "entity.name.function.ts" - }, - "5": { - "name": "keyword.operator.optional.ts" - } - } - }, - { - "match": "(?:\\s*\\b(public|private|protected|readonly)\\s+)?(\\.\\.\\.)?\\s*(?<!=|:)(?:((?<!\\.|\\$)\\bthis\\b(?!\\.|\\$))|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)", - "captures": { - "1": { - "name": "storage.modifier.ts" - }, - "2": { - "name": "keyword.operator.rest.ts" - }, - "3": { - "name": "variable.parameter.ts variable.language.this.ts" - }, - "4": { - "name": "variable.parameter.ts" - }, - "5": { - "name": "keyword.operator.optional.ts" - } - } + "include": "#expression" } ] }, - "destructuring-parameter": { + "cast": { "patterns": [ { - "name": "meta.parameter.object-binding-pattern.ts", - "begin": "(?<!=|:)\\s*(\\{)", + "name": "cast.expr.ts", + "begin": "(?:(?<!\\+\\+|--)(?<=^return|[^\\._$[:alnum:]]return|^throw|[^\\._$[:alnum:]]throw|^yield|[^\\._$[:alnum:]]yield|^await|[^\\._$[:alnum:]]await|^default|[^\\._$[:alnum:]]default|[=(,:>*?\\&\\|\\^]|[^_$[:alnum:]](?:\\+\\+|\\-\\-)|[^\\+]\\+|[^\\-]\\-))\\s*(<)(?!<?\\=)", "beginCaptures": { "1": { - "name": "punctuation.definition.binding-pattern.object.ts" + "name": "meta.brace.angle.ts" } }, - "end": "\\}", + "end": "(\\>)\\s*", "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.object.ts" + "1": { + "name": "meta.brace.angle.ts" } }, "patterns": [ { - "include": "#parameter-object-binding-element" + "include": "#type" } ] }, { - "name": "meta.paramter.array-binding-pattern.ts", - "begin": "(?<!=|:)\\s*(\\[)", + "name": "cast.expr.ts", + "begin": "(?:(?<=^))\\s*(<)(?=[_$[:alpha:]][_$[:alnum:]]*\\s*>)", "beginCaptures": { "1": { - "name": "punctuation.definition.binding-pattern.array.ts" + "name": "meta.brace.angle.ts" } }, - "end": "\\]", + "end": "(\\>)\\s*", "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.array.ts" + "1": { + "name": "meta.brace.angle.ts" } }, "patterns": [ { - "include": "#parameter-binding-element" - }, - { - "include": "#punctuation-comma" + "include": "#type" } ] } ] }, - "parameter-object-binding-element": { + "expression-operators": { "patterns": [ { - "include": "#comment" + "name": "keyword.control.flow.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(await)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", - "end": "(?=,|\\})", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?=\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*\\*)", + "beginCaptures": { + "1": { + "name": "keyword.control.flow.ts" + } + }, + "end": "\\*", + "endCaptures": { + "0": { + "name": "keyword.generator.asterisk.ts" + } + }, "patterns": [ { - "include": "#object-binding-element-propertyName" - }, - { - "include": "#parameter-binding-element" + "include": "#comment" } ] }, { - "include": "#parameter-object-binding-pattern" - }, - { - "include": "#destructuring-parameter-rest" - }, - { - "include": "#variable-initializer" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?:\\s*(\\*))?", + "captures": { + "1": { + "name": "keyword.control.flow.ts" + }, + "2": { + "name": "keyword.generator.asterisk.ts" + } + } }, { - "include": "#punctuation-comma" - } - ] - }, - "parameter-binding-element": { - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.expression.delete.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))delete(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#parameter-object-binding-pattern" + "name": "keyword.operator.expression.in.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))in(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()" }, { - "include": "#parameter-array-binding-pattern" + "name": "keyword.operator.expression.of.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))of(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()" }, { - "include": "#destructuring-parameter-rest" + "name": "keyword.operator.expression.instanceof.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))instanceof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#variable-initializer" - } - ] - }, - "destructuring-parameter-rest": { - "match": "(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)", - "captures": { - "1": { - "name": "keyword.operator.rest.ts" - }, - "2": { - "name": "variable.parameter.ts" - } - } - }, - "parameter-object-binding-pattern": { - "begin": "(?:(\\.\\.\\.)\\s*)?(\\{)", - "beginCaptures": { - "1": { - "name": "keyword.operator.rest.ts" - }, - "2": { - "name": "punctuation.definition.binding-pattern.object.ts" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.object.ts" - } - }, - "patterns": [ - { - "include": "#parameter-object-binding-element" - } - ] - }, - "parameter-array-binding-pattern": { - "begin": "(?:(\\.\\.\\.)\\s*)?(\\[)", - "beginCaptures": { - "1": { - "name": "keyword.operator.rest.ts" + "name": "keyword.operator.new.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))new(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, - "2": { - "name": "punctuation.definition.binding-pattern.array.ts" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.array.ts" - } - }, - "patterns": [ { - "include": "#parameter-binding-element" + "include": "#typeof-operator" }, { - "include": "#punctuation-comma" - } - ] - }, - "return-type": { - "name": "meta.return.type.ts", - "begin": "(?<=\\))\\s*(:)", - "beginCaptures": { - "1": { - "name": "keyword.operator.type.annotation.ts" - } - }, - "end": "(?<![:|&])(?=$|^|[{};,]|//)", - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.expression.void.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))void(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "begin": "(?<=[:])(?=\\s*\\{)", - "end": "(?<=\\})", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(as)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.control.as.ts" + } + }, + "end": "(?=$|^|[;,:})\\]]|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(as)\\s+))", "patterns": [ { - "include": "#type-object" + "include": "#type" } ] }, { - "include": "#type-predicate-operator" - }, - { - "include": "#type" - } - ] - }, - "type-predicate-operator": { - "name": "keyword.operator.expression.is.ts", - "match": "(?<!\\.|\\$)\\bis\\b(?!\\$|\\.)" - }, - "type-annotation": { - "name": "meta.type.annotation.ts", - "begin": ":", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.annotation.ts" - } - }, - "end": "(?=$|^|[,);\\}\\]]|//)|(?==[^>])|(?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)", - "patterns": [ - { - "include": "#comment" - }, - { - "include": "#type" - } - ] - }, - "type": { - "patterns": [ - { - "include": "#comment" - }, - { - "include": "#string" - }, - { - "include": "#numeric-literal" - }, - { - "include": "#type-primitive" - }, - { - "include": "#type-builtin-literals" - }, - { - "include": "#type-parameters" - }, - { - "include": "#type-tuple" - }, - { - "include": "#type-object" + "name": "keyword.operator.spread.ts", + "match": "\\.\\.\\." }, { - "include": "#type-operators" + "name": "keyword.operator.assignment.compound.ts", + "match": "\\*=|(?<!\\()/=|%=|\\+=|\\-=" }, { - "include": "#type-fn-type-parameters" + "name": "keyword.operator.assignment.compound.bitwise.ts", + "match": "\\&=|\\^=|<<=|>>=|>>>=|\\|=" }, { - "include": "#type-paren-or-function-parameters" + "name": "keyword.operator.bitwise.shift.ts", + "match": "<<|>>>|>>" }, { - "include": "#type-function-return-type" + "name": "keyword.operator.comparison.ts", + "match": "===|!==|==|!=" }, { - "include": "#type-name" - } - ] - }, - "function-parameters": { - "name": "meta.parameters.ts", - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "punctuation.definition.parameters.begin.ts" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.parameters.end.ts" - } - }, - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.relational.ts", + "match": "<=|>=|<>|<|>" }, { - "include": "#decorator" + "name": "keyword.operator.logical.ts", + "match": "\\!|&&|\\|\\|" }, { - "include": "#destructuring-parameter" + "name": "keyword.operator.bitwise.ts", + "match": "\\&|~|\\^|\\|" }, { - "include": "#parameter-name" + "name": "keyword.operator.assignment.ts", + "match": "\\=" }, { - "include": "#type-annotation" + "name": "keyword.operator.decrement.ts", + "match": "--" }, { - "include": "#variable-initializer" + "name": "keyword.operator.increment.ts", + "match": "\\+\\+" }, { - "name": "punctuation.separator.parameter.ts", - "match": "," - } - ] - }, - "type-primitive": { - "name": "support.type.primitive.ts", - "match": "(?<!\\.|\\$)\\b(string|number|boolean|symbol|any|void|never)\\b(?!\\$|\\.)" - }, - "type-builtin-literals": { - "name": "support.type.builtin.ts", - "match": "(?<!\\.|\\$)\\b(this|true|false|undefined|null|object)\\b(?!\\$|\\.)" - }, - "type-paren-or-function-parameters": { - "name": "meta.type.paren.cover.ts", - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "meta.brace.round.ts" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.ts" - } - }, - "patterns": [ - { - "include": "#type" + "name": "keyword.operator.arithmetic.ts", + "match": "%|\\*|/|-|\\+" }, { - "include": "#function-parameters" - } - ] - }, - "type-fn-type-parameters": { - "patterns": [ - { - "name": "meta.type.constructor.ts", - "match": "(?<!\\.|\\$)\\b(new)\\b(?=\\s*\\<)", + "match": "(?<=[_$[:alnum:])\\]])\\s*(/)(?![/*])", "captures": { "1": { - "name": "keyword.control.new.ts" + "name": "keyword.operator.arithmetic.ts" } } - }, - { - "name": "meta.type.constructor.ts", - "begin": "(?<!\\.|\\$)\\b(new)\\b\\s*(?=\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.new.ts" - } - }, - "end": "(?<=\\))", - "patterns": [ - { - "include": "#function-parameters" - } - ] - }, - { - "name": "meta.type.function.ts", - "begin": "(?x)(\n (?=\n [(]\\s*(\n ([)]) | \n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n )\n )\n)", - "end": "(?<=\\))", - "patterns": [ - { - "include": "#function-parameters" - } - ] } ] }, - "type-operators": { + "typeof-operator": { + "name": "keyword.operator.expression.typeof.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))typeof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "literal": { "patterns": [ { - "include": "#typeof-operator" + "include": "#numeric-literal" }, { - "begin": "([&|])(?=\\s*\\{)", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.ts" - } - }, - "end": "(?<=\\})", - "patterns": [ - { - "include": "#type-object" - } - ] + "include": "#boolean-literal" }, { - "begin": "[&|]", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.ts" - } - }, - "end": "(?=\\S)" + "include": "#null-literal" }, { - "name": "keyword.operator.expression.keyof.ts", - "match": "(?<!\\.|\\$)\\bkeyof\\b(?!\\$|\\.)" - } - ] - }, - "type-function-return-type": { - "name": "meta.type.function.return.ts", - "begin": "=>", - "beginCaptures": { - "0": { - "name": "storage.type.function.arrow.ts" - } - }, - "end": "(?<!=>)(?<![|&])(?=[,\\]\\)\\{\\}=;>]|//|$)", - "patterns": [ + "include": "#undefined-literal" + }, { - "include": "#comment" + "include": "#numericConstant-literal" }, { - "begin": "(?<==>)(?=\\s*\\{)", - "end": "(?<=\\})", - "patterns": [ - { - "include": "#type-object" - } - ] + "include": "#array-literal" }, { - "include": "#type-predicate-operator" + "include": "#this-literal" }, { - "include": "#type" + "include": "#super-literal" } ] }, - "type-tuple": { - "name": "meta.type.tuple.ts", - "begin": "\\[", + "array-literal": { + "name": "meta.array.literal.ts", + "begin": "\\s*(\\[)", "beginCaptures": { - "0": { + "1": { "name": "meta.brace.square.ts" } }, @@ -2034,205 +2714,92 @@ }, "patterns": [ { - "include": "#type" + "include": "#expression" }, { "include": "#punctuation-comma" } ] }, - "type-name": { - "patterns": [ - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)", - "captures": { - "1": { - "name": "entity.name.type.module.ts" - }, - "2": { - "name": "punctuation.accessor.ts" - } - } - }, - { - "name": "entity.name.type.ts", - "match": "[_$[:alpha:]][_$[:alnum:]]*" - } - ] - }, - "type-parameters": { - "name": "meta.type.parameters.ts", - "begin": "(<)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.typeparameters.begin.ts" - } - }, - "end": "(>)", - "endCaptures": { - "1": { - "name": "punctuation.definition.typeparameters.end.ts" - } - }, + "numeric-literal": { "patterns": [ { - "include": "#comment" - }, - { - "name": "storage.modifier.ts", - "match": "(?<!\\.|\\$)\\b(extends)\\b(?!\\$)" - }, - { - "name": "keyword.operator.assignment.ts", - "match": "\\=(?!>)" + "name": "constant.numeric.hex.ts", + "match": "\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$)" }, { - "include": "#type" + "name": "constant.numeric.binary.ts", + "match": "\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$)" }, { - "include": "#punctuation-comma" - } - ] - }, - "variable-initializer": { - "patterns": [ - { - "begin": "(?<!=|!)(=)(?!=)(?=\\s*\\S)", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.ts" - } - }, - "end": "(?=$|^|[,);}\\]])", - "patterns": [ - { - "include": "#expression" - } - ] + "name": "constant.numeric.octal.ts", + "match": "\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$)" }, { - "begin": "(?<!=|!)(=)(?!=)", - "beginCaptures": { + "match": "(?x)\n(?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$)", + "captures": { + "0": { + "name": "constant.numeric.decimal.ts" + }, "1": { - "name": "keyword.operator.assignment.ts" - } - }, - "end": "(?=[,);}\\]])|(?=^\\s*$)|(?<=\\S)(?<!=)", - "patterns": [ - { - "include": "#expression" + "name": "meta.delimiter.decimal.period.ts" + }, + "2": { + "name": "meta.delimiter.decimal.period.ts" + }, + "3": { + "name": "meta.delimiter.decimal.period.ts" + }, + "4": { + "name": "meta.delimiter.decimal.period.ts" + }, + "5": { + "name": "meta.delimiter.decimal.period.ts" + }, + "6": { + "name": "meta.delimiter.decimal.period.ts" } - ] + } } ] }, - "for-loop": { - "begin": "(?<!\\.|\\$)\\b(for)(?:\\s+(await))?\\s*(\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.loop.ts" - }, - "2": { - "name": "keyword.control.loop.ts" - }, - "3": { - "name": "meta.brace.round.ts" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.ts" - } - }, + "boolean-literal": { "patterns": [ { - "include": "#var-expr" - }, - { - "include": "#expression" + "name": "constant.language.boolean.true.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))true(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#punctuation-semicolon" + "name": "constant.language.boolean.false.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))false(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" } ] }, - "switch-expression": { - "name": "switch-expression.expr.ts", - "begin": "(?<!\\.|\\$)\\b(switch)\\s*(\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.switch.ts" - }, - "2": { - "name": "meta.brace.round.ts" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.ts" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] + "null-literal": { + "name": "constant.language.null.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))null(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, - "switch-block": { - "name": "switch-block.expr.ts", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.ts" - } - }, - "end": "(?=\\})", - "patterns": [ - { - "include": "#case-clause" - }, - { - "include": "#statements" - } - ] + "this-literal": { + "name": "variable.language.this.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))this\\b(?!\\$)" }, - "case-clause": { - "name": "case-clause.expr.ts", - "begin": "(?<!\\.|\\$)\\b(case|default(?=:))\\b(?!\\$|\\.)", - "beginCaptures": { - "1": { - "name": "keyword.control.switch.ts" - } - }, - "end": ":", - "endCaptures": { - "0": { - "name": "punctuation.definition.section.case-statement.ts" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] + "super-literal": { + "name": "variable.language.super.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))super\\b(?!\\$)" }, - "switch-statement": { - "name": "switch-statement.expr.ts", - "begin": "(?<!\\.|\\$)(?=\\bswitch\\s*\\()", - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.ts" - } - }, + "undefined-literal": { + "name": "constant.language.undefined.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))undefined(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "numericConstant-literal": { "patterns": [ { - "include": "#switch-expression" + "name": "constant.language.nan.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))NaN(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#switch-block" + "name": "constant.language.infinity.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))Infinity(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" } ] }, @@ -2240,22 +2807,26 @@ "patterns": [ { "name": "variable.language.arguments.ts", - "match": "(?<!\\.|\\$)\\b(arguments)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(arguments)\\b(?!\\$)" }, { "name": "support.class.builtin.ts", - "match": "(?x)(?<!\\.|\\$)\\b(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator\n |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Promise|Proxy\n |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray\n |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\\b(?!\\$)" + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator\n |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Proxy\n |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray\n |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\\b(?!\\$)" }, { "name": "support.class.error.ts", - "match": "(?<!\\.|\\$)\\b((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\\b(?!\\$)" + }, + { + "name": "support.class.promise.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Promise)\\b(?!\\$)" }, { "name": "support.function.ts", - "match": "(?x)(?<!\\.|\\$)\\b(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|\n isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\\s*\\() " + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|\n isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\\s*\\()" }, { - "match": "(?x)(?<!\\.|\\$)\\b(Math)(?:\\s*(\\.)\\s*(?:\n (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|\n expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|\n round|sign|sin|sinh|sqrt|tan|tanh|trunc)\n |\n (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Math)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|\n expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|\n round|sign|sin|sinh|sqrt|tan|tanh|trunc)\n |\n (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\\b(?!\\$)", "captures": { "1": { "name": "support.constant.math.ts" @@ -2264,15 +2835,18 @@ "name": "punctuation.accessor.ts" }, "3": { - "name": "support.function.math.ts" + "name": "punctuation.accessor.optional.ts" }, "4": { + "name": "support.function.math.ts" + }, + "5": { "name": "support.constant.property.math.ts" } } }, { - "match": "(?x)(?<!\\.|\\$)\\b(console)(?:\\s*(\\.)\\s*(\n assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log\n |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(console)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(\n assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log\n |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\\b(?!\\$)", "captures": { "1": { "name": "support.class.console.ts" @@ -2281,12 +2855,15 @@ "name": "punctuation.accessor.ts" }, "3": { + "name": "punctuation.accessor.optional.ts" + }, + "4": { "name": "support.function.console.ts" } } }, { - "match": "(?<!\\.|\\$)\\b(JSON)(?:\\s*(\\.)\\s*(parse|stringify))?\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(JSON)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(parse|stringify))?\\b(?!\\$)", "captures": { "1": { "name": "support.constant.json.ts" @@ -2295,26 +2872,66 @@ "name": "punctuation.accessor.ts" }, "3": { + "name": "punctuation.accessor.optional.ts" + }, + "4": { "name": "support.function.json.ts" } } }, { - "match": "(?x) (\\.) \\s* (?:\n (constructor|length|prototype|__proto__) \n |\n (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(import)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(meta)\\b(?!\\$)", "captures": { "1": { + "name": "keyword.control.import.ts" + }, + "2": { "name": "punctuation.accessor.ts" }, + "3": { + "name": "punctuation.accessor.optional.ts" + }, + "4": { + "name": "support.variable.property.importmeta.ts" + } + } + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(target)\\b(?!\\$)", + "captures": { + "1": { + "name": "keyword.operator.new.ts" + }, "2": { - "name": "support.variable.property.ts" + "name": "punctuation.accessor.ts" + }, + "3": { + "name": "punctuation.accessor.optional.ts" + }, + "4": { + "name": "support.variable.property.target.ts" + } + } + }, + { + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s* (?:\n (constructor|length|prototype|__proto__)\n |\n (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\\b(?!\\$)", + "captures": { + "1": { + "name": "punctuation.accessor.ts" + }, + "2": { + "name": "punctuation.accessor.optional.ts" }, "3": { + "name": "support.variable.property.ts" + }, + "4": { "name": "support.constant.ts" } } }, { - "match": "(?x) (?<!\\.|\\$) \\b (?:\n (document|event|navigator|performance|screen|window) \n |\n (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener\n |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule\n |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration\n |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern\n |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent\n |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException\n |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer\n |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry\n |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent\n |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential\n |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync\n |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement\n |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement\n |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement\n |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement\n |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement\n |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement\n |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement\n |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement\n |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement\n |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement\n |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement\n |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase\n |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction\n |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities\n |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess\n |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent\n |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream\n |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent\n |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID\n |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification\n |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential\n |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark\n |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList\n |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent\n |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList\n |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager\n |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource\n |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement\n |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength\n |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio\n |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement\n |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement\n |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement\n |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength\n |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement\n |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio\n |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList\n |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement\n |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement\n |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState\n |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet\n |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable\n |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer\n |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat\n |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES\n |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope\n |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult\n |XSLTProcessor))\\b(?!\\$)", + "match": "(?x) (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.)) \\b (?:\n (document|event|navigator|performance|screen|window)\n |\n (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener\n |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule\n |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration\n |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern\n |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent\n |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException\n |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer\n |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry\n |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent\n |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential\n |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync\n |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement\n |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement\n |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement\n |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement\n |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement\n |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement\n |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement\n |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement\n |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement\n |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement\n |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement\n |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase\n |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction\n |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities\n |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess\n |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent\n |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream\n |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent\n |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID\n |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification\n |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential\n |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark\n |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList\n |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent\n |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList\n |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager\n |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource\n |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement\n |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength\n |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio\n |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement\n |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement\n |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement\n |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength\n |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement\n |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio\n |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList\n |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement\n |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement\n |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState\n |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet\n |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable\n |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer\n |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat\n |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES\n |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope\n |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult\n |XSLTProcessor))\\b(?!\\$)", "captures": { "1": { "name": "support.variable.dom.ts" @@ -2325,25 +2942,28 @@ } }, { - "match": "(?x) (\\.) \\s* (?:\n (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE\n |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR\n |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR\n |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)\n |\n (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName\n |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop\n |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor\n |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption\n |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear\n |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete\n |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset\n |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight\n |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds\n |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize\n |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host\n |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth\n |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext\n |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom\n |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple\n |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName\n |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight\n |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer\n |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling\n |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText\n |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts\n |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove\n |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary\n |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead\n |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile\n |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\\b(?!\\$|\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s* (?:\n (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE\n |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR\n |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR\n |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)\n |\n (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName\n |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop\n |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor\n |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption\n |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear\n |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete\n |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset\n |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight\n |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds\n |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize\n |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host\n |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth\n |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext\n |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom\n |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple\n |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName\n |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight\n |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer\n |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling\n |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText\n |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts\n |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove\n |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary\n |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead\n |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile\n |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\\b(?!\\$|\\s*(<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\\()", "captures": { "1": { "name": "punctuation.accessor.ts" }, "2": { - "name": "support.constant.dom.ts" + "name": "punctuation.accessor.optional.ts" }, "3": { + "name": "support.constant.dom.ts" + }, + "4": { "name": "support.variable.property.dom.ts" } } }, { "name": "support.class.node.ts", - "match": "(?x)(?<!\\.|\\$)\\b(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)" + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)" }, { - "match": "(?x)(?<!\\.|\\$)\\b(process)(?:(\\.)(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(process)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)", "captures": { "1": { "name": "support.variable.object.process.ts" @@ -2352,15 +2972,18 @@ "name": "punctuation.accessor.ts" }, "3": { - "name": "support.variable.property.process.ts" + "name": "punctuation.accessor.optional.ts" }, "4": { + "name": "support.variable.property.process.ts" + }, + "5": { "name": "support.function.process.ts" } } }, { - "match": "(?<!\\.|\\$)\\b(?:(exports)|(module)(?:(\\.)(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(exports)|(module)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)", "captures": { "1": { "name": "support.type.object.module.ts" @@ -2372,88 +2995,39 @@ "name": "punctuation.accessor.ts" }, "4": { + "name": "punctuation.accessor.optional.ts" + }, + "5": { "name": "support.type.object.module.ts" } } }, { "name": "support.variable.object.node.ts", - "match": "(?<!\\.|\\$)\\b(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)" }, { - "match": "(?x) (\\.) \\s* \n(?:\n (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|\n Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|\n Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|\n Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|\n Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|\n Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|\n Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|\n Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\n ) |\n (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|\n scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|\n sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|\n Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|\n Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|\n savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|\n contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|\n createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|\n test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|\n untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|\n print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|\n fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|\n forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|\n abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|\n releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|\n Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|\n Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|\n moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back\n ) |\n (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|\n appendChild|appendData|before|blur|canPlayType|captureStream|\n caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|\n cloneContents|cloneNode|cloneRange|close|closest|collapse|\n compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|\n convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|\n createAttributeNS|createCaption|createCDATASection|createComment|\n createContextualFragment|createDocument|createDocumentFragment|\n createDocumentType|createElement|createElementNS|createEntityReference|\n createEvent|createExpression|createHTMLDocument|createNodeIterator|\n createNSResolver|createProcessingInstruction|createRange|createShadowRoot|\n createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|\n deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|\n deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|\n enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|\n exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|\n getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|\n getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|\n getClientRects|getContext|getDestinationInsertionPoints|getElementById|\n getElementsByClassName|getElementsByName|getElementsByTagName|\n getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|\n getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|\n hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|\n insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|\n insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|\n isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|\n lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|\n moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|\n parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|\n previousSibling|probablySupportsContext|queryCommandEnabled|\n queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|\n querySelector|querySelectorAll|registerContentHandler|registerElement|\n registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|\n removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|\n removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|\n requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|\n scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|\n setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|\n setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|\n setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|\n slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|\n submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|\n toDataURL|toggle|toString|values|write|writeln\n )\n)(?=\\s*\\()", + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s*\n(?:\n (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|\n Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|\n Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|\n Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|\n Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|\n Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|\n Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|\n Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\n ) |\n (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|\n scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|\n sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|\n Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|\n Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|\n savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|\n contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|\n createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|\n test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|\n untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|\n print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|\n fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|\n forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|\n abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|\n releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|\n Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|\n Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|\n moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back\n ) |\n (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|\n appendChild|appendData|before|blur|canPlayType|captureStream|\n caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|\n cloneContents|cloneNode|cloneRange|close|closest|collapse|\n compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|\n convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|\n createAttributeNS|createCaption|createCDATASection|createComment|\n createContextualFragment|createDocument|createDocumentFragment|\n createDocumentType|createElement|createElementNS|createEntityReference|\n createEvent|createExpression|createHTMLDocument|createNodeIterator|\n createNSResolver|createProcessingInstruction|createRange|createShadowRoot|\n createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|\n deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|\n deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|\n enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|\n exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|\n getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|\n getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|\n getClientRects|getContext|getDestinationInsertionPoints|getElementById|\n getElementsByClassName|getElementsByName|getElementsByTagName|\n getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|\n getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|\n hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|\n insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|\n insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|\n isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|\n lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|\n moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|\n parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|\n previousSibling|probablySupportsContext|queryCommandEnabled|\n queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|\n querySelector|querySelectorAll|registerContentHandler|registerElement|\n registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|\n removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|\n removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|\n requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|\n scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|\n setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|\n setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|\n setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|\n slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|\n submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|\n toDataURL|toggle|toString|values|write|writeln\n ) |\n (all|catch|finally|race|reject|resolve|then\n )\n)(?=\\s*\\()", "captures": { "1": { "name": "punctuation.accessor.ts" }, "2": { - "name": "support.function.event-handler.ts" + "name": "punctuation.accessor.optional.ts" }, "3": { - "name": "support.function.ts" + "name": "support.function.event-handler.ts" }, "4": { - "name": "support.function.dom.ts" - } - } - } - ] - }, - "function-call": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "end": "(?<=\\))(?!(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "patterns": [ - { - "name": "meta.function-call.ts", - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*))", - "end": "(?=\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "patterns": [ - { - "include": "#literal" - }, - { - "include": "#support-objects" - }, - { - "include": "#object-identifiers" - }, - { - "include": "#punctuation-accessor" + "name": "support.function.ts" }, - { - "name": "entity.name.function.ts", - "match": "([_$[:alpha:]][_$[:alnum:]]*)" - } - ] - }, - { - "include": "#comment" - }, - { - "name": "meta.type.parameters.ts", - "begin": "\\<", - "beginCaptures": { - "0": { - "name": "punctuation.definition.typeparameters.begin.ts" - } - }, - "end": "\\>", - "endCaptures": { - "0": { - "name": "punctuation.definition.typeparameters.end.ts" - } - }, - "patterns": [ - { - "include": "#type" + "5": { + "name": "support.function.dom.ts" }, - { - "include": "#punctuation-comma" + "6": { + "name": "support.function.promise.ts" } - ] - }, - { - "include": "#paren-expression" + } } ] }, @@ -2463,34 +3037,43 @@ "include": "#object-identifiers" }, { - "match": "(?x)(?:(\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n))", + "match": "(?x)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n))", "captures": { "1": { "name": "punctuation.accessor.ts" }, "2": { + "name": "punctuation.accessor.optional.ts" + }, + "3": { "name": "entity.name.function.ts" } } }, { - "match": "(\\.)\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", "captures": { "1": { "name": "punctuation.accessor.ts" }, "2": { + "name": "punctuation.accessor.optional.ts" + }, + "3": { "name": "variable.other.constant.property.ts" } } }, { - "match": "(\\.)\\s*([_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*([_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "punctuation.accessor.ts" }, "2": { + "name": "punctuation.accessor.optional.ts" + }, + "3": { "name": "variable.other.property.ts" } } @@ -2509,24 +3092,27 @@ "patterns": [ { "name": "support.class.ts", - "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\.\\s*prototype\\b(?!\\$))" + "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\??\\.\\s*prototype\\b(?!\\$))" }, { - "match": "(?x)(\\.)\\s*(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?x)(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "punctuation.accessor.ts" }, "2": { - "name": "variable.other.constant.object.property.ts" + "name": "punctuation.accessor.optional.ts" }, "3": { + "name": "variable.other.constant.object.property.ts" + }, + "4": { "name": "variable.other.object.property.ts" } } }, { - "match": "(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "variable.other.constant.object.ts" @@ -2538,22 +3124,17 @@ } ] }, - "cast": { + "type-annotation": { "patterns": [ { - "name": "cast.expr.ts", - "begin": "(?:(?<=return|throw|yield|await|default|[=(,:>*?]))\\s*(<)(?!<?\\=)", + "name": "meta.type.annotation.ts", + "begin": "(:)(?=\\s*\\S)", "beginCaptures": { "1": { - "name": "meta.brace.angle.ts" - } - }, - "end": "(\\>)\\s*", - "endCaptures": { - "1": { - "name": "meta.brace.angle.ts" + "name": "keyword.operator.type.annotation.ts" } }, + "end": "(?<![:|&])((?=$|^|[,);\\}\\]]|//)|(?==[^>])|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", "patterns": [ { "include": "#type" @@ -2561,19 +3142,14 @@ ] }, { - "name": "cast.expr.ts", - "begin": "(?:(?<=^))\\s*(<)(?=[_$[:alpha:]][_$[:alnum:]]*\\s*>)", + "name": "meta.type.annotation.ts", + "begin": "(:)", "beginCaptures": { "1": { - "name": "meta.brace.angle.ts" - } - }, - "end": "(\\>)\\s*", - "endCaptures": { - "1": { - "name": "meta.brace.angle.ts" + "name": "keyword.operator.type.annotation.ts" } }, + "end": "(?<![:|&])((?=[,);\\}\\]]|//)|(?==[^>])|(?=^\\s*$)|((?<=\\S)(?=\\s*$))|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", "patterns": [ { "include": "#type" @@ -2582,342 +3158,485 @@ } ] }, - "new-expr": { - "name": "new.expr.ts", - "begin": "(?<!\\.|\\$)\\b(new)\\b(?!\\$|\\.)", - "beginCaptures": { - "1": { - "name": "keyword.operator.new.ts" - } - }, - "end": "(?<=\\))|(?=[;),}]|$|((?<!\\.|\\$)\\bnew\\b(?!\\$|\\.))|((?<!\\.|\\$)\\bfunction((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", - "patterns": [ - { - "include": "#paren-expression" - }, - { - "include": "#class-or-interface-declaration" - }, - { - "include": "#type" - } - ] - }, - "object-member": { + "return-type": { "patterns": [ { - "include": "#comment" - }, - { - "include": "#object-literal-method-declaration" - }, - { - "name": "meta.object.member.ts", - "begin": "(?=(?:(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(?:\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*:)", - "end": "(?=,|\\})", - "patterns": [ - { - "name": "meta.object-literal.key.ts", - "begin": "(?=(?:(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(?:\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*:)", - "end": ":", - "endCaptures": { - "0": { - "name": "punctuation.separator.key-value.ts" - } - }, - "patterns": [ - { - "include": "#string" - }, - { - "include": "#array-literal" - } - ] - }, - { - "include": "#expression" - } - ] - }, - { - "name": "meta.object.member.ts", - "begin": "(?![_$[:alpha:]])([[:digit:]]+)\\s*(:)", + "name": "meta.return.type.ts", + "begin": "(?<=\\))\\s*(:)(?=\\s*\\S)", "beginCaptures": { - "0": { - "name": "meta.object-literal.key.ts" - }, "1": { - "name": "constant.numeric.decimal.ts" - }, - "2": { - "name": "punctuation.separator.key-value.ts" + "name": "keyword.operator.type.annotation.ts" } }, - "end": "(?=,|\\})", + "end": "(?<![:|&])(?=$|^|[{};,]|//)", "patterns": [ { - "include": "#expression" + "include": "#return-type-core" } ] }, { - "name": "meta.object.member.ts", - "begin": "(?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)(?=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n)))", + "name": "meta.return.type.ts", + "begin": "(?<=\\))\\s*(:)", "beginCaptures": { - "0": { - "name": "meta.object-literal.key.ts" - }, "1": { - "name": "entity.name.function.ts" - }, - "2": { - "name": "punctuation.separator.key-value.ts" + "name": "keyword.operator.type.annotation.ts" } }, - "end": "(?=,|\\})", + "end": "(?<![:|&])((?=[{};,]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", "patterns": [ { - "include": "#expression" + "include": "#return-type-core" } ] + } + ] + }, + "return-type-core": { + "patterns": [ + { + "include": "#comment" }, { - "name": "meta.object.member.ts", - "begin": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(:)", - "beginCaptures": { - "0": { - "name": "meta.object-literal.key.ts" - }, - "1": { - "name": "punctuation.separator.key-value.ts" - } - }, - "end": "(?=,|\\})", + "begin": "(?<=[:|&])(?=\\s*\\{)", + "end": "(?<=\\})", "patterns": [ { - "include": "#expression" + "include": "#type-object" } ] }, { - "name": "meta.object.member.ts", - "begin": "\\.\\.\\.", - "beginCaptures": { - "0": { - "name": "keyword.operator.spread.ts" - } - }, - "end": "(?=,|\\})", + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "arrow-return-type": { + "name": "meta.return.type.arrow.ts", + "begin": "(?<=\\))\\s*(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.ts" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "possibly-arrow-return-type": { + "begin": "(?<=\\))\\s*(:)(?=\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+\\s*=>)", + "beginCaptures": { + "1": { + "name": "meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "contentName": "meta.arrow.ts meta.return.type.arrow.ts", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "arrow-return-type-body": { + "patterns": [ + { + "begin": "(?<=[:])(?=\\s*\\{)", + "end": "(?<=\\})", "patterns": [ { - "include": "#expression" + "include": "#type-object" } ] }, { - "name": "meta.object.member.ts", - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$)", - "captures": { - "1": { - "name": "variable.other.readwrite.ts" - } - } + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "type-parameters": { + "name": "meta.type.parameters.ts", + "begin": "(<)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.begin.ts" + } + }, + "end": "(>)", + "endCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.end.ts" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "name": "storage.modifier.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(extends)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "include": "#type" }, { "include": "#punctuation-comma" } ] }, - "expression-operators": { + "type-arguments": { + "name": "meta.type.parameters.ts", + "begin": "\\<", + "beginCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.begin.ts" + } + }, + "end": "\\>", + "endCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.end.ts" + } + }, "patterns": [ { - "name": "keyword.control.flow.ts", - "match": "(?<!\\.|\\$)\\b(await)\\b(?!\\$|\\.)" + "include": "#type" }, { - "match": "(?<!\\.|\\$)\\b(yield)\\b(?!\\$|\\.)(?:\\s*(\\*))?", - "captures": { - "1": { - "name": "keyword.control.flow.ts" - }, - "2": { - "name": "keyword.generator.asterisk.ts" - } - } + "include": "#punctuation-comma" + } + ] + }, + "type": { + "patterns": [ + { + "include": "#comment" }, { - "name": "keyword.operator.expression.delete.ts", - "match": "(?<!\\.|\\$)\\bdelete\\b(?!\\$|\\.)" + "include": "#string" }, { - "name": "keyword.operator.expression.in.ts", - "match": "(?<!\\.|\\$)\\bin\\b(?!\\$|\\.)" + "include": "#numeric-literal" }, { - "name": "keyword.operator.expression.of.ts", - "match": "(?<!\\.|\\$)\\bof\\b(?!\\$|\\.)" + "include": "#type-primitive" }, { - "name": "keyword.operator.expression.instanceof.ts", - "match": "(?<!\\.|\\$)\\binstanceof\\b(?!\\$|\\.)" + "include": "#type-builtin-literals" }, { - "name": "keyword.operator.new.ts", - "match": "(?<!\\.|\\$)\\bnew\\b(?!\\$|\\.)" + "include": "#type-parameters" }, { - "include": "#typeof-operator" + "include": "#type-tuple" }, { - "name": "keyword.operator.expression.void.ts", - "match": "(?<!\\.|\\$)\\bvoid\\b(?!\\$|\\.)" + "include": "#type-object" }, { - "begin": "(?<!\\.|\\$)\\b(as)\\s+", - "beginCaptures": { - "1": { - "name": "keyword.control.as.ts" - } - }, - "end": "(?=$|^|[;,:})\\]])", - "patterns": [ - { - "include": "#type" - } - ] + "include": "#type-conditional" }, { - "name": "keyword.operator.spread.ts", - "match": "\\.\\.\\." + "include": "#type-operators" }, { - "name": "keyword.operator.assignment.compound.ts", - "match": "\\*=|(?<!\\()/=|%=|\\+=|\\-=" + "include": "#type-fn-type-parameters" }, { - "name": "keyword.operator.assignment.compound.bitwise.ts", - "match": "\\&=|\\^=|<<=|>>=|>>>=|\\|=" + "include": "#type-paren-or-function-parameters" }, { - "name": "keyword.operator.bitwise.shift.ts", - "match": "<<|>>>|>>" + "include": "#type-function-return-type" }, { - "name": "keyword.operator.comparison.ts", - "match": "===|!==|==|!=" + "include": "#type-name" + } + ] + }, + "type-primitive": { + "name": "support.type.primitive.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(string|number|boolean|symbol|any|void|never)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-builtin-literals": { + "name": "support.type.builtin.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(this|true|false|undefined|null|object)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-tuple": { + "name": "meta.type.tuple.ts", + "begin": "\\[", + "beginCaptures": { + "0": { + "name": "meta.brace.square.ts" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "meta.brace.square.ts" + } + }, + "patterns": [ + { + "include": "#type" }, { - "name": "keyword.operator.relational.ts", - "match": "<=|>=|<>|<|>" + "include": "#punctuation-comma" + } + ] + }, + "type-object": { + "name": "meta.object.type.ts", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.ts" + } + }, + "patterns": [ + { + "include": "#comment" }, { - "name": "keyword.operator.logical.ts", - "match": "\\!|&&|\\|\\|" + "include": "#method-declaration" }, { - "name": "keyword.operator.bitwise.ts", - "match": "\\&|~|\\^|\\|" + "include": "#indexer-declaration" }, { - "name": "keyword.operator.assignment.ts", - "match": "\\=" + "include": "#indexer-mapped-type-declaration" }, { - "name": "keyword.operator.decrement.ts", - "match": "--" + "include": "#field-declaration" }, { - "name": "keyword.operator.increment.ts", - "match": "\\+\\+" + "include": "#type-annotation" }, { - "name": "keyword.operator.arithmetic.ts", - "match": "%|\\*|/|-|\\+" + "begin": "\\.\\.\\.", + "beginCaptures": { + "0": { + "name": "keyword.operator.spread.ts" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#type" + } + ] }, { - "match": "(?<=[_$[:alnum:])])\\s*(/)(?![/*])", - "captures": { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-semicolon" + }, + { + "include": "#type" + } + ] + }, + "type-conditional": { + "patterns": [ + { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(extends)\\s+", + "beginCaptures": { "1": { - "name": "keyword.operator.arithmetic.ts" + "name": "storage.modifier.ts" } - } + }, + "end": "(?<=:)", + "patterns": [ + { + "begin": "\\?", + "beginCaptures": { + "0": { + "name": "keyword.operator.ternary.ts" + } + }, + "end": ":", + "endCaptures": { + "0": { + "name": "keyword.operator.ternary.ts" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "include": "#type" + } + ] } ] }, - "typeof-operator": { - "name": "keyword.operator.expression.typeof.ts", - "match": "(?<!\\.|\\$)\\btypeof\\b(?!\\$|\\.)" - }, - "arrow-function": { + "type-paren-or-function-parameters": { + "name": "meta.type.paren.cover.ts", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, "patterns": [ { - "name": "meta.arrow.ts", - "match": "(?:(?<!\\.|\\$)(\\basync)\\s+)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)", + "include": "#destructuring-parameter" + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=\\s*(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?[\\(]\\s*([\\{\\[]\\s*)?$)))", "captures": { "1": { - "name": "storage.modifier.async.ts" + "name": "storage.modifier.ts" + }, + "2": { + "name": "keyword.operator.rest.ts" + }, + "3": { + "name": "entity.name.function.ts variable.language.this.ts" + }, + "4": { + "name": "entity.name.function.ts" + }, + "5": { + "name": "keyword.operator.optional.ts" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=:)", + "captures": { + "1": { + "name": "storage.modifier.ts" }, "2": { + "name": "keyword.operator.rest.ts" + }, + "3": { + "name": "variable.parameter.ts variable.language.this.ts" + }, + "4": { "name": "variable.parameter.ts" + }, + "5": { + "name": "keyword.operator.optional.ts" } } }, { - "name": "meta.arrow.ts", - "begin": "(?x) (?:\n (?<!\\.|\\$)(\\basync)\n)? ((?<![})!\\]])\\s*\n (?=\n # sure shot arrow functions even if => is on new line\n (\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n ) |\n (\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends \n ) |\n # arrow function possible to detect only with => on same line\n (\n (<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)? # typeparameters\n \\(([^()]|\\([^()]*\\))*\\) # parameteres\n (\\s*:\\s*(.)*)? # return type\n \\s*=> # arrow operator\n )\n )\n)", + "include": "#type-annotation" + }, + { + "name": "punctuation.separator.parameter.ts", + "match": "," + }, + { + "include": "#type" + } + ] + }, + "type-fn-type-parameters": { + "patterns": [ + { + "name": "meta.type.constructor.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\b(?=\\s*\\<)", + "captures": { + "1": { + "name": "keyword.control.new.ts" + } + } + }, + { + "name": "meta.type.constructor.ts", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\b\\s*(?=\\()", "beginCaptures": { "1": { - "name": "storage.modifier.async.ts" + "name": "keyword.control.new.ts" } }, - "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "end": "(?<=\\))", "patterns": [ { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, + "include": "#function-parameters" + } + ] + }, + { + "name": "meta.type.function.ts", + "begin": "(?x)(\n (?=\n [(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n )\n )\n)", + "end": "(?<=\\))", + "patterns": [ { "include": "#function-parameters" - }, + } + ] + } + ] + }, + "type-function-return-type": { + "patterns": [ + { + "name": "meta.type.function.return.ts", + "begin": "(=>)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "storage.type.function.arrow.ts" + } + }, + "end": "(?<!=>)(?<![|&])(?=[,\\]\\)\\{\\}=;>:\\?]|//|$)", + "patterns": [ { - "include": "#arrow-return-type" + "include": "#type-function-return-type-core" } ] }, { - "name": "meta.arrow.ts", + "name": "meta.type.function.return.ts", "begin": "=>", "beginCaptures": { "0": { "name": "storage.type.function.arrow.ts" } }, - "end": "(?<=\\}|\\S)(?<!=>)|((?!\\{)(?=\\S))", + "end": "(?<!=>)(?<![|&])((?=[,\\]\\)\\{\\}=;:\\?>]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", "patterns": [ { - "include": "#decl-block" - }, - { - "include": "#expression" + "include": "#type-function-return-type-core" } ] } ] }, - "arrow-return-type": { - "name": "meta.return.type.arrow.ts", - "begin": "(?<=\\))\\s*(:)", - "beginCaptures": { - "1": { - "name": "keyword.operator.type.annotation.ts" - } - }, - "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "type-function-return-type-core": { "patterns": [ { - "begin": "(?<=[:])(?=\\s*\\{)", + "include": "#comment" + }, + { + "begin": "(?<==>)(?=\\s*\\{)", "end": "(?<=\\})", "patterns": [ { @@ -2933,6 +3652,84 @@ } ] }, + "type-operators": { + "patterns": [ + { + "include": "#typeof-operator" + }, + { + "begin": "(?:([&|])|(=(?!>)))(?=\\s*\\{)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.ts" + }, + "2": { + "name": "keyword.operator.assignment.ts" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "begin": "([&|])|(=(?!>))", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.ts" + }, + "2": { + "name": "keyword.operator.assignment.ts" + } + }, + "end": "(?=\\S)" + }, + { + "name": "keyword.operator.expression.keyof.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))keyof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.operator.ternary.ts", + "match": "(\\?|\\:)" + }, + { + "name": "keyword.operator.expression.infer.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))infer(?=\\s+[_$[:alpha:]])" + }, + { + "name": "keyword.operator.expression.import.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))import(?=\\s*\\()" + } + ] + }, + "type-predicate-operator": { + "name": "keyword.operator.expression.is.ts", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))is(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-name": { + "patterns": [ + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "entity.name.type.module.ts" + }, + "2": { + "name": "punctuation.accessor.ts" + }, + "3": { + "name": "punctuation.accessor.optional.ts" + } + } + }, + { + "name": "entity.name.type.ts", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + } + ] + }, "punctuation-comma": { "name": "punctuation.separator.comma.ts", "match": "," @@ -2942,28 +3739,23 @@ "match": ";" }, "punctuation-accessor": { - "name": "punctuation.accessor.ts", - "match": "\\." - }, - "paren-expression": { - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "meta.brace.round.ts" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.ts" + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "punctuation.accessor.ts" + }, + "2": { + "name": "punctuation.accessor.optional.ts" } - }, + } + }, + "string": { "patterns": [ { - "include": "#expression" + "include": "#qstring-single" }, { - "include": "#punctuation-comma" + "include": "#qstring-double" } ] }, @@ -3013,17 +3805,87 @@ } ] }, + "string-character-escape": { + "name": "constant.character.escape.ts", + "match": "\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" + }, + "template": { + "patterns": [ + { + "name": "string.template.ts", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.ts" + } + }, + "end": "(?=`)", + "patterns": [ + { + "include": "#type-arguments" + } + ] + }, + { + "name": "string.template.ts", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.ts" + }, + "2": { + "name": "punctuation.definition.string.template.begin.ts" + } + }, + "end": "`", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.template.end.ts" + } + }, + "patterns": [ + { + "include": "#template-substitution-element" + }, + { + "include": "#string-character-escape" + } + ] + } + ] + }, + "template-substitution-element": { + "name": "meta.template.expression.ts", + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.template-expression.begin.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.template-expression.end.ts" + } + }, + "patterns": [ + { + "include": "#expression" + } + ], + "contentName": "meta.embedded.line.ts" + }, "regex": { "patterns": [ { "name": "string.regexp.ts", - "begin": "(?<=[=(:,\\[?+!]|return|case|=>|&&|\\|\\||\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/(?![\\/*])[gimy]*(?!\\s*[a-zA-Z0-9_$]))", + "begin": "(?<!\\+\\+|--)(?<=[=(:,\\[?+!]|^return|[^\\._$[:alnum:]]return|^case|[^\\._$[:alnum:]]case|=>|&&|\\|\\||\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))", "beginCaptures": { "1": { "name": "punctuation.definition.string.begin.ts" } }, - "end": "(/)([gimuy]*)", + "end": "(/)([gimsuy]*)", "endCaptures": { "1": { "name": "punctuation.definition.string.end.ts" @@ -3040,13 +3902,13 @@ }, { "name": "string.regexp.ts", - "begin": "(?<![_$[:alnum:])])\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/(?![\\/*])[gimy]*(?!\\s*[a-zA-Z0-9_$]))", + "begin": "(?<![_$[:alnum:])\\]]|\\+\\+|--)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.ts" } }, - "end": "(/)([gimuy]*)", + "end": "(/)([gimsuy]*)", "endCaptures": { "1": { "name": "punctuation.definition.string.end.ts" @@ -3070,8 +3932,15 @@ "match": "\\\\[bB]|\\^|\\$" }, { - "name": "keyword.other.back-reference.regexp", - "match": "\\\\[1-9]\\d*" + "match": "\\\\[1-9]\\d*|\\\\k<([a-zA-Z_$][\\w$]*)>", + "captures": { + "0": { + "name": "keyword.other.back-reference.regexp" + }, + "1": { + "name": "variable.other.regexp" + } + } }, { "name": "keyword.operator.quantifier.regexp", @@ -3083,7 +3952,7 @@ }, { "name": "meta.group.assertion.regexp", - "begin": "(\\()((\\?=)|(\\?!))", + "begin": "(\\()((\\?=)|(\\?!)|(\\?<=)|(\\?<!))", "beginCaptures": { "1": { "name": "punctuation.definition.group.regexp" @@ -3096,6 +3965,12 @@ }, "4": { "name": "meta.assertion.negative-look-ahead.regexp" + }, + "5": { + "name": "meta.assertion.look-behind.regexp" + }, + "6": { + "name": "meta.assertion.negative-look-behind.regexp" } }, "end": "(\\))", @@ -3112,13 +3987,16 @@ }, { "name": "meta.group.regexp", - "begin": "\\((\\?:)?", + "begin": "\\((?:(\\?:)|(?:\\?<([a-zA-Z_$][\\w$]*)>))?", "beginCaptures": { "0": { "name": "punctuation.definition.group.regexp" }, "1": { - "name": "punctuation.definition.group.capture.regexp" + "name": "punctuation.definition.group.no-capture.regexp" + }, + "2": { + "name": "variable.other.regexp" } }, "end": "\\)", @@ -3153,7 +4031,7 @@ "patterns": [ { "name": "constant.other.character-class.range.regexp", - "match": "(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))", + "match": "(?:.|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))", "captures": { "1": { "name": "constant.character.numeric.regexp" @@ -3193,7 +4071,7 @@ }, { "name": "constant.character.numeric.regexp", - "match": "\\\\([0-7]{3}|x\\h\\h|u\\h\\h\\h\\h)" + "match": "\\\\([0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4})" }, { "name": "constant.character.control.regexp", @@ -3205,207 +4083,6 @@ } ] }, - "string": { - "patterns": [ - { - "include": "#qstring-single" - }, - { - "include": "#qstring-double" - } - ] - }, - "template": { - "name": "string.template.ts", - "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", - "beginCaptures": { - "1": { - "name": "entity.name.function.tagged-template.ts" - }, - "2": { - "name": "punctuation.definition.string.template.begin.ts" - } - }, - "end": "`", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.template.end.ts" - } - }, - "patterns": [ - { - "include": "#template-substitution-element" - }, - { - "include": "#string-character-escape" - } - ] - }, - "string-character-escape": { - "name": "constant.character.escape.ts", - "match": "\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" - }, - "template-substitution-element": { - "name": "meta.template.expression.ts", - "begin": "\\$\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.template-expression.begin.ts" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.template-expression.end.ts" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] - }, - "literal": { - "patterns": [ - { - "include": "#numeric-literal" - }, - { - "include": "#boolean-literal" - }, - { - "include": "#null-literal" - }, - { - "include": "#undefined-literal" - }, - { - "include": "#numericConstant-literal" - }, - { - "include": "#array-literal" - }, - { - "include": "#this-literal" - }, - { - "include": "#super-literal" - } - ] - }, - "array-literal": { - "name": "meta.array.literal.ts", - "begin": "\\[", - "beginCaptures": { - "0": { - "name": "meta.brace.square.ts" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "meta.brace.square.ts" - } - }, - "patterns": [ - { - "include": "#expression" - }, - { - "include": "#punctuation-comma" - } - ] - }, - "numeric-literal": { - "patterns": [ - { - "name": "constant.numeric.hex.ts", - "match": "\\b(?<!\\$)0(x|X)[0-9a-fA-F]+\\b(?!\\$)" - }, - { - "name": "constant.numeric.binary.ts", - "match": "\\b(?<!\\$)0(b|B)[01]+\\b(?!\\$)" - }, - { - "name": "constant.numeric.octal.ts", - "match": "\\b(?<!\\$)0(o|O)?[0-7]+\\b(?!\\$)" - }, - { - "match": "(?x)\n(?<!\\$)(?:\n (?:\\b[0-9]+(\\.)[0-9]+[eE][+-]?[0-9]+\\b)| # 1.1E+3\n (?:\\b[0-9]+(\\.)[eE][+-]?[0-9]+\\b)| # 1.E+3\n (?:\\B(\\.)[0-9]+[eE][+-]?[0-9]+\\b)| # .1E+3\n (?:\\b[0-9]+[eE][+-]?[0-9]+\\b)| # 1E+3\n (?:\\b[0-9]+(\\.)[0-9]+\\b)| # 1.1\n (?:\\b[0-9]+(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9]+\\b)| # .1\n (?:\\b[0-9]+\\b(?!\\.)) # 1\n)(?!\\$)", - "captures": { - "0": { - "name": "constant.numeric.decimal.ts" - }, - "1": { - "name": "meta.delimiter.decimal.period.ts" - }, - "2": { - "name": "meta.delimiter.decimal.period.ts" - }, - "3": { - "name": "meta.delimiter.decimal.period.ts" - }, - "4": { - "name": "meta.delimiter.decimal.period.ts" - }, - "5": { - "name": "meta.delimiter.decimal.period.ts" - }, - "6": { - "name": "meta.delimiter.decimal.period.ts" - } - } - } - ] - }, - "boolean-literal": { - "patterns": [ - { - "name": "constant.language.boolean.true.ts", - "match": "(?<!\\.|\\$)\\btrue\\b(?!\\$)" - }, - { - "name": "constant.language.boolean.false.ts", - "match": "(?<!\\.|\\$)\\bfalse\\b(?!\\$)" - } - ] - }, - "null-literal": { - "name": "constant.language.null.ts", - "match": "(?<!\\.|\\$)\\bnull\\b(?!\\$)" - }, - "this-literal": { - "name": "variable.language.this.ts", - "match": "(?<!\\.|\\$)\\bthis\\b(?!\\$)" - }, - "super-literal": { - "name": "variable.language.super.ts", - "match": "(?<!\\.|\\$)\\bsuper\\b(?!\\$)" - }, - "undefined-literal": { - "name": "constant.language.undefined.ts", - "match": "(?<!\\.|\\$)\\bundefined\\b(?!\\$)" - }, - "numericConstant-literal": { - "patterns": [ - { - "name": "constant.language.nan.ts", - "match": "(?<!\\.|\\$)\\bNaN\\b(?!\\$)" - }, - { - "name": "constant.language.infinity.ts", - "match": "(?<!\\.|\\$)\\bInfinity\\b(?!\\$)" - } - ] - }, - "access-modifier": { - "name": "storage.modifier.ts", - "match": "(?<!\\.|\\$)\\b(abstract|public|protected|private|readonly|static)\\b(?!\\$|\\.)" - }, - "property-accessor": { - "name": "storage.type.property.ts", - "match": "(?<!\\.|\\$)\\b(get|set)\\b(?!\\$|\\.)" - }, "comment": { "patterns": [ { @@ -3430,10 +4107,16 @@ }, { "name": "comment.block.ts", - "begin": "/\\*", + "begin": "(/\\*)(?:\\s*((@)internal)(?=\\s|(\\*/)))?", "beginCaptures": { - "0": { + "1": { "name": "punctuation.definition.comment.ts" + }, + "2": { + "name": "storage.type.internaldeclaration.ts" + }, + "3": { + "name": "punctuation.decorator.internaldeclaration.ts" } }, "end": "\\*/", @@ -3444,13 +4127,22 @@ } }, { - "begin": "(^[ \\t]+)?(//)", + "begin": "(^[ \\t]+)?((//)(?:\\s*((@)internal)(?=\\s|$))?)", "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.ts" }, "2": { - "name": "comment.line.double-slash.ts punctuation.definition.comment.ts" + "name": "comment.line.double-slash.ts" + }, + "3": { + "name": "punctuation.definition.comment.ts" + }, + "4": { + "name": "storage.type.internaldeclaration.ts" + }, + "5": { + "name": "punctuation.decorator.internaldeclaration.ts" } }, "end": "(?=^)", @@ -3460,7 +4152,7 @@ }, "directives": { "name": "comment.line.triple-slash.directive.ts", - "begin": "^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|name)\\s*=\\s*((\\'[^']*\\')|(\\\"[^\"]*\\\")))+\\s*/>\\s*$)", + "begin": "^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|name)\\s*=\\s*((\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")))+\\s*/>\\s*$)", "beginCaptures": { "1": { "name": "punctuation.definition.comment.ts" @@ -3504,7 +4196,7 @@ "docblock": { "patterns": [ { - "match": "(?x)\n((@)access)\n\\s+\n(private|protected|public)\n\\b", + "match": "(?x)\n((@)(?:access|api))\n\\s+\n(private|protected|public)\n\\b", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3628,7 +4320,7 @@ } }, { - "match": "(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!https?://)\n (?:[^@\\s*/]|\\*[^/])+\n )\n)", + "match": "(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!\n # Avoid matching bare URIs (also acceptable as links)\n https?://\n |\n # Avoid matching {@inline tags}; we match those below\n (?:\\[[^\\[\\]]*\\])? # Possible description [preceding]{@tag}\n {@(?:link|linkcode|linkplain|tutorial)\\b\n )\n # Matched namepath\n (?:[^@\\s*/]|\\*[^/])+\n )\n)", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3645,7 +4337,7 @@ } }, { - "match": "(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(?:\n ([A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]*) # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* (,) \\s*\n ([A-Za-z_$]\n [\\w$.\\[\\]]*)\n )*\n)", + "match": "(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(\n [A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]* # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* , \\s*\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n )*\n)", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3655,12 +4347,6 @@ }, "3": { "name": "variable.other.jsdoc" - }, - "4": { - "name": "punctuation.delimiter.object.comma.jsdoc" - }, - "5": { - "name": "variable.other.jsdoc" } } }, @@ -3720,32 +4406,29 @@ }, { "name": "variable.other.jsdoc", - "begin": "\\[", - "end": "\\]|(?=\\*/)", - "patterns": [ - { - "match": "(=)((?:[^\\]*]|\\*[^/])*)", - "captures": { - "1": { - "name": "keyword.operator.assignment.jsdoc" - }, - "2": { - "name": "source.embedded.ts" - } - } + "match": "(?x)\n(\\[)\\s*\n[\\w$]+\n(?:\n (?:\\[\\])? # Foo[ ].bar properties within an array\n \\. # Foo.Bar namespaced parameter\n [\\w$]+\n)*\n(?:\n \\s*\n (=) # [foo=bar] Default parameter value\n \\s*\n (\n # The inner regexes are to stop the match early at */ and to not stop at escaped quotes\n (?>\n \"(?:(?:\\*(?!/))|(?:\\\\(?!\"))|[^*\\\\])*?\" | # [foo=\"bar\"] Double-quoted\n '(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted\n \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal\n (?:(?:\\*(?!/))|\\s(?!\\s*\\])|\\[.*?(?:\\]|(?=\\*/))|[^*\\s\\[\\]])* # Everything else\n )*\n )\n)?\n\\s*(?:(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/))", + "captures": { + "1": { + "name": "punctuation.definition.optional-value.begin.bracket.square.jsdoc" }, - { - "include": "#brackets" + "2": { + "name": "keyword.operator.assignment.jsdoc" }, - { - "include": "#quotes" + "3": { + "name": "source.embedded.ts" + }, + "4": { + "name": "punctuation.definition.optional-value.end.bracket.square.jsdoc" + }, + "5": { + "name": "invalid.illegal.syntax.jsdoc" } - ] + } } ] }, { - "begin": "((@)(?:define|enum|exception|implements|modifies|namespace|private|protected|returns?|suppress|throws|type))\\s+(?={)", + "begin": "(?x)\n(\n (@)\n (?:define|enum|exception|export|extends|lends|implements|modifies\n |namespace|private|protected|returns?|suppress|this|throws|type\n |yields?)\n)\n\\s+(?={)", "beginCaptures": { "1": { "name": "storage.type.class.jsdoc" @@ -3818,7 +4501,7 @@ }, { "name": "storage.type.class.jsdoc", - "match": "(?x) (@) (?:abstract|access|alias|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|global|host|ignore|implements|implicitCast|inherit[Dd]oc|inner|instance|interface|kind |lends|license|listens|main|member|memberof!?|method|mixes|mixins?|modifies|module|name|namespace |noalias|nocollapse|nocompile|nosideeffects|override|overview|package|param|preserve|private|prop |property|protected|public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule |summary|suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce) \\b", + "match": "(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \\b", "captures": { "1": { "name": "punctuation.definition.block.tag.jsdoc" @@ -3913,28 +4596,6 @@ } ] }, - "quotes": { - "patterns": [ - { - "begin": "'", - "end": "'|(?=\\*/)", - "patterns": [ - { - "include": "#quotes" - } - ] - }, - { - "begin": "\"", - "end": "\"|(?=\\*/)", - "patterns": [ - { - "include": "#quotes" - } - ] - } - ] - }, "jsdoctype": { "patterns": [ { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/typescript/syntaxes/TypeScriptReact.tmLanguage.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/typescript/syntaxes/TypeScriptReact.tmLanguage.json index 78145cde03..f9bfa9b323 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/typescript/syntaxes/TypeScriptReact.tmLanguage.json +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/typescript/syntaxes/TypeScriptReact.tmLanguage.json @@ -4,13 +4,12 @@ "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/3a70fab1b03520774fa236f1f7e7a0939463739f", + "version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/7bf8960f7042474b10b519f39339fc527907ce16", "name": "TypeScriptReact", "scopeName": "source.tsx", "fileTypes": [ "tsx" ], - "uuid": "805375ec-d614-41f5-8993-5843fe63ea82", "patterns": [ { "include": "#directives" @@ -44,31 +43,249 @@ "include": "#declaration" }, { + "include": "#control-statement" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#label" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-semicolon" + } + ] + }, + "declaration": { + "patterns": [ + { + "include": "#decorator" + }, + { + "include": "#var-expr" + }, + { + "include": "#function-declaration" + }, + { + "include": "#class-declaration" + }, + { + "include": "#interface-declaration" + }, + { + "include": "#enum-declaration" + }, + { + "include": "#namespace-declaration" + }, + { + "include": "#type-alias-declaration" + }, + { + "include": "#import-equals-declaration" + }, + { + "include": "#import-declaration" + }, + { + "include": "#export-declaration" + } + ] + }, + "control-statement": { + "patterns": [ + { "include": "#switch-statement" }, { "include": "#for-loop" }, { - "include": "#after-operator-block" + "name": "keyword.control.trycatch.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#decl-block" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|goto)\\s+([_$[:alpha:]][_$[:alnum:]]*)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "captures": { + "1": { + "name": "keyword.control.loop.tsx" + }, + "2": { + "name": "entity.name.label.tsx" + } + } }, { - "include": "#control-statement" + "name": "keyword.control.loop.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#expression" + "name": "keyword.control.flow.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(return)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#punctuation-semicolon" + "name": "keyword.control.switch.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.conditional.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(else|if)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.control.with.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(with)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.other.debugger.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(debugger)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "storage.modifier.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(declare)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + } + ] + }, + "label": { + "patterns": [ + { + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)(?=\\s*\\{)", + "beginCaptures": { + "1": { + "name": "entity.name.label.tsx" + }, + "2": { + "name": "punctuation.separator.label.tsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#decl-block" + } + ] + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)", + "captures": { + "1": { + "name": "entity.name.label.tsx" + }, + "2": { + "name": "punctuation.separator.label.tsx" + } + } + } + ] + }, + "expression": { + "patterns": [ + { + "include": "#expressionWithoutIdentifiers" + }, + { + "include": "#identifiers" + }, + { + "include": "#expressionPunctuations" + } + ] + }, + "expressionWithoutIdentifiers": { + "patterns": [ + { + "include": "#jsx" + }, + { + "include": "#string" + }, + { + "include": "#regex" + }, + { + "include": "#template" + }, + { + "include": "#comment" + }, + { + "include": "#function-expression" + }, + { + "include": "#class-expression" + }, + { + "include": "#arrow-function" + }, + { + "include": "#paren-expression-possibly-arrow" + }, + { + "include": "#cast" + }, + { + "include": "#ternary-expression" + }, + { + "include": "#new-expr" + }, + { + "include": "#instanceof-expr" + }, + { + "include": "#object-literal" + }, + { + "include": "#expression-operators" + }, + { + "include": "#function-call" + }, + { + "include": "#literal" + }, + { + "include": "#support-objects" + }, + { + "include": "#paren-expression" + } + ] + }, + "expressionPunctuations": { + "patterns": [ + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-accessor" + } + ] + }, + "decorator": { + "name": "meta.decorator.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))\\@", + "beginCaptures": { + "0": { + "name": "punctuation.decorator.tsx" + } + }, + "end": "(?=\\s)", + "patterns": [ + { + "include": "#expression" } ] }, "var-expr": { "name": "meta.var.expr.tsx", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(var|let|const(?!\\s+enum\\b))\\b(?!\\$|\\.)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(var|let|const(?!\\s+enum\\b))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { "name": "keyword.control.export.tsx" @@ -92,6 +309,29 @@ "include": "#comment" }, { + "begin": "(,)\\s*(?!\\S)", + "beginCaptures": { + "1": { + "name": "punctuation.separator.comma.tsx" + } + }, + "end": "(?<!,)((?==|;|}|(\\s+(of|in)\\s+)|^\\s*$))|((?<=\\S)(?=\\s*$))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#destructuring-variable" + }, + { + "include": "#var-single-variable" + }, + { + "include": "#punctuation-comma" + } + ] + }, + { "include": "#punctuation-comma" } ] @@ -100,7 +340,7 @@ "patterns": [ { "name": "meta.var-single-variable.expr.tsx", - "begin": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)", + "begin": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", "beginCaptures": { "1": { "name": "meta.definition.variable.tsx entity.name.function.tsx" @@ -162,7 +402,7 @@ "patterns": [ { "name": "meta.object-binding-pattern-variable.tsx", - "begin": "(?<!=|:|of|in)\\s*(?=\\{)", + "begin": "(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\{)", "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", "patterns": [ { @@ -178,7 +418,7 @@ }, { "name": "meta.array-binding-pattern-variable.tsx", - "begin": "(?<!=|:|of|in)\\s*(?=\\[)", + "begin": "(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\[)", "end": "(?=$|^|[;,=}]|(\\s+(of|in)\\s+))", "patterns": [ { @@ -200,7 +440,7 @@ "include": "#comment" }, { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", "end": "(?=,|\\})", "patterns": [ { @@ -226,7 +466,7 @@ ] }, "object-binding-element-propertyName": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", "end": "(:)", "endCaptures": { "0": { @@ -241,6 +481,9 @@ "include": "#array-literal" }, { + "include": "#numeric-literal" + }, + { "name": "variable.object.property.tsx", "match": "([_$[:alpha:]][_$[:alnum:]]*)" } @@ -252,6 +495,9 @@ "include": "#comment" }, { + "include": "#string" + }, + { "include": "#object-binding-pattern" }, { @@ -323,212 +569,941 @@ } ] }, - "ternary-expression": { - "begin": "(\\?)", - "beginCaptures": { - "0": { - "name": "keyword.operator.ternary.tsx" + "parameter-name": { + "patterns": [ + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|protected|private|readonly)\\s+(?=(public|protected|private|readonly)\\s+)", + "captures": { + "1": { + "name": "storage.modifier.tsx" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "storage.modifier.tsx" + }, + "2": { + "name": "keyword.operator.rest.tsx" + }, + "3": { + "name": "entity.name.function.tsx variable.language.this.tsx" + }, + "4": { + "name": "entity.name.function.tsx" + }, + "5": { + "name": "keyword.operator.optional.tsx" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)", + "captures": { + "1": { + "name": "storage.modifier.tsx" + }, + "2": { + "name": "keyword.operator.rest.tsx" + }, + "3": { + "name": "variable.parameter.tsx variable.language.this.tsx" + }, + "4": { + "name": "variable.parameter.tsx" + }, + "5": { + "name": "keyword.operator.optional.tsx" + } + } } - }, - "end": "(:)", - "endCaptures": { - "0": { - "name": "keyword.operator.ternary.tsx" + ] + }, + "destructuring-parameter": { + "patterns": [ + { + "name": "meta.parameter.object-binding-pattern.tsx", + "begin": "(?<!=|:)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.binding-pattern.object.tsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.object.tsx" + } + }, + "patterns": [ + { + "include": "#parameter-object-binding-element" + } + ] + }, + { + "name": "meta.paramter.array-binding-pattern.tsx", + "begin": "(?<!=|:)\\s*(\\[)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.binding-pattern.array.tsx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.tsx" + } + }, + "patterns": [ + { + "include": "#parameter-binding-element" + }, + { + "include": "#punctuation-comma" + } + ] } - }, + ] + }, + "parameter-object-binding-element": { "patterns": [ { - "include": "#expression" + "include": "#comment" + }, + { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", + "end": "(?=,|\\})", + "patterns": [ + { + "include": "#object-binding-element-propertyName" + }, + { + "include": "#parameter-binding-element" + } + ] + }, + { + "include": "#parameter-object-binding-pattern" + }, + { + "include": "#destructuring-parameter-rest" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#punctuation-comma" } ] }, - "expression": { + "parameter-binding-element": { "patterns": [ { - "include": "#jsx" + "include": "#comment" }, { "include": "#string" }, { - "include": "#regex" + "include": "#parameter-object-binding-pattern" }, { - "include": "#template" + "include": "#parameter-array-binding-pattern" }, { - "include": "#comment" + "include": "#destructuring-parameter-rest" }, { - "include": "#function-expression" + "include": "#variable-initializer" + } + ] + }, + "destructuring-parameter-rest": { + "match": "(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "keyword.operator.rest.tsx" + }, + "2": { + "name": "variable.parameter.tsx" + } + } + }, + "parameter-object-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\{)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.tsx" }, + "2": { + "name": "punctuation.definition.binding-pattern.object.tsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.object.tsx" + } + }, + "patterns": [ { - "include": "#class-or-interface-declaration" + "include": "#parameter-object-binding-element" + } + ] + }, + "parameter-array-binding-pattern": { + "begin": "(?:(\\.\\.\\.)\\s*)?(\\[)", + "beginCaptures": { + "1": { + "name": "keyword.operator.rest.tsx" }, + "2": { + "name": "punctuation.definition.binding-pattern.array.tsx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.binding-pattern.array.tsx" + } + }, + "patterns": [ { - "include": "#arrow-function" + "include": "#parameter-binding-element" }, { - "include": "#cast" + "include": "#punctuation-comma" + } + ] + }, + "field-declaration": { + "name": "meta.field.declaration.tsx", + "begin": "(?x)(?<!\\()(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(readonly)\\s+)?(?=\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", + "beginCaptures": { + "1": { + "name": "storage.modifier.tsx" + } + }, + "end": "(?x)(?=\\}|;|,|$|(^(?!\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "patterns": [ + { + "include": "#variable-initializer" }, { - "include": "#ternary-expression" + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", + "end": "(?x)(?=[};,=]|$|(^(?!\\s*((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "patterns": [ + { + "include": "#type-annotation" + }, + { + "include": "#string" + }, + { + "include": "#array-literal" + }, + { + "include": "#numeric-literal" + }, + { + "include": "#comment" + }, + { + "match": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(\\?)?(?=(\\?\\s*)?\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "meta.definition.property.tsx entity.name.function.tsx" + }, + "2": { + "name": "keyword.operator.optional.tsx" + } + } + }, + { + "name": "meta.definition.property.tsx variable.object.property.tsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + { + "name": "keyword.operator.optional.tsx", + "match": "\\?" + } + ] + } + ] + }, + "variable-initializer": { + "patterns": [ + { + "begin": "(?<!=|!)(=)(?!=)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.tsx" + } + }, + "end": "(?=$|^|[,);}\\]])", + "patterns": [ + { + "include": "#expression" + } + ] }, { - "include": "#new-expr" + "begin": "(?<!=|!)(=)(?!=)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.tsx" + } + }, + "end": "(?=[,);}\\]])|(?=^\\s*$)|(?<=\\S)(?<!=)(?=\\s*$)", + "patterns": [ + { + "include": "#expression" + } + ] + } + ] + }, + "function-declaration": { + "name": "meta.function.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.export.tsx" + }, + "2": { + "name": "storage.modifier.async.tsx" }, + "3": { + "name": "storage.type.function.tsx" + }, + "4": { + "name": "keyword.generator.asterisk.tsx" + }, + "5": { + "name": "meta.definition.function.tsx entity.name.function.tsx" + } + }, + "end": "(?=$|^|;)|(?<=\\})", + "patterns": [ { - "include": "#object-literal" + "include": "#function-name" }, { - "include": "#expression-operators" + "include": "#function-body" + } + ] + }, + "function-expression": { + "name": "meta.function.expression.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.tsx" + }, + "2": { + "name": "storage.type.function.tsx" + }, + "3": { + "name": "keyword.generator.asterisk.tsx" }, + "4": { + "name": "meta.definition.function.tsx entity.name.function.tsx" + } + }, + "end": "(?<=\\})", + "patterns": [ { - "include": "#function-call" + "include": "#function-name" }, { - "include": "#literal" + "include": "#function-body" + } + ] + }, + "function-name": { + "name": "meta.definition.function.tsx entity.name.function.tsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + "function-body": { + "patterns": [ + { + "include": "#comment" }, { - "include": "#support-objects" + "include": "#type-parameters" }, { - "include": "#identifiers" + "include": "#function-parameters" }, { - "include": "#paren-expression" + "include": "#return-type" }, { - "include": "#punctuation-comma" + "include": "#decl-block" }, { - "include": "#punctuation-accessor" + "name": "keyword.generator.asterisk.tsx", + "match": "\\*" } ] }, - "control-statement": { + "method-declaration": { "patterns": [ { - "name": "keyword.control.trycatch.tsx", - "match": "(?<!\\.|\\$)\\b(catch|finally|throw|try)\\b(?!\\$|\\.)" + "name": "meta.method.declaration.tsx", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?\\s*\\b(constructor)\\b(?!:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "storage.modifier.tsx" + }, + "2": { + "name": "storage.modifier.tsx" + }, + "3": { + "name": "storage.modifier.async.tsx" + }, + "4": { + "name": "storage.type.tsx" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] }, { - "name": "keyword.control.loop.tsx", - "match": "(?<!\\.|\\$)\\b(break|continue|do|goto|while)\\b(?!\\$|\\.)" + "name": "meta.method.declaration.tsx", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:(?:\\s*\\b(new)\\b(?!:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|(?:(\\*)\\s*)?)(?=\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.tsx" + }, + "2": { + "name": "storage.modifier.tsx" + }, + "3": { + "name": "storage.modifier.async.tsx" + }, + "4": { + "name": "keyword.operator.new.tsx" + }, + "5": { + "name": "keyword.generator.asterisk.tsx" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] }, { - "name": "keyword.control.flow.tsx", - "match": "(?<!\\.|\\$)\\b(return)\\b(?!\\$|\\.)" + "name": "meta.method.declaration.tsx", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.tsx" + }, + "2": { + "name": "storage.modifier.tsx" + }, + "3": { + "name": "storage.modifier.async.tsx" + }, + "4": { + "name": "storage.type.property.tsx" + }, + "5": { + "name": "keyword.generator.asterisk.tsx" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] + } + ] + }, + "object-literal-method-declaration": { + "name": "meta.method.declaration.tsx", + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.tsx" }, + "2": { + "name": "storage.type.property.tsx" + }, + "3": { + "name": "keyword.generator.asterisk.tsx" + } + }, + "end": "(?=\\}|;|,)|(?<=\\})", + "patterns": [ { - "name": "keyword.control.switch.tsx", - "match": "(?<!\\.|\\$)\\b(case|default|switch)\\b(?!\\$|\\.)" + "include": "#method-declaration-name" }, { - "name": "keyword.control.conditional.tsx", - "match": "(?<!\\.|\\$)\\b(else|if)\\b(?!\\$|\\.)" + "include": "#function-body" }, { - "name": "keyword.control.with.tsx", - "match": "(?<!\\.|\\$)\\b(with)\\b(?!\\$|\\.)" + "begin": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=\\s*(((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.tsx" + }, + "2": { + "name": "storage.type.property.tsx" + }, + "3": { + "name": "keyword.generator.asterisk.tsx" + } + }, + "end": "(?=\\(|\\<)", + "patterns": [ + { + "include": "#method-declaration-name" + } + ] + } + ] + }, + "method-declaration-name": { + "begin": "(?x)(?=((\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$))|(\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$))|(\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$))|((?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??)\\s*[\\(\\<])", + "end": "(?=\\(|\\<)", + "patterns": [ + { + "include": "#string" }, { - "name": "keyword.other.debugger.tsx", - "match": "(?<!\\.|\\$)\\b(debugger)\\b(?!\\$|\\.)" + "include": "#array-literal" }, { - "name": "storage.modifier.tsx", - "match": "(?<!\\.|\\$)\\b(declare)\\b(?!\\$|\\.)" + "include": "#numeric-literal" + }, + { + "name": "meta.definition.method.tsx entity.name.function.tsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + }, + { + "name": "keyword.operator.optional.tsx", + "match": "\\?" } ] }, - "declaration": { + "arrow-function": { "patterns": [ { - "include": "#decorator" + "name": "meta.arrow.tsx", + "match": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\\s+)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)", + "captures": { + "1": { + "name": "storage.modifier.async.tsx" + }, + "2": { + "name": "variable.parameter.tsx" + } + } }, { - "include": "#var-expr" + "name": "meta.arrow.tsx", + "begin": "(?x) (?:\n (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\n)? ((?<![})!\\]])\\s*\n (?=\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n )\n)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.tsx" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "include": "#function-parameters" + }, + { + "include": "#arrow-return-type" + } + ] }, { - "include": "#function-declaration" + "name": "meta.arrow.tsx", + "begin": "=>", + "beginCaptures": { + "0": { + "name": "storage.type.function.arrow.tsx" + } + }, + "end": "(?<=\\}|\\S)(?<!=>)|((?!\\{)(?=\\S))", + "patterns": [ + { + "include": "#decl-block" + }, + { + "include": "#expression" + } + ] + } + ] + }, + "indexer-declaration": { + "name": "meta.indexer.declaration.tsx", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(readonly)\\s*)?\\s*(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "beginCaptures": { + "1": { + "name": "storage.modifier.tsx" + }, + "2": { + "name": "meta.brace.square.tsx" + }, + "3": { + "name": "variable.parameter.tsx" + } + }, + "end": "(\\])\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.tsx" }, + "2": { + "name": "keyword.operator.optional.tsx" + } + }, + "patterns": [ { - "include": "#class-or-interface-declaration" + "include": "#type-annotation" + } + ] + }, + "indexer-mapped-type-declaration": { + "name": "meta.indexer.mappedtype.declaration.tsx", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))([+-])?(readonly)\\s*)?\\s*(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s+(in)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.modifier.tsx" + }, + "2": { + "name": "storage.modifier.tsx" + }, + "3": { + "name": "meta.brace.square.tsx" + }, + "4": { + "name": "entity.name.type.tsx" }, + "5": { + "name": "keyword.operator.expression.in.tsx" + } + }, + "end": "(\\])([+-])?\\s*(\\?\\s*)?|$", + "endCaptures": { + "1": { + "name": "meta.brace.square.tsx" + }, + "2": { + "name": "keyword.operator.type.modifier.tsx" + }, + "3": { + "name": "keyword.operator.optional.tsx" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + "function-parameters": { + "name": "meta.parameters.tsx", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.definition.parameters.begin.tsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.parameters.end.tsx" + } + }, + "patterns": [ + { + "include": "#function-parameters-body" + } + ] + }, + "function-parameters-body": { + "patterns": [ { - "include": "#type-declaration" + "include": "#comment" }, { - "include": "#enum-declaration" + "include": "#decorator" }, { - "include": "#namespace-declaration" + "include": "#destructuring-parameter" }, { - "include": "#import-equals-declaration" + "include": "#parameter-name" }, { - "include": "#import-declaration" + "include": "#type-annotation" }, { - "include": "#export-declaration" + "include": "#variable-initializer" + }, + { + "name": "punctuation.separator.parameter.tsx", + "match": "," } ] }, - "decorator": { - "name": "meta.decorator.tsx", - "begin": "(?<!\\.|\\$)\\@", + "class-declaration": { + "name": "meta.class.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(class)\\b(?=\\s+|/[/*])", "beginCaptures": { - "0": { - "name": "punctuation.decorator.tsx" + "1": { + "name": "keyword.control.export.tsx" + }, + "2": { + "name": "storage.modifier.tsx" + }, + "3": { + "name": "storage.type.class.tsx" } }, - "end": "(?=\\s)", + "end": "(?<=\\})", "patterns": [ { - "include": "#expression" + "include": "#class-declaration-or-expression-patterns" } ] }, - "type-declaration": { - "name": "meta.type.declaration.tsx", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(type)\\b\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*", + "class-expression": { + "name": "meta.class.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(class)\\b(?=\\s+|[<{]|\\/[\\/*])", + "beginCaptures": { + "1": { + "name": "storage.type.class.tsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#class-declaration-or-expression-patterns" + } + ] + }, + "class-declaration-or-expression-patterns": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" + }, + { + "match": "[_$[:alpha:]][_$[:alnum:]]*", + "captures": { + "0": { + "name": "entity.name.type.class.tsx" + } + } + }, + { + "include": "#type-parameters" + }, + { + "include": "#class-or-interface-body" + } + ] + }, + "interface-declaration": { + "name": "meta.interface.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(interface)\\b(?=\\s+|/[/*])", "beginCaptures": { "1": { "name": "keyword.control.export.tsx" }, "2": { - "name": "storage.type.type.tsx" + "name": "storage.modifier.tsx" }, "3": { - "name": "entity.name.type.alias.tsx" + "name": "storage.type.interface.tsx" } }, - "end": "(?=[};]|\\bvar\\b|\\blet\\b|\\bconst\\b|\\btype\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\bnamespace\\b|\\bmodule\\b|\\bimport\\b|\\benum\\b|\\bdeclare\\b|\\bexport\\b|\\babstract\\b|\\basync\\b)", + "end": "(?<=\\})", "patterns": [ { "include": "#comment" }, { + "include": "#class-or-interface-heritage" + }, + { + "match": "[_$[:alpha:]][_$[:alnum:]]*", + "captures": { + "0": { + "name": "entity.name.type.interface.tsx" + } + } + }, + { "include": "#type-parameters" }, { - "include": "#type" + "include": "#class-or-interface-body" + } + ] + }, + "class-or-interface-heritage": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(extends|implements)\\b)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "storage.modifier.tsx" + } + }, + "end": "(?=\\{)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#class-or-interface-heritage" }, { - "match": "(=)\\s*", + "include": "#type-parameters" + }, + { + "include": "#expressionWithoutIdentifiers" + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*)", "captures": { "1": { - "name": "keyword.operator.assignment.tsx" + "name": "entity.name.type.module.tsx" + }, + "2": { + "name": "punctuation.accessor.tsx" + }, + "3": { + "name": "punctuation.accessor.optional.tsx" } } + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "entity.other.inherited-class.tsx" + } + } + }, + { + "include": "#expressionPunctuations" } ] }, + "class-or-interface-body": { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.tsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.tsx" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#decorator" + }, + { + "include": "#method-declaration" + }, + { + "include": "#indexer-declaration" + }, + { + "include": "#field-declaration" + }, + { + "include": "#string" + }, + { + "include": "#type-annotation" + }, + { + "include": "#variable-initializer" + }, + { + "include": "#access-modifier" + }, + { + "include": "#property-accessor" + }, + { + "include": "#async-modifier" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-semicolon" + } + ] + }, + "access-modifier": { + "name": "storage.modifier.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(abstract|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "property-accessor": { + "name": "storage.type.property.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(get|set)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "async-modifier": { + "name": "storage.modifier.async.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(async)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, "enum-declaration": { "name": "meta.enum.declaration.tsx", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)", "beginCaptures": { "1": { "name": "keyword.control.export.tsx" @@ -583,7 +1558,7 @@ ] }, { - "begin": "(?=((\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))", + "begin": "(?=((\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))", "end": "(?=,|\\}|$)", "patterns": [ { @@ -609,7 +1584,7 @@ }, "namespace-declaration": { "name": "meta.namespace.declaration.tsx", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+(?=[_$[:alpha:]\"'`])", + "begin": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+(?=[_$[:alpha:]\"'`]))", "beginCaptures": { "1": { "name": "keyword.control.export.tsx" @@ -618,7 +1593,7 @@ "name": "storage.type.namespace.tsx" } }, - "end": "(?<=\\})", + "end": "(?<=\\})|(?=;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#comment" @@ -638,11 +1613,49 @@ } ] }, + "type-alias-declaration": { + "name": "meta.type.declaration.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(type)\\b\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.control.export.tsx" + }, + "2": { + "name": "storage.type.type.tsx" + }, + "3": { + "name": "entity.name.type.alias.tsx" + } + }, + "end": "(?=\\}|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "begin": "(=)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.tsx" + } + }, + "end": "(?=\\}|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, "import-equals-declaration": { "patterns": [ { "name": "meta.import-equals.external.tsx", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(require)\\s*(\\()", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(require)\\s*(\\()", "beginCaptures": { "1": { "name": "keyword.control.export.tsx" @@ -680,7 +1693,7 @@ }, { "name": "meta.import-equals.internal.tsx", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(?!require\\b)", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)\\s+([_$[:alpha:]][_$[:alnum:]]*)\\s*(=)\\s*(?!require\\b)", "beginCaptures": { "1": { "name": "keyword.control.export.tsx" @@ -695,19 +1708,22 @@ "name": "keyword.operator.assignment.tsx" } }, - "end": "(?=;|$)", + "end": "(?=;|$|^)", "patterns": [ { "include": "#comment" }, { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", "captures": { "1": { "name": "entity.name.type.module.tsx" }, "2": { "name": "punctuation.accessor.tsx" + }, + "3": { + "name": "punctuation.accessor.optional.tsx" } } }, @@ -721,7 +1737,7 @@ }, "import-declaration": { "name": "meta.import.tsx", - "begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(import)(?!(\\s*:)|(\\$|\\.))\\b", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?\\b(import)(?!\\s*[:\\(])(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { "name": "keyword.control.export.tsx" @@ -730,9 +1746,29 @@ "name": "keyword.control.import.tsx" } }, - "end": "(?=;|$)", + "end": "(?<!^import|[^\\._$[:alnum:]]import)(?=;|$|^)", "patterns": [ { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "begin": "(?<=^import|[^\\._$[:alnum:]]import)(?!\\s*[\"'])", + "end": "\\bfrom\\b", + "endCaptures": { + "0": { + "name": "keyword.control.from.tsx" + } + }, + "patterns": [ + { + "include": "#import-export-declaration" + } + ] + }, + { "include": "#import-export-declaration" } ] @@ -740,7 +1776,7 @@ "export-declaration": { "patterns": [ { - "match": "(?<!\\.|\\$)\\b(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "keyword.control.export.tsx" @@ -758,7 +1794,7 @@ }, { "name": "meta.export.default.tsx", - "begin": "(?<!\\.|\\$)\\b(export)(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))", "beginCaptures": { "1": { "name": "keyword.control.export.tsx" @@ -770,7 +1806,7 @@ "name": "keyword.control.default.tsx" } }, - "end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)", + "end": "(?=$|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#expression" @@ -779,13 +1815,13 @@ }, { "name": "meta.export.tsx", - "begin": "(?<!\\.|\\$)\\b(export)(?!(\\s*:)|(\\$))\\b", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?!\\s*:)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "0": { "name": "keyword.control.export.tsx" } }, - "end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)", + "end": "(?=$|;|\\babstract\\b|\\basync\\b|\\bclass\\b|\\bconst\\b|\\bdeclare\\b|\\benum\\b|\\bexport\\b|\\bfunction\\b|\\bimport\\b|\\binterface\\b|\\blet\\b|\\bmodule\\b|\\bnamespace\\b|\\breturn\\b|\\btype\\b|\\bvar\\b)", "patterns": [ { "include": "#import-export-declaration" @@ -840,8 +1876,7 @@ "include": "#comment" }, { - "comment": "(default|*|name) as alias", - "match": "(?x) (?: \\b(default)\\b | (\\*) | ([_$[:alpha:]][_$[:alnum:]]*)) \\s+ \n (as) \\s+ (?: (\\b default \\b | \\*) | ([_$[:alpha:]][_$[:alnum:]]*))", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bdefault)|(\\*)|(\\b[_$[:alpha:]][_$[:alnum:]]*))\\s+(as)\\s+(?:(\\bdefault(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|(\\b[_$[:alpha:]][_$[:alnum:]]*))", "captures": { "1": { "name": "keyword.control.default.tsx" @@ -856,7 +1891,7 @@ "name": "keyword.control.as.tsx" }, "5": { - "name": "invalid.illegal.tsx" + "name": "keyword.control.default.tsx" }, "6": { "name": "variable.other.readwrite.alias.tsx" @@ -880,147 +1915,170 @@ } ] }, - "class-or-interface-declaration": { + "switch-statement": { + "name": "switch-statement.expr.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?=\\bswitch\\s*\\()", + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.tsx" + } + }, "patterns": [ { - "name": "meta.class.tsx", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(class)\\b(?=\\s+|/[/*])", + "name": "switch-expression.expr.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(switch)\\s*(\\()", "beginCaptures": { "1": { - "name": "keyword.control.export.tsx" + "name": "keyword.control.switch.tsx" }, "2": { - "name": "storage.modifier.tsx" - }, - "3": { - "name": "storage.type.class.tsx" + "name": "meta.brace.round.tsx" } }, - "end": "(?<=\\})", + "end": "\\)", "endCaptures": { - "1": { + "0": { + "name": "meta.brace.round.tsx" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "name": "switch-block.expr.tsx", + "begin": "\\{", + "beginCaptures": { + "0": { "name": "punctuation.definition.block.tsx" } }, + "end": "(?=\\})", "patterns": [ { - "include": "#comment" + "name": "case-clause.expr.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default(?=:))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", + "beginCaptures": { + "1": { + "name": "keyword.control.switch.tsx" + } + }, + "end": "(?=:)", + "patterns": [ + { + "include": "#expression" + } + ] }, { - "include": "#class-or-interface-heritage" + "begin": "(:)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "case-clause.expr.tsx punctuation.definition.section.case-statement.tsx" + }, + "2": { + "name": "meta.block.tsx punctuation.definition.block.tsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "meta.block.tsx punctuation.definition.block.tsx" + } + }, + "contentName": "meta.block.tsx", + "patterns": [ + { + "include": "#statements" + } + ] }, { - "match": "[_$[:alpha:]][_$[:alnum:]]*", + "match": "(:)", "captures": { "0": { - "name": "entity.name.type.class.tsx" + "name": "case-clause.expr.tsx punctuation.definition.section.case-statement.tsx" } } }, { - "include": "#type-parameters" - }, - { - "include": "#class-or-interface-body" + "include": "#statements" } ] + } + ] + }, + "for-loop": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))for(?=((\\s+|(\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*))await)?\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)?(\\())", + "beginCaptures": { + "0": { + "name": "keyword.control.loop.tsx" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#comment" + }, + { + "name": "keyword.control.loop.tsx", + "match": "await" }, { - "name": "meta.interface.tsx", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(interface)\\b(?=\\s+|/[/*])", + "begin": "\\(", "beginCaptures": { - "1": { - "name": "keyword.control.export.tsx" - }, - "2": { - "name": "storage.modifier.tsx" - }, - "3": { - "name": "storage.type.interface.tsx" + "0": { + "name": "meta.brace.round.tsx" } }, - "end": "(?<=\\})", + "end": "\\)", "endCaptures": { - "1": { - "name": "punctuation.definition.block.tsx" + "0": { + "name": "meta.brace.round.tsx" } }, "patterns": [ { - "include": "#comment" - }, - { - "include": "#class-or-interface-heritage" - }, - { - "match": "[_$[:alpha:]][_$[:alnum:]]*", - "captures": { - "0": { - "name": "entity.name.type.interface.tsx" - } - } + "include": "#var-expr" }, { - "include": "#type-parameters" + "include": "#expression" }, { - "include": "#class-or-interface-body" + "include": "#punctuation-semicolon" } ] } ] }, - "class-or-interface-heritage": { - "begin": "(?<!\\.|\\$)(?:\\b(extends|implements)\\b)(?!\\$|\\.)", + "decl-block": { + "name": "meta.block.tsx", + "begin": "\\{", "beginCaptures": { - "1": { - "name": "storage.modifier.tsx" + "0": { + "name": "punctuation.definition.block.tsx" } }, - "end": "(?=\\{)", + "end": "\\}", "endCaptures": { - "1": { + "0": { "name": "punctuation.definition.block.tsx" } }, "patterns": [ { - "include": "#comment" - }, - { - "include": "#class-or-interface-heritage" - }, - { - "include": "#type-parameters" - }, - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*([,<{]|extends|implements|//|/\\*))", - "captures": { - "1": { - "name": "entity.name.type.module.tsx" - }, - "2": { - "name": "punctuation.accessor.tsx" - } - } - }, - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*([,<{]|extends|implements|//|/\\*))", - "captures": { - "1": { - "name": "entity.other.inherited-class.tsx" - } - } - }, - { - "include": "#expression" + "include": "#statements" } ] }, - "class-or-interface-body": { - "begin": "\\{", + "after-operator-block-as-object-literal": { + "name": "meta.objectliteral.tsx", + "begin": "(?<!\\+\\+|--)(?<=[:=(,\\[?+!>]|^await|[^\\._$[:alnum:]]await|^return|[^\\._$[:alnum:]]return|^yield|[^\\._$[:alnum:]]yield|^throw|[^\\._$[:alnum:]]throw|^in|[^\\._$[:alnum:]]in|^of|[^\\._$[:alnum:]]of|^typeof|[^\\._$[:alnum:]]typeof|&&|\\|\\||\\*)\\s*(\\{)", "beginCaptures": { - "0": { + "1": { "name": "punctuation.definition.block.tsx" } }, @@ -1032,54 +2090,12 @@ }, "patterns": [ { - "include": "#string" - }, - { - "include": "#comment" - }, - { - "include": "#decorator" - }, - { - "include": "#method-declaration" - }, - { - "include": "#indexer-declaration" - }, - { - "include": "#field-declaration" - }, - { - "include": "#type-annotation" - }, - { - "include": "#variable-initializer" - }, - { - "include": "#access-modifier" - }, - { - "include": "#property-accessor" - }, - { - "include": "#after-operator-block" - }, - { - "include": "#decl-block" - }, - { - "include": "#expression" - }, - { - "include": "#punctuation-comma" - }, - { - "include": "#punctuation-semicolon" + "include": "#object-member" } ] }, - "type-object": { - "name": "meta.object.type.tsx", + "object-literal": { + "name": "meta.objectliteral.tsx", "begin": "\\{", "beginCaptures": { "0": { @@ -1094,938 +2110,565 @@ }, "patterns": [ { - "include": "#comment" - }, - { - "include": "#method-declaration" - }, + "include": "#object-member" + } + ] + }, + "object-member": { + "patterns": [ { - "include": "#indexer-declaration" + "include": "#comment" }, { - "include": "#indexer-mapped-type-declaration" + "include": "#object-literal-method-declaration" }, { - "include": "#field-declaration" + "name": "meta.object.member.tsx meta.object-literal.key.tsx", + "begin": "(?=\\[)", + "end": "(?=:)|((?<=[\\]])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#array-literal" + } + ] }, { - "include": "#type-annotation" + "name": "meta.object.member.tsx meta.object-literal.key.tsx", + "begin": "(?=[\\'\\\"])", + "end": "(?=:)|((?<=[\\'\\\"])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#string" + } + ] }, { - "begin": "\\.\\.\\.", - "beginCaptures": { - "0": { - "name": "keyword.operator.spread.tsx" - } - }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + "name": "meta.method.declaration.tsx", + "begin": "(?<=[\\]\\'\\\"])(?=\\s*[\\(\\<])", + "end": "(?=\\}|;|,)|(?<=\\})", "patterns": [ { - "include": "#type" + "include": "#function-body" } ] }, { - "include": "#punctuation-comma" + "name": "meta.object.member.tsx", + "match": "(?![_$[:alpha:]])([[:digit:]]+)\\s*(?=:)", + "captures": { + "0": { + "name": "meta.object-literal.key.tsx" + }, + "1": { + "name": "constant.numeric.decimal.tsx" + } + } }, { - "include": "#punctuation-semicolon" + "name": "meta.object.member.tsx", + "match": "(?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "0": { + "name": "meta.object-literal.key.tsx" + }, + "1": { + "name": "entity.name.function.tsx" + } + } }, { - "include": "#type" - } - ] - }, - "field-declaration": { - "name": "meta.field.declaration.tsx", - "begin": "(?<!\\()(?:(?<!\\.|\\$)\\b(readonly)\\s+)?(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", - "beginCaptures": { - "1": { - "name": "storage.modifier.tsx" - } - }, - "end": "(?=\\}|;|,|$|(^(?!(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", - "patterns": [ - { - "include": "#variable-initializer" + "name": "meta.object.member.tsx", + "match": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "captures": { + "0": { + "name": "meta.object-literal.key.tsx" + } + } }, { - "begin": "(?=((?:[_$[:alpha:]][_$[:alnum:]]*)|(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))", - "end": "(?=[};,=]|$|(^(?!(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\?\\s*)?(=|:))))|(?<=\\})", + "name": "meta.object.member.tsx", + "begin": "\\.\\.\\.", + "beginCaptures": { + "0": { + "name": "keyword.operator.spread.tsx" + } + }, + "end": "(?=,|\\})", "patterns": [ { - "include": "#type-annotation" - }, - { - "include": "#string" - }, - { - "include": "#array-literal" - }, - { - "include": "#comment" - }, - { - "name": "meta.definition.property.tsx entity.name.function.tsx", - "match": "(?x)([_$[:alpha:]][_$[:alnum:]]*)(?=(\\?\\s*)?\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)" - }, - { - "name": "meta.definition.property.tsx variable.object.property.tsx", - "match": "[_$[:alpha:]][_$[:alnum:]]*" - }, - { - "name": "keyword.operator.optional.tsx", - "match": "\\?" + "include": "#expression" } ] - } - ] - }, - "method-declaration": { - "patterns": [ + }, { - "name": "meta.method.declaration.tsx", - "begin": "(?<!\\.|\\$)(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", - "beginCaptures": { + "name": "meta.object.member.tsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$)", + "captures": { "1": { - "name": "storage.modifier.tsx" - }, - "2": { - "name": "storage.modifier.tsx" - }, - "3": { - "name": "storage.modifier.async.tsx" - }, - "4": { - "name": "storage.type.property.tsx" - }, - "5": { - "name": "keyword.generator.asterisk.tsx" + "name": "variable.other.readwrite.tsx" } - }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + } + }, + { + "name": "meta.object.member.tsx", + "begin": "(?=[_$[:alpha:]][_$[:alnum:]]*\\s*=)", + "end": "(?=,|\\}|$)", "patterns": [ { - "include": "#method-declaration-name" - }, - { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" - }, - { - "include": "#return-type" - }, - { - "include": "#decl-block" + "include": "#expression" } ] }, { - "name": "meta.method.declaration.tsx", - "begin": "(?<!\\.|\\$)(?:\\b(public|private|protected)\\s+)?(?:\\b(abstract)\\s+)?(?:\\b(async)\\s+)?(?:(?:\\b(?:(new)|(constructor))\\b(?!\\$|\\.|:))|(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))?\\s*[\\(\\<]))", + "name": "meta.object.member.tsx", + "begin": ":", "beginCaptures": { - "1": { - "name": "storage.modifier.tsx" - }, - "2": { - "name": "storage.modifier.tsx" - }, - "3": { - "name": "storage.modifier.async.tsx" - }, - "4": { - "name": "keyword.operator.new.tsx" - }, - "5": { - "name": "storage.type.tsx" - }, - "6": { - "name": "keyword.generator.asterisk.tsx" + "0": { + "name": "meta.object-literal.key.tsx punctuation.separator.key-value.tsx" } }, - "end": "(?=\\}|;|,|$)|(?<=\\})", + "end": "(?=,|\\})", "patterns": [ { - "include": "#method-declaration-name" - }, - { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" + "begin": "(?<=:)\\s*(async)?(?=\\s*(<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)\\(\\s*([\\{\\[]\\s*)?$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.tsx" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#type-parameters" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.tsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.tsx" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + } + ] }, { - "include": "#return-type" + "begin": "(?<=:)\\s*(async)?\\s*(\\()(?=\\s*([\\{\\[]\\s*)?$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.tsx" + }, + "2": { + "name": "meta.brace.round.tsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.tsx" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] }, { - "include": "#decl-block" + "include": "#expression" } ] - } - ] - }, - "method-declaration-name": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??)\\s*[\\(\\<])", - "end": "(?=\\(|\\<)", - "patterns": [ - { - "include": "#string" - }, - { - "include": "#array-literal" - }, - { - "name": "meta.definition.method.tsx entity.name.function.tsx", - "match": "[_$[:alpha:]][_$[:alnum:]]*" - }, - { - "name": "keyword.operator.optional.tsx", - "match": "\\?" - } - ] - }, - "object-literal-method-declaration": { - "name": "meta.method.declaration.tsx", - "begin": "(?<!\\.|\\$)(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", - "beginCaptures": { - "1": { - "name": "storage.modifier.async.tsx" - }, - "2": { - "name": "storage.type.property.tsx" - }, - "3": { - "name": "keyword.generator.asterisk.tsx" - } - }, - "end": "(?=\\}|;|,)|(?<=\\})", - "patterns": [ - { - "include": "#method-declaration-name" - }, - { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" - }, - { - "include": "#return-type" - }, - { - "include": "#object-literal-method-overload-declaration" - }, - { - "include": "#decl-block" - } - ] - }, - "object-literal-method-overload-declaration": { - "begin": "(?<!\\.|\\$)(?:\\b(async)\\s+)?(?:\\b(get|set)\\s+)?(?:(\\*)\\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(\\??))\\s*[\\(\\<])", - "beginCaptures": { - "1": { - "name": "storage.modifier.async.tsx" - }, - "2": { - "name": "storage.type.property.tsx" }, - "3": { - "name": "keyword.generator.asterisk.tsx" - } - }, - "end": "(?=\\(|\\<)", - "patterns": [ { - "include": "#method-declaration-name" + "include": "#punctuation-comma" } ] }, - "indexer-declaration": { - "name": "meta.indexer.declaration.tsx", - "begin": "(?:(?<!\\.|\\$)\\b(readonly)\\s*)?(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=:)", + "ternary-expression": { + "begin": "(?!\\?\\.\\s*[^[:digit:]])(\\?)", "beginCaptures": { "1": { - "name": "storage.modifier.tsx" - }, - "2": { - "name": "meta.brace.square.tsx" - }, - "3": { - "name": "variable.parameter.tsx" + "name": "keyword.operator.ternary.tsx" } }, - "end": "(\\])\\s*(\\?\\s*)?|$", + "end": "\\s*(:)", "endCaptures": { "1": { - "name": "meta.brace.square.tsx" - }, - "2": { - "name": "keyword.operator.optional.tsx" + "name": "keyword.operator.ternary.tsx" } }, "patterns": [ { - "include": "#type-annotation" + "include": "#expression" } ] }, - "indexer-mapped-type-declaration": { - "name": "meta.indexer.mappedtype.declaration.tsx", - "begin": "(?:(?<!\\.|\\$)\\b(readonly)\\s*)?(\\[)\\s*([_$[:alpha:]][_$[:alnum:]]*)\\s+(in)\\s+", - "beginCaptures": { - "1": { - "name": "storage.modifier.tsx" - }, - "2": { - "name": "meta.brace.square.tsx" - }, - "3": { - "name": "entity.name.type.tsx" - }, - "4": { - "name": "keyword.operator.expression.in.tsx" - } - }, - "end": "(\\])\\s*(\\?\\s*)?|$", - "endCaptures": { - "1": { - "name": "meta.brace.square.tsx" - }, - "2": { - "name": "keyword.operator.optional.tsx" - } - }, + "function-call": { + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "end": "(?<=\\))(?!(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", "patterns": [ { - "include": "#type" - } - ] - }, - "function-declaration": { - "name": "meta.function.tsx", - "begin": "(?<!\\.|\\$)\\b(?:(export)\\s+)?(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", - "beginCaptures": { - "1": { - "name": "keyword.control.export.tsx" - }, - "2": { - "name": "storage.modifier.async.tsx" - }, - "3": { - "name": "storage.type.function.tsx" - }, - "4": { - "name": "keyword.generator.asterisk.tsx" + "name": "meta.function-call.tsx", + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*))", + "end": "(?=\\s*(\\?\\.\\s*)?(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)?\\()", + "patterns": [ + { + "include": "#literal" + }, + { + "include": "#support-objects" + }, + { + "include": "#object-identifiers" + }, + { + "include": "#punctuation-accessor" + }, + { + "name": "keyword.operator.expression.import.tsx", + "match": "(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))import(?=\\s*[\\(]\\s*[\\\"\\'\\`]))" + }, + { + "name": "entity.name.function.tsx", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" + } + ] }, - "5": { - "name": "meta.definition.function.tsx entity.name.function.tsx" - } - }, - "end": "(?=$|^|;)|(?<=\\})", - "patterns": [ { "include": "#comment" }, { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" + "name": "meta.function-call.tsx punctuation.accessor.optional.tsx", + "match": "\\?\\." }, { - "include": "#return-type" + "include": "#type-arguments" }, { - "include": "#decl-block" + "include": "#paren-expression" } ] }, - "function-expression": { - "name": "meta.function.expression.tsx", - "begin": "(?<!\\.|\\$)\\b(?:(async)\\s+)?(function\\b)(?:\\s*(\\*))?(?:(?:\\s+|(?<=\\*))([_$[:alpha:]][_$[:alnum:]]*))?\\s*", + "new-expr": { + "name": "new.expr.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { - "name": "storage.modifier.async.tsx" - }, - "2": { - "name": "storage.type.function.tsx" - }, - "3": { - "name": "keyword.generator.asterisk.tsx" - }, - "4": { - "name": "meta.definition.function.tsx entity.name.function.tsx" + "name": "keyword.operator.new.tsx" } }, - "end": "(?<=\\})", + "end": "(?<=\\))|(?=[;),}\\]:]|\\|\\||\\&\\&|$|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))new(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))function((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", "patterns": [ { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, - { - "include": "#function-parameters" + "include": "#paren-expression" }, { - "include": "#return-type" + "include": "#class-declaration" }, { - "include": "#decl-block" - } - ] - }, - "object-literal": { - "name": "meta.objectliteral.tsx", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.tsx" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.tsx" - } - }, - "patterns": [ - { - "include": "#object-member" - } - ] - }, - "decl-block": { - "name": "meta.block.tsx", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.tsx" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.tsx" - } - }, - "patterns": [ - { - "include": "#statements" + "include": "#type" } ] }, - "after-operator-block": { - "name": "meta.objectliteral.tsx", - "begin": "(?<=[=(,\\[?+!]|await|return|yield|throw|in|of|typeof|&&|\\|\\||\\*)\\s*(\\{)", + "instanceof-expr": { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(instanceof)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))", "beginCaptures": { "1": { - "name": "punctuation.definition.block.tsx" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.tsx" + "name": "keyword.operator.expression.instanceof.tsx" } }, + "end": "(?<=\\))|(?=[;),}\\]:?]|\\|\\||\\&\\&|$|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))function((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", "patterns": [ { - "include": "#object-member" - } - ] - }, - "parameter-name": { - "patterns": [ - { - "match": "\\s*\\b(public|protected|private|readonly)(?=\\s+(public|protected|private|readonly)\\s+)", - "captures": { - "1": { - "name": "storage.modifier.tsx" - } - } - }, - { - "match": "(?x)(?:\\s*\\b(public|private|protected|readonly)\\s+)?(\\.\\.\\.)?\\s*(?<!=|:)(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=\\s*\n (=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n )) |\n (:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n ))\n)", - "captures": { - "1": { - "name": "storage.modifier.tsx" - }, - "2": { - "name": "keyword.operator.rest.tsx" - }, - "3": { - "name": "entity.name.function.tsx variable.language.this.tsx" - }, - "4": { - "name": "entity.name.function.tsx" - }, - "5": { - "name": "keyword.operator.optional.tsx" - } - } - }, - { - "match": "(?:\\s*\\b(public|private|protected|readonly)\\s+)?(\\.\\.\\.)?\\s*(?<!=|:)(?:((?<!\\.|\\$)\\bthis\\b(?!\\.|\\$))|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)", - "captures": { - "1": { - "name": "storage.modifier.tsx" - }, - "2": { - "name": "keyword.operator.rest.tsx" - }, - "3": { - "name": "variable.parameter.tsx variable.language.this.tsx" - }, - "4": { - "name": "variable.parameter.tsx" - }, - "5": { - "name": "keyword.operator.optional.tsx" - } - } + "include": "#type" } ] }, - "destructuring-parameter": { + "paren-expression-possibly-arrow": { "patterns": [ { - "name": "meta.parameter.object-binding-pattern.tsx", - "begin": "(?<!=|:)\\s*(\\{)", + "begin": "(?<=[(=,])\\s*(async)?(?=\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*))?\\(\\s*[\\{\\[]\\s*$)", "beginCaptures": { "1": { - "name": "punctuation.definition.binding-pattern.object.tsx" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.object.tsx" + "name": "storage.modifier.async.tsx" } }, + "end": "(?<=\\))", "patterns": [ { - "include": "#parameter-object-binding-element" + "include": "#paren-expression-possibly-arrow-with-typeparameters" } ] }, { - "name": "meta.paramter.array-binding-pattern.tsx", - "begin": "(?<!=|:)\\s*(\\[)", + "begin": "(?<=[(=,]|=>)\\s*(async)?(?=\\s*((<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*))?\\(\\s*$)", "beginCaptures": { "1": { - "name": "punctuation.definition.binding-pattern.array.tsx" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.array.tsx" + "name": "storage.modifier.async.tsx" } }, + "end": "(?<=\\))", "patterns": [ { - "include": "#parameter-binding-element" - }, - { - "include": "#punctuation-comma" + "include": "#paren-expression-possibly-arrow-with-typeparameters" } ] + }, + { + "include": "#possibly-arrow-return-type" } ] }, - "parameter-object-binding-element": { + "paren-expression-possibly-arrow-with-typeparameters": { "patterns": [ { - "include": "#comment" + "include": "#type-parameters" }, { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\\'[^']*\\')|(\\\"[^\"]*\\\")|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*(:))", - "end": "(?=,|\\})", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.tsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.tsx" + } + }, "patterns": [ { - "include": "#object-binding-element-propertyName" - }, - { - "include": "#parameter-binding-element" + "include": "#expression-inside-possibly-arrow-parens" } ] - }, - { - "include": "#parameter-object-binding-pattern" - }, - { - "include": "#destructuring-parameter-rest" - }, - { - "include": "#variable-initializer" - }, - { - "include": "#punctuation-comma" } ] }, - "parameter-binding-element": { + "expression-inside-possibly-arrow-parens": { "patterns": [ { - "include": "#comment" - }, - { - "include": "#parameter-object-binding-pattern" + "include": "#expressionWithoutIdentifiers" }, { - "include": "#parameter-array-binding-pattern" + "include": "#function-parameters-body" }, { - "include": "#destructuring-parameter-rest" + "include": "#identifiers" }, { - "include": "#variable-initializer" + "include": "#expressionPunctuations" } ] }, - "destructuring-parameter-rest": { - "match": "(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)", - "captures": { - "1": { - "name": "keyword.operator.rest.tsx" - }, - "2": { - "name": "variable.parameter.tsx" - } - } - }, - "parameter-object-binding-pattern": { - "begin": "(?:(\\.\\.\\.)\\s*)?(\\{)", + "paren-expression": { + "begin": "\\(", "beginCaptures": { - "1": { - "name": "keyword.operator.rest.tsx" - }, - "2": { - "name": "punctuation.definition.binding-pattern.object.tsx" + "0": { + "name": "meta.brace.round.tsx" } }, - "end": "\\}", + "end": "\\)", "endCaptures": { "0": { - "name": "punctuation.definition.binding-pattern.object.tsx" + "name": "meta.brace.round.tsx" } }, "patterns": [ { - "include": "#parameter-object-binding-element" + "include": "#expression" } ] }, - "parameter-array-binding-pattern": { - "begin": "(?:(\\.\\.\\.)\\s*)?(\\[)", - "beginCaptures": { - "1": { - "name": "keyword.operator.rest.tsx" - }, - "2": { - "name": "punctuation.definition.binding-pattern.array.tsx" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "punctuation.definition.binding-pattern.array.tsx" - } - }, + "cast": { "patterns": [ { - "include": "#parameter-binding-element" - }, - { - "include": "#punctuation-comma" + "include": "#jsx" } ] }, - "return-type": { - "name": "meta.return.type.tsx", - "begin": "(?<=\\))\\s*(:)", - "beginCaptures": { - "1": { - "name": "keyword.operator.type.annotation.tsx" - } - }, - "end": "(?<![:|&])(?=$|^|[{};,]|//)", + "expression-operators": { "patterns": [ { - "include": "#comment" + "name": "keyword.control.flow.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(await)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "begin": "(?<=[:])(?=\\s*\\{)", - "end": "(?<=\\})", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?=\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*\\*)", + "beginCaptures": { + "1": { + "name": "keyword.control.flow.tsx" + } + }, + "end": "\\*", + "endCaptures": { + "0": { + "name": "keyword.generator.asterisk.tsx" + } + }, "patterns": [ { - "include": "#type-object" + "include": "#comment" } ] }, { - "include": "#type-predicate-operator" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?:\\s*(\\*))?", + "captures": { + "1": { + "name": "keyword.control.flow.tsx" + }, + "2": { + "name": "keyword.generator.asterisk.tsx" + } + } }, { - "include": "#type" - } - ] - }, - "type-predicate-operator": { - "name": "keyword.operator.expression.is.tsx", - "match": "(?<!\\.|\\$)\\bis\\b(?!\\$|\\.)" - }, - "type-annotation": { - "name": "meta.type.annotation.tsx", - "begin": ":", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.annotation.tsx" - } - }, - "end": "(?=$|^|[,);\\}\\]]|//)|(?==[^>])|(?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)", - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.expression.delete.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))delete(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#type" - } - ] - }, - "type": { - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.expression.in.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))in(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()" }, { - "include": "#string" + "name": "keyword.operator.expression.of.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))of(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()" }, { - "include": "#numeric-literal" + "name": "keyword.operator.expression.instanceof.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))instanceof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#type-primitive" + "name": "keyword.operator.new.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))new(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#type-builtin-literals" + "include": "#typeof-operator" }, { - "include": "#type-parameters" + "name": "keyword.operator.expression.void.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))void(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#type-tuple" + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(as)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.control.as.tsx" + } + }, + "end": "(?=$|^|[;,:})\\]]|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(as)\\s+))", + "patterns": [ + { + "include": "#type" + } + ] }, { - "include": "#type-object" + "name": "keyword.operator.spread.tsx", + "match": "\\.\\.\\." }, { - "include": "#type-operators" + "name": "keyword.operator.assignment.compound.tsx", + "match": "\\*=|(?<!\\()/=|%=|\\+=|\\-=" }, { - "include": "#type-fn-type-parameters" + "name": "keyword.operator.assignment.compound.bitwise.tsx", + "match": "\\&=|\\^=|<<=|>>=|>>>=|\\|=" }, { - "include": "#type-paren-or-function-parameters" + "name": "keyword.operator.bitwise.shift.tsx", + "match": "<<|>>>|>>" }, { - "include": "#type-function-return-type" + "name": "keyword.operator.comparison.tsx", + "match": "===|!==|==|!=" }, { - "include": "#type-name" - } - ] - }, - "function-parameters": { - "name": "meta.parameters.tsx", - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "punctuation.definition.parameters.begin.tsx" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.parameters.end.tsx" - } - }, - "patterns": [ - { - "include": "#comment" + "name": "keyword.operator.relational.tsx", + "match": "<=|>=|<>|<|>" }, { - "include": "#decorator" + "name": "keyword.operator.logical.tsx", + "match": "\\!|&&|\\|\\|" }, { - "include": "#destructuring-parameter" + "name": "keyword.operator.bitwise.tsx", + "match": "\\&|~|\\^|\\|" }, { - "include": "#parameter-name" + "name": "keyword.operator.assignment.tsx", + "match": "\\=" }, { - "include": "#type-annotation" + "name": "keyword.operator.decrement.tsx", + "match": "--" }, { - "include": "#variable-initializer" + "name": "keyword.operator.increment.tsx", + "match": "\\+\\+" }, { - "name": "punctuation.separator.parameter.tsx", - "match": "," - } - ] - }, - "type-primitive": { - "name": "support.type.primitive.tsx", - "match": "(?<!\\.|\\$)\\b(string|number|boolean|symbol|any|void|never)\\b(?!\\$|\\.)" - }, - "type-builtin-literals": { - "name": "support.type.builtin.tsx", - "match": "(?<!\\.|\\$)\\b(this|true|false|undefined|null|object)\\b(?!\\$|\\.)" - }, - "type-paren-or-function-parameters": { - "name": "meta.type.paren.cover.tsx", - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "meta.brace.round.tsx" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.tsx" - } - }, - "patterns": [ - { - "include": "#type" + "name": "keyword.operator.arithmetic.tsx", + "match": "%|\\*|/|-|\\+" }, { - "include": "#function-parameters" - } - ] - }, - "type-fn-type-parameters": { - "patterns": [ - { - "name": "meta.type.constructor.tsx", - "match": "(?<!\\.|\\$)\\b(new)\\b(?=\\s*\\<)", + "match": "(?<=[_$[:alnum:])\\]])\\s*(/)(?![/*])", "captures": { "1": { - "name": "keyword.control.new.tsx" + "name": "keyword.operator.arithmetic.tsx" } } - }, - { - "name": "meta.type.constructor.tsx", - "begin": "(?<!\\.|\\$)\\b(new)\\b\\s*(?=\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.new.tsx" - } - }, - "end": "(?<=\\))", - "patterns": [ - { - "include": "#function-parameters" - } - ] - }, - { - "name": "meta.type.function.tsx", - "begin": "(?x)(\n (?=\n [(]\\s*(\n ([)]) | \n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n )\n )\n)", - "end": "(?<=\\))", - "patterns": [ - { - "include": "#function-parameters" - } - ] } ] }, - "type-operators": { + "typeof-operator": { + "name": "keyword.operator.expression.typeof.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))typeof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "literal": { "patterns": [ { - "include": "#typeof-operator" + "include": "#numeric-literal" }, { - "begin": "([&|])(?=\\s*\\{)", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.tsx" - } - }, - "end": "(?<=\\})", - "patterns": [ - { - "include": "#type-object" - } - ] + "include": "#boolean-literal" }, { - "begin": "[&|]", - "beginCaptures": { - "0": { - "name": "keyword.operator.type.tsx" - } - }, - "end": "(?=\\S)" + "include": "#null-literal" }, { - "name": "keyword.operator.expression.keyof.tsx", - "match": "(?<!\\.|\\$)\\bkeyof\\b(?!\\$|\\.)" - } - ] - }, - "type-function-return-type": { - "name": "meta.type.function.return.tsx", - "begin": "=>", - "beginCaptures": { - "0": { - "name": "storage.type.function.arrow.tsx" - } - }, - "end": "(?<!=>)(?<![|&])(?=[,\\]\\)\\{\\}=;>]|//|$)", - "patterns": [ + "include": "#undefined-literal" + }, { - "include": "#comment" + "include": "#numericConstant-literal" }, { - "begin": "(?<==>)(?=\\s*\\{)", - "end": "(?<=\\})", - "patterns": [ - { - "include": "#type-object" - } - ] + "include": "#array-literal" }, { - "include": "#type-predicate-operator" + "include": "#this-literal" }, { - "include": "#type" + "include": "#super-literal" } ] }, - "type-tuple": { - "name": "meta.type.tuple.tsx", - "begin": "\\[", + "array-literal": { + "name": "meta.array.literal.tsx", + "begin": "\\s*(\\[)", "beginCaptures": { - "0": { + "1": { "name": "meta.brace.square.tsx" } }, @@ -2037,205 +2680,92 @@ }, "patterns": [ { - "include": "#type" + "include": "#expression" }, { "include": "#punctuation-comma" } ] }, - "type-name": { - "patterns": [ - { - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)", - "captures": { - "1": { - "name": "entity.name.type.module.tsx" - }, - "2": { - "name": "punctuation.accessor.tsx" - } - } - }, - { - "name": "entity.name.type.tsx", - "match": "[_$[:alpha:]][_$[:alnum:]]*" - } - ] - }, - "type-parameters": { - "name": "meta.type.parameters.tsx", - "begin": "(<)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.typeparameters.begin.tsx" - } - }, - "end": "(>)", - "endCaptures": { - "1": { - "name": "punctuation.definition.typeparameters.end.tsx" - } - }, + "numeric-literal": { "patterns": [ { - "include": "#comment" - }, - { - "name": "storage.modifier.tsx", - "match": "(?<!\\.|\\$)\\b(extends)\\b(?!\\$)" - }, - { - "name": "keyword.operator.assignment.tsx", - "match": "\\=(?!>)" + "name": "constant.numeric.hex.tsx", + "match": "\\b(?<!\\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b(?!\\$)" }, { - "include": "#type" + "name": "constant.numeric.binary.tsx", + "match": "\\b(?<!\\$)0(b|B)[01][01_]*\\b(?!\\$)" }, { - "include": "#punctuation-comma" - } - ] - }, - "variable-initializer": { - "patterns": [ - { - "begin": "(?<!=|!)(=)(?!=)(?=\\s*\\S)", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.tsx" - } - }, - "end": "(?=$|^|[,);}\\]])", - "patterns": [ - { - "include": "#expression" - } - ] + "name": "constant.numeric.octal.tsx", + "match": "\\b(?<!\\$)0(o|O)?[0-7][0-7_]*\\b(?!\\$)" }, { - "begin": "(?<!=|!)(=)(?!=)", - "beginCaptures": { + "match": "(?x)\n(?<!\\$)(?:\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1.1E+3\n (?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*\\b)| # 1.E+3\n (?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # .1E+3\n (?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\\b)| # 1E+3\n (?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*\\b)| # 1.1\n (?:\\b[0-9][0-9_]*(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9][0-9_]*\\b)| # .1\n (?:\\b[0-9][0-9_]*\\b(?!\\.)) # 1\n)(?!\\$)", + "captures": { + "0": { + "name": "constant.numeric.decimal.tsx" + }, "1": { - "name": "keyword.operator.assignment.tsx" - } - }, - "end": "(?=[,);}\\]])|(?=^\\s*$)|(?<=\\S)(?<!=)", - "patterns": [ - { - "include": "#expression" + "name": "meta.delimiter.decimal.period.tsx" + }, + "2": { + "name": "meta.delimiter.decimal.period.tsx" + }, + "3": { + "name": "meta.delimiter.decimal.period.tsx" + }, + "4": { + "name": "meta.delimiter.decimal.period.tsx" + }, + "5": { + "name": "meta.delimiter.decimal.period.tsx" + }, + "6": { + "name": "meta.delimiter.decimal.period.tsx" } - ] + } } ] }, - "for-loop": { - "begin": "(?<!\\.|\\$)\\b(for)(?:\\s+(await))?\\s*(\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.loop.tsx" - }, - "2": { - "name": "keyword.control.loop.tsx" - }, - "3": { - "name": "meta.brace.round.tsx" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.tsx" - } - }, + "boolean-literal": { "patterns": [ { - "include": "#var-expr" - }, - { - "include": "#expression" + "name": "constant.language.boolean.true.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))true(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#punctuation-semicolon" + "name": "constant.language.boolean.false.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))false(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" } ] }, - "switch-expression": { - "name": "switch-expression.expr.tsx", - "begin": "(?<!\\.|\\$)\\b(switch)\\s*(\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.switch.tsx" - }, - "2": { - "name": "meta.brace.round.tsx" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.tsx" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] + "null-literal": { + "name": "constant.language.null.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))null(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, - "switch-block": { - "name": "switch-block.expr.tsx", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.tsx" - } - }, - "end": "(?=\\})", - "patterns": [ - { - "include": "#case-clause" - }, - { - "include": "#statements" - } - ] + "this-literal": { + "name": "variable.language.this.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))this\\b(?!\\$)" }, - "case-clause": { - "name": "case-clause.expr.tsx", - "begin": "(?<!\\.|\\$)\\b(case|default(?=:))\\b(?!\\$|\\.)", - "beginCaptures": { - "1": { - "name": "keyword.control.switch.tsx" - } - }, - "end": ":", - "endCaptures": { - "0": { - "name": "punctuation.definition.section.case-statement.tsx" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] + "super-literal": { + "name": "variable.language.super.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))super\\b(?!\\$)" }, - "switch-statement": { - "name": "switch-statement.expr.tsx", - "begin": "(?<!\\.|\\$)(?=\\bswitch\\s*\\()", - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.tsx" - } - }, + "undefined-literal": { + "name": "constant.language.undefined.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))undefined(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "numericConstant-literal": { "patterns": [ { - "include": "#switch-expression" + "name": "constant.language.nan.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))NaN(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" }, { - "include": "#switch-block" + "name": "constant.language.infinity.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))Infinity(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" } ] }, @@ -2243,22 +2773,26 @@ "patterns": [ { "name": "variable.language.arguments.tsx", - "match": "(?<!\\.|\\$)\\b(arguments)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(arguments)\\b(?!\\$)" }, { "name": "support.class.builtin.tsx", - "match": "(?x)(?<!\\.|\\$)\\b(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator\n |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Promise|Proxy\n |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray\n |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\\b(?!\\$)" + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator\n |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Proxy\n |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray\n |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\\b(?!\\$)" }, { "name": "support.class.error.tsx", - "match": "(?<!\\.|\\$)\\b((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\\b(?!\\$)" + }, + { + "name": "support.class.promise.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Promise)\\b(?!\\$)" }, { "name": "support.function.tsx", - "match": "(?x)(?<!\\.|\\$)\\b(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|\n isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\\s*\\() " + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|\n isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\\s*\\()" }, { - "match": "(?x)(?<!\\.|\\$)\\b(Math)(?:\\s*(\\.)\\s*(?:\n (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|\n expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|\n round|sign|sin|sinh|sqrt|tan|tanh|trunc)\n |\n (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Math)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|\n expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|\n round|sign|sin|sinh|sqrt|tan|tanh|trunc)\n |\n (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\\b(?!\\$)", "captures": { "1": { "name": "support.constant.math.tsx" @@ -2267,15 +2801,18 @@ "name": "punctuation.accessor.tsx" }, "3": { - "name": "support.function.math.tsx" + "name": "punctuation.accessor.optional.tsx" }, "4": { + "name": "support.function.math.tsx" + }, + "5": { "name": "support.constant.property.math.tsx" } } }, { - "match": "(?x)(?<!\\.|\\$)\\b(console)(?:\\s*(\\.)\\s*(\n assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log\n |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(console)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(\n assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log\n |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\\b(?!\\$)", "captures": { "1": { "name": "support.class.console.tsx" @@ -2284,12 +2821,15 @@ "name": "punctuation.accessor.tsx" }, "3": { + "name": "punctuation.accessor.optional.tsx" + }, + "4": { "name": "support.function.console.tsx" } } }, { - "match": "(?<!\\.|\\$)\\b(JSON)(?:\\s*(\\.)\\s*(parse|stringify))?\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(JSON)(?:\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(parse|stringify))?\\b(?!\\$)", "captures": { "1": { "name": "support.constant.json.tsx" @@ -2298,26 +2838,66 @@ "name": "punctuation.accessor.tsx" }, "3": { + "name": "punctuation.accessor.optional.tsx" + }, + "4": { "name": "support.function.json.tsx" } } }, { - "match": "(?x) (\\.) \\s* (?:\n (constructor|length|prototype|__proto__) \n |\n (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(import)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(meta)\\b(?!\\$)", + "captures": { + "1": { + "name": "keyword.control.import.tsx" + }, + "2": { + "name": "punctuation.accessor.tsx" + }, + "3": { + "name": "punctuation.accessor.optional.tsx" + }, + "4": { + "name": "support.variable.property.importmeta.tsx" + } + } + }, + { + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(target)\\b(?!\\$)", + "captures": { + "1": { + "name": "keyword.operator.new.tsx" + }, + "2": { + "name": "punctuation.accessor.tsx" + }, + "3": { + "name": "punctuation.accessor.optional.tsx" + }, + "4": { + "name": "support.variable.property.target.tsx" + } + } + }, + { + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s* (?:\n (constructor|length|prototype|__proto__)\n |\n (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\\b(?!\\$)", "captures": { "1": { "name": "punctuation.accessor.tsx" }, "2": { - "name": "support.variable.property.tsx" + "name": "punctuation.accessor.optional.tsx" }, "3": { + "name": "support.variable.property.tsx" + }, + "4": { "name": "support.constant.tsx" } } }, { - "match": "(?x) (?<!\\.|\\$) \\b (?:\n (document|event|navigator|performance|screen|window) \n |\n (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener\n |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule\n |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration\n |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern\n |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent\n |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException\n |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer\n |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry\n |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent\n |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential\n |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync\n |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement\n |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement\n |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement\n |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement\n |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement\n |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement\n |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement\n |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement\n |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement\n |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement\n |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement\n |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase\n |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction\n |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities\n |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess\n |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent\n |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream\n |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent\n |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID\n |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification\n |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential\n |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark\n |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList\n |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent\n |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList\n |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager\n |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource\n |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement\n |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength\n |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio\n |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement\n |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement\n |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement\n |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength\n |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement\n |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio\n |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList\n |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement\n |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement\n |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState\n |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet\n |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable\n |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer\n |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat\n |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES\n |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope\n |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult\n |XSLTProcessor))\\b(?!\\$)", + "match": "(?x) (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.)) \\b (?:\n (document|event|navigator|performance|screen|window)\n |\n (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener\n |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule\n |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration\n |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern\n |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent\n |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException\n |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer\n |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry\n |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent\n |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential\n |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync\n |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement\n |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement\n |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement\n |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement\n |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement\n |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement\n |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement\n |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement\n |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement\n |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement\n |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement\n |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase\n |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction\n |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities\n |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess\n |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent\n |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream\n |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent\n |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID\n |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification\n |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential\n |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark\n |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList\n |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent\n |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList\n |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager\n |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource\n |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement\n |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength\n |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio\n |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement\n |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement\n |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement\n |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength\n |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement\n |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio\n |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList\n |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement\n |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement\n |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState\n |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet\n |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable\n |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer\n |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat\n |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES\n |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope\n |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult\n |XSLTProcessor))\\b(?!\\$)", "captures": { "1": { "name": "support.variable.dom.tsx" @@ -2328,25 +2908,28 @@ } }, { - "match": "(?x) (\\.) \\s* (?:\n (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE\n |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR\n |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR\n |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)\n |\n (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName\n |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop\n |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor\n |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption\n |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear\n |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete\n |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset\n |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight\n |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds\n |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize\n |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host\n |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth\n |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext\n |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom\n |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple\n |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName\n |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight\n |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer\n |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling\n |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText\n |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts\n |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove\n |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary\n |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead\n |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile\n |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\\b(?!\\$|\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s* (?:\n (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE\n |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR\n |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR\n |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)\n |\n (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName\n |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop\n |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor\n |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption\n |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear\n |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete\n |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset\n |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight\n |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds\n |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize\n |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host\n |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth\n |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext\n |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom\n |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple\n |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName\n |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight\n |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer\n |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling\n |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText\n |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts\n |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove\n |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary\n |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead\n |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile\n |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\\b(?!\\$|\\s*(<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\\()", "captures": { "1": { "name": "punctuation.accessor.tsx" }, "2": { - "name": "support.constant.dom.tsx" + "name": "punctuation.accessor.optional.tsx" }, "3": { + "name": "support.constant.dom.tsx" + }, + "4": { "name": "support.variable.property.dom.tsx" } } }, { "name": "support.class.node.tsx", - "match": "(?x)(?<!\\.|\\$)\\b(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)" + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)" }, { - "match": "(?x)(?<!\\.|\\$)\\b(process)(?:(\\.)(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)", + "match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(process)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)", "captures": { "1": { "name": "support.variable.object.process.tsx" @@ -2355,15 +2938,18 @@ "name": "punctuation.accessor.tsx" }, "3": { - "name": "support.variable.property.process.tsx" + "name": "punctuation.accessor.optional.tsx" }, "4": { + "name": "support.variable.property.process.tsx" + }, + "5": { "name": "support.function.process.tsx" } } }, { - "match": "(?<!\\.|\\$)\\b(?:(exports)|(module)(?:(\\.)(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(exports)|(module)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)", "captures": { "1": { "name": "support.type.object.module.tsx" @@ -2375,88 +2961,39 @@ "name": "punctuation.accessor.tsx" }, "4": { + "name": "punctuation.accessor.optional.tsx" + }, + "5": { "name": "support.type.object.module.tsx" } } }, { "name": "support.variable.object.node.tsx", - "match": "(?<!\\.|\\$)\\b(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)" + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)" }, { - "match": "(?x) (\\.) \\s* \n(?:\n (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|\n Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|\n Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|\n Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|\n Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|\n Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|\n Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|\n Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\n ) |\n (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|\n scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|\n sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|\n Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|\n Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|\n savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|\n contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|\n createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|\n test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|\n untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|\n print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|\n fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|\n forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|\n abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|\n releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|\n Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|\n Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|\n moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back\n ) |\n (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|\n appendChild|appendData|before|blur|canPlayType|captureStream|\n caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|\n cloneContents|cloneNode|cloneRange|close|closest|collapse|\n compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|\n convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|\n createAttributeNS|createCaption|createCDATASection|createComment|\n createContextualFragment|createDocument|createDocumentFragment|\n createDocumentType|createElement|createElementNS|createEntityReference|\n createEvent|createExpression|createHTMLDocument|createNodeIterator|\n createNSResolver|createProcessingInstruction|createRange|createShadowRoot|\n createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|\n deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|\n deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|\n enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|\n exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|\n getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|\n getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|\n getClientRects|getContext|getDestinationInsertionPoints|getElementById|\n getElementsByClassName|getElementsByName|getElementsByTagName|\n getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|\n getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|\n hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|\n insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|\n insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|\n isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|\n lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|\n moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|\n parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|\n previousSibling|probablySupportsContext|queryCommandEnabled|\n queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|\n querySelector|querySelectorAll|registerContentHandler|registerElement|\n registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|\n removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|\n removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|\n requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|\n scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|\n setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|\n setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|\n setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|\n slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|\n submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|\n toDataURL|toggle|toString|values|write|writeln\n )\n)(?=\\s*\\()", + "match": "(?x) (?:(\\.)|(\\?\\.(?!\\s*[[:digit:]]))) \\s*\n(?:\n (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|\n Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|\n Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|\n Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|\n Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|\n Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|\n Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|\n Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)\n ) |\n (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|\n scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|\n sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|\n Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|\n Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|\n savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|\n contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|\n createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|\n test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|\n untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|\n print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|\n fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|\n forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|\n abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|\n releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|\n Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|\n Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|\n moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back\n ) |\n (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|\n appendChild|appendData|before|blur|canPlayType|captureStream|\n caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|\n cloneContents|cloneNode|cloneRange|close|closest|collapse|\n compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|\n convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|\n createAttributeNS|createCaption|createCDATASection|createComment|\n createContextualFragment|createDocument|createDocumentFragment|\n createDocumentType|createElement|createElementNS|createEntityReference|\n createEvent|createExpression|createHTMLDocument|createNodeIterator|\n createNSResolver|createProcessingInstruction|createRange|createShadowRoot|\n createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|\n deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|\n deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|\n enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|\n exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|\n getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|\n getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|\n getClientRects|getContext|getDestinationInsertionPoints|getElementById|\n getElementsByClassName|getElementsByName|getElementsByTagName|\n getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|\n getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|\n hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|\n insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|\n insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|\n isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|\n lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|\n moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|\n parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|\n previousSibling|probablySupportsContext|queryCommandEnabled|\n queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|\n querySelector|querySelectorAll|registerContentHandler|registerElement|\n registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|\n removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|\n removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|\n requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|\n scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|\n setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|\n setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|\n setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|\n slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|\n submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|\n toDataURL|toggle|toString|values|write|writeln\n ) |\n (all|catch|finally|race|reject|resolve|then\n )\n)(?=\\s*\\()", "captures": { "1": { "name": "punctuation.accessor.tsx" }, "2": { - "name": "support.function.event-handler.tsx" + "name": "punctuation.accessor.optional.tsx" }, "3": { - "name": "support.function.tsx" + "name": "support.function.event-handler.tsx" }, "4": { - "name": "support.function.dom.tsx" - } - } - } - ] - }, - "function-call": { - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "end": "(?<=\\))(?!(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "patterns": [ - { - "name": "meta.function-call.tsx", - "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\.\\s*)*|(\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*))", - "end": "(?=\\s*(<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\()", - "patterns": [ - { - "include": "#literal" - }, - { - "include": "#support-objects" - }, - { - "include": "#object-identifiers" - }, - { - "include": "#punctuation-accessor" + "name": "support.function.tsx" }, - { - "name": "entity.name.function.tsx", - "match": "([_$[:alpha:]][_$[:alnum:]]*)" - } - ] - }, - { - "include": "#comment" - }, - { - "name": "meta.type.parameters.tsx", - "begin": "\\<", - "beginCaptures": { - "0": { - "name": "punctuation.definition.typeparameters.begin.tsx" - } - }, - "end": "\\>", - "endCaptures": { - "0": { - "name": "punctuation.definition.typeparameters.end.tsx" - } - }, - "patterns": [ - { - "include": "#type" + "5": { + "name": "support.function.dom.tsx" }, - { - "include": "#punctuation-comma" + "6": { + "name": "support.function.promise.tsx" } - ] - }, - { - "include": "#paren-expression" + } } ] }, @@ -2466,34 +3003,43 @@ "include": "#object-identifiers" }, { - "match": "(?x)(?:(\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n))", + "match": "(?x)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([\\(]\\s*([\\{\\[]\\s*)?$) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)?\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\]))([^=<>]|=[^<])*\\>)*>\\s*)? # typeparameters\n \\(\\s*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\)))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+)? # return type\n \\s*=> # arrow operator\n)\n ))\n))", "captures": { "1": { "name": "punctuation.accessor.tsx" }, "2": { + "name": "punctuation.accessor.optional.tsx" + }, + "3": { "name": "entity.name.function.tsx" } } }, { - "match": "(\\.)\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", "captures": { "1": { "name": "punctuation.accessor.tsx" }, "2": { + "name": "punctuation.accessor.optional.tsx" + }, + "3": { "name": "variable.other.constant.property.tsx" } } }, { - "match": "(\\.)\\s*([_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*([_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "punctuation.accessor.tsx" }, "2": { + "name": "punctuation.accessor.optional.tsx" + }, + "3": { "name": "variable.other.property.tsx" } } @@ -2512,24 +3058,27 @@ "patterns": [ { "name": "support.class.tsx", - "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\.\\s*prototype\\b(?!\\$))" + "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\??\\.\\s*prototype\\b(?!\\$))" }, { - "match": "(?x)(\\.)\\s*(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?x)(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "punctuation.accessor.tsx" }, "2": { - "name": "variable.other.constant.object.property.tsx" + "name": "punctuation.accessor.optional.tsx" }, "3": { + "name": "variable.other.constant.object.property.tsx" + }, + "4": { "name": "variable.other.object.property.tsx" } } }, { - "match": "(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", + "match": "(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)", "captures": { "1": { "name": "variable.other.constant.object.tsx" @@ -2541,349 +3090,519 @@ } ] }, - "cast": { - "patterns": [ - { - "include": "#jsx" - } - ] - }, - "new-expr": { - "name": "new.expr.tsx", - "begin": "(?<!\\.|\\$)\\b(new)\\b(?!\\$|\\.)", - "beginCaptures": { - "1": { - "name": "keyword.operator.new.tsx" - } - }, - "end": "(?<=\\))|(?=[;),}]|$|((?<!\\.|\\$)\\bnew\\b(?!\\$|\\.))|((?<!\\.|\\$)\\bfunction((\\s+[_$[:alpha:]][_$[:alnum:]]*)|(\\s*[\\(]))))", - "patterns": [ - { - "include": "#paren-expression" - }, - { - "include": "#class-or-interface-declaration" - }, - { - "include": "#type" - } - ] - }, - "object-member": { + "type-annotation": { "patterns": [ { - "include": "#comment" - }, - { - "include": "#object-literal-method-declaration" - }, - { - "name": "meta.object.member.tsx", - "begin": "(?=(?:(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(?:\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*:)", - "end": "(?=,|\\})", + "name": "meta.type.annotation.tsx", + "begin": "(:)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.tsx" + } + }, + "end": "(?<![:|&])((?=$|^|[,);\\}\\]]|//)|(?==[^>])|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", "patterns": [ { - "name": "meta.object-literal.key.tsx", - "begin": "(?=(?:(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")|(?:\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\]))\\s*:)", - "end": ":", - "endCaptures": { - "0": { - "name": "punctuation.separator.key-value.tsx" - } - }, - "patterns": [ - { - "include": "#string" - }, - { - "include": "#array-literal" - } - ] - }, - { - "include": "#expression" + "include": "#type" } ] }, { - "name": "meta.object.member.tsx", - "begin": "(?![_$[:alpha:]])([[:digit:]]+)\\s*(:)", + "name": "meta.type.annotation.tsx", + "begin": "(:)", "beginCaptures": { - "0": { - "name": "meta.object-literal.key.tsx" - }, "1": { - "name": "constant.numeric.decimal.tsx" - }, - "2": { - "name": "punctuation.separator.key-value.tsx" + "name": "keyword.operator.type.annotation.tsx" } }, - "end": "(?=,|\\})", + "end": "(?<![:|&])((?=[,);\\}\\]]|//)|(?==[^>])|(?=^\\s*$)|((?<=\\S)(?=\\s*$))|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", "patterns": [ { - "include": "#expression" + "include": "#type" } ] - }, + } + ] + }, + "return-type": { + "patterns": [ { - "name": "meta.object.member.tsx", - "begin": "(?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\\s*(:)(?=\\s*(\n ((async\\s+)?(\n (function\\s*[(<]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ([(]\\s*(([)]\\s*:)|([_$[:alpha:]][_$[:alnum:]]*\\s*:)|(\\.\\.\\.) )) |\n ([<]\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s*[^=>])|(\\s*[,]))) |\n ((<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)?\\(([^()]|\\([^()]*\\))*\\)(\\s*:\\s*(.)*)?\\s*=>)\n ))\n)))", + "name": "meta.return.type.tsx", + "begin": "(?<=\\))\\s*(:)(?=\\s*\\S)", "beginCaptures": { - "0": { - "name": "meta.object-literal.key.tsx" - }, "1": { - "name": "entity.name.function.tsx" - }, - "2": { - "name": "punctuation.separator.key-value.tsx" + "name": "keyword.operator.type.annotation.tsx" } }, - "end": "(?=,|\\})", + "end": "(?<![:|&])(?=$|^|[{};,]|//)", "patterns": [ { - "include": "#expression" + "include": "#return-type-core" } ] }, { - "name": "meta.object.member.tsx", - "begin": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(:)", + "name": "meta.return.type.tsx", + "begin": "(?<=\\))\\s*(:)", "beginCaptures": { - "0": { - "name": "meta.object-literal.key.tsx" - }, "1": { - "name": "punctuation.separator.key-value.tsx" + "name": "keyword.operator.type.annotation.tsx" } }, - "end": "(?=,|\\})", + "end": "(?<![:|&])((?=[{};,]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", "patterns": [ { - "include": "#expression" + "include": "#return-type-core" } ] + } + ] + }, + "return-type-core": { + "patterns": [ + { + "include": "#comment" }, { - "name": "meta.object.member.tsx", - "begin": "\\.\\.\\.", - "beginCaptures": { - "0": { - "name": "keyword.operator.spread.tsx" - } - }, - "end": "(?=,|\\})", + "begin": "(?<=[:|&])(?=\\s*\\{)", + "end": "(?<=\\})", "patterns": [ { - "include": "#expression" + "include": "#type-object" } ] }, { - "name": "meta.object.member.tsx", - "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$)", - "captures": { - "1": { - "name": "variable.other.readwrite.tsx" + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "arrow-return-type": { + "name": "meta.return.type.arrow.tsx", + "begin": "(?<=\\))\\s*(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.tsx" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "possibly-arrow-return-type": { + "begin": "(?<=\\))\\s*(:)(?=\\s*([^<>\\(\\)]|\\<[^<>]+\\>|\\([^\\(\\)]+\\))+\\s*=>)", + "beginCaptures": { + "1": { + "name": "meta.arrow.tsx meta.return.type.arrow.tsx keyword.operator.type.annotation.tsx" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "contentName": "meta.arrow.tsx meta.return.type.arrow.tsx", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "arrow-return-type-body": { + "patterns": [ + { + "begin": "(?<=[:])(?=\\s*\\{)", + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" } - } + ] + }, + { + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "type-parameters": { + "name": "meta.type.parameters.tsx", + "begin": "(<)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.begin.tsx" + } + }, + "end": "(>)", + "endCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.end.tsx" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "name": "storage.modifier.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(extends)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "include": "#type" }, { "include": "#punctuation-comma" } ] }, - "expression-operators": { + "type-arguments": { + "name": "meta.type.parameters.tsx", + "begin": "\\<", + "beginCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.begin.tsx" + } + }, + "end": "\\>", + "endCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.end.tsx" + } + }, "patterns": [ { - "name": "keyword.control.flow.tsx", - "match": "(?<!\\.|\\$)\\b(await)\\b(?!\\$|\\.)" + "include": "#type" }, { - "match": "(?<!\\.|\\$)\\b(yield)\\b(?!\\$|\\.)(?:\\s*(\\*))?", - "captures": { - "1": { - "name": "keyword.control.flow.tsx" - }, - "2": { - "name": "keyword.generator.asterisk.tsx" - } - } + "include": "#punctuation-comma" + } + ] + }, + "type": { + "patterns": [ + { + "include": "#comment" }, { - "name": "keyword.operator.expression.delete.tsx", - "match": "(?<!\\.|\\$)\\bdelete\\b(?!\\$|\\.)" + "include": "#string" }, { - "name": "keyword.operator.expression.in.tsx", - "match": "(?<!\\.|\\$)\\bin\\b(?!\\$|\\.)" + "include": "#numeric-literal" }, { - "name": "keyword.operator.expression.of.tsx", - "match": "(?<!\\.|\\$)\\bof\\b(?!\\$|\\.)" + "include": "#type-primitive" }, { - "name": "keyword.operator.expression.instanceof.tsx", - "match": "(?<!\\.|\\$)\\binstanceof\\b(?!\\$|\\.)" + "include": "#type-builtin-literals" }, { - "name": "keyword.operator.new.tsx", - "match": "(?<!\\.|\\$)\\bnew\\b(?!\\$|\\.)" + "include": "#type-parameters" }, { - "include": "#typeof-operator" + "include": "#type-tuple" }, { - "name": "keyword.operator.expression.void.tsx", - "match": "(?<!\\.|\\$)\\bvoid\\b(?!\\$|\\.)" + "include": "#type-object" }, { - "begin": "(?<!\\.|\\$)\\b(as)\\s+", - "beginCaptures": { - "1": { - "name": "keyword.control.as.tsx" - } - }, - "end": "(?=$|^|[;,:})\\]])", - "patterns": [ - { - "include": "#type" - } - ] + "include": "#type-conditional" }, { - "name": "keyword.operator.spread.tsx", - "match": "\\.\\.\\." + "include": "#type-operators" }, { - "name": "keyword.operator.assignment.compound.tsx", - "match": "\\*=|(?<!\\()/=|%=|\\+=|\\-=" + "include": "#type-fn-type-parameters" }, { - "name": "keyword.operator.assignment.compound.bitwise.tsx", - "match": "\\&=|\\^=|<<=|>>=|>>>=|\\|=" + "include": "#type-paren-or-function-parameters" }, { - "name": "keyword.operator.bitwise.shift.tsx", - "match": "<<|>>>|>>" + "include": "#type-function-return-type" }, { - "name": "keyword.operator.comparison.tsx", - "match": "===|!==|==|!=" + "include": "#type-name" + } + ] + }, + "type-primitive": { + "name": "support.type.primitive.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(string|number|boolean|symbol|any|void|never)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-builtin-literals": { + "name": "support.type.builtin.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(this|true|false|undefined|null|object)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-tuple": { + "name": "meta.type.tuple.tsx", + "begin": "\\[", + "beginCaptures": { + "0": { + "name": "meta.brace.square.tsx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "meta.brace.square.tsx" + } + }, + "patterns": [ + { + "include": "#type" }, { - "name": "keyword.operator.relational.tsx", - "match": "<=|>=|<>|<|>" + "include": "#punctuation-comma" + } + ] + }, + "type-object": { + "name": "meta.object.type.tsx", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.tsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.tsx" + } + }, + "patterns": [ + { + "include": "#comment" }, { - "name": "keyword.operator.logical.tsx", - "match": "\\!|&&|\\|\\|" + "include": "#method-declaration" }, { - "name": "keyword.operator.bitwise.tsx", - "match": "\\&|~|\\^|\\|" + "include": "#indexer-declaration" }, { - "name": "keyword.operator.assignment.tsx", - "match": "\\=" + "include": "#indexer-mapped-type-declaration" }, { - "name": "keyword.operator.decrement.tsx", - "match": "--" + "include": "#field-declaration" }, { - "name": "keyword.operator.increment.tsx", - "match": "\\+\\+" + "include": "#type-annotation" }, { - "name": "keyword.operator.arithmetic.tsx", - "match": "%|\\*|/|-|\\+" + "begin": "\\.\\.\\.", + "beginCaptures": { + "0": { + "name": "keyword.operator.spread.tsx" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#type" + } + ] }, { - "match": "(?<=[_$[:alnum:])])\\s*(/)(?![/*])", - "captures": { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-semicolon" + }, + { + "include": "#type" + } + ] + }, + "type-conditional": { + "patterns": [ + { + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(extends)\\s+", + "beginCaptures": { "1": { - "name": "keyword.operator.arithmetic.tsx" + "name": "storage.modifier.tsx" } - } + }, + "end": "(?<=:)", + "patterns": [ + { + "begin": "\\?", + "beginCaptures": { + "0": { + "name": "keyword.operator.ternary.tsx" + } + }, + "end": ":", + "endCaptures": { + "0": { + "name": "keyword.operator.ternary.tsx" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "include": "#type" + } + ] } ] }, - "typeof-operator": { - "name": "keyword.operator.expression.typeof.tsx", - "match": "(?<!\\.|\\$)\\btypeof\\b(?!\\$|\\.)" - }, - "arrow-function": { + "type-paren-or-function-parameters": { + "name": "meta.type.paren.cover.tsx", + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.tsx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.tsx" + } + }, "patterns": [ { - "name": "meta.arrow.tsx", - "match": "(?:(?<!\\.|\\$)(\\basync)\\s+)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)", + "include": "#destructuring-parameter" + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=\\s*(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*([\\(]\\s*([\\{\\[]\\s*)?$)))", "captures": { "1": { - "name": "storage.modifier.async.tsx" + "name": "storage.modifier.tsx" + }, + "2": { + "name": "keyword.operator.rest.tsx" + }, + "3": { + "name": "entity.name.function.tsx variable.language.this.tsx" + }, + "4": { + "name": "entity.name.function.tsx" + }, + "5": { + "name": "keyword.operator.optional.tsx" + } + } + }, + { + "match": "(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))\\s*(\\??)(?=:)", + "captures": { + "1": { + "name": "storage.modifier.tsx" }, "2": { + "name": "keyword.operator.rest.tsx" + }, + "3": { + "name": "variable.parameter.tsx variable.language.this.tsx" + }, + "4": { "name": "variable.parameter.tsx" + }, + "5": { + "name": "keyword.operator.optional.tsx" } } }, { - "name": "meta.arrow.tsx", - "begin": "(?x) (?:\n (?<!\\.|\\$)(\\basync)\n)? ((?<![})!\\]])\\s*\n (?=\n # sure shot arrow functions even if => is on new line\n (\n [(]\\s*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n ) |\n (\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends \n ) |\n # arrow function possible to detect only with => on same line\n (\n (<([^<>=]|=[^<]|\\<([^=<>]|=[^<])+\\>)+>\\s*)? # typeparameters\n \\(([^()]|\\([^()]*\\))*\\) # parameteres\n (\\s*:\\s*(.)*)? # return type\n \\s*=> # arrow operator\n )\n )\n)", + "include": "#type-annotation" + }, + { + "name": "punctuation.separator.parameter.tsx", + "match": "," + }, + { + "include": "#type" + } + ] + }, + "type-fn-type-parameters": { + "patterns": [ + { + "name": "meta.type.constructor.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\b(?=\\s*\\<)", + "captures": { + "1": { + "name": "keyword.control.new.tsx" + } + } + }, + { + "name": "meta.type.constructor.tsx", + "begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(new)\\b\\s*(?=\\()", "beginCaptures": { "1": { - "name": "storage.modifier.async.tsx" + "name": "keyword.control.new.tsx" } }, - "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "end": "(?<=\\))", "patterns": [ { - "include": "#comment" - }, - { - "include": "#type-parameters" - }, + "include": "#function-parameters" + } + ] + }, + { + "name": "meta.type.function.tsx", + "begin": "(?x)(\n (?=\n [(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n )\n )\n)", + "end": "(?<=\\))", + "patterns": [ { "include": "#function-parameters" - }, + } + ] + } + ] + }, + "type-function-return-type": { + "patterns": [ + { + "name": "meta.type.function.return.tsx", + "begin": "(=>)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "storage.type.function.arrow.tsx" + } + }, + "end": "(?<!=>)(?<![|&])(?=[,\\]\\)\\{\\}=;>:\\?]|//|$)", + "patterns": [ { - "include": "#arrow-return-type" + "include": "#type-function-return-type-core" } ] }, { - "name": "meta.arrow.tsx", + "name": "meta.type.function.return.tsx", "begin": "=>", "beginCaptures": { "0": { "name": "storage.type.function.arrow.tsx" } }, - "end": "(?<=\\}|\\S)(?<!=>)|((?!\\{)(?=\\S))", + "end": "(?<!=>)(?<![|&])((?=[,\\]\\)\\{\\}=;:\\?>]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", "patterns": [ { - "include": "#decl-block" - }, - { - "include": "#expression" + "include": "#type-function-return-type-core" } ] } ] }, - "arrow-return-type": { - "name": "meta.return.type.arrow.tsx", - "begin": "(?<=\\))\\s*(:)", - "beginCaptures": { - "1": { - "name": "keyword.operator.type.annotation.tsx" - } - }, - "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "type-function-return-type-core": { "patterns": [ { - "begin": "(?<=[:])(?=\\s*\\{)", + "include": "#comment" + }, + { + "begin": "(?<==>)(?=\\s*\\{)", "end": "(?<=\\})", "patterns": [ { @@ -2899,6 +3618,84 @@ } ] }, + "type-operators": { + "patterns": [ + { + "include": "#typeof-operator" + }, + { + "begin": "(?:([&|])|(=(?!>)))(?=\\s*\\{)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.tsx" + }, + "2": { + "name": "keyword.operator.assignment.tsx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "begin": "([&|])|(=(?!>))", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.tsx" + }, + "2": { + "name": "keyword.operator.assignment.tsx" + } + }, + "end": "(?=\\S)" + }, + { + "name": "keyword.operator.expression.keyof.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))keyof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + { + "name": "keyword.operator.ternary.tsx", + "match": "(\\?|\\:)" + }, + { + "name": "keyword.operator.expression.infer.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))infer(?=\\s+[_$[:alpha:]])" + }, + { + "name": "keyword.operator.expression.import.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))import(?=\\s*\\()" + } + ] + }, + "type-predicate-operator": { + "name": "keyword.operator.expression.is.tsx", + "match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))is(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))" + }, + "type-name": { + "patterns": [ + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "entity.name.type.module.tsx" + }, + "2": { + "name": "punctuation.accessor.tsx" + }, + "3": { + "name": "punctuation.accessor.optional.tsx" + } + } + }, + { + "name": "entity.name.type.tsx", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + } + ] + }, "punctuation-comma": { "name": "punctuation.separator.comma.tsx", "match": "," @@ -2908,28 +3705,23 @@ "match": ";" }, "punctuation-accessor": { - "name": "punctuation.accessor.tsx", - "match": "\\." - }, - "paren-expression": { - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "meta.brace.round.tsx" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "meta.brace.round.tsx" + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "punctuation.accessor.tsx" + }, + "2": { + "name": "punctuation.accessor.optional.tsx" } - }, + } + }, + "string": { "patterns": [ { - "include": "#expression" + "include": "#qstring-single" }, { - "include": "#punctuation-comma" + "include": "#qstring-double" } ] }, @@ -2979,17 +3771,87 @@ } ] }, + "string-character-escape": { + "name": "constant.character.escape.tsx", + "match": "\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" + }, + "template": { + "patterns": [ + { + "name": "string.template.tsx", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=(<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.tsx" + } + }, + "end": "(?=`)", + "patterns": [ + { + "include": "#type-arguments" + } + ] + }, + { + "name": "string.template.tsx", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.tsx" + }, + "2": { + "name": "punctuation.definition.string.template.begin.tsx" + } + }, + "end": "`", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.template.end.tsx" + } + }, + "patterns": [ + { + "include": "#template-substitution-element" + }, + { + "include": "#string-character-escape" + } + ] + } + ] + }, + "template-substitution-element": { + "name": "meta.template.expression.tsx", + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.template-expression.begin.tsx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.template-expression.end.tsx" + } + }, + "patterns": [ + { + "include": "#expression" + } + ], + "contentName": "meta.embedded.line.tsx" + }, "regex": { "patterns": [ { "name": "string.regexp.tsx", - "begin": "(?<=[=(:,\\[?+!]|return|case|=>|&&|\\|\\||\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/(?![\\/*])[gimy]*(?!\\s*[a-zA-Z0-9_$]))", + "begin": "(?<!\\+\\+|--)(?<=[=(:,\\[?+!]|^return|[^\\._$[:alnum:]]return|^case|[^\\._$[:alnum:]]case|=>|&&|\\|\\||\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))", "beginCaptures": { "1": { "name": "punctuation.definition.string.begin.tsx" } }, - "end": "(/)([gimuy]*)", + "end": "(/)([gimsuy]*)", "endCaptures": { "1": { "name": "punctuation.definition.string.end.tsx" @@ -3006,13 +3868,13 @@ }, { "name": "string.regexp.tsx", - "begin": "(?<![_$[:alnum:])])\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/(?![\\/*])[gimy]*(?!\\s*[a-zA-Z0-9_$]))", + "begin": "(?<![_$[:alnum:])\\]]|\\+\\+|--)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.tsx" } }, - "end": "(/)([gimuy]*)", + "end": "(/)([gimsuy]*)", "endCaptures": { "1": { "name": "punctuation.definition.string.end.tsx" @@ -3036,8 +3898,15 @@ "match": "\\\\[bB]|\\^|\\$" }, { - "name": "keyword.other.back-reference.regexp", - "match": "\\\\[1-9]\\d*" + "match": "\\\\[1-9]\\d*|\\\\k<([a-zA-Z_$][\\w$]*)>", + "captures": { + "0": { + "name": "keyword.other.back-reference.regexp" + }, + "1": { + "name": "variable.other.regexp" + } + } }, { "name": "keyword.operator.quantifier.regexp", @@ -3049,7 +3918,7 @@ }, { "name": "meta.group.assertion.regexp", - "begin": "(\\()((\\?=)|(\\?!))", + "begin": "(\\()((\\?=)|(\\?!)|(\\?<=)|(\\?<!))", "beginCaptures": { "1": { "name": "punctuation.definition.group.regexp" @@ -3062,6 +3931,12 @@ }, "4": { "name": "meta.assertion.negative-look-ahead.regexp" + }, + "5": { + "name": "meta.assertion.look-behind.regexp" + }, + "6": { + "name": "meta.assertion.negative-look-behind.regexp" } }, "end": "(\\))", @@ -3078,13 +3953,16 @@ }, { "name": "meta.group.regexp", - "begin": "\\((\\?:)?", + "begin": "\\((?:(\\?:)|(?:\\?<([a-zA-Z_$][\\w$]*)>))?", "beginCaptures": { "0": { "name": "punctuation.definition.group.regexp" }, "1": { - "name": "punctuation.definition.group.capture.regexp" + "name": "punctuation.definition.group.no-capture.regexp" + }, + "2": { + "name": "variable.other.regexp" } }, "end": "\\)", @@ -3119,7 +3997,7 @@ "patterns": [ { "name": "constant.other.character-class.range.regexp", - "match": "(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))", + "match": "(?:.|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))", "captures": { "1": { "name": "constant.character.numeric.regexp" @@ -3159,7 +4037,7 @@ }, { "name": "constant.character.numeric.regexp", - "match": "\\\\([0-7]{3}|x\\h\\h|u\\h\\h\\h\\h)" + "match": "\\\\([0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4})" }, { "name": "constant.character.control.regexp", @@ -3171,207 +4049,6 @@ } ] }, - "string": { - "patterns": [ - { - "include": "#qstring-single" - }, - { - "include": "#qstring-double" - } - ] - }, - "template": { - "name": "string.template.tsx", - "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", - "beginCaptures": { - "1": { - "name": "entity.name.function.tagged-template.tsx" - }, - "2": { - "name": "punctuation.definition.string.template.begin.tsx" - } - }, - "end": "`", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.template.end.tsx" - } - }, - "patterns": [ - { - "include": "#template-substitution-element" - }, - { - "include": "#string-character-escape" - } - ] - }, - "string-character-escape": { - "name": "constant.character.escape.tsx", - "match": "\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" - }, - "template-substitution-element": { - "name": "meta.template.expression.tsx", - "begin": "\\$\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.template-expression.begin.tsx" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.template-expression.end.tsx" - } - }, - "patterns": [ - { - "include": "#expression" - } - ] - }, - "literal": { - "patterns": [ - { - "include": "#numeric-literal" - }, - { - "include": "#boolean-literal" - }, - { - "include": "#null-literal" - }, - { - "include": "#undefined-literal" - }, - { - "include": "#numericConstant-literal" - }, - { - "include": "#array-literal" - }, - { - "include": "#this-literal" - }, - { - "include": "#super-literal" - } - ] - }, - "array-literal": { - "name": "meta.array.literal.tsx", - "begin": "\\[", - "beginCaptures": { - "0": { - "name": "meta.brace.square.tsx" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "meta.brace.square.tsx" - } - }, - "patterns": [ - { - "include": "#expression" - }, - { - "include": "#punctuation-comma" - } - ] - }, - "numeric-literal": { - "patterns": [ - { - "name": "constant.numeric.hex.tsx", - "match": "\\b(?<!\\$)0(x|X)[0-9a-fA-F]+\\b(?!\\$)" - }, - { - "name": "constant.numeric.binary.tsx", - "match": "\\b(?<!\\$)0(b|B)[01]+\\b(?!\\$)" - }, - { - "name": "constant.numeric.octal.tsx", - "match": "\\b(?<!\\$)0(o|O)?[0-7]+\\b(?!\\$)" - }, - { - "match": "(?x)\n(?<!\\$)(?:\n (?:\\b[0-9]+(\\.)[0-9]+[eE][+-]?[0-9]+\\b)| # 1.1E+3\n (?:\\b[0-9]+(\\.)[eE][+-]?[0-9]+\\b)| # 1.E+3\n (?:\\B(\\.)[0-9]+[eE][+-]?[0-9]+\\b)| # .1E+3\n (?:\\b[0-9]+[eE][+-]?[0-9]+\\b)| # 1E+3\n (?:\\b[0-9]+(\\.)[0-9]+\\b)| # 1.1\n (?:\\b[0-9]+(\\.)\\B)| # 1.\n (?:\\B(\\.)[0-9]+\\b)| # .1\n (?:\\b[0-9]+\\b(?!\\.)) # 1\n)(?!\\$)", - "captures": { - "0": { - "name": "constant.numeric.decimal.tsx" - }, - "1": { - "name": "meta.delimiter.decimal.period.tsx" - }, - "2": { - "name": "meta.delimiter.decimal.period.tsx" - }, - "3": { - "name": "meta.delimiter.decimal.period.tsx" - }, - "4": { - "name": "meta.delimiter.decimal.period.tsx" - }, - "5": { - "name": "meta.delimiter.decimal.period.tsx" - }, - "6": { - "name": "meta.delimiter.decimal.period.tsx" - } - } - } - ] - }, - "boolean-literal": { - "patterns": [ - { - "name": "constant.language.boolean.true.tsx", - "match": "(?<!\\.|\\$)\\btrue\\b(?!\\$)" - }, - { - "name": "constant.language.boolean.false.tsx", - "match": "(?<!\\.|\\$)\\bfalse\\b(?!\\$)" - } - ] - }, - "null-literal": { - "name": "constant.language.null.tsx", - "match": "(?<!\\.|\\$)\\bnull\\b(?!\\$)" - }, - "this-literal": { - "name": "variable.language.this.tsx", - "match": "(?<!\\.|\\$)\\bthis\\b(?!\\$)" - }, - "super-literal": { - "name": "variable.language.super.tsx", - "match": "(?<!\\.|\\$)\\bsuper\\b(?!\\$)" - }, - "undefined-literal": { - "name": "constant.language.undefined.tsx", - "match": "(?<!\\.|\\$)\\bundefined\\b(?!\\$)" - }, - "numericConstant-literal": { - "patterns": [ - { - "name": "constant.language.nan.tsx", - "match": "(?<!\\.|\\$)\\bNaN\\b(?!\\$)" - }, - { - "name": "constant.language.infinity.tsx", - "match": "(?<!\\.|\\$)\\bInfinity\\b(?!\\$)" - } - ] - }, - "access-modifier": { - "name": "storage.modifier.tsx", - "match": "(?<!\\.|\\$)\\b(abstract|public|protected|private|readonly|static)\\b(?!\\$|\\.)" - }, - "property-accessor": { - "name": "storage.type.property.tsx", - "match": "(?<!\\.|\\$)\\b(get|set)\\b(?!\\$|\\.)" - }, "comment": { "patterns": [ { @@ -3396,10 +4073,16 @@ }, { "name": "comment.block.tsx", - "begin": "/\\*", + "begin": "(/\\*)(?:\\s*((@)internal)(?=\\s|(\\*/)))?", "beginCaptures": { - "0": { + "1": { "name": "punctuation.definition.comment.tsx" + }, + "2": { + "name": "storage.type.internaldeclaration.tsx" + }, + "3": { + "name": "punctuation.decorator.internaldeclaration.tsx" } }, "end": "\\*/", @@ -3410,13 +4093,22 @@ } }, { - "begin": "(^[ \\t]+)?(//)", + "begin": "(^[ \\t]+)?((//)(?:\\s*((@)internal)(?=\\s|$))?)", "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.tsx" }, "2": { - "name": "comment.line.double-slash.tsx punctuation.definition.comment.tsx" + "name": "comment.line.double-slash.tsx" + }, + "3": { + "name": "punctuation.definition.comment.tsx" + }, + "4": { + "name": "storage.type.internaldeclaration.tsx" + }, + "5": { + "name": "punctuation.decorator.internaldeclaration.tsx" } }, "end": "(?=^)", @@ -3426,7 +4118,7 @@ }, "directives": { "name": "comment.line.triple-slash.directive.tsx", - "begin": "^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|name)\\s*=\\s*((\\'[^']*\\')|(\\\"[^\"]*\\\")))+\\s*/>\\s*$)", + "begin": "^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|name)\\s*=\\s*((\\'([^\\'\\\\]|\\\\\\'|\\\\)*\\')|(\\\"([^\\\"\\\\]|\\\\\\\"|\\\\)*\\\")))+\\s*/>\\s*$)", "beginCaptures": { "1": { "name": "punctuation.definition.comment.tsx" @@ -3470,7 +4162,7 @@ "docblock": { "patterns": [ { - "match": "(?x)\n((@)access)\n\\s+\n(private|protected|public)\n\\b", + "match": "(?x)\n((@)(?:access|api))\n\\s+\n(private|protected|public)\n\\b", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3594,7 +4286,7 @@ } }, { - "match": "(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!https?://)\n (?:[^@\\s*/]|\\*[^/])+\n )\n)", + "match": "(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!\n # Avoid matching bare URIs (also acceptable as links)\n https?://\n |\n # Avoid matching {@inline tags}; we match those below\n (?:\\[[^\\[\\]]*\\])? # Possible description [preceding]{@tag}\n {@(?:link|linkcode|linkplain|tutorial)\\b\n )\n # Matched namepath\n (?:[^@\\s*/]|\\*[^/])+\n )\n)", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3611,7 +4303,7 @@ } }, { - "match": "(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(?:\n ([A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]*) # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* (,) \\s*\n ([A-Za-z_$]\n [\\w$.\\[\\]]*)\n )*\n)", + "match": "(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(\n [A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]* # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* , \\s*\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n )*\n)", "captures": { "1": { "name": "storage.type.class.jsdoc" @@ -3621,12 +4313,6 @@ }, "3": { "name": "variable.other.jsdoc" - }, - "4": { - "name": "punctuation.delimiter.object.comma.jsdoc" - }, - "5": { - "name": "variable.other.jsdoc" } } }, @@ -3686,32 +4372,29 @@ }, { "name": "variable.other.jsdoc", - "begin": "\\[", - "end": "\\]|(?=\\*/)", - "patterns": [ - { - "match": "(=)((?:[^\\]*]|\\*[^/])*)", - "captures": { - "1": { - "name": "keyword.operator.assignment.jsdoc" - }, - "2": { - "name": "source.embedded.tsx" - } - } + "match": "(?x)\n(\\[)\\s*\n[\\w$]+\n(?:\n (?:\\[\\])? # Foo[ ].bar properties within an array\n \\. # Foo.Bar namespaced parameter\n [\\w$]+\n)*\n(?:\n \\s*\n (=) # [foo=bar] Default parameter value\n \\s*\n (\n # The inner regexes are to stop the match early at */ and to not stop at escaped quotes\n (?>\n \"(?:(?:\\*(?!/))|(?:\\\\(?!\"))|[^*\\\\])*?\" | # [foo=\"bar\"] Double-quoted\n '(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted\n \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal\n (?:(?:\\*(?!/))|\\s(?!\\s*\\])|\\[.*?(?:\\]|(?=\\*/))|[^*\\s\\[\\]])* # Everything else\n )*\n )\n)?\n\\s*(?:(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/))", + "captures": { + "1": { + "name": "punctuation.definition.optional-value.begin.bracket.square.jsdoc" }, - { - "include": "#brackets" + "2": { + "name": "keyword.operator.assignment.jsdoc" }, - { - "include": "#quotes" + "3": { + "name": "source.embedded.tsx" + }, + "4": { + "name": "punctuation.definition.optional-value.end.bracket.square.jsdoc" + }, + "5": { + "name": "invalid.illegal.syntax.jsdoc" } - ] + } } ] }, { - "begin": "((@)(?:define|enum|exception|implements|modifies|namespace|private|protected|returns?|suppress|throws|type))\\s+(?={)", + "begin": "(?x)\n(\n (@)\n (?:define|enum|exception|export|extends|lends|implements|modifies\n |namespace|private|protected|returns?|suppress|this|throws|type\n |yields?)\n)\n\\s+(?={)", "beginCaptures": { "1": { "name": "storage.type.class.jsdoc" @@ -3784,7 +4467,7 @@ }, { "name": "storage.type.class.jsdoc", - "match": "(?x) (@) (?:abstract|access|alias|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|global|host|ignore|implements|implicitCast|inherit[Dd]oc|inner|instance|interface|kind |lends|license|listens|main|member|memberof!?|method|mixes|mixins?|modifies|module|name|namespace |noalias|nocollapse|nocompile|nosideeffects|override|overview|package|param|preserve|private|prop |property|protected|public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule |summary|suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce) \\b", + "match": "(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \\b", "captures": { "1": { "name": "punctuation.definition.block.tag.jsdoc" @@ -3879,28 +4562,6 @@ } ] }, - "quotes": { - "patterns": [ - { - "begin": "'", - "end": "'|(?=\\*/)", - "patterns": [ - { - "include": "#quotes" - } - ] - }, - { - "begin": "\"", - "end": "\"|(?=\\*/)", - "patterns": [ - { - "include": "#quotes" - } - ] - } - ] - }, "jsdoctype": { "patterns": [ { @@ -3935,136 +4596,46 @@ } ] }, - "jsx-tag-attributes": { - "patterns": [ - { - "include": "#jsx-tag-attribute-name" - }, - { - "include": "#jsx-tag-attribute-assignment" - }, - { - "include": "#jsx-string-double-quoted" - }, - { - "include": "#jsx-string-single-quoted" - }, - { - "include": "#jsx-evaluated-code" - } - ] - }, - "jsx-tag-attribute-name": { - "match": "(?x)\n \\s*\n ([_$a-zA-Z][-$\\w]*)\n (?=\\s|=|/?>|/\\*|//)", - "captures": { - "1": { - "name": "entity.other.attribute-name.tsx" - } - } - }, - "jsx-tag-attribute-assignment": { - "name": "keyword.operator.assignment.tsx", - "match": "=(?=\\s*(?:'|\"|{|/\\*|//|\\n))" - }, - "jsx-string-double-quoted": { - "name": "string.quoted.double.tsx", - "begin": "\"", - "end": "\"", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.tsx" - } - }, - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.tsx" - } - }, - "patterns": [ - { - "include": "#jsx-entities" - } - ] - }, - "jsx-string-single-quoted": { - "name": "string.quoted.single.tsx", - "begin": "'", - "end": "'", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.tsx" - } - }, - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.tsx" - } - }, - "patterns": [ - { - "include": "#jsx-entities" - } - ] - }, - "jsx-entities": { + "jsx": { "patterns": [ { - "name": "constant.character.entity.tsx", - "match": "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)", - "captures": { - "1": { - "name": "punctuation.definition.entity.tsx" - }, - "3": { - "name": "punctuation.definition.entity.tsx" - } - } + "include": "#jsx-tag-without-attributes-in-expression" }, { - "name": "invalid.illegal.bad-ampersand.tsx", - "match": "&" + "include": "#jsx-tag-in-expression" } ] }, - "jsx-evaluated-code": { - "name": "meta.embedded.expression.tsx", - "begin": "\\{", - "end": "\\}", - "beginCaptures": { - "0": { - "name": "punctuation.section.embedded.begin.tsx" - } - }, - "endCaptures": { - "0": { - "name": "punctuation.section.embedded.end.tsx" - } - }, + "jsx-tag-without-attributes-in-expression": { + "begin": "(?<!\\+\\+|--)(?<=[({\\[,?=>:*]|&&|\\|\\||\\?|^return|[^\\._$[:alnum:]]return|^default|[^\\._$[:alnum:]]default|^)\\s*(?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", + "end": "(?!(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", "patterns": [ { - "include": "#expression" + "include": "#jsx-tag-without-attributes" } ] }, - "jsx-tag-attributes-illegal": { - "name": "invalid.illegal.attribute.tsx", - "match": "\\S+" - }, "jsx-tag-without-attributes": { "name": "meta.tag.without-attributes.tsx", - "begin": "(<)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\\s*(>)", - "end": "(</)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\\s*(>)", + "begin": "(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>)", + "end": "(</)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>)", "beginCaptures": { "1": { "name": "punctuation.definition.tag.begin.tsx" }, "2": { - "name": "entity.name.tag.tsx" + "name": "entity.name.tag.namespace.tsx" }, "3": { - "name": "support.class.component.tsx" + "name": "punctuation.separator.namespace.tsx" }, "4": { + "name": "entity.name.tag.tsx" + }, + "5": { + "name": "support.class.component.tsx" + }, + "6": { "name": "punctuation.definition.tag.end.tsx" } }, @@ -4073,12 +4644,18 @@ "name": "punctuation.definition.tag.begin.tsx" }, "2": { - "name": "entity.name.tag.tsx" + "name": "entity.name.tag.namespace.tsx" }, "3": { - "name": "support.class.component.tsx" + "name": "punctuation.separator.namespace.tsx" }, "4": { + "name": "entity.name.tag.tsx" + }, + "5": { + "name": "support.class.component.tsx" + }, + "6": { "name": "punctuation.definition.tag.end.tsx" } }, @@ -4090,41 +4667,19 @@ ] }, "jsx-tag-in-expression": { - "begin": "(?x)\n (?<=[({\\[,?=>:*]|&&|\\|\\||\\?|\\Wreturn|^return|\\Wdefault|^)\\s*\n (?!(<)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>)) #look ahead is not start of tag without attributes\n (?!<\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=>])|,)) # look ahead is not type parameter of arrow\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))", - "end": "(/>)|(?:(</)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\\s*(>))", - "endCaptures": { - "0": { - "name": "meta.tag.tsx" - }, - "1": { - "name": "punctuation.definition.tag.end.tsx" - }, - "2": { - "name": "punctuation.definition.tag.begin.tsx" - }, - "3": { - "name": "entity.name.tag.tsx" - }, - "4": { - "name": "support.class.component.tsx" - }, - "5": { - "name": "punctuation.definition.tag.end.tsx" - } - }, + "begin": "(?x)\n (?<!\\+\\+|--)(?<=[({\\[,?=>:*]|&&|\\|\\||\\?|^return|[^\\._$[:alnum:]]return|^default|[^\\._$[:alnum:]]default|^)\\s*\n (?!<\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=>])|,)) # look ahead is not type parameter of arrow\n (?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", + "end": "(?!(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", "patterns": [ { "include": "#jsx-tag" } ] }, - "jsx-child-tag": { - "begin": "(?x)\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))", - "end": "(/>)|(?:(</)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\\s*(>))", + "jsx-tag": { + "name": "meta.tag.tsx", + "begin": "(?=(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>))", + "end": "(/>)|(?:(</)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))?\\s*(>))", "endCaptures": { - "0": { - "name": "meta.tag.tsx" - }, "1": { "name": "punctuation.definition.tag.end.tsx" }, @@ -4132,36 +4687,38 @@ "name": "punctuation.definition.tag.begin.tsx" }, "3": { - "name": "entity.name.tag.tsx" + "name": "entity.name.tag.namespace.tsx" }, "4": { - "name": "support.class.component.tsx" + "name": "punctuation.separator.namespace.tsx" }, "5": { + "name": "entity.name.tag.tsx" + }, + "6": { + "name": "support.class.component.tsx" + }, + "7": { "name": "punctuation.definition.tag.end.tsx" } }, "patterns": [ { - "include": "#jsx-tag" - } - ] - }, - "jsx-tag": { - "name": "meta.tag.tsx", - "begin": "(?x)\n (?=(<)\\s*\n ([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>))", - "end": "(?=(/>)|(?:(</)\\s*([_$a-zA-Z][-$\\w.]*(?<!\\.|-))\\s*(>)))", - "patterns": [ - { - "begin": "(?x)\n (<)\\s*\n ((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))\n (?=\\s+(?!\\?)|/?>)", + "begin": "(<)\\s*(?:([_$a-zA-Z][-$\\w.]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?<!\\.|-))(?=((<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{[^\\{\\}]*\\}))*\\})|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(\\[([^\\[\\]]|(\\[[^\\[\\]]*\\]))*\\])|(\\'[^\\']*\\')|(\\\"[^\\\"]*\\\")|(\\`[^\\`]*\\`))(?=\\s*([\\<\\>\\,\\.\\[=]|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))|(?<==)\\>)*(?!=)\\>)*(?!=)>\\s*)|(\\s+))(?!\\?)|\\/?>)", "beginCaptures": { "1": { "name": "punctuation.definition.tag.begin.tsx" }, "2": { - "name": "entity.name.tag.tsx" + "name": "entity.name.tag.namespace.tsx" }, "3": { + "name": "punctuation.separator.namespace.tsx" + }, + "4": { + "name": "entity.name.tag.tsx" + }, + "5": { "name": "support.class.component.tsx" } }, @@ -4171,10 +4728,10 @@ "include": "#comment" }, { - "include": "#jsx-tag-attributes" + "include": "#type-arguments" }, { - "include": "#jsx-tag-attributes-illegal" + "include": "#jsx-tag-attributes" } ] }, @@ -4195,20 +4752,13 @@ } ] }, - "jsx-tag-invalid": { - "name": "invalid.illegal.tag.incomplete.tsx", - "match": "<\\s*>" - }, "jsx-children": { "patterns": [ { "include": "#jsx-tag-without-attributes" }, { - "include": "#jsx-child-tag" - }, - { - "include": "#jsx-tag-invalid" + "include": "#jsx-tag" }, { "include": "#jsx-evaluated-code" @@ -4218,18 +4768,135 @@ } ] }, - "jsx": { + "jsx-evaluated-code": { + "name": "meta.embedded.expression.tsx", + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.tsx" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.tsx" + } + }, "patterns": [ { - "include": "#jsx-tag-without-attributes" + "include": "#expression" + } + ] + }, + "jsx-entities": { + "patterns": [ + { + "name": "constant.character.entity.tsx", + "match": "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)", + "captures": { + "1": { + "name": "punctuation.definition.entity.tsx" + }, + "3": { + "name": "punctuation.definition.entity.tsx" + } + } }, { - "include": "#jsx-tag-in-expression" + "name": "invalid.illegal.bad-ampersand.tsx", + "match": "&" + } + ] + }, + "jsx-tag-attributes": { + "name": "meta.tag.attributes.tsx", + "begin": "\\s+", + "end": "(?=[/]?>)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#jsx-tag-attribute-name" + }, + { + "include": "#jsx-tag-attribute-assignment" + }, + { + "include": "#jsx-string-double-quoted" + }, + { + "include": "#jsx-string-single-quoted" + }, + { + "include": "#jsx-evaluated-code" + }, + { + "include": "#jsx-tag-attributes-illegal" + } + ] + }, + "jsx-tag-attribute-name": { + "match": "(?x)\n \\s*\n (?:([_$a-zA-Z][-$\\w.]*)(:))?\n ([_$a-zA-Z][-$\\w]*)\n (?=\\s|=|/?>|/\\*|//)", + "captures": { + "1": { + "name": "entity.other.attribute-name.namespace.tsx" + }, + "2": { + "name": "punctuation.separator.namespace.tsx" }, + "3": { + "name": "entity.other.attribute-name.tsx" + } + } + }, + "jsx-tag-attribute-assignment": { + "name": "keyword.operator.assignment.tsx", + "match": "=(?=\\s*(?:'|\"|{|/\\*|//|\\n))" + }, + "jsx-string-double-quoted": { + "name": "string.quoted.double.tsx", + "begin": "\"", + "end": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.tsx" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.tsx" + } + }, + "patterns": [ + { + "include": "#jsx-entities" + } + ] + }, + "jsx-string-single-quoted": { + "name": "string.quoted.single.tsx", + "begin": "'", + "end": "'", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.tsx" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.tsx" + } + }, + "patterns": [ { - "include": "#jsx-tag-invalid" + "include": "#jsx-entities" } ] + }, + "jsx-tag-attributes-illegal": { + "name": "invalid.illegal.attribute.tsx", + "match": "\\S+" } } }
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/DarkStyle.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/DarkStyle.json index 402707fedc..859d555cba 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/DarkStyle.json +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/DarkStyle.json @@ -154,7 +154,7 @@ { "name": "Html Element Name", "fore": "skyblue1" }, { "name": "Html Entity", "fore": "skyblue1" }, { "name": "Html Operator", "fore": "aluminium1" }, - { "name": "Html Server-Side Script", "fore": "butter2", "back": "black" }, + { "name": "Html Server-Side Script", "fore": "black", "back": "#d2d295" }, { "name": "Html Tag Delimiter", "fore": "aluminium1" }, { "name": "Razor Code", "fore": "aluminium1", "back": "aluminium7" }, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/LightStyle.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/LightStyle.json index 5e6891a78d..e2a5ff3a30 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/LightStyle.json +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/LightStyle.json @@ -151,7 +151,7 @@ { "name": "Html Element Name", "fore": "skyblue2" }, { "name": "Html Entity", "fore": "#c12dad" }, { "name": "Html Operator", "fore": "skyblue2" }, - { "name": "Html Server-Side Script", "fore": "text-black", "back": "#fdf0bd" }, + { "name": "Html Server-Side Script", "fore": "text-black", "back": "#ffff33" }, { "name": "Html Tag Delimiter", "fore": "skyblue2" }, { "name": "Razor Code", "fore": "text-black", "back": "#fdfaed" }, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/OblivionStyle.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/OblivionStyle.json index 3af8b35d14..bffbc9329b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/OblivionStyle.json +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/OblivionStyle.json @@ -154,7 +154,7 @@ { "name": "Html Element Name", "fore": "plum1" }, { "name": "Html Entity", "fore": "skyblue1" }, { "name": "Html Operator", "fore": "aluminium2" }, - { "name": "Html Server-Side Script", "fore": "butter2", "back": "black" }, + { "name": "Html Server-Side Script", "fore": "black", "back": "#d2d295" }, { "name": "Html Tag Delimiter", "fore": "aluminium2" }, { "name": "Razor Code", "fore": "aluminium2", "back": "aluminium7" }, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/TangoStyle.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/TangoStyle.json index 697d590ab0..e6b3060eaf 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/TangoStyle.json +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/TangoStyle.json @@ -85,6 +85,7 @@ { "name": "Html Comment", "fore": "aluminium4" }, { "name": "Html Element Name", "fore": "skyblue3" }, { "name": "Html Operator", "fore": "skyblue3" }, + { "name": "Html Server-Side Script", "fore": "black", "back": "#FFFF33" }, { "name": "Keyword(Access)", "fore": "skyblue2" }, { "name": "Keyword(Type)", "fore": "skyblue2" }, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/VisualStudioStyle.json b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/VisualStudioStyle.json index f354222aea..f3f39a54d9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/VisualStudioStyle.json +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/themes/VisualStudioStyle.json @@ -66,7 +66,7 @@ { "name": "Html Element Name", "fore": "#800000" }, { "name": "Html Entity", "fore": "#FF0000" }, { "name": "Html Operator", "fore": "keyword-blue" }, - { "name": "Html Server-Side Script", "back": "#FEFF00" }, + { "name": "Html Server-Side Script", "fore": "black", "back": "#FFFF33" }, { "name": "Html Tag Delimiter", "fore": "keyword-blue" }, { "name": "Razor Code", "back": "#E7EFF2" }, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.TextMate/ShowTextMateScopesHandler.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.TextMate/ShowTextMateScopesHandler.cs index 38c6c9e42f..04be27b1bb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.TextMate/ShowTextMateScopesHandler.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.TextMate/ShowTextMateScopesHandler.cs @@ -53,7 +53,7 @@ namespace MonoDevelop.Ide.Editor.TextMate var window = new TooltipPopoverWindow (); - window.Markup = "<span size=\"larger\" font='" + FontService.MonospaceFontName + "'>" + sb.ToString () + "</span>"; + window.Markup = "<span font='" + FontService.MonospaceFontName + "'>" + sb.ToString () + "</span>"; editor.ShowTooltipWindow (window); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.TextMate/TextMateBundleOptionsPanelWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.TextMate/TextMateBundleOptionsPanelWidget.cs index 6aa8f42097..a354ae963d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.TextMate/TextMateBundleOptionsPanelWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.TextMate/TextMateBundleOptionsPanelWidget.cs @@ -119,7 +119,9 @@ namespace MonoDevelop.Ide.Editor.TextMate void FillBundles () { styleStore.Clear (); - foreach (var bundle in SyntaxHighlightingService.LanguageBundles) { + foreach (var bundle in SyntaxHighlightingService.AllBundles) { + if (bundle.BuiltInBundle) + continue; styleStore.AppendValues (bundle.Name, bundle); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditorConfigService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditorConfigService.cs index e0e59ad2fc..4dbaf49f75 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditorConfigService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditorConfigService.cs @@ -43,7 +43,7 @@ namespace MonoDevelop.Ide.Editor public static Task<ICodingConventionContext> GetEditorConfigContext (string fileName, CancellationToken token = default (CancellationToken)) { - if (!File.Exists (fileName)) + if (!string.IsNullOrEmpty (fileName)) return TaskUtil.Default<ICodingConventionContext> (); lock (contextCacheLock) { if (contextCache.TryGetValue (fileName, out Task<ICodingConventionContext> result)) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/Projection/Projection.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/Projection/Projection.cs index 4cd4b71ff6..cbe4e492cd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/Projection/Projection.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/Projection/Projection.cs @@ -30,6 +30,7 @@ using MonoDevelop.Core.Text; using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.TypeSystem; using System.Collections.Generic; +using MonoDevelop.Core; namespace MonoDevelop.Ide.Editor.Projection { @@ -122,7 +123,11 @@ namespace MonoDevelop.Ide.Editor.Projection foreach (var segment in originalProjections) { if (segment.Contains (change.Offset)) { var projectedOffset = change.Offset - segment.Offset + segment.LinkedTo.Offset; - projectedEditor.ReplaceText (projectedOffset, change.RemovalLength, change.InsertedText); + try { + projectedEditor.ReplaceText (projectedOffset, change.RemovalLength, change.InsertedText); + } catch (Exception ex) { + LoggingService.LogError ($"Error while replacing in projected editor at {projectedOffset} with length {projectedEditor.Length} change: {change}", ex); + } } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs index be8aa68061..3c50105a7b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/ExtensibleTreeView.cs @@ -64,7 +64,7 @@ namespace MonoDevelop.Ide.Gui.Components ZoomableCellRendererPixbuf pix_render; CustomCellRendererText text_render; TreeBuilderContext builderContext; - Hashtable callbacks = new Hashtable (); + Dictionary<object, List<TreeNodeCallback>> callbacks = new Dictionary<object, List<TreeNodeCallback>> (); bool editingText = false; TreePadOption[] options; @@ -829,12 +829,11 @@ namespace MonoDevelop.Ide.Gui.Components callback (GetNodeAtObject (dataObject)); return; } - - ArrayList list = callbacks [dataObject] as ArrayList; - if (list != null) +
+ if (callbacks.TryGetValue (dataObject, out var list)) { list.Add (callback); - else { - list = new ArrayList (); + } else { + list = new List<TreeNodeCallback> (); list.Add (callback); callbacks [dataObject] = list; } @@ -847,9 +846,9 @@ namespace MonoDevelop.Ide.Gui.Components class MulticastNodeRouter: IMultiCastCommandRouter { - ArrayList targets; + List<NodeCommandTargetChain> targets; - public MulticastNodeRouter (ArrayList targets) + public MulticastNodeRouter (List<NodeCommandTargetChain> targets) { this.targets = targets; } @@ -869,7 +868,7 @@ namespace MonoDevelop.Ide.Gui.Components if (editingText) return null; - ArrayList targets = new ArrayList (); + List<NodeCommandTargetChain> targets = new List<NodeCommandTargetChain> (); foreach (SelectionGroup grp in GetSelectedNodesGrouped ()) { NodeBuilder[] chain = grp.BuilderChain; @@ -1722,7 +1721,7 @@ namespace MonoDevelop.Ide.Gui.Components if (copyObjects != null) { int i = Array.IndexOf (copyObjects, dataObject); if (i != -1) { - ArrayList list = new ArrayList (copyObjects); + var list = new List<object> (copyObjects); list.RemoveAt (i); if (list.Count > 0) copyObjects = list.ToArray (); @@ -1736,7 +1735,7 @@ namespace MonoDevelop.Ide.Gui.Components if (tree.dragObjects != null) { int i = Array.IndexOf (tree.dragObjects, dataObject); if (i != -1) { - ArrayList list = new ArrayList (tree.dragObjects); + var list = new List<object> (tree.dragObjects); list.RemoveAt (i); if (list.Count > 0) tree.dragObjects = list.ToArray (); @@ -1806,8 +1805,7 @@ namespace MonoDevelop.Ide.Gui.Components internal void NotifyInserted (Gtk.TreeIter it, object dataObject) { if (callbacks.Count > 0) { - ArrayList list = callbacks [dataObject] as ArrayList; - if (list != null) { + if (callbacks.TryGetValue (dataObject, out var list)) { ITreeNavigator nav = new TreeNodeNavigator (this, it); NodePosition pos = nav.CurrentPosition; foreach (TreeNodeCallback callback in list) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs index 086f4a09a8..a4bbd79916 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ClassNodeBuilder.cs @@ -94,31 +94,36 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad if (classData.Class.TypeKind == TypeKind.Delegate) return; - builder.AddChildren (classData.Class.GetTypeMembers ()
+ builder.AddChildren (classData.Class.GetTypeMembers () .Where (innerClass => innerClass.DeclaredAccessibility == Accessibility.Public || (innerClass.DeclaredAccessibility == Accessibility.Protected && publicProtectedOnly) ||
- !publicOnly)
+ !publicOnly) + .Where (c => !c.IsImplicitClass) .Select (innerClass => new ClassData (classData.Project, innerClass))); builder.AddChildren (classData.Class.GetMembers ().OfType<IMethodSymbol> ().Where (m => m.MethodKind != MethodKind.PropertyGet && m.MethodKind != MethodKind.PropertySet)
.Where (method => method.DeclaredAccessibility == Accessibility.Public || (method.DeclaredAccessibility == Accessibility.Protected && publicProtectedOnly) || - !publicOnly)); + !publicOnly) + .Where (m => !m.IsImplicitlyDeclared)); builder.AddChildren (classData.Class.GetMembers ().OfType<IPropertySymbol> ()
.Where (property => property.DeclaredAccessibility == Accessibility.Public || (property.DeclaredAccessibility == Accessibility.Protected && publicProtectedOnly) ||
- !publicOnly)); + !publicOnly) + .Where (m => !m.IsImplicitlyDeclared)); builder.AddChildren (classData.Class.GetMembers ().OfType<IFieldSymbol> ()
.Where (field => field.DeclaredAccessibility == Accessibility.Public ||
(field.DeclaredAccessibility == Accessibility.Protected && publicProtectedOnly) ||
- !publicOnly)); + !publicOnly) + .Where (m => !m.IsImplicitlyDeclared)); builder.AddChildren (classData.Class.GetMembers ().OfType<IEventSymbol> ()
.Where (e => e.DeclaredAccessibility == Accessibility.Public || (e.DeclaredAccessibility == Accessibility.Protected && publicProtectedOnly) ||
- !publicOnly)); + !publicOnly) + .Where (m => !m.IsImplicitlyDeclared)); } public override bool HasChildNodes (ITreeBuilder builder, object dataObject) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs index e5cdb2278e..066e8b5a9a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs @@ -114,7 +114,8 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad } } builder.AddChildren (dom.Assembly.GlobalNamespace.GetTypeMembers ()
- .Where (type => !publicOnly || type.DeclaredAccessibility == Accessibility.Public)
+ .Where (type => !publicOnly || type.DeclaredAccessibility == Accessibility.Public) + .Where (t => !t.IsImplicitClass)
.Select (type => new ClassData (project, type))); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs index 4f4dc00dce..c35e7b50bd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs @@ -55,6 +55,7 @@ using MonoDevelop.Components.AutoTest; using System.ComponentModel; using MonoDevelop.Ide.BuildOutputView; using System.Threading.Tasks; +using MonoDevelop.Core.ProgressMonitoring; namespace MonoDevelop.Ide.Gui.Pads { @@ -65,11 +66,13 @@ namespace MonoDevelop.Ide.Gui.Pads PadTreeView view; BuildOutputViewContent buildOutputViewContent; BuildOutput buildOutput; + LogView logView; TreeStore store; TreeModelFilter filter; TreeModelSort sort; ToggleButton errorBtn, warnBtn, msgBtn; - Button logBtn; + Button buildLogBtn; + ToggleButton logBtn; Label errorBtnLbl, warnBtnLbl, msgBtnLbl, logBtnLbl; SearchEntry searchEntry; string currentSearchPattern = null; @@ -77,6 +80,7 @@ namespace MonoDevelop.Ide.Gui.Pads int errorCount; int warningCount; int infoCount; + bool initialLogShow = true; Clipboard clipboard; @@ -89,6 +93,8 @@ namespace MonoDevelop.Ide.Gui.Pads public readonly ConfigurationProperty<bool> ShowErrors = ConfigurationProperty.Create ("SharpDevelop.TaskList.ShowErrors", true); public readonly ConfigurationProperty<bool> ShowWarnings = ConfigurationProperty.Create ("SharpDevelop.TaskList.ShowWarnings", true); public readonly ConfigurationProperty<bool> ShowMessages = ConfigurationProperty.Create ("SharpDevelop.TaskList.ShowMessages", true); + public readonly ConfigurationProperty<double> LogSeparatorPosition = ConfigurationProperty.Create ("SharpDevelop.TaskList.LogSeparatorPosition", 0.5d); + public readonly ConfigurationProperty<bool> OutputViewVisible = ConfigurationProperty.Create ("SharpDevelop.TaskList.OutputViewVisible", false); static class DataColumns { @@ -170,7 +176,7 @@ namespace MonoDevelop.Ide.Gui.Pads errorBtn = MakeButton (Stock.Error, "toggleErrors", ShowErrors, out errorBtnLbl); errorBtn.Accessible.Name = "ErrorPad.ErrorButton"; - errorBtn.Toggled += new EventHandler (FilterChanged); + errorBtn.Toggled += FilterChanged; errorBtn.TooltipText = GettextCatalog.GetString ("Show Errors"); errorBtn.Accessible.Description = GettextCatalog.GetString ("Show Errors"); UpdateErrorsNum (); @@ -178,7 +184,7 @@ namespace MonoDevelop.Ide.Gui.Pads warnBtn = MakeButton (Stock.Warning, "toggleWarnings", ShowWarnings, out warnBtnLbl); warnBtn.Accessible.Name = "ErrorPad.WarningButton"; - warnBtn.Toggled += new EventHandler (FilterChanged); + warnBtn.Toggled += FilterChanged; warnBtn.TooltipText = GettextCatalog.GetString ("Show Warnings"); warnBtn.Accessible.Description = GettextCatalog.GetString ("Show Warnings"); UpdateWarningsNum (); @@ -186,7 +192,7 @@ namespace MonoDevelop.Ide.Gui.Pads msgBtn = MakeButton (Stock.Information, "toggleMessages", ShowMessages, out msgBtnLbl); msgBtn.Accessible.Name = "ErrorPad.MessageButton"; - msgBtn.Toggled += new EventHandler (FilterChanged); + msgBtn.Toggled += FilterChanged; msgBtn.TooltipText = GettextCatalog.GetString ("Show Messages"); msgBtn.Accessible.Description = GettextCatalog.GetString ("Show Messages"); UpdateMessagesNum (); @@ -196,17 +202,26 @@ namespace MonoDevelop.Ide.Gui.Pads sep.Accessible.SetShouldIgnore (true); toolbar.Add (sep); - logBtn = MakeButton ("md-message-log", "toggleBuildOutput", out logBtnLbl); + logBtn = MakeButton ("md-message-log", "toggleBuildOutput", false, out logBtnLbl); logBtn.Accessible.Name = "ErrorPad.LogButton"; - logBtn.TooltipText = GettextCatalog.GetString ("Show build output"); - logBtn.Accessible.Description = GettextCatalog.GetString ("Show build output"); - + logBtn.TooltipText = GettextCatalog.GetString ("Build Output"); + logBtn.Accessible.Description = GettextCatalog.GetString ("Build Output"); logBtnLbl.Text = GettextCatalog.GetString ("Build Output"); logBtn.Accessible.SetTitle (logBtnLbl.Text); - - logBtn.Clicked += HandleLogBtnClicked; + logBtn.Toggled += HandleTextLogToggled; toolbar.Add (logBtn); + buildLogBtn = MakeButton ("md-message-log", "toggleBuildOutput", out logBtnLbl); + buildLogBtn.Accessible.Name = "ErrorPad.BuildLogButton"; + buildLogBtn.TooltipText = GettextCatalog.GetString ("Structured Build Output"); + buildLogBtn.Accessible.Description = GettextCatalog.GetString ("Structured Build Output"); + + logBtnLbl.Text = GettextCatalog.GetString ("Structured Build Output"); + buildLogBtn.Accessible.SetTitle (logBtnLbl.Text); + + buildLogBtn.Clicked += HandleBinLogClicked; + toolbar.Add (buildLogBtn); + buildOutput = new BuildOutput (); //Dummy widget to take all space between "Build Output" button and SearchEntry @@ -282,7 +297,7 @@ namespace MonoDevelop.Ide.Gui.Pads IdeApp.Workspace.FirstWorkspaceItemOpened += OnCombineOpen; IdeApp.Workspace.LastWorkspaceItemClosed += OnCombineClosed; - view.RowActivated += new RowActivatedHandler (OnRowActivated); + view.RowActivated += OnRowActivated; iconWarning = ImageService.GetIcon (Ide.Gui.Stock.Warning, Gtk.IconSize.Menu); iconError = ImageService.GetIcon (Ide.Gui.Stock.Error, Gtk.IconSize.Menu); @@ -291,38 +306,95 @@ namespace MonoDevelop.Ide.Gui.Pads control.Add1 (sw); + logView = new LogView { Name = "buildOutput" }; + control.Add2 (logView); + control.ShowAll (); + control.SizeAllocated += HandleControlSizeAllocated; + sw.SizeAllocated += HandleSwSizeAllocated; + + if (OutputViewVisible) { + logView.Visible = true; + logBtn.Active = true; + } else { + logBtn.Active = false; + } + // Load existing tasks foreach (TaskListEntry t in TaskService.Errors) { AddTask (t); } + + control.FocusChain = new Gtk.Widget [] { logView }; } public override void Dispose ()
{ + errorBtn.Toggled -= FilterChanged; + warnBtn.Toggled -= FilterChanged; + msgBtn.Toggled -= FilterChanged; + logBtn.Toggled -= HandleTextLogToggled; + buildLogBtn.Clicked -= HandleBinLogClicked; + searchEntry.Entry.Changed -= searchPatternChanged; + IdeApp.Workspace.FirstWorkspaceItemOpened -= OnCombineOpen; IdeApp.Workspace.LastWorkspaceItemClosed -= OnCombineClosed; IdeApp.ProjectOperations.StartBuild -= OnBuildStarted; + TaskService.Errors.TasksRemoved -= ShowResults; + TaskService.Errors.TasksAdded -= TaskAdded; + TaskService.Errors.TasksChanged -= TaskChanged; + TaskService.Errors.CurrentLocationTaskChanged -= HandleTaskServiceErrorsCurrentLocationTaskChanged; + buildOutput?.Dispose (); buildOutputViewContent?.Dispose (); buildOutputDoc?.Close (); // Set the model to null as it makes Gtk clean up faster if (view != null) { + view.RowActivated -= OnRowActivated; view.Model = null; } + + if (control != null) { + control.SizeAllocated -= HandleControlSizeAllocated; + } + + if (sw != null) { + sw.SizeAllocated -= HandleSwSizeAllocated; + } base.Dispose ();
} + void HandleSwSizeAllocated (object o, SizeAllocatedArgs args) + { + if (!initialLogShow && OutputViewVisible) { + var val = (double)((double)control.Position / (double)control.Allocation.Width); + LogSeparatorPosition.Value = val; + } + } + + [GLib.ConnectBefore] + void HandleControlSizeAllocated (object o, SizeAllocatedArgs args) + { + if (initialLogShow && OutputViewVisible) { + SetInitialOutputViewSize (args.Allocation.Width); + initialLogShow = false; + } + } + public ProgressMonitor GetBuildProgressMonitor () { if (control == null) CreateControl (); - - return buildOutput.GetProgressMonitor (); + + var monitor = new AggregatedProgressMonitor (); + monitor.AddFollowerMonitor (buildOutput.GetProgressMonitor ()); + monitor.AddFollowerMonitor (logView.GetProgressMonitor ()); + + return monitor; } void HandleTaskServiceErrorsCurrentLocationTaskChanged (object sender, EventArgs e) @@ -950,11 +1022,28 @@ namespace MonoDevelop.Ide.Gui.Pads internal void FocusOutputView () { - HandleLogBtnClicked (this, EventArgs.Empty); + HandleBinLogClicked (this, EventArgs.Empty); + } + + void HandleTextLogToggled (object sender, EventArgs e) + { + var visible = logBtn.Active; + OutputViewVisible.Value = visible; + logView.Visible = visible; + + SetInitialOutputViewSize (control.Allocation.Width); + } + + void SetInitialOutputViewSize (int controlWidth) + { + double relPos = LogSeparatorPosition; + int pos = (int)(controlWidth * relPos); + pos = Math.Max(30, Math.Min(pos, controlWidth - 30)); + control.Position = pos; } Document buildOutputDoc; - void HandleLogBtnClicked (object sender, EventArgs e) + void HandleBinLogClicked (object sender, EventArgs e) { OpenBuildOutputViewDocument (); } @@ -973,6 +1062,7 @@ namespace MonoDevelop.Ide.Gui.Pads void BuildOutputDocClosed (object sender, EventArgs e) { buildOutputViewContent?.Dispose (); + buildOutputDoc.Closed -= BuildOutputDocClosed; buildOutputViewContent = null; buildOutputDoc = null; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs index 35772dc3e9..046f397317 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs @@ -80,7 +80,6 @@ namespace MonoDevelop.Ide.Gui bool closeAll; - bool fullscreen; Rectangle normalBounds = new Rectangle(0, 0, MinimumWidth, MinimumHeight); Gtk.Container rootWidget; @@ -641,10 +640,9 @@ namespace MonoDevelop.Ide.Gui public ICustomXmlSerializer Memento { get { - WorkbenchMemento memento = new WorkbenchMemento (new Properties ()); - int x, y, width, height; - GetPosition (out x, out y); - GetSize (out width, out height); + var memento = new WorkbenchMemento (new Properties ()); + GetPosition (out int x, out int y); + GetSize (out int width, out int height); // HACK: always capture bounds on OS X because we don't restore Gdk.WindowState.Maximized due to // the bug mentioned below. So we simular Maximized by capturing the Maximized size. if (GdkWindow.State == 0 || Platform.IsMac) { @@ -653,7 +651,7 @@ namespace MonoDevelop.Ide.Gui memento.Bounds = normalBounds; } memento.WindowState = GdkWindow.State; - memento.FullScreen = fullscreen; + memento.FullScreen = FullScreen; return memento.ToProperties (); } set { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs index 5bcc0363ce..7cac47851b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs @@ -169,11 +169,17 @@ namespace MonoDevelop.Ide.Gui if (window.ViewContent.Project != null) window.ViewContent.Project.Modified += HandleProjectModified; window.ViewsChanged += HandleViewsChanged; - window.ViewContent.ContentNameChanged += ReloadAnalysisDocumentHandler; + window.ViewContent.ContentNameChanged += OnContentNameChanged; MonoDevelopWorkspace.LoadingFinished += ReloadAnalysisDocumentHandler; DocumentRegistry.Add (this); } + void OnContentNameChanged (object sender, EventArgs e) + { + OnFileNameChanged (); + ReloadAnalysisDocumentHandler (sender, e); + } + void ReloadAnalysisDocumentHandler (object sender, EventArgs e) { UnsubscribeAnalysisDocument (); @@ -201,6 +207,13 @@ namespace MonoDevelop.Ide.Gui } } + internal event EventHandler FileNameChanged; + + void OnFileNameChanged () + { + FileNameChanged?.Invoke (this, EventArgs.Empty); + } + public bool IsFile { get { return Window.ViewContent.IsFile; } } @@ -602,7 +615,8 @@ namespace MonoDevelop.Ide.Gui // Unsubscribe project events if (window.ViewContent.Project != null) window.ViewContent.Project.Modified -= HandleProjectModified; - window.ViewsChanged += HandleViewsChanged; + window.ViewsChanged -= HandleViewsChanged; + window.ViewContent.ContentNameChanged -= OnContentNameChanged; MonoDevelopWorkspace.LoadingFinished -= ReloadAnalysisDocumentHandler; window = null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentRegistry.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentRegistry.cs index 170d158866..07731f9697 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentRegistry.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentRegistry.cs @@ -216,6 +216,7 @@ namespace MonoDevelop.Ide.Gui LastSaveTimeUtc = DateTime.UtcNow; doc.Saved += Doc_Saved; doc.Reloaded += Doc_Saved; + doc.FileNameChanged += Doc_Saved; } @@ -233,6 +234,7 @@ namespace MonoDevelop.Ide.Gui { Document.Saved -= Doc_Saved; Document.Reloaded -= Doc_Saved; + Document.FileNameChanged -= Doc_Saved; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs index e513708297..f541ac413f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs @@ -126,8 +126,7 @@ namespace MonoDevelop.Ide.Gui var memento = PropertyService.Get (workbenchMemento, new Properties ()); Counters.Initialization.Trace ("Setting memento"); workbench.Memento = memento; - Counters.Initialization.Trace ("Making Visible"); - RootWindow.Visible = true; + Counters.Initialization.Trace ("Setting layout"); workbench.CurrentLayout = "Solution"; // now we have an layout set notify it @@ -137,7 +136,8 @@ namespace MonoDevelop.Ide.Gui Counters.Initialization.Trace ("Initializing monitors"); monitors.Initialize (); - + + Counters.Initialization.Trace ("Making visible"); Present (); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/MonoDevelopGlobalOptionPersister.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/MonoDevelopGlobalOptionPersister.cs index 062575ed36..76503232c6 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/MonoDevelopGlobalOptionPersister.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/MonoDevelopGlobalOptionPersister.cs @@ -43,6 +43,7 @@ using System.Runtime.Serialization; using System.ComponentModel; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Projects.Policies; +using System.Collections.Immutable; namespace MonoDevelop.Ide.RoslynServices.Options { @@ -104,7 +105,7 @@ namespace MonoDevelop.Ide.RoslynServices.Options value = Deserialize (serializedValue, optionKey.Option.Type); return true; } catch (Exception ex) { - LoggingService.LogError ($"Failed to deserialize key: {storageKey} type: {optionKey.Option.Type} value: {serializedValue}", ex); + LoggingService.LogError ($"Failed to deserialize option: '{storageKey}' Type: '{optionKey.Option.Type}' value: '{serializedValue}'", ex); } } @@ -208,28 +209,31 @@ namespace MonoDevelop.Ide.RoslynServices.Options static object Deserialize (object value, Type optionType) { - if (optionType.IsEnum && value != null && optionType.IsEnumDefined (value)) - return Enum.ToObject (optionType, value); + if (optionType.IsValueType) { + // check if we have a nullable, then returning null is ok + var isNullable = optionType.IsGenericType && optionType.GetGenericTypeDefinition () == typeof (Nullable<>); + + if (value == null) { + if (!isNullable) + throw new SerializationException (); + } else { + if (isNullable && optionType.GenericTypeArguments [0] == value.GetType ()) + optionType = value.GetType (); + } + } - if (RoslynPreferences.TryGetSerializationMethods<object> (optionType, out var serializer, out var deserializer) && value is string serializedValue) { - return deserializer (serializedValue); + if (optionType.IsEnum) { + if (value != null && optionType.IsEnumDefined (value)) + return Enum.ToObject (optionType, value); + throw new SerializationException (); } - - if (optionType == typeof (bool)) { - // TypeScript used to store some booleans as integers. We now handle them properly for legacy sync scenarios. - if (value is int intValue) - return intValue != 0; - - if (value is long longValue) - return longValue != 0; + + if (RoslynPreferences.TryGetSerializationMethods<object> (optionType, out var serializer, out var deserializer)) { + if (value is string serializedValue) + return deserializer (serializedValue); } - if (optionType == typeof (bool?)) { - // code uses object to hold onto any value which will use boxing on value types. - // see boxing on nullable types - https://msdn.microsoft.com/en-us/library/ms228597.aspx - if (!(value is bool) && value != null) - throw new SerializationException (); - } else if (value != null && optionType != value.GetType ()) { + if (value != null && optionType != value.GetType ()) { // We got something back different than we expected, so fail to deserialize throw new SerializationException (); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/OptionsExtensions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/OptionsExtensions.cs index 2a9ce1494e..660d93e092 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/OptionsExtensions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/OptionsExtensions.cs @@ -24,6 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; +using System.Collections.Generic; using System.Linq; using Microsoft.CodeAnalysis.Options; using MonoDevelop.Ide.Gui.Content; @@ -33,21 +34,22 @@ namespace MonoDevelop.Ide.RoslynServices.Options { static class OptionsExtensions { - public static string GetPropertyName (this OptionKey optionKey) + public static IEnumerable<string> GetPropertyNames (this OptionKey optionKey) { // Prevent NRE being thrown on iteration. if (optionKey.Option.StorageLocations.IsDefaultOrEmpty) - return null; + yield break; foreach (var storageLocation in optionKey.Option.StorageLocations) { if (storageLocation is RoamingProfileStorageLocation roamingLocation) - return roamingLocation.GetKeyNameForLanguage (optionKey.Language); + yield return roamingLocation.GetKeyNameForLanguage (optionKey.Language); if (storageLocation is LocalUserProfileStorageLocation userLocation) - return userLocation.KeyName; + yield return userLocation.KeyName; } - return null; } + public static string GetPropertyName (this OptionKey optionKey) => GetPropertyNames (optionKey).FirstOrDefault (); + public static TextStylePolicy GetTextStylePolicy (this OptionKey optionKey) { var mimeChain = DesktopService.GetMimeTypeInheritanceChainForRoslynLanguage (optionKey.Language); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferences.Properties.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferences.Properties.cs index ea840cb182..9ac4bda76b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferences.Properties.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferences.Properties.cs @@ -41,19 +41,30 @@ namespace MonoDevelop.Ide.RoslynServices.Options internal bool TryGet (OptionKey key, out string propertyKey, out object value) { - // Check for roaming/profile properties - propertyKey = key.GetPropertyName (); - if (propertyKey != null) { - var defaultValue = key.Option.DefaultValue; - if (TryGetSerializationMethods<object> (key.Option.Type, out var serializer, out var deserializer)) - defaultValue = serializer (defaultValue); + propertyKey = null; + value = null; + + var type = key.Option.Type; + var defaultValue = key.Option.DefaultValue; + if (TryGetSerializationMethods<object> (type, out var serializer, out var deserializer)) { + defaultValue = serializer (defaultValue); + type = typeof (object); + } - value = PropertyService.Get (propertyKey, defaultValue); - return true; + // Check for roaming/profile properties + foreach (var keyToCheck in key.GetPropertyNames ()) { + propertyKey = propertyKey ?? keyToCheck; + value = value ?? defaultValue; + if (keyToCheck == null) + continue; + + if (PropertyService.HasValue (keyToCheck)) { + value = PropertyService.GlobalInstance.Get (keyToCheck, defaultValue, type); + return true; + } } - value = default (object); - return false; + return propertyKey != null; } internal bool TryGetUpdater (OptionKey key, out string propertyKey, out Action<object> updater) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices/MonoDevelopDocumentSupportsFeatureService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices/MonoDevelopDocumentSupportsFeatureService.cs new file mode 100644 index 0000000000..b205a6e12a --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices/MonoDevelopDocumentSupportsFeatureService.cs @@ -0,0 +1,50 @@ +// +// MonoDevelopDocumentSupportsFeatureService.cs +// +// Author: +// iain <iaholmes@microsoft.com> +// +// Copyright (c) 2018 Microsoft Corp +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Composition; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Editor.Shared; +using Microsoft.CodeAnalysis.Host.Mef; + +using MonoDevelop.Ide; +using MonoDevelop.Ide.TypeSystem; + +namespace MonoDevelop.Ide.RoslynServices +{ + [ExportWorkspaceService (typeof(IDocumentSupportsFeatureService), ServiceLayer.Host), Shared] + internal sealed class MonoDevelopDocumentSupportsFeatureService : IDocumentSupportsFeatureService + { + public bool SupportsCodeFixes (Document document) => !IsContainedDocument (document); + public bool SupportsNavigationToAnyPosition (Document document) => !IsContainedDocument (document); + public bool SupportsRefactorings (Document document) => !IsContainedDocument (document); + public bool SupportsRename (Document document) => !IsContainedDocument (document); + + static bool IsContainedDocument (Document document) + { + return (MonoDevelopHostDocumentRegistration.FromDocument (document) != null); + } + } +} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs index acb780bc24..7155d9b8cb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs @@ -44,6 +44,8 @@ using MonoDevelop.Ide.Editor; using MonoDevelop.Projects.SharedAssetsProjects; using MonoDevelop.Core.StringParsing; using System.Threading.Tasks; +using MonoDevelop.Core.Text; +using Gtk; namespace MonoDevelop.Ide.Templates { @@ -465,13 +467,14 @@ namespace MonoDevelop.Ide.Templates string mime = DesktopService.GetMimeTypeForUri (fileName); var formatter = !string.IsNullOrEmpty (mime) ? CodeFormatterService.GetFormatter (mime) : null; - + if (formatter != null) { - var formatted = formatter.FormatText (policyParent != null ? policyParent.Policies : null, content); + var document = TextEditorFactory.CreateNewReadonlyDocument (new StringTextSource (content), fileName); + var formatted = formatter.Format (policyParent?.Policies, document); if (formatted != null) - content = formatted; + content = formatted.Text; } - + var ms = new MemoryStream (); Encoding encoding = null; TextStylePolicy textPolicy = policyParent != null ? policyParent.Policies.Get<TextStylePolicy> (mime ?? "text/plain") @@ -502,8 +505,17 @@ namespace MonoDevelop.Ide.Templates byte[] eolMarkerBytes = encoding.GetBytes (eolMarker); - - var tabToSpaces = textPolicy.TabsToSpaces? new string (' ', textPolicy.TabWidth) : null; + bool convertTabsToSpaces = textPolicy.TabsToSpaces; + int tabWidth = textPolicy.TabWidth; + + if (ctx != null) { + if (ctx.CurrentConventions.UniversalConventions.TryGetIndentStyle (out Microsoft.VisualStudio.CodingConventions.IndentStyle result)) + convertTabsToSpaces = result == Microsoft.VisualStudio.CodingConventions.IndentStyle.Spaces; + if (ctx.CurrentConventions.UniversalConventions.TryGetTabWidth (out int editorConfigTabWidth)) + tabWidth = editorConfigTabWidth; + } + var tabToSpaces = convertTabsToSpaces ? new string (' ', tabWidth) : null; + IDocumentLine lastLine = null; foreach (var line in doc.GetLines ()) { var lineText = doc.GetTextAt (line.Offset, line.Length); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopAddMetadataReferenceCodeActionOperationFactoryWorkspaceService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopAddMetadataReferenceCodeActionOperationFactoryWorkspaceService.cs new file mode 100644 index 0000000000..932a0798be --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopAddMetadataReferenceCodeActionOperationFactoryWorkspaceService.cs @@ -0,0 +1,88 @@ +// +// MonoDevelopAddMetadataReferenceCodeActionOperationFactoryWorkspaceService.cs +// +// Author: +// Mike Krüger <mikkrg@microsoft.com> +// +// Copyright (c) 2018 Microsoft Corporation. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Composition; +using System.Threading; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeActions.WorkspaceServices; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.VisualStudio; +using MonoDevelop.Core; +using MonoDevelop.Core.Assemblies; + +namespace MonoDevelop.Ide.TypeSystem +{ + [ExportWorkspaceService (typeof (IAddMetadataReferenceCodeActionOperationFactoryWorkspaceService), ServiceLayer.Host), Shared] + sealed class MonoDevelopAddMetadataReferenceCodeActionOperationFactoryWorkspaceService : IAddMetadataReferenceCodeActionOperationFactoryWorkspaceService + { + public CodeActionOperation CreateAddMetadataReferenceOperation (ProjectId projectId, AssemblyIdentity assemblyIdentity) + { + if (projectId == null) + throw new ArgumentNullException (nameof (projectId)); + if (assemblyIdentity == null) + throw new ArgumentNullException (nameof (assemblyIdentity)); + return new AddMetadataReferenceOperation (projectId, assemblyIdentity); + } + + class AddMetadataReferenceOperation : CodeActionOperation + { + readonly AssemblyIdentity assemblyIdentity; + readonly ProjectId projectId; + + public AddMetadataReferenceOperation (ProjectId projectId, AssemblyIdentity assemblyIdentity) + { + this.projectId = projectId; + this.assemblyIdentity = assemblyIdentity; + } + + public override void Apply (Workspace workspace, CancellationToken cancellationToken = default (CancellationToken)) + { + var mdWorkspace = workspace as MonoDevelopWorkspace; + if (mdWorkspace == null) + return; // no md workspace -> not a common file/ignore. + var mdProject = mdWorkspace.GetMonoProject (projectId) as MonoDevelop.Projects.DotNetProject; + if (mdProject == null) { + LoggingService.LogWarning ("Can't find project " + projectId + " to add reference " + assemblyIdentity.GetDisplayName ()); + return; + } + var newReference = MonoDevelop.Projects.ProjectReference.CreateAssemblyReference (assemblyIdentity.GetDisplayName ()); + foreach (var r in mdProject.References) { + if (r.ReferenceType == newReference.ReferenceType && r.Reference == newReference.Reference) { + LoggingService.LogWarning ("Warning duplicate reference is added " + newReference.Reference); + return; + } + } + + mdProject.References.Add (newReference); + IdeApp.ProjectOperations.SaveAsync (mdProject); + } + + public override string Title => string.Format (GettextCatalog.GetString("Add a reference to '{0}'"), assemblyIdentity.GetDisplayName ()); + } + } +} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs index 2cf0e80233..c97748c5a1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs @@ -172,7 +172,7 @@ namespace MonoDevelop.Ide.TypeSystem // make sure we show info bar only once for the same solution. Options = Options.WithChangedOption (RuntimeOptions.FullSolutionAnalysisInfoBarShown, true); - const string LowVMMoreInfoLink = "http://go.microsoft.com/fwlink/?LinkID=799402&clcid=0x409"; + const string LowVMMoreInfoLink = "https://go.microsoft.com/fwlink/?linkid=2003417&clcid=0x409"; Services.GetService<IErrorReportingService> ().ShowGlobalErrorInfo (
GettextCatalog.GetString ("{0} has suspended some advanced features to improve performance", BrandingService.ApplicationName),
new InfoBarUI ("Learn more", InfoBarUI.UIKind.HyperLink, () => DesktopService.ShowUrl (LowVMMoreInfoLink), closeAfterAction: false), diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index 542873f3cc..6ffdb20e0d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -4126,6 +4126,8 @@ <Compile Include="MonoDevelop.Ide.RoslynServices\MonoDevelopErrorReportingService.cs" /> <Compile Include="MonoDevelop.Ide.RoslynServices\MonoDevelopInfoBarService.cs" /> <Compile Include="MonoDevelop.Ide.Gui.Components\InfoBar.cs" /> + <Compile Include="MonoDevelop.Ide.TypeSystem\MonoDevelopAddMetadataReferenceCodeActionOperationFactoryWorkspaceService.cs" /> + <Compile Include="MonoDevelop.Ide.RoslynServices\MonoDevelopDocumentSupportsFeatureService.cs" /> </ItemGroup> <ItemGroup> <Data Include="options\DefaultEditingLayout.xml" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs index 715de50c75..b8fb472324 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs @@ -190,7 +190,21 @@ namespace MonoDevelop.Ide return Runtime.Version; } } - + + // This flag tells us whether or not the solution being loaded was from the file manager. + static bool reportTimeToCode; + static bool fmTimeoutExpired; + public static bool ReportTimeToCode { + get => reportTimeToCode && !fmTimeoutExpired; + set { + reportTimeToCode = value; + if (fmTimeoutId > 0) { + GLib.Source.Remove (fmTimeoutId); + fmTimeoutId = 0; + } + } + } + public static void Initialize (ProgressMonitor monitor) { // Already done in IdeSetup, but called again since unit tests don't use IdeSetup. @@ -333,7 +347,23 @@ namespace MonoDevelop.Ide { Ide.IdeApp.Workbench.StatusBar.ShowWarning (e.Message); } - + + static readonly uint fmTimeoutMs = 2500; + static uint fmTimeoutId; + internal static void StartFMOpenTimer (Action timeCompletion) + { + // We only track time to code if the reportTimeToCode flag is set within fmTimeoutMs from this method being called + fmTimeoutId = GLib.Timeout.Add (fmTimeoutMs, () => FMOpenTimerExpired (timeCompletion)); + } + + static bool FMOpenTimerExpired (Action timeCompletion) + { + fmTimeoutExpired = true; + fmTimeoutId = 0; + timeCompletion (); + return false; + } + //this method is MIT/X11, 2009, Michael Hutchinson / (c) Novell public static void OpenFiles (IEnumerable<FileOpenInformation> files) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs index cfc800f36e..1b08071603 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs @@ -64,10 +64,13 @@ namespace MonoDevelop.Ide public class IdeStartup: IApplication { Socket listen_socket = null; - ArrayList errorsList = new ArrayList (); + List<AddinError> errorsList = new List<AddinError> (); bool initialized; static readonly int ipcBasePort = 40000; static Stopwatch startupTimer = new Stopwatch (); + static Stopwatch timeToCodeTimer = new Stopwatch (); + + static TimeToCodeMetadata ttcMetadata; Task<int> IApplication.Run (string[] args) { @@ -233,7 +236,6 @@ namespace MonoDevelop.Ide Counters.Initialization.Trace ("Loading Icons"); //force initialisation before the workbench so that it can register stock icons for GTK before they get requested ImageService.Initialize (); - LocalizationService.Initialize (); // If we display an error dialog before the main workbench window on OS X then a second application menu is created // which is then replaced with a second empty Apple menu. @@ -242,7 +244,7 @@ namespace MonoDevelop.Ide IdeApp.Initialize (monitor); if (errorsList.Count > 0) { - using (AddinLoadErrorDialog dlg = new AddinLoadErrorDialog ((AddinError[]) errorsList.ToArray (typeof(AddinError)), false)) { + using (AddinLoadErrorDialog dlg = new AddinLoadErrorDialog (errorsList.ToArray (), false)) { if (!dlg.Run ()) return 1; } @@ -285,7 +287,7 @@ namespace MonoDevelop.Ide } if (errorsList.Count > reportedFailures) { - using (AddinLoadErrorDialog dlg = new AddinLoadErrorDialog ((AddinError[]) errorsList.ToArray (typeof(AddinError)), true)) + using (AddinLoadErrorDialog dlg = new AddinLoadErrorDialog (errorsList.ToArray (), true)) dlg.Run (); } @@ -314,6 +316,16 @@ namespace MonoDevelop.Ide startupTimer.Stop (); + // Need to start this timer because we don't know yet if we've been asked to open a solution from the file manager. + timeToCodeTimer.Start (); + ttcMetadata = new TimeToCodeMetadata { + StartupTime = startupTimer.ElapsedMilliseconds + }; + + // Start this timer to limit the time to decide if the app was opened by a file manager + IdeApp.StartFMOpenTimer (FMOpenTimerExpired); + IdeApp.Workspace.FirstWorkspaceItemOpened += CompleteTimeToCode; + CreateStartupMetadata (startupInfo); GLib.Idle.Add (OnIdle); @@ -336,6 +348,14 @@ namespace MonoDevelop.Ide return 0; } + void FMOpenTimerExpired () + { + IdeApp.Workspace.FirstWorkspaceItemOpened -= CompleteTimeToCode; + timeToCodeTimer.Stop (); + timeToCodeTimer = null; + ttcMetadata = null; + } + /// <summary> /// Resolves MSBuild 15.0 assemblies that are used by MonoDevelop.Ide and are included with Mono. /// </summary> @@ -390,6 +410,27 @@ namespace MonoDevelop.Ide IdeApp.OnStartupCompleted (); } + static void CompleteTimeToCode (object sender, EventArgs args) + { + IdeApp.Workspace.FirstWorkspaceItemOpened -= CompleteTimeToCode; + + if (timeToCodeTimer == null) { + return; + } + + timeToCodeTimer.Stop (); + ttcMetadata.SolutionLoadTime = timeToCodeTimer.ElapsedMilliseconds; + + ttcMetadata.CorrectedDuration = ttcMetadata.StartupTime + ttcMetadata.SolutionLoadTime; + + timeToCodeTimer = null; + + if (IdeApp.ReportTimeToCode) { + Counters.TimeToCode.Inc ("SolutionLoaded", ttcMetadata); + IdeApp.ReportTimeToCode = false; + } + } + static DateTime lastIdle; static bool lockupCheckRunning = true; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/LocalizationService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/LocalizationService.cs index 433129c775..7b9d0f890d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/LocalizationService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/LocalizationService.cs @@ -37,7 +37,7 @@ namespace MonoDevelop.Ide const string path = "/MonoDevelop/Ide/LocaleSet";
static readonly List<LocaleSet[]> locales = new List<LocaleSet[]> ();
- internal static void Initialize ()
+ static LocalizationService ()
{
AddinManager.AddExtensionNodeHandler (path, OnExtensionChanged);
Array.Sort (defaultLocaleSet, (x, y) => x.DisplayName.CompareTo (y.DisplayName));
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs index ee863ce281..b4d4f2e968 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs @@ -1075,6 +1075,11 @@ namespace MonoDevelop.Ide async Task ExecuteAsync (IBuildTarget entry, ExecutionContext context, CancellationTokenSource cs, ConfigurationSelector configuration, RunConfiguration runConfiguration, bool buildBeforeExecuting) { + var metadata = new CounterMetadata (); + metadata.SetSuccess (); + Counters.BuildAndDeploy.BeginTiming ("Execute", metadata); + Counters.TrackingBuildAndDeploy = true; + if (configuration == null) configuration = IdeApp.Workspace.ActiveConfiguration; @@ -1082,14 +1087,22 @@ namespace MonoDevelop.Ide var rt = entry as IRunTarget; if (bth != null && rt != null) { var h = await bth.Configure (rt, context, configuration, runConfiguration); - if (h == null) + if (h == null) { + metadata.SetFailure (); + Counters.TrackingBuildAndDeploy = false; + Counters.BuildAndDeploy.EndTiming (); return; + } context = new ExecutionContext (h, context.ConsoleFactory, context.ExecutionTarget); } if (buildBeforeExecuting) { - if (!await CheckAndBuildForExecute (entry, context, configuration, runConfiguration)) + if (!await CheckAndBuildForExecute (entry, context, configuration, runConfiguration)) { + metadata.SetFailure (); + Counters.TrackingBuildAndDeploy = false; + Counters.BuildAndDeploy.EndTiming (); return; + } } ProgressMonitor monitor = new ProgressMonitor (cs); @@ -1103,8 +1116,12 @@ namespace MonoDevelop.Ide await t; var error = monitor.Errors.FirstOrDefault (); - if (error != null) + if (error != null) { IdeApp.Workbench.StatusBar.ShowError (error.DisplayMessage); + metadata.SetFailure (); + Counters.TrackingBuildAndDeploy = false; + Counters.BuildAndDeploy.EndTiming (); + } currentRunOperationOwners.Remove (entry); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs index 0999db44bc..d50d1a1e1f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs @@ -532,11 +532,13 @@ namespace MonoDevelop.Ide IdeApp.Workbench.LockGui (); metadata = GetOpenWorkspaceItemMetadata (metadata); ITimeTracker timer = Counters.OpenWorkspaceItemTimer.BeginTiming (metadata); + try { var oper = BackgroundLoadWorkspace (monitor, file, loadPreferences, reloading, metadata, timer); return await oper; } finally { timer.End (); + monitor.Dispose (); IdeApp.Workbench.UnlockGui (); } @@ -880,7 +882,7 @@ namespace MonoDevelop.Ide } if (entry is SolutionFolder) { - ArrayList ens = new ArrayList (); + var ens = new List<SolutionFolderItem> (); foreach (SolutionFolderItem ce in ((SolutionFolder)entry).Items) ens.Add (ce); foreach (SolutionFolderItem ce in ens) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Services.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Services.cs index 6bc3773c76..2ee515bea0 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Services.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Services.cs @@ -65,6 +65,10 @@ namespace MonoDevelop.Ide internal static TimerCounter CompositionSave = InstrumentationService.CreateTimerCounter ("MEF Composition Save", "IDE", id: "Ide.CompositionSave"); internal static TimerCounter ProcessCodeCompletion = InstrumentationService.CreateTimerCounter ("Process Code Completion", "IDE", id: "Ide.ProcessCodeCompletion", logMessages:false); internal static Counter CodeCompletionStats = InstrumentationService.CreateCounter ("Code Completion Statistics", "IDE", id:"Ide.CodeCompletionStatistics"); + internal static Counter<TimeToCodeMetadata> TimeToCode = InstrumentationService.CreateCounter<TimeToCodeMetadata> ("Time To Code", "IDE", id: "Ide.TimeToCode"); + + internal static bool TrackingBuildAndDeploy; + internal static TimerCounter<CounterMetadata> BuildAndDeploy = InstrumentationService.CreateTimerCounter<CounterMetadata> ("Build and Deploy", "IDE", id: "Ide.BuildAndDeploy"); internal static class ParserService { public static TimerCounter FileParsed = InstrumentationService.CreateTimerCounter ("File parsed", "Parser Service"); @@ -137,5 +141,23 @@ namespace MonoDevelop.Ide set => SetProperty (value); } } + + class TimeToCodeMetadata : CounterMetadata + { + public long CorrectedDuration { + get => GetProperty<long> (); + set => SetProperty (value); + } + + public long StartupTime { + get => GetProperty<long> (); + set => SetProperty (value); + } + + public long SolutionLoadTime { + get => GetProperty<long> (); + set => SetProperty (value); + } + } } diff --git a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs index 84a1e188b3..32dbcb1a0c 100644 --- a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs +++ b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs @@ -212,6 +212,16 @@ namespace Mono.TextEditor.Tests TestOutput ("$\"{foo}\"", "<span foreground=\"#e5da73\">$\"{</span><span foreground=\"#eeeeec\">foo</span><span foreground=\"#e5da73\">}\"</span>"); } - + [Test] + public void ParseFileTypeTest () + { + Assert.AreEqual ("xml", SyntaxHighlightingService.ParseFileType ("\"xml\"")); + Assert.AreEqual ("xml", SyntaxHighlightingService.ParseFileType ("\".xml\"")); + Assert.AreEqual ("xml", SyntaxHighlightingService.ParseFileType ("\"xml\",")); + Assert.AreEqual ("xml", SyntaxHighlightingService.ParseFileType ("\".xml\",")); + Assert.IsTrue (string.IsNullOrEmpty (SyntaxHighlightingService.ParseFileType ("\"\","))); + Assert.IsTrue (string.IsNullOrEmpty (SyntaxHighlightingService.ParseFileType ("\".\","))); + Assert.IsTrue (string.IsNullOrEmpty (SyntaxHighlightingService.ParseFileType ("}"))); + } } } diff --git a/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/DocumentReloadTests.cs b/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/DocumentReloadTests.cs new file mode 100644 index 0000000000..c0ae4b5e97 --- /dev/null +++ b/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/DocumentReloadTests.cs @@ -0,0 +1,99 @@ +// +// DocumentReloadTests.cs +// +// Author: +// Matt Ward <matt.ward@microsoft.com> +// +// Copyright (c) 2018 Microsoft +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using MonoDevelop.Core;
+using MonoDevelop.Core.Text; +using MonoDevelop.Ide.Gui; +using NUnit.Framework; + +namespace MonoDevelop.Ide.Editor +{ + [TestFixture] + public class DocumentReloadTests : IdeTestBase + { + [Test] + public async Task Refactor_RenameClassNameAndFileName_ShouldNotPromptToReload () + { + FilePath directory = UnitTests.Util.CreateTmpDir ("FileRenameShouldNotPromptToReload"); + FilePath fileName = directory.Combine ("test.cs"); + File.WriteAllText (fileName, "class Test {}"); + + var window = new TestWorkbenchWindow (); + var content = new TestViewContentWithDocumentReloadPresenter (); + window.ViewContent = content; + var doc = new Document (window); + + using (var testCase = new TextEditorExtensionTestCase (doc, content, window, null, false)) { + content.Document = doc; + await content.Load (fileName); + + bool reloadWarningDisplayed = false; + content.OnShowFileChangeWarning = multiple => { + reloadWarningDisplayed = true; + }; + doc.Editor.Text = "class rename {}"; + doc.IsDirty = true; // Refactor leaves file unsaved in text editor. + FilePath newFileName = fileName.ChangeName ("renamed"); + FileService.RenameFile (fileName, newFileName); + // Simulate DefaultWorkbench which updates the view content name when the FileService + // fires the rename event. + content.ContentName = newFileName; + FileService.NotifyFileChanged (newFileName); + + Assert.IsFalse (reloadWarningDisplayed); + } + } + + class TestViewContentWithDocumentReloadPresenter : TestViewContent, IDocumentReloadPresenter + { + public Document Document { get; set; } + + public void RemoveMessageBar () + { + } + + public Action<bool> OnShowFileChangeWarning = multiple => { }; + + public void ShowFileChangedWarning (bool multiple) + { + OnShowFileChangeWarning (multiple); + } + + public override Task Load (FileOpenInformation fileOpenInformation) + { + var fileName = fileOpenInformation.FileName; + string text = text = TextFileUtility.ReadAllText (fileName, out Encoding encoding); + Document.Editor.Text = text; + ContentName = fileName; + return Task.FromResult (true); + } + } + } +} diff --git a/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/RegexTests.cs b/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/RegexTests.cs index 5f55130106..27d9bba5a4 100644 --- a/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/RegexTests.cs +++ b/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/RegexTests.cs @@ -89,10 +89,20 @@ namespace MonoDevelop.Ide.Editor var editor = TextEditorFactory.CreateNewEditor (); editor.Text = "// FooBar\nusing System;"; - var r = new Regex ("^\\s*(using)\\s+([^ ;]*);"); + var r = new Regex ("^\\s*(using)\\s+([^ ;]*);", RegexOptions.Multiline); var line = editor.GetLine (2); var match = r.Match (editor.Text, line.Offset, line.Length); Assert.IsTrue (match.Success); } + + // Bug 595108: [Feedback] VS for MAC 7.4 and 7.5 preview: javascript syntax highlighting breaks when passing parameter to a function + [Test] + public void TestVSTS595108 () + { + var regex = new MonoDevelop.Ide.Editor.Highlighting.RegexEngine.Regex ("(?=^)"); + var input = "// test"; + var match = regex.Match (input, 2, input.Length - 2); + Assert.AreEqual (false, match.Success); + } } }
\ No newline at end of file diff --git a/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/SyntaxHighlightingTest_TextMate.cs b/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/SyntaxHighlightingTest_TextMate.cs index 4f67e5e78e..f1f582fece 100644 --- a/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/SyntaxHighlightingTest_TextMate.cs +++ b/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/SyntaxHighlightingTest_TextMate.cs @@ -143,5 +143,32 @@ test ""f\t"" this bar var h = TextMateFormat.ReadHighlighting (new MemoryStream (Encoding.UTF8.GetBytes (highlighting))); SyntaxHighlightingTest.RunHighlightingTest (h, test); } + + [Test] + public void TestTryScanJSonStyle () + { + using (var stream = new MemoryStream ()) + using (var writer = new StreamWriter (stream)) { + writer.Write (@"{ + ""information_for_contributors"": [ + ""This file has been converted from https://github.com/Microsoft/TypeScript-TmLanguage/blob/master/TypeScript.tmLanguage"", + ""If you want to provide a fix or improvement, please create a pull request against the original repository."", + ""Once accepted there, we are happy to receive an update request."" + ], + ""version"": ""https://github.com/Microsoft/TypeScript-TmLanguage/commit/7bf8960f7042474b10b519f39339fc527907ce16"", + ""name"": ""TypeScript"", + ""scopeName"": ""source.ts"", + ""fileTypes"": [ + ""ts"" + ],"); + writer.Flush (); + stream.Position = 0; + bool result = SyntaxHighlightingService.TryScanJSonStyle (stream, out var name, out var format, out var fileTypes, out var scopeName); + Assert.AreEqual (true, result); + Assert.AreEqual ("TypeScript", name); + Assert.AreEqual ("source.ts", scopeName); + Assert.True (fileTypes.Contains ("ts")); + } + } } } diff --git a/main/tests/Ide.Tests/MonoDevelop.Ide.RoslynServices.Options/MonoDevelopOptionPersisterTests.cs b/main/tests/Ide.Tests/MonoDevelop.Ide.RoslynServices.Options/MonoDevelopOptionPersisterTests.cs index d69eddb76a..01ff34b10c 100644 --- a/main/tests/Ide.Tests/MonoDevelop.Ide.RoslynServices.Options/MonoDevelopOptionPersisterTests.cs +++ b/main/tests/Ide.Tests/MonoDevelop.Ide.RoslynServices.Options/MonoDevelopOptionPersisterTests.cs @@ -63,8 +63,10 @@ namespace MonoDevelop.Ide.RoslynServices.Options // Serialized value is transformed. public static SerializationTestCase Ok<T> (T value, object serializedValue) => new SerializationTestCaseT<T> (value, serializedValue, true, typeof (T)); + public static SerializationTestCase Fail<T> (T value, object serializedValue) => new SerializationTestCaseT<T> (value, serializedValue, false, typeof (T)); + // It fails, whatever happens. - public static SerializationTestCase Fail<T> (object value, object serializedValue) => new SerializationTestCaseT<T> (value, serializedValue, false, typeof (T)); + public static SerializationTestCase Fail<T> (object serializedValue) => new SerializationTestCaseT<T> (null, serializedValue, false, typeof (T)); public string Feature => "feature"; public string Name => "name"; @@ -109,7 +111,7 @@ namespace MonoDevelop.Ide.RoslynServices.Options SerializationTestCase.Ok (stringOption, stringOption.ToXElement ().ToString ()), SerializationTestCase.Ok (namingOption, namingOption.CreateXElement ().ToString ()), SerializationTestCase.Ok ("string"), - SerializationTestCase.Fail<CodeStyleOption<MyCustomClass>> (classOption, stringOption.ToXElement ().ToString ()), + SerializationTestCase.Fail (classOption, stringOption.ToXElement ().ToString ()), }; [TestCaseSource (nameof (SerializationTestCases))] @@ -138,19 +140,28 @@ namespace MonoDevelop.Ide.RoslynServices.Options } SerializationTestCase [] DeserializationTestCases = { - SerializationTestCase.Ok(true, 3), - SerializationTestCase.Ok(true, 2L), - SerializationTestCase.Ok(false, 0), - SerializationTestCase.Ok(false, 0L), - SerializationTestCase.Ok<bool?>(true, true), - SerializationTestCase.Ok<bool?>(false, false), + // Simple types + SerializationTestCase.Ok(true, "True"), + SerializationTestCase.Ok(false, "False"), + SerializationTestCase.Ok<bool?>(true, "True"), + SerializationTestCase.Ok<bool?>(false, "False"), SerializationTestCase.Ok<bool?>(null, null), - SerializationTestCase.Fail<PlatformID> (-1, 1.0), - SerializationTestCase.Fail<PlatformID> (-1, ulong.MaxValue), + SerializationTestCase.Ok<string>("test", "test"), + SerializationTestCase.Ok(1, "1"), + SerializationTestCase.Ok(1L, "1"), + SerializationTestCase.Ok(1U, "1"), + SerializationTestCase.Ok(1D, "1"), + SerializationTestCase.Ok(1F, "1"), + SerializationTestCase.Ok(ExpressionBodyPreference.Never, "Never"), + SerializationTestCase.Ok<int?>(1, "1"), + SerializationTestCase.Fail<bool>(0), + SerializationTestCase.Fail<bool>(0L), + SerializationTestCase.Fail<ExpressionBodyPreference> (1.0), + SerializationTestCase.Fail<ExpressionBodyPreference> (ulong.MaxValue), SerializationTestCase.Ok(namingOption, namingOption.CreateXElement ().ToString()), SerializationTestCase.Ok(boolOption, boolOption.ToXElement ().ToString()), SerializationTestCase.Ok(enumOption, enumOption.ToXElement ().ToString()), - SerializationTestCase.Fail<CodeStyleOption<MyCustomClass>>(classOption, stringOption.ToXElement ().ToString()), + SerializationTestCase.Fail<CodeStyleOption<MyCustomClass>>(stringOption.ToXElement ().ToString()), }; [TestCaseSource (nameof (DeserializationTestCases))] @@ -164,13 +175,9 @@ namespace MonoDevelop.Ide.RoslynServices.Options // Set the value and deserialize it PropertyService.Set (property, testCase.SerializedValue); - Assert.AreEqual (testCase.Success, persister.TryFetch (optionKey, out var deserialized)); - if (!testCase.Success) { - Assert.IsNull (deserialized); - return; - } - - Assert.AreEqual (testCase.Value, deserialized); + var success = persister.TryFetch (optionKey, out var deserialized); + Assert.AreEqual (testCase.Success, success); + Assert.AreEqual (testCase.Value, deserialized, $"Could not convert {testCase.SerializedValue} to {testCase.Value}"); } } diff --git a/main/tests/Ide.Tests/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferencesTests.cs b/main/tests/Ide.Tests/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferencesTests.cs index afe112b1b1..ce341a3800 100644 --- a/main/tests/Ide.Tests/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferencesTests.cs +++ b/main/tests/Ide.Tests/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferencesTests.cs @@ -24,6 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; +using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Options; using MonoDevelop.Core; @@ -55,5 +56,25 @@ namespace MonoDevelop.Ide.RoslynServices.Options Assert.AreEqual (false, prop.Value); } } + + [Test] + public void TestRoslynPropertyWithMultipleKeys () + { + var (preferences, persister) = Setup (); + + var option = new PerLanguageOption<bool> ("test", "name", false, new RoamingProfileStorageLocation ("feature.%LANGUAGE%.test"), new RoamingProfileStorageLocation ("feature.test")); + var optionKey = new OptionKey (option, LanguageNames.CSharp); + + var propertyNames = optionKey.GetPropertyNames ().ToArray (); + Assert.AreEqual (2, propertyNames.Length); + Assert.AreEqual ("feature.CSharp.test", propertyNames [0]); + Assert.AreEqual ("feature.test", propertyNames [1]); + + PropertyService.Set (propertyNames [1], true); + + var success = persister.TryFetch (optionKey, out object value); + Assert.AreEqual (true, success); + Assert.AreEqual (true, value); + } } } diff --git a/main/tests/Ide.Tests/MonoDevelop.Ide.Tests.csproj b/main/tests/Ide.Tests/MonoDevelop.Ide.Tests.csproj index 2e54fa76bd..25946f699a 100644 --- a/main/tests/Ide.Tests/MonoDevelop.Ide.Tests.csproj +++ b/main/tests/Ide.Tests/MonoDevelop.Ide.Tests.csproj @@ -126,6 +126,7 @@ <Compile Include="MonoDevelop.Ide.RoslynServices.Options\MonoDevelopOptionPersisterTests.cs" /> <Compile Include="TypeForwarders.cs" /> <Compile Include="MonoDevelop.Ide.RoslynServices\ExportedServicesAndWorkspaceServicesTests.cs" /> + <Compile Include="MonoDevelop.Ide.Editor\DocumentReloadTests.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\src\core\MonoDevelop.Ide\MonoDevelop.Ide.csproj"> diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core.Tests.csproj b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core.Tests.csproj index db7d4cb357..1ae671fb85 100644 --- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core.Tests.csproj +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core.Tests.csproj @@ -109,6 +109,8 @@ <Compile Include="MonoDevelop.Projects\DotNetCoreFileWatcherTests.cs" /> <Compile Include="MonoDevelop.Projects\FileWatcherTests.cs" /> <Compile Include="MonoDevelop.Core\InstrumentationTests.cs" /> + <Compile Include="MonoDevelop.FSW\PathTreeNodeTests.cs" /> + <Compile Include="MonoDevelop.FSW\PathTreeTests.cs" /> </ItemGroup> <ItemGroup> </ItemGroup> @@ -140,5 +142,8 @@ <ItemGroup> <None Include="packages.config" /> </ItemGroup> + <ItemGroup> + <Folder Include="MonoDevelop.FSW\" /> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core/InstrumentationTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core/InstrumentationTests.cs index 4cf3499fc8..a65b324898 100644 --- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core/InstrumentationTests.cs +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core/InstrumentationTests.cs @@ -211,5 +211,13 @@ namespace MonoDevelop.Core Assert.IsNull (value.Metadata); } + + [Test] + public void CounterMetadataQueryingDoesNotCrash () + { + var metadata = new CustomCounterMetadata (); + + Assert.AreEqual (default (int), metadata.SomeMeasure); + } } } diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.FSW/PathTreeNodeTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.FSW/PathTreeNodeTests.cs new file mode 100644 index 0000000000..05f3d08c37 --- /dev/null +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.FSW/PathTreeNodeTests.cs @@ -0,0 +1,103 @@ +// +// PathTreeNodeTests.cs +// +// Author: +// Marius Ungureanu <maungu@microsoft.com> +// +// Copyright (c) 2018 Microsoft Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using MonoDevelop.Core; +using NUnit.Framework; + +namespace MonoDevelop.FSW +{ + [TestFixture] + public class PathTreeNodeTests + { + string [] seps = { + "", + Path.DirectorySeparatorChar.ToString(), + }; + + static readonly string prefix = Platform.IsWindows ? "C:\\" : "/"; + static string MakePath (params string [] segments) => Path.Combine (prefix, Path.Combine (segments)); + + [TestCaseSource (nameof (seps))] + public void CreateSubTree (string sep) + { + var path = MakePath ("a", "b", "c") + sep; + + var (first, leaf) = PathTreeNode.CreateSubTree (path, 0); + + PathTreeNode a; + if (Platform.IsWindows) { + AssertPathTreeSubtree (first, "C:"); + Assert.AreEqual (1, first.ChildrenCount); + + a = first.FirstChild; + Assert.AreSame (first, a.Parent); + } else { + a = first; + } + + AssertPathTreeSubtree (a, "a"); + Assert.AreEqual (1, a.ChildrenCount); + + var b = a.FirstChild; + Assert.AreSame (a, b.Parent); + AssertPathTreeSubtree (b, "b"); + Assert.AreEqual (1, b.ChildrenCount); + + var c = b.FirstChild; + Assert.AreSame (b, c.Parent); + AssertPathTreeSubtree (c, "c"); + Assert.AreEqual (0, c.ChildrenCount); + Assert.AreSame (c, leaf); + + Assert.IsNull (c.FirstChild); + + void AssertPathTreeSubtree (PathTreeNode node, string segment) + { + Assert.AreEqual (segment, node.Segment); + Assert.IsNull (node.Next); + Assert.AreSame (node.FirstChild, node.LastChild); + } + } + + [TestCase (0)] + [TestCase (1)] // Should not crash + public void EmptySubTrie (int startIndex) + { + var (node, leaf) = PathTreeNode.CreateSubTree (string.Empty, startIndex); + Assert.IsNull (node); + Assert.IsNull (leaf); + } + + [Test] + public void JustSlash () + { + var (node, leaf) = PathTreeNode.CreateSubTree (Path.DirectorySeparatorChar.ToString (), 0); + Assert.IsNull (node); + Assert.IsNull (leaf); + } + } +} diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.FSW/PathTreeTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.FSW/PathTreeTests.cs new file mode 100644 index 0000000000..7595a1e0a0 --- /dev/null +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.FSW/PathTreeTests.cs @@ -0,0 +1,495 @@ +// +// PathTreeTests.cs +// +// Author: +// Marius Ungureanu <maungu@microsoft.com> +// +// Copyright (c) 2018 Microsoft Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using System.Linq; +using MonoDevelop.Core; +using NUnit.Framework; + +namespace MonoDevelop.FSW +{ + [TestFixture] + public class PathTreeTests + { + static object id = new object (); + + [Test] + public void CreateEmptyTree () + { + var tree = new PathTree (); + var node = tree.rootNode; + + if (!Platform.IsWindows) { + node = node.FirstChild; + Assert.AreEqual ("/", node.FullPath); + } + + Assert.IsNull (node.FirstChild); + Assert.IsNull (node.LastChild); + Assert.IsNull (node.Next); + } + + + static readonly string prefix = Platform.IsWindows ? "C:\\" : "/"; + static string MakePath (params string [] segments) => Path.Combine (prefix, Path.Combine (segments)); + + static PathTree CreateTree () + { + var tree = new PathTree (); + + // a + // + b + // + c + // + d + // + e + // + f + // + f1 + // + f2 + // + g + // + g1 + // + g2 + tree.AddNode (MakePath ("a", "b", "g", "g1"), id); + tree.AddNode (MakePath ("a", "b", "g"), id); + tree.AddNode (MakePath ("a", "b", "c"), id); + tree.AddNode (MakePath ("a", "b", "e"), id); + tree.AddNode (MakePath ("a", "b", "d"), id); + tree.AddNode (MakePath ("a", "b", "f"), id); + tree.AddNode (MakePath ("a", "b", "f", "f1"), id); + tree.AddNode (MakePath ("a", "b", "f", "f2"), id); + tree.AddNode (MakePath ("a", "b", "g", "g2"), id); + + return tree; + } + + [Test] + public void CreateSimpleTree () + { + var tree = CreateTree (); + + PathTreeNode root, pathRoot, a, b, c, d, e, f, f1, f2, g, g1, g2, x, y, z; + + root = tree.rootNode; + pathRoot = root.FirstChild; + a = pathRoot.FirstChild; + b = a.FirstChild; + c = b.FirstChild; + d = c.Next; + e = d.Next; + f = e.Next; + f1 = f.FirstChild; + f2 = f1.Next; + g = f.Next; + g1 = g.FirstChild; + g2 = g1.Next; + + Assert.AreEqual (1, root.ChildrenCount); + Assert.AreSame (pathRoot, root.FirstChild); + + // rootNode -> a + Assert.AreEqual (nameof (a), a.Segment); + Assert.IsNull (a.Next); + Assert.AreSame (a, pathRoot.LastChild); + Assert.AreEqual (1, pathRoot.ChildrenCount); + Assert.IsNull (a.Previous); + Assert.AreSame (pathRoot, a.Parent); + + // a -> b + Assert.AreEqual (nameof (b), b.Segment); + Assert.AreSame (a.LastChild, b); + Assert.IsNull (b.Next); + Assert.AreEqual (1, a.ChildrenCount); + Assert.AreSame (a, b.Parent); + + // b -> c, d, e, f, g + Assert.AreEqual (nameof (c), c.Segment); + Assert.AreEqual (nameof (d), d.Segment); + Assert.AreEqual (nameof (e), e.Segment); + Assert.AreEqual (nameof (f), f.Segment); + Assert.AreEqual (nameof (g), g.Segment); + Assert.AreSame (b, c.Parent); + Assert.AreSame (b, d.Parent); + Assert.AreSame (b, e.Parent); + Assert.AreSame (b, f.Parent); + Assert.AreSame (b, g.Parent); + Assert.AreEqual (5, b.ChildrenCount); + + Assert.AreSame (b.LastChild, g); + + // c, d, e + Assert.IsNull (c.FirstChild); + Assert.AreEqual (0, c.ChildrenCount); + Assert.IsNull (d.FirstChild); + Assert.AreEqual (0, d.ChildrenCount); + Assert.IsNull (e.FirstChild); + Assert.AreEqual (0, e.ChildrenCount); + Assert.IsNull (g.Next); + + // f -> f1, f2 + Assert.AreSame (f2, f.LastChild); + Assert.AreEqual (nameof (f1), f1.Segment); + Assert.AreEqual (nameof (f2), f2.Segment); + Assert.AreEqual (2, f.ChildrenCount); + Assert.AreEqual (0, f1.ChildrenCount); + Assert.AreEqual (0, f2.ChildrenCount); + Assert.AreSame (f, f1.Parent); + Assert.AreSame (f, f2.Parent); + + Assert.IsNull (f1.Previous); + Assert.AreSame (f1, f2.Previous); + Assert.AreSame (f2, f1.Next); + Assert.IsNull (f2.Next); + + // g -> g1, g2 + Assert.AreEqual (nameof (g1), g1.Segment); + Assert.AreEqual (nameof (g2), g2.Segment); + Assert.AreSame (g2, g.LastChild); + Assert.AreEqual (2, g.ChildrenCount); + Assert.AreEqual (0, g1.ChildrenCount); + Assert.AreEqual (0, g2.ChildrenCount); + + Assert.AreSame (g, g1.Parent); + Assert.AreSame (g, g2.Parent); + + Assert.IsNull (g1.Previous); + Assert.AreSame (g1, g2.Previous); + Assert.AreSame (g2, g1.Next); + Assert.IsNull (g2.Next); + // a + // ... + // z + // + y + // + x + + tree.AddNode (MakePath ("z", "y", "x"), id); + + z = a.Next; + y = z.FirstChild; + x = y.FirstChild; + + // root -> z + Assert.AreEqual (nameof (z), z.Segment); + Assert.AreSame (z, pathRoot.LastChild); + Assert.AreSame (a.Next, z); + Assert.AreEqual (2, pathRoot.ChildrenCount); + Assert.IsNull (z.Next); + + // z -> y + Assert.AreEqual (nameof (z), z.Segment); + Assert.AreSame (y, z.LastChild); + Assert.AreEqual (1, z.ChildrenCount); + Assert.IsNull (y.Next); + + // y -> x + Assert.AreEqual (nameof (x), x.Segment); + Assert.AreEqual (1, y.ChildrenCount); + Assert.IsNull (x.FirstChild); + Assert.IsNull (x.LastChild); + Assert.IsNull (x.Next); + } + + [Test] + public void AssertSameNodeIsReturned () + { + var tree = new PathTree (); + + var b = tree.AddNode (MakePath ("a", "b"), id); + + var firstA = tree.FindNode (MakePath ("a")); + var newA = tree.AddNode (MakePath ("a"), id); + + Assert.AreSame (firstA, newA); + Assert.AreSame (b, firstA.FirstChild); + Assert.AreSame (b, firstA.LastChild); + } + + [Test] + public void AssertNodeRemoved () + { + var tree = CreateTree (); + + var b = tree.FindNode (MakePath ("a", "b")); + Assert.AreEqual (nameof (b), b.Segment); + + // b -> c + var c = b.FirstChild; + Assert.AreEqual (nameof (c), c.Segment); + + // Remove first + var c2 = tree.RemoveNode (MakePath ("a", "b", "c"), id); + Assert.AreSame (c, c2); + + Assert.IsNull (tree.FindNode (MakePath ("a", "b", "c"))); + + // b -> d + var d = b.FirstChild; + Assert.AreNotSame (c, d); + Assert.AreEqual (nameof (d), d.Segment); + + // b -> g + var g = b.LastChild; + Assert.AreEqual (nameof (g), g.Segment); + + // Remove g + var gRemoved = tree.RemoveNode (MakePath ("a", "b", "g"), id); + Assert.AreSame (g, gRemoved); + + Assert.IsNotNull (tree.FindNode (MakePath ("a", "b", "g"))); + Assert.IsFalse (gRemoved.IsLive); + + var g1 = tree.FindNode (MakePath ("a", "b", "g", "g1")); + Assert.IsNotNull (g1); + Assert.IsTrue (g1.IsLive); + + var g2 = tree.FindNode (MakePath ("a", "b", "g", "g2")); + Assert.IsNotNull (g2); + Assert.IsTrue (g2.IsLive); + + // Remove g1 + var g1Removed = tree.RemoveNode (MakePath ("a", "b", "g", "g1"), id); + Assert.AreSame (g1, g1Removed); + + Assert.IsNull (tree.FindNode (MakePath ("a", "b", "g", "g1"))); + Assert.AreSame (g2, g.FirstChild); + + // Remove g2 + var g2Removed = tree.RemoveNode (MakePath ("a", "b", "g", "g2"), id); + Assert.AreSame (g2, g2Removed); + + Assert.IsNull (tree.FindNode (MakePath ("a", "b", "g", "g2"))); + Assert.IsNull (tree.FindNode (MakePath ("a", "b", "g"))); + + // b -> f + var f = b.LastChild; + Assert.AreEqual (nameof (f), f.Segment); + + // Remove middle + var e = tree.FindNode (MakePath ("a", "b", "e")); + Assert.IsNotNull (e); + + var e2 = tree.RemoveNode (MakePath ("a", "b", "e"), id); + Assert.AreSame (e, e2); + + Assert.IsNull (tree.FindNode (MakePath ("a", "b", "e"))); + + Assert.AreSame (d, b.FirstChild); + Assert.AreSame (f, b.LastChild); + Assert.AreSame (f, d.Next); + } + + [Test] + public void AssertNodeNotRemovedWithMultipleRegistrations () + { + var tree = CreateTree (); + + var c = tree.FindNode (MakePath ("a", "b", "c")); + Assert.AreEqual (nameof (c), c.Segment); + + var newId = new object (); + + var c2 = tree.AddNode (MakePath ("a", "b", "c"), newId); + Assert.AreSame (c, c2); + Assert.IsNotNull (c2); + + var c3 = tree.RemoveNode (MakePath ("a", "b", "c"), id); + Assert.AreSame (c2, c3); + Assert.IsNotNull (c3); + + var c4 = tree.FindNode (MakePath ("a", "b", "c")); + Assert.AreSame (c3, c4); + Assert.IsNotNull (c4); + + var c5 = tree.RemoveNode (MakePath ("a", "b", "c"), newId); + Assert.AreSame (c4, c5); + Assert.IsNotNull (c5); + + var cRemoved = tree.FindNode (MakePath ("a", "b", "c")); + Assert.IsNull (cRemoved); + } + + [Test] + public void Normalize () + { + var tree = CreateTree (); + + var nodes = tree.Normalize (1).ToArray (); + Assert.AreEqual (1, nodes.Length); + Assert.AreEqual ("b", nodes [0].Segment); + + nodes = tree.Normalize (2).ToArray (); + Assert.AreEqual (1, nodes.Length); + Assert.AreEqual ("b", nodes [0].Segment); + + nodes = tree.Normalize (3).ToArray (); + Assert.AreEqual (1, nodes.Length); + Assert.AreEqual ("b", nodes [0].Segment); + + nodes = tree.Normalize (4).ToArray (); + Assert.AreEqual (1, nodes.Length); + Assert.AreEqual ("b", nodes [0].Segment); + + // b has 5 children + nodes = tree.Normalize (5).ToArray (); + Assert.AreEqual (5, nodes.Length); + Assert.AreEqual ("c", nodes [0].Segment); + Assert.AreEqual ("d", nodes [1].Segment); + Assert.AreEqual ("e", nodes [2].Segment); + Assert.AreEqual ("f", nodes [3].Segment); + Assert.AreEqual ("g", nodes [4].Segment); + + // f has 2 children, but it is live + nodes = tree.Normalize (6).ToArray (); + Assert.AreEqual (5, nodes.Length); + Assert.AreEqual ("c", nodes [0].Segment); + Assert.AreEqual ("d", nodes [1].Segment); + Assert.AreEqual ("e", nodes [2].Segment); + Assert.AreEqual ("f", nodes [3].Segment); + Assert.AreEqual ("g", nodes [4].Segment); + + // remove f's registration + var node = tree.FindNode (MakePath ("a", "b", "f")); + node.UnregisterId (id); + + // f has 2 children which should be unrolled + nodes = tree.Normalize (6).ToArray (); + Assert.AreEqual (6, nodes.Length); + Assert.AreEqual ("c", nodes [0].Segment); + Assert.AreEqual ("d", nodes [1].Segment); + Assert.AreEqual ("e", nodes [2].Segment); + Assert.AreEqual ("g", nodes [3].Segment); + Assert.AreEqual ("f1", nodes [4].Segment); + Assert.AreEqual ("f2", nodes [5].Segment); + + // g has 2 children, but it is live + nodes = tree.Normalize (7).ToArray (); + Assert.AreEqual (6, nodes.Length); + Assert.AreEqual ("c", nodes [0].Segment); + Assert.AreEqual ("d", nodes [1].Segment); + Assert.AreEqual ("e", nodes [2].Segment); + Assert.AreEqual ("g", nodes [3].Segment); + Assert.AreEqual ("f1", nodes [4].Segment); + Assert.AreEqual ("f2", nodes [5].Segment); + + // remove f's registration + node = tree.FindNode (MakePath ("a", "b", "g")); + node.UnregisterId (id); + + nodes = tree.Normalize (7).ToArray (); + Assert.AreEqual (7, nodes.Length); + Assert.AreEqual ("c", nodes [0].Segment); + Assert.AreEqual ("d", nodes [1].Segment); + Assert.AreEqual ("e", nodes [2].Segment); + Assert.AreEqual ("f1", nodes [3].Segment); + Assert.AreEqual ("f2", nodes [4].Segment); + Assert.AreEqual ("g1", nodes [5].Segment); + Assert.AreEqual ("g2", nodes [6].Segment); + + node = tree.FindNode (MakePath ("a")); + node.RegisterId (id); + + nodes = tree.Normalize (1).ToArray (); + Assert.AreEqual (1, nodes.Length); + Assert.AreEqual ("a", nodes [0].Segment); + + nodes = tree.Normalize (7).ToArray (); + Assert.AreEqual (1, nodes.Length); + Assert.AreEqual ("a", nodes [0].Segment); + } + + [Test] + public void CreateTreeAndDestructItNodeByNode () + { + var tree = new PathTree (); + var id1 = new object (); + var id2 = new object (); + + var a = tree.AddNode (MakePath ("a"), id1); + var b = tree.AddNode (MakePath ("a", "b"), id1); + var c = tree.AddNode (MakePath ("a", "b", "c"), id1); + + var b2 = tree.AddNode (MakePath ("a", "b"), id2); + Assert.AreSame (b, b2); + Assert.AreSame (b.FirstChild, c); + + var b3 = tree.RemoveNode (MakePath ("a", "b"), id1); + + Assert.IsNotNull (tree.FindNode (MakePath ("a", "b"))); + Assert.AreSame (c, b3.FirstChild); + + var b4 = tree.RemoveNode (MakePath ("a", "b"), id2); + Assert.IsNotNull (tree.FindNode (MakePath ("a", "b"))); + Assert.AreSame (c, b3.FirstChild); + + tree.RemoveNode (MakePath ("a", "b", "c"), id1); + Assert.IsNull (a.FirstChild); + } + + [Test] + public void CreateTreeAndRegisterRoot () + { + var tree = new PathTree (); + + tree.AddNode (prefix, id); + tree.RemoveNode (prefix, id); + + var node = tree.FindNode (prefix); + if (Platform.IsWindows) { + Assert.IsNull (node); + } else { + Assert.IsNotNull (node); + Assert.AreEqual (false, node.IsLive); + } + } + + [Test] + public void TestRemovalOfNodeAddedToTheBeginning () + { + var tree = new PathTree (); + + var c = tree.AddNode (MakePath ("a", "c"), id); + + var b = tree.AddNode (MakePath ("a", "b"), id); + var a = tree.AddNode (MakePath ("a", "a"), id); + + Assert.IsNotNull (tree.FindNode (MakePath ("a", "a"))); + Assert.IsNotNull (tree.FindNode (MakePath ("a", "b"))); + Assert.IsNotNull (tree.FindNode (MakePath ("a", "c"))); + + tree.RemoveNode (MakePath ("a", "b"), id); + + Assert.AreSame (c, a.Next); + Assert.AreSame (a, c.Previous); + + tree.RemoveNode (MakePath ("a", "c"), id); + + Assert.IsNull (a.Next); + tree.RemoveNode (MakePath ("a", "a"), id); + + Assert.IsNull (tree.FindNode (MakePath ("a", "a"))); + Assert.IsNull (tree.FindNode (MakePath ("a", "b"))); + Assert.IsNull (tree.FindNode (MakePath ("a", "c"))); + } + } +} diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/FileWatcherTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/FileWatcherTests.cs index 7634f39bb1..f5744a9940 100644 --- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/FileWatcherTests.cs +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/FileWatcherTests.cs @@ -462,49 +462,6 @@ namespace MonoDevelop.Projects } [Test] - public void NormalizeDirectories1 () - { - FilePath fileName = Util.GetSampleProject ("FileWatcherTest", "Root.sln"); - FilePath rootDirectory = fileName.ParentDirectory; - - var directories = new [] { - rootDirectory.Combine ("a"), - rootDirectory, - rootDirectory.Combine ("c") - }; - - var normalized = FileWatcherService.Normalize (directories).ToArray (); - - Assert.AreEqual (1, normalized.Length); - Assert.That (normalized, Contains.Item (rootDirectory)); - } - - [Test] - public void NormalizeDirectories2 () - { - FilePath fileName = Util.GetSampleProject ("FileWatcherTest", "Root.sln"); - FilePath rootDirectory = fileName.ParentDirectory; - - var bDirectory = rootDirectory.Combine ("..", "b").FullPath; - var dDirectory = rootDirectory.Combine ("..", "d").FullPath; - - var directories = new [] { - rootDirectory.Combine ("a"), - bDirectory, - rootDirectory, - rootDirectory.Combine ("c"), - dDirectory - }; - - var normalized = FileWatcherService.Normalize (directories).ToArray (); - - Assert.AreEqual (3, normalized.Length); - Assert.That (normalized, Contains.Item (rootDirectory)); - Assert.That (normalized, Contains.Item (bDirectory)); - Assert.That (normalized, Contains.Item (dDirectory)); - } - - [Test] public async Task DeleteProjectFileExternally_TwoSolutionsOpen_OneSolutionDisposed () { FilePath rootSolFile = Util.GetSampleProject ("FileWatcherTest", "Root.sln"); diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs index a126f38f0c..9cd54eed2e 100644 --- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs @@ -1633,6 +1633,42 @@ namespace MonoDevelop.Projects MSBuildProjectService.UnregisterGlobalPropertyProvider (prov2); } } + + /// <summary> + /// Tests that the MSBuildProject.Load method includes information about the file + /// being loaded when there was an error. This makes it easier to fix problems when + /// the project file or imported file fails to load in the IDE. + /// </summary> + [Test] + public void LoadInvalidXml_ExceptionContainsFileBeingLoaded () + { + string directory = Util.CreateTmpDir ("MSBuildProjectLoadInvalidXml"); + string fileName = Path.Combine (directory, "MSBuildProjectLoadInvalidXml.csproj"); + File.WriteAllText (fileName, "<Project></Project>\n</Project>"); + var p = new MSBuildProject (); + try { + p.Load (fileName); + } catch (Exception ex) { + Assert.That (ex.Message, Contains.Substring (fileName)); + } + } + + [Test] + public void EvaluateInvalidMSBuildImportXml_ExceptionContainsFileBeingLoaded () + { + string directory = Util.CreateTmpDir ("MSBuildImportLoadInvalidXml"); + string fileName = Path.Combine (directory, "MSBuildImportLoadInvalidXml.csproj"); + File.WriteAllText (fileName, "<Project><Import Project='InvalidXmlImport.targets' /></Project>"); + string importFileName = Path.Combine (directory, "InvalidXmlImport.targets"); + File.WriteAllText (importFileName, "<Project></Project>\n</Project>"); + var p = new MSBuildProject (); + p.Load (fileName); + try { + p.Evaluate (); + } catch (Exception ex) { + Assert.That (ex.Message, Contains.Substring (importFileName)); + } + } } class CustomGlobalPropertyProvider : IMSBuildGlobalPropertyProvider diff --git a/main/tests/MonoDevelop.Refactoring.Tests/MonoDevelop.Refactoring.Tests.csproj b/main/tests/MonoDevelop.Refactoring.Tests/MonoDevelop.Refactoring.Tests.csproj index e1de975891..4cb1a342c3 100644 --- a/main/tests/MonoDevelop.Refactoring.Tests/MonoDevelop.Refactoring.Tests.csproj +++ b/main/tests/MonoDevelop.Refactoring.Tests/MonoDevelop.Refactoring.Tests.csproj @@ -131,6 +131,10 @@ <ItemGroup> <Compile Include="ResultsEditorExtensionTestBase.cs" /> <Compile Include="CodeActionEditorExtensionTestBase.cs" /> + <Compile Include="MonoDevelop.Refactoring\RenameRefactoringTests.cs" /> + </ItemGroup> + <ItemGroup> + <Folder Include="MonoDevelop.Refactoring\" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project> diff --git a/main/tests/MonoDevelop.Refactoring.Tests/MonoDevelop.Refactoring/RenameRefactoringTests.cs b/main/tests/MonoDevelop.Refactoring.Tests/MonoDevelop.Refactoring/RenameRefactoringTests.cs new file mode 100644 index 0000000000..12fc3e6bec --- /dev/null +++ b/main/tests/MonoDevelop.Refactoring.Tests/MonoDevelop.Refactoring/RenameRefactoringTests.cs @@ -0,0 +1,153 @@ +// +// RenameRefactoringTests.cs +// +// Author: +// Mike Krüger <mikkrg@microsoft.com> +// +// Copyright (c) 2018 Microsoft Corporation. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using MonoDevelop.AnalysisCore.Gui; +using MonoDevelop.Core; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Editor.Extension; +using MonoDevelop.Ide.TypeSystem; +using NUnit.Framework; +using NUnit.Framework.Internal; +using MonoDevelop.Refactoring.Rename; +using MonoDevelop.Core.Text; + +namespace MonoDevelop.Refactoring.Tests +{ + [TestFixture] + class RenameRefactoringTests : TextEditorExtensionTestBase + { + protected override EditorExtensionTestData GetContentData () => EditorExtensionTestData.CSharp; + + async Task CheckRename (string input) + { + var sb = StringBuilderCache.Allocate (); + try { + bool inLink = false; + int linkStart = 0; + var expectedLinks = new List<TextSegment> (); + foreach (var ch in input) { + if (ch == '$') { + if (inLink) { + expectedLinks.Add (new TextSegment (linkStart, sb.Length - linkStart)); + } else { + linkStart = sb.Length; + } + inLink = !inLink; + continue; + } + sb.Append (ch); + } + + using (var testCase = await SetupTestCase (sb.ToString())) { + var model = await testCase.Document.AnalysisDocument.GetSemanticModelAsync (); + ISymbol symbol = null; + var root = await model.SyntaxTree.GetRootAsync (); + foreach (var l in expectedLinks) { + var node = root.FindToken (l.Offset).Parent; + if (node == null) + continue; + var symbolInfo = model.GetSymbolInfo (node); + if (symbolInfo.Symbol == null) + continue; + symbol = symbolInfo.Symbol; + break; + } + Assert.NotNull (symbol, "No symbol found."); + + var links = await RenameRefactoring.GetTextLinksAsync (testCase.Document, 0, symbol); + Assert.AreEqual (expectedLinks.Count, links [0].Links.Count); + foreach (var l in links [0].Links) { + var expected = expectedLinks.FirstOrDefault (el => l.Offset == el.Offset); + Assert.NotNull (expected, "No expected link found at : " + l.Offset); + Assert.AreEqual (expected.Length, l.Length); + } + } + } finally { + StringBuilderCache.Free (sb); + } + } + + /// <summary> + /// Bug 641295: Renaming method should not trigger removal of generic type arguments + /// </summary> + [Test] + public async Task TestVSTS641295 () + { + await CheckRename (@"using System; + +namespace RenameGenericMethodParameterInference +{ + class MainClass + { + static T $Apply$<T> (int arg) => default (T); + + static void TakeInt (int i) { } + + public static void Main (string [] args) + { + TakeInt ($Apply$<int> (0)); + TakeInt ($Apply$<int> (0)); + } + } +}"); + } + + + /// <summary> + /// Bug 40464 - Rename refactoring a method parameter causes subsequent document elements to be removed. + /// </summary> + [Test] + public async Task TestBugzilla40464 () + { + await CheckRename (@"using System; + +namespace RenameGenericMethodParameterInference +{ + class MainClass + { + /// <summary> + /// Apply the specified value and dataReader. + /// </summary> + /// <param name=""$value$""> Value.</param> + /// <param name=""dataReader"" > Data reader.</param> + /// <typeparam name=""T""> The 1st type parameter.</typeparam> + /// <exception cref=""ArgumentNullException""> Thrown</exception> + static T Apply<T> (object $value$, object dataReader) + { + if ($value$ == null) { + throw new ArgumentNullException (nameof ($value$)); + } + } + } +}"); + } + } +}
\ No newline at end of file |