private checkScope()

in src/wskdeployYamlCompletion.ts [138:181]


    private checkScope(document: vscode.TextDocument, position: vscode.Position): ScopeResult {
        const firstNonWhitespaceCharacterIndex = document.lineAt(position.line)
            .firstNonWhitespaceCharacterIndex;

        for (let i = position.line; i--; i >= 0) {
            const lineAt = document.lineAt(i);
            if (lineAt.firstNonWhitespaceCharacterIndex >= firstNonWhitespaceCharacterIndex) {
                continue;
            }
            const actionScopeIndex = lineAt.text.indexOf('actions:');
            if (actionScopeIndex >= 0) {
                return {
                    scope: Scope.ACTIONS,
                };
            }
            const triggerScopeIndex = lineAt.text.indexOf('triggers:');
            if (triggerScopeIndex >= 0) {
                return {
                    scope: Scope.TRIGGERS,
                };
            }
            const ruleScopeIndex = lineAt.text.indexOf('rules:');
            if (ruleScopeIndex >= 0) {
                return {
                    scope: Scope.RULES,
                };
            }
            const packageScopeIndex = lineAt.text.indexOf('packages:');
            if (packageScopeIndex >= 0) {
                return {
                    scope: Scope.PACKAGES,
                };
            }
            const dependencyScopeIndex = lineAt.text.indexOf('dependencies:');
            if (dependencyScopeIndex >= 0) {
                return {
                    scope: Scope.DEPENDENCIES,
                };
            }
        }
        return {
            scope: Scope.None,
        };
    }