44 *--------------------------------------------------------------------------------------------*/
55
66import { getLocation , parse , visit } from 'jsonc-parser' ;
7- import * as path from 'path' ;
87import * as vscode from 'vscode' ;
98import * as nls from 'vscode-nls' ;
109import { SettingsDocument } from './settingsDocumentHelper' ;
1110const localize = nls . loadMessageBundle ( ) ;
1211
13- const fadedDecoration = vscode . window . createTextEditorDecorationType ( {
14- light : {
15- color : '#757575'
16- } ,
17- dark : {
18- color : '#878787'
19- }
20- } ) ;
21-
22- let pendingLaunchJsonDecoration : NodeJS . Timer ;
23-
2412export function activate ( context : vscode . ExtensionContext ) : void {
2513 //settings.json suggestions
2614 context . subscriptions . push ( registerSettingsCompletions ( ) ) ;
@@ -33,18 +21,6 @@ export function activate(context: vscode.ExtensionContext): void {
3321
3422 // task.json variable suggestions
3523 context . subscriptions . push ( registerVariableCompletions ( '**/tasks.json' ) ) ;
36-
37- // launch.json decorations
38- context . subscriptions . push ( vscode . window . onDidChangeActiveTextEditor ( editor => updateLaunchJsonDecorations ( editor ) , null , context . subscriptions ) ) ;
39- context . subscriptions . push ( vscode . workspace . onDidChangeTextDocument ( event => {
40- if ( vscode . window . activeTextEditor && event . document === vscode . window . activeTextEditor . document ) {
41- if ( pendingLaunchJsonDecoration ) {
42- clearTimeout ( pendingLaunchJsonDecoration ) ;
43- }
44- pendingLaunchJsonDecoration = setTimeout ( ( ) => updateLaunchJsonDecorations ( vscode . window . activeTextEditor ) , 1000 ) ;
45- }
46- } , null , context . subscriptions ) ) ;
47- updateLaunchJsonDecorations ( vscode . window . activeTextEditor ) ;
4824}
4925
5026function registerSettingsCompletions ( ) : vscode . Disposable {
@@ -153,39 +129,6 @@ function provideInstalledExtensionProposals(extensionsContent: IExtensionsConten
153129 return undefined ;
154130}
155131
156- function updateLaunchJsonDecorations ( editor : vscode . TextEditor | undefined ) : void {
157- if ( ! editor || path . basename ( editor . document . fileName ) !== 'launch.json' ) {
158- return ;
159- }
160-
161- const ranges : vscode . Range [ ] = [ ] ;
162- let addPropertyAndValue = false ;
163- let depthInArray = 0 ;
164- visit ( editor . document . getText ( ) , {
165- onObjectProperty : ( property , offset , length ) => {
166- // Decorate attributes which are unlikely to be edited by the user.
167- // Only decorate "configurations" if it is not inside an array (compounds have a configurations property which should not be decorated).
168- addPropertyAndValue = property === 'version' || property === 'type' || property === 'request' || property === 'compounds' || ( property === 'configurations' && depthInArray === 0 ) ;
169- if ( addPropertyAndValue ) {
170- ranges . push ( new vscode . Range ( editor . document . positionAt ( offset ) , editor . document . positionAt ( offset + length ) ) ) ;
171- }
172- } ,
173- onLiteralValue : ( _value , offset , length ) => {
174- if ( addPropertyAndValue ) {
175- ranges . push ( new vscode . Range ( editor . document . positionAt ( offset ) , editor . document . positionAt ( offset + length ) ) ) ;
176- }
177- } ,
178- onArrayBegin : ( _offset : number , _length : number ) => {
179- depthInArray ++ ;
180- } ,
181- onArrayEnd : ( _offset : number , _length : number ) => {
182- depthInArray -- ;
183- }
184- } ) ;
185-
186- editor . setDecorations ( fadedDecoration , ranges ) ;
187- }
188-
189132vscode . languages . registerDocumentSymbolProvider ( { pattern : '**/launch.json' , language : 'jsonc' } , {
190133 provideDocumentSymbols ( document : vscode . TextDocument , _token : vscode . CancellationToken ) : vscode . ProviderResult < vscode . SymbolInformation [ ] > {
191134 const result : vscode . SymbolInformation [ ] = [ ] ;
0 commit comments