tftsr-devops_investigation/node_modules/sucrase/dist/esm/parser/traverser/lval.js

160 lines
4.2 KiB
JavaScript
Raw Normal View History

feat: initial implementation of TFTSR IT Triage & RCA application Implements Phases 1-8 of the TFTSR implementation plan. Rust backend (Tauri 2.x, src-tauri/): - Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama - PII detection engine: 11 regex patterns with overlap resolution - SQLCipher AES-256 encrypted database with 10 versioned migrations - 28 Tauri IPC commands for triage, analysis, document, and system ops - Ollama: hardware probe, model recommendations, pull/delete with events - RCA and blameless post-mortem Markdown document generators - PDF export via printpdf - Audit log: SHA-256 hash of every external data send - Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2) Frontend (React 18 + TypeScript + Vite, src/): - 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings - 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives - 3 Zustand stores: session, settings (persisted), history - Type-safe tauriCommands.ts matching Rust backend types exactly - 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs) DevOps: - .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push - .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload Verified: - cargo check: zero errors - tsc --noEmit: zero errors - vitest run: 13/13 unit tests passing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
import {flowParseAssignableListItemTypes} from "../plugins/flow";
import {tsParseAssignableListItemTypes, tsParseModifiers} from "../plugins/typescript";
import {
eat,
IdentifierRole,
match,
next,
popTypeContext,
pushTypeContext,
} from "../tokenizer/index";
import {ContextualKeyword} from "../tokenizer/keywords";
import {TokenType, TokenType as tt} from "../tokenizer/types";
import {isFlowEnabled, isTypeScriptEnabled, state} from "./base";
import {parseIdentifier, parseMaybeAssign, parseObj} from "./expression";
import {expect, unexpected} from "./util";
export function parseSpread() {
next();
parseMaybeAssign(false);
}
export function parseRest(isBlockScope) {
next();
parseBindingAtom(isBlockScope);
}
export function parseBindingIdentifier(isBlockScope) {
parseIdentifier();
markPriorBindingIdentifier(isBlockScope);
}
export function parseImportedIdentifier() {
parseIdentifier();
state.tokens[state.tokens.length - 1].identifierRole = IdentifierRole.ImportDeclaration;
}
export function markPriorBindingIdentifier(isBlockScope) {
let identifierRole;
if (state.scopeDepth === 0) {
identifierRole = IdentifierRole.TopLevelDeclaration;
} else if (isBlockScope) {
identifierRole = IdentifierRole.BlockScopedDeclaration;
} else {
identifierRole = IdentifierRole.FunctionScopedDeclaration;
}
state.tokens[state.tokens.length - 1].identifierRole = identifierRole;
}
// Parses lvalue (assignable) atom.
export function parseBindingAtom(isBlockScope) {
switch (state.type) {
case tt._this: {
// In TypeScript, "this" may be the name of a parameter, so allow it.
const oldIsType = pushTypeContext(0);
next();
popTypeContext(oldIsType);
return;
}
case tt._yield:
case tt.name: {
state.type = tt.name;
parseBindingIdentifier(isBlockScope);
return;
}
case tt.bracketL: {
next();
parseBindingList(tt.bracketR, isBlockScope, true /* allowEmpty */);
return;
}
case tt.braceL:
parseObj(true, isBlockScope);
return;
default:
unexpected();
}
}
export function parseBindingList(
close,
isBlockScope,
allowEmpty = false,
allowModifiers = false,
contextId = 0,
) {
let first = true;
let hasRemovedComma = false;
const firstItemTokenIndex = state.tokens.length;
while (!eat(close) && !state.error) {
if (first) {
first = false;
} else {
expect(tt.comma);
state.tokens[state.tokens.length - 1].contextId = contextId;
// After a "this" type in TypeScript, we need to set the following comma (if any) to also be
// a type token so that it will be removed.
if (!hasRemovedComma && state.tokens[firstItemTokenIndex].isType) {
state.tokens[state.tokens.length - 1].isType = true;
hasRemovedComma = true;
}
}
if (allowEmpty && match(tt.comma)) {
// Empty item; nothing further to parse for this item.
} else if (eat(close)) {
break;
} else if (match(tt.ellipsis)) {
parseRest(isBlockScope);
parseAssignableListItemTypes();
// Support rest element trailing commas allowed by TypeScript <2.9.
eat(TokenType.comma);
expect(close);
break;
} else {
parseAssignableListItem(allowModifiers, isBlockScope);
}
}
}
function parseAssignableListItem(allowModifiers, isBlockScope) {
if (allowModifiers) {
tsParseModifiers([
ContextualKeyword._public,
ContextualKeyword._protected,
ContextualKeyword._private,
ContextualKeyword._readonly,
ContextualKeyword._override,
]);
}
parseMaybeDefault(isBlockScope);
parseAssignableListItemTypes();
parseMaybeDefault(isBlockScope, true /* leftAlreadyParsed */);
}
function parseAssignableListItemTypes() {
if (isFlowEnabled) {
flowParseAssignableListItemTypes();
} else if (isTypeScriptEnabled) {
tsParseAssignableListItemTypes();
}
}
// Parses assignment pattern around given atom if possible.
export function parseMaybeDefault(isBlockScope, leftAlreadyParsed = false) {
if (!leftAlreadyParsed) {
parseBindingAtom(isBlockScope);
}
if (!eat(tt.eq)) {
return;
}
const eqIndex = state.tokens.length - 1;
parseMaybeAssign();
state.tokens[eqIndex].rhsEndIndex = state.tokens.length;
}