import * as vscode from 'vscode' ; import * as path from 'path' ; import { DevToolsExtensionContext } from '../devToolsExtensionContext' ; import { JsonFormEditor } from './jsonFormEditor' ; import { AppJsonEditor } from './appJsonEditor' ; import { RuleSetEditor } from './ruleSetEditor' ; import { AppSourceCopEditor } from './appSourceCopEditor' ; export class JsonEditorProvider implements vscode . CustomTextEditorProvider { protected _devToolsContext : DevToolsExtensionContext ; constructor ( devToolsContext ) { this . _devToolsContext = devToolsContext ; } public async resolveCustomTextEditor ( document , webviewPanel , token ) { let filePath = path . parse ( document . uri . fsPath ) ; let fileName = filePath . base . toLowerCase ( ) ; let editor = undefined ; if ( fileName == "app.json" ) editor = new AppJsonEditor ( this . _devToolsContext ) ; else if ( ( fileName . endsWith ( ".ruleset.json" ) ) || ( fileName == "ruleset.json" ) ) editor = new RuleSetEditor ( this . _devToolsContext ) ; else if ( fileName == "appsourcecop.json" ) editor = new AppSourceCopEditor ( this . _devToolsContext ) ; if ( editor ) editor . resolveCustomTextEditor ( document , webviewPanel ) ; } }