@nocturnium/svelte-ide 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/components/agents/AgentActivityPanel.svelte +565 -0
- package/dist/components/agents/AgentActivityPanel.svelte.d.ts +24 -0
- package/dist/components/agents/AgentAvatar.svelte +417 -0
- package/dist/components/agents/AgentAvatar.svelte.d.ts +23 -0
- package/dist/components/agents/AgentCursor.svelte +224 -0
- package/dist/components/agents/AgentCursor.svelte.d.ts +35 -0
- package/dist/components/agents/AgentPresenceBar.svelte +261 -0
- package/dist/components/agents/AgentPresenceBar.svelte.d.ts +20 -0
- package/dist/components/agents/index.d.ts +4 -0
- package/dist/components/agents/index.js +5 -0
- package/dist/components/ai/AIConversationList.svelte +524 -0
- package/dist/components/ai/AIConversationList.svelte.d.ts +17 -0
- package/dist/components/ai/AIEditPreview.svelte +132 -0
- package/dist/components/ai/AIEditPreview.svelte.d.ts +8 -0
- package/dist/components/ai/AIInlineEdit.svelte +155 -0
- package/dist/components/ai/AIInlineEdit.svelte.d.ts +10 -0
- package/dist/components/ai/AIMessage.svelte +239 -0
- package/dist/components/ai/AIMessage.svelte.d.ts +13 -0
- package/dist/components/ai/AIMessageActions.svelte +176 -0
- package/dist/components/ai/AIMessageActions.svelte.d.ts +12 -0
- package/dist/components/ai/AIMessageContent.svelte +355 -0
- package/dist/components/ai/AIMessageContent.svelte.d.ts +7 -0
- package/dist/components/ai/AIPanel.svelte +561 -0
- package/dist/components/ai/AIPanel.svelte.d.ts +7 -0
- package/dist/components/ai/AISuggestionWidget.svelte +132 -0
- package/dist/components/ai/AISuggestionWidget.svelte.d.ts +10 -0
- package/dist/components/ai/AIToolCallDisplay.svelte +317 -0
- package/dist/components/ai/AIToolCallDisplay.svelte.d.ts +12 -0
- package/dist/components/ai/index.d.ts +9 -0
- package/dist/components/ai/index.js +10 -0
- package/dist/components/core/Avatar.svelte +110 -0
- package/dist/components/core/Avatar.svelte.d.ts +12 -0
- package/dist/components/core/Badge.svelte +98 -0
- package/dist/components/core/Badge.svelte.d.ts +11 -0
- package/dist/components/core/Button.svelte +175 -0
- package/dist/components/core/Button.svelte.d.ts +18 -0
- package/dist/components/core/ConnectionStatus.svelte +294 -0
- package/dist/components/core/ConnectionStatus.svelte.d.ts +20 -0
- package/dist/components/core/ContextMenu.svelte +176 -0
- package/dist/components/core/ContextMenu.svelte.d.ts +19 -0
- package/dist/components/core/ErrorBoundary.svelte +277 -0
- package/dist/components/core/ErrorBoundary.svelte.d.ts +23 -0
- package/dist/components/core/Icon.svelte +107 -0
- package/dist/components/core/Icon.svelte.d.ts +8 -0
- package/dist/components/core/Input.svelte +138 -0
- package/dist/components/core/Input.svelte.d.ts +20 -0
- package/dist/components/core/Kbd.svelte +34 -0
- package/dist/components/core/Kbd.svelte.d.ts +7 -0
- package/dist/components/core/ResizeHandle.svelte +200 -0
- package/dist/components/core/ResizeHandle.svelte.d.ts +23 -0
- package/dist/components/core/Spinner.svelte +35 -0
- package/dist/components/core/Spinner.svelte.d.ts +7 -0
- package/dist/components/core/Textarea.svelte +112 -0
- package/dist/components/core/Textarea.svelte.d.ts +18 -0
- package/dist/components/core/Tooltip.svelte +103 -0
- package/dist/components/core/Tooltip.svelte.d.ts +11 -0
- package/dist/components/core/index.d.ts +13 -0
- package/dist/components/core/index.js +14 -0
- package/dist/components/editor/AIFocusLayer.svelte +430 -0
- package/dist/components/editor/AIFocusLayer.svelte.d.ts +32 -0
- package/dist/components/editor/Breadcrumbs.svelte +435 -0
- package/dist/components/editor/Breadcrumbs.svelte.d.ts +33 -0
- package/dist/components/editor/BreakpointLayer.svelte +642 -0
- package/dist/components/editor/BreakpointLayer.svelte.d.ts +20 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte +324 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte.d.ts +18 -0
- package/dist/components/editor/CollaborativeEditor.svelte +218 -0
- package/dist/components/editor/CollaborativeEditor.svelte.d.ts +32 -0
- package/dist/components/editor/CommandPalette.svelte +434 -0
- package/dist/components/editor/CommandPalette.svelte.d.ts +11 -0
- package/dist/components/editor/ComplexityLayer.svelte +293 -0
- package/dist/components/editor/ComplexityLayer.svelte.d.ts +23 -0
- package/dist/components/editor/ConflictZoneLayer.svelte +441 -0
- package/dist/components/editor/ConflictZoneLayer.svelte.d.ts +25 -0
- package/dist/components/editor/ContextLens.svelte +262 -0
- package/dist/components/editor/ContextLens.svelte.d.ts +27 -0
- package/dist/components/editor/CustomEditor.svelte +1242 -0
- package/dist/components/editor/CustomEditor.svelte.d.ts +37 -0
- package/dist/components/editor/DebugConsole.svelte +646 -0
- package/dist/components/editor/DebugConsole.svelte.d.ts +41 -0
- package/dist/components/editor/EchoCursorLayer.svelte +363 -0
- package/dist/components/editor/EchoCursorLayer.svelte.d.ts +24 -0
- package/dist/components/editor/Editor.svelte +61 -0
- package/dist/components/editor/Editor.svelte.d.ts +22 -0
- package/dist/components/editor/EditorGutter.svelte +119 -0
- package/dist/components/editor/EditorGutter.svelte.d.ts +19 -0
- package/dist/components/editor/EditorLines.svelte +182 -0
- package/dist/components/editor/EditorLines.svelte.d.ts +43 -0
- package/dist/components/editor/EditorPane.svelte +134 -0
- package/dist/components/editor/EditorPane.svelte.d.ts +9 -0
- package/dist/components/editor/EditorSelections.svelte +186 -0
- package/dist/components/editor/EditorSelections.svelte.d.ts +25 -0
- package/dist/components/editor/EditorTabs.svelte +170 -0
- package/dist/components/editor/EditorTabs.svelte.d.ts +12 -0
- package/dist/components/editor/FileExplorer.svelte +811 -0
- package/dist/components/editor/FileExplorer.svelte.d.ts +67 -0
- package/dist/components/editor/FileIcon.svelte +110 -0
- package/dist/components/editor/FileIcon.svelte.d.ts +10 -0
- package/dist/components/editor/FindReplace.svelte +448 -0
- package/dist/components/editor/FindReplace.svelte.d.ts +40 -0
- package/dist/components/editor/GhostBracketLayer.svelte +391 -0
- package/dist/components/editor/GhostBracketLayer.svelte.d.ts +24 -0
- package/dist/components/editor/GitBlameLayer.svelte +436 -0
- package/dist/components/editor/GitBlameLayer.svelte.d.ts +18 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte +540 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte.d.ts +35 -0
- package/dist/components/editor/InlineDiffLayer.svelte +337 -0
- package/dist/components/editor/InlineDiffLayer.svelte.d.ts +31 -0
- package/dist/components/editor/MinimalEditor.svelte +75 -0
- package/dist/components/editor/MinimalEditor.svelte.d.ts +6 -0
- package/dist/components/editor/MinimalEditor2.svelte +84 -0
- package/dist/components/editor/MinimalEditor2.svelte.d.ts +6 -0
- package/dist/components/editor/Minimap.svelte +327 -0
- package/dist/components/editor/Minimap.svelte.d.ts +34 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte +793 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte.d.ts +49 -0
- package/dist/components/editor/ProblemsPanel.svelte +628 -0
- package/dist/components/editor/ProblemsPanel.svelte.d.ts +25 -0
- package/dist/components/editor/QuickActionsMenu.svelte +403 -0
- package/dist/components/editor/QuickActionsMenu.svelte.d.ts +18 -0
- package/dist/components/editor/SnippetPalette.svelte +530 -0
- package/dist/components/editor/SnippetPalette.svelte.d.ts +16 -0
- package/dist/components/editor/StructureMap.svelte +431 -0
- package/dist/components/editor/StructureMap.svelte.d.ts +37 -0
- package/dist/components/editor/SymbolOutline.svelte +722 -0
- package/dist/components/editor/SymbolOutline.svelte.d.ts +44 -0
- package/dist/components/editor/TimelineScrubber.svelte +470 -0
- package/dist/components/editor/TimelineScrubber.svelte.d.ts +40 -0
- package/dist/components/editor/TokenRenderer.svelte +69 -0
- package/dist/components/editor/TokenRenderer.svelte.d.ts +15 -0
- package/dist/components/editor/constants.d.ts +32 -0
- package/dist/components/editor/constants.js +36 -0
- package/dist/components/editor/core/ai-awareness.d.ts +176 -0
- package/dist/components/editor/core/ai-awareness.js +210 -0
- package/dist/components/editor/core/bracket-healer.d.ts +189 -0
- package/dist/components/editor/core/bracket-healer.js +406 -0
- package/dist/components/editor/core/breakpoints.d.ts +203 -0
- package/dist/components/editor/core/breakpoints.js +414 -0
- package/dist/components/editor/core/commands.d.ts +108 -0
- package/dist/components/editor/core/commands.js +246 -0
- package/dist/components/editor/core/complexity-analyzer.d.ts +123 -0
- package/dist/components/editor/core/complexity-analyzer.js +376 -0
- package/dist/components/editor/core/conflict-predictor.d.ts +135 -0
- package/dist/components/editor/core/conflict-predictor.js +316 -0
- package/dist/components/editor/core/crdt-binding.d.ts +118 -0
- package/dist/components/editor/core/crdt-binding.js +286 -0
- package/dist/components/editor/core/diagnostics.d.ts +210 -0
- package/dist/components/editor/core/diagnostics.js +335 -0
- package/dist/components/editor/core/echo-cursor.d.ts +201 -0
- package/dist/components/editor/core/echo-cursor.js +267 -0
- package/dist/components/editor/core/folding.d.ts +124 -0
- package/dist/components/editor/core/folding.js +672 -0
- package/dist/components/editor/core/ghost-pair.d.ts +122 -0
- package/dist/components/editor/core/ghost-pair.js +221 -0
- package/dist/components/editor/core/git-blame.d.ts +170 -0
- package/dist/components/editor/core/git-blame.js +324 -0
- package/dist/components/editor/core/index.d.ts +26 -0
- package/dist/components/editor/core/index.js +24 -0
- package/dist/components/editor/core/keybindings.d.ts +79 -0
- package/dist/components/editor/core/keybindings.js +357 -0
- package/dist/components/editor/core/multi-cursor.d.ts +196 -0
- package/dist/components/editor/core/multi-cursor.js +521 -0
- package/dist/components/editor/core/navigation.d.ts +107 -0
- package/dist/components/editor/core/navigation.js +408 -0
- package/dist/components/editor/core/quick-actions.d.ts +189 -0
- package/dist/components/editor/core/quick-actions.js +427 -0
- package/dist/components/editor/core/search.d.ts +88 -0
- package/dist/components/editor/core/search.js +192 -0
- package/dist/components/editor/core/semantic-analyzer.d.ts +77 -0
- package/dist/components/editor/core/semantic-analyzer.js +424 -0
- package/dist/components/editor/core/snippet-manager.d.ts +202 -0
- package/dist/components/editor/core/snippet-manager.js +565 -0
- package/dist/components/editor/core/state.d.ts +367 -0
- package/dist/components/editor/core/state.js +900 -0
- package/dist/components/editor/core/timeline.d.ts +204 -0
- package/dist/components/editor/core/timeline.js +349 -0
- package/dist/components/editor/editor-find.d.ts +56 -0
- package/dist/components/editor/editor-find.js +148 -0
- package/dist/components/editor/editor-input.d.ts +77 -0
- package/dist/components/editor/editor-input.js +445 -0
- package/dist/components/editor/editor-multicursor.d.ts +21 -0
- package/dist/components/editor/editor-multicursor.js +196 -0
- package/dist/components/editor/editor-scroll.d.ts +14 -0
- package/dist/components/editor/editor-scroll.js +34 -0
- package/dist/components/editor/index.d.ts +15 -0
- package/dist/components/editor/index.js +21 -0
- package/dist/components/editor/languages.d.ts +62 -0
- package/dist/components/editor/languages.js +285 -0
- package/dist/components/editor/theme.d.ts +88 -0
- package/dist/components/editor/theme.js +139 -0
- package/dist/components/editor/tokenizer/base.d.ts +40 -0
- package/dist/components/editor/tokenizer/base.js +203 -0
- package/dist/components/editor/tokenizer/index.d.ts +56 -0
- package/dist/components/editor/tokenizer/index.js +215 -0
- package/dist/components/editor/tokenizer/languages/css.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/css.js +194 -0
- package/dist/components/editor/tokenizer/languages/go.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/go.js +220 -0
- package/dist/components/editor/tokenizer/languages/html.d.ts +24 -0
- package/dist/components/editor/tokenizer/languages/html.js +145 -0
- package/dist/components/editor/tokenizer/languages/javascript.d.ts +56 -0
- package/dist/components/editor/tokenizer/languages/javascript.js +452 -0
- package/dist/components/editor/tokenizer/languages/json.d.ts +12 -0
- package/dist/components/editor/tokenizer/languages/json.js +91 -0
- package/dist/components/editor/tokenizer/languages/markdown.d.ts +16 -0
- package/dist/components/editor/tokenizer/languages/markdown.js +156 -0
- package/dist/components/editor/tokenizer/languages/python.d.ts +20 -0
- package/dist/components/editor/tokenizer/languages/python.js +227 -0
- package/dist/components/editor/tokenizer/languages/svelte.d.ts +40 -0
- package/dist/components/editor/tokenizer/languages/svelte.js +326 -0
- package/dist/components/editor/tokenizer/types.d.ts +86 -0
- package/dist/components/editor/tokenizer/types.js +4 -0
- package/dist/components/layout/IDELayout.svelte +274 -0
- package/dist/components/layout/IDELayout.svelte.d.ts +29 -0
- package/dist/components/layout/StatusBar.svelte +511 -0
- package/dist/components/layout/StatusBar.svelte.d.ts +47 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.js +3 -0
- package/dist/components/lsp/AutocompleteWidget.svelte +364 -0
- package/dist/components/lsp/AutocompleteWidget.svelte.d.ts +33 -0
- package/dist/components/lsp/DiagnosticMarker.svelte +166 -0
- package/dist/components/lsp/DiagnosticMarker.svelte.d.ts +19 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte +388 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte.d.ts +21 -0
- package/dist/components/lsp/HoverTooltip.svelte +274 -0
- package/dist/components/lsp/HoverTooltip.svelte.d.ts +24 -0
- package/dist/components/lsp/LSPEditor.svelte +486 -0
- package/dist/components/lsp/LSPEditor.svelte.d.ts +39 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte +216 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte.d.ts +22 -0
- package/dist/components/lsp/index.d.ts +6 -0
- package/dist/components/lsp/index.js +7 -0
- package/dist/components/plugins/PluginCard.svelte +153 -0
- package/dist/components/plugins/PluginCard.svelte.d.ts +19 -0
- package/dist/components/plugins/PluginPanel.svelte +280 -0
- package/dist/components/plugins/PluginPanel.svelte.d.ts +8 -0
- package/dist/components/plugins/PluginProposalForm.svelte +250 -0
- package/dist/components/plugins/PluginProposalForm.svelte.d.ts +6 -0
- package/dist/components/plugins/PluginStatusBadge.svelte +14 -0
- package/dist/components/plugins/PluginStatusBadge.svelte.d.ts +8 -0
- package/dist/components/plugins/index.d.ts +4 -0
- package/dist/components/plugins/index.js +5 -0
- package/dist/components/vfs/LockConflictDialog.svelte +705 -0
- package/dist/components/vfs/LockConflictDialog.svelte.d.ts +21 -0
- package/dist/components/vfs/LockIndicator.svelte +194 -0
- package/dist/components/vfs/LockIndicator.svelte.d.ts +29 -0
- package/dist/components/vfs/LockOverlay.svelte +344 -0
- package/dist/components/vfs/LockOverlay.svelte.d.ts +17 -0
- package/dist/components/vfs/VersionConflictDialog.svelte +549 -0
- package/dist/components/vfs/VersionConflictDialog.svelte.d.ts +24 -0
- package/dist/components/vfs/index.d.ts +4 -0
- package/dist/components/vfs/index.js +5 -0
- package/dist/crdt/awareness.d.ts +42 -0
- package/dist/crdt/awareness.js +109 -0
- package/dist/crdt/document.d.ts +101 -0
- package/dist/crdt/document.js +187 -0
- package/dist/crdt/index.d.ts +9 -0
- package/dist/crdt/index.js +8 -0
- package/dist/crdt/provider.d.ts +85 -0
- package/dist/crdt/provider.js +150 -0
- package/dist/crdt/types.d.ts +61 -0
- package/dist/crdt/types.js +4 -0
- package/dist/crdt/undo.d.ts +34 -0
- package/dist/crdt/undo.js +70 -0
- package/dist/index.d.ts +277 -0
- package/dist/index.js +280 -0
- package/dist/plugins/index.d.ts +103 -0
- package/dist/plugins/index.js +153 -0
- package/dist/services/error-handling.d.ts +95 -0
- package/dist/services/error-handling.js +413 -0
- package/dist/services/ide-integration.d.ts +83 -0
- package/dist/services/ide-integration.js +367 -0
- package/dist/services/lsp-client.d.ts +69 -0
- package/dist/services/lsp-client.js +667 -0
- package/dist/services/mock-ai.d.ts +37 -0
- package/dist/services/mock-ai.js +318 -0
- package/dist/services/optimistic.d.ts +141 -0
- package/dist/services/optimistic.js +367 -0
- package/dist/services/vfs-client.d.ts +81 -0
- package/dist/services/vfs-client.js +348 -0
- package/dist/stores/agents.svelte.d.ts +85 -0
- package/dist/stores/agents.svelte.js +459 -0
- package/dist/stores/ai-persistence.svelte.d.ts +76 -0
- package/dist/stores/ai-persistence.svelte.js +334 -0
- package/dist/stores/ai.svelte.d.ts +140 -0
- package/dist/stores/ai.svelte.js +383 -0
- package/dist/stores/collaboration.svelte.d.ts +164 -0
- package/dist/stores/collaboration.svelte.js +334 -0
- package/dist/stores/editor.svelte.d.ts +131 -0
- package/dist/stores/editor.svelte.js +250 -0
- package/dist/stores/index.d.ts +10 -0
- package/dist/stores/index.js +29 -0
- package/dist/stores/layout.svelte.d.ts +171 -0
- package/dist/stores/layout.svelte.js +351 -0
- package/dist/stores/plugin.svelte.d.ts +121 -0
- package/dist/stores/plugin.svelte.js +410 -0
- package/dist/stores/vfs.svelte.d.ts +123 -0
- package/dist/stores/vfs.svelte.js +680 -0
- package/dist/styles/theme.css +623 -0
- package/dist/types/agents.d.ts +127 -0
- package/dist/types/agents.js +5 -0
- package/dist/types/ai.d.ts +137 -0
- package/dist/types/ai.js +4 -0
- package/dist/types/crdt.d.ts +222 -0
- package/dist/types/crdt.js +5 -0
- package/dist/types/editor.d.ts +52 -0
- package/dist/types/editor.js +18 -0
- package/dist/types/events.d.ts +133 -0
- package/dist/types/events.js +4 -0
- package/dist/types/filesystem.d.ts +77 -0
- package/dist/types/filesystem.js +4 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +12 -0
- package/dist/types/lsp.d.ts +691 -0
- package/dist/types/lsp.js +108 -0
- package/dist/types/plugin.d.ts +239 -0
- package/dist/types/plugin.js +5 -0
- package/dist/types/vfs.d.ts +191 -0
- package/dist/types/vfs.js +18 -0
- package/dist/utils/format.d.ts +55 -0
- package/dist/utils/format.js +152 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/keybindings.d.ts +33 -0
- package/dist/utils/keybindings.js +171 -0
- package/dist/utils/language.d.ts +27 -0
- package/dist/utils/language.js +222 -0
- package/package.json +178 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic Analyzer
|
|
3
|
+
*
|
|
4
|
+
* Analyzes code to identify semantic regions for intelligent folding.
|
|
5
|
+
* Unlike syntax-based folding, semantic folding understands code meaning:
|
|
6
|
+
* - "Collapse all imports"
|
|
7
|
+
* - "Show only public API"
|
|
8
|
+
* - "Hide error handling"
|
|
9
|
+
*/
|
|
10
|
+
import type { Line } from './state';
|
|
11
|
+
/**
|
|
12
|
+
* Semantic categories for code regions
|
|
13
|
+
*/
|
|
14
|
+
export type SemanticCategory = 'imports' | 'exports' | 'types' | 'constants' | 'error-handling' | 'logging' | 'tests' | 'setup' | 'private' | 'public' | 'comments' | 'boilerplate' | 'function' | 'class';
|
|
15
|
+
/**
|
|
16
|
+
* A semantic region in the code
|
|
17
|
+
*/
|
|
18
|
+
export interface SemanticRegion {
|
|
19
|
+
/** Category of this region */
|
|
20
|
+
category: SemanticCategory;
|
|
21
|
+
/** Start line (0-based) */
|
|
22
|
+
startLine: number;
|
|
23
|
+
/** End line (0-based) */
|
|
24
|
+
endLine: number;
|
|
25
|
+
/** Confidence score (0-1) */
|
|
26
|
+
confidence: number;
|
|
27
|
+
/** Human-readable label */
|
|
28
|
+
label?: string;
|
|
29
|
+
/** Nested regions */
|
|
30
|
+
children?: SemanticRegion[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Semantic Analyzer class
|
|
34
|
+
*/
|
|
35
|
+
export declare class SemanticAnalyzer {
|
|
36
|
+
private cache;
|
|
37
|
+
private cacheKey;
|
|
38
|
+
/**
|
|
39
|
+
* Analyze lines and return semantic regions
|
|
40
|
+
*/
|
|
41
|
+
analyze(lines: readonly Line[], language: string): SemanticRegion[];
|
|
42
|
+
/**
|
|
43
|
+
* Get regions by category
|
|
44
|
+
*/
|
|
45
|
+
getByCategory(regions: SemanticRegion[], category: SemanticCategory): SemanticRegion[];
|
|
46
|
+
/**
|
|
47
|
+
* Get all categories present in regions
|
|
48
|
+
*/
|
|
49
|
+
getCategories(regions: SemanticRegion[]): SemanticCategory[];
|
|
50
|
+
/**
|
|
51
|
+
* Clear cache
|
|
52
|
+
*/
|
|
53
|
+
clearCache(): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Fold preset configuration
|
|
57
|
+
*/
|
|
58
|
+
export interface FoldPreset {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
/** Categories to keep visible */
|
|
63
|
+
show: SemanticCategory[];
|
|
64
|
+
/** Categories to collapse */
|
|
65
|
+
hide: SemanticCategory[];
|
|
66
|
+
/** Icon for UI */
|
|
67
|
+
icon?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Default fold presets
|
|
71
|
+
*/
|
|
72
|
+
export declare const DEFAULT_FOLD_PRESETS: FoldPreset[];
|
|
73
|
+
export declare function getSemanticAnalyzer(): SemanticAnalyzer;
|
|
74
|
+
/**
|
|
75
|
+
* Create new analyzer instance
|
|
76
|
+
*/
|
|
77
|
+
export declare function createSemanticAnalyzer(): SemanticAnalyzer;
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic Analyzer
|
|
3
|
+
*
|
|
4
|
+
* Analyzes code to identify semantic regions for intelligent folding.
|
|
5
|
+
* Unlike syntax-based folding, semantic folding understands code meaning:
|
|
6
|
+
* - "Collapse all imports"
|
|
7
|
+
* - "Show only public API"
|
|
8
|
+
* - "Hide error handling"
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Pattern definitions for JavaScript/TypeScript
|
|
12
|
+
*/
|
|
13
|
+
const JAVASCRIPT_PATTERNS = new Map([
|
|
14
|
+
[
|
|
15
|
+
'imports',
|
|
16
|
+
{
|
|
17
|
+
startPattern: /^import\s|^const\s+\w+\s*=\s*require\s*\(/,
|
|
18
|
+
endPattern: /^(?!import|const\s+\w+\s*=\s*require)/,
|
|
19
|
+
multiline: true,
|
|
20
|
+
getLabel: () => 'Import statements'
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
'exports',
|
|
25
|
+
{
|
|
26
|
+
startPattern: /^export\s+(default\s+)?(function|class|const|let|var|interface|type)/,
|
|
27
|
+
blockBased: true,
|
|
28
|
+
getLabel: (m) => `Export: ${m[2] || 'default'}`
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
'types',
|
|
33
|
+
{
|
|
34
|
+
startPattern: /^(export\s+)?(interface|type)\s+(\w+)/,
|
|
35
|
+
blockBased: true,
|
|
36
|
+
getLabel: (m) => `Type: ${m[3]}`
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
'error-handling',
|
|
41
|
+
{
|
|
42
|
+
startPattern: /\btry\s*\{/,
|
|
43
|
+
blockBased: true,
|
|
44
|
+
getLabel: () => 'Error handling'
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
'logging',
|
|
49
|
+
{
|
|
50
|
+
linePattern: /\b(console|logger)\.\w+\s*\(/,
|
|
51
|
+
getLabel: () => 'Logging'
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
'tests',
|
|
56
|
+
{
|
|
57
|
+
startPattern: /\b(describe|it|test|beforeEach|afterEach|beforeAll|afterAll)\s*\(/,
|
|
58
|
+
blockBased: true,
|
|
59
|
+
getLabel: (m) => `Test: ${m[1]}`
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
'comments',
|
|
64
|
+
{
|
|
65
|
+
startPattern: /^\s*\/\*\*/,
|
|
66
|
+
endPattern: /\*\/\s*$/,
|
|
67
|
+
multiline: true,
|
|
68
|
+
getLabel: () => 'Documentation'
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
'function',
|
|
73
|
+
{
|
|
74
|
+
startPattern: /^(export\s+)?(async\s+)?function\s+(\w+)|^const\s+(\w+)\s*=\s*(async\s*)?\([^)]*\)\s*=>/,
|
|
75
|
+
blockBased: true,
|
|
76
|
+
getLabel: (m) => `Function: ${m[3] || m[4] || 'anonymous'}`
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
'class',
|
|
81
|
+
{
|
|
82
|
+
startPattern: /^(export\s+)?class\s+(\w+)/,
|
|
83
|
+
blockBased: true,
|
|
84
|
+
getLabel: (m) => `Class: ${m[2]}`
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
'private',
|
|
89
|
+
{
|
|
90
|
+
startPattern: /^\s*(private|#)\s*(\w+)|^\s*_\w+\s*[=(:]/,
|
|
91
|
+
blockBased: true,
|
|
92
|
+
getLabel: () => 'Private member'
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
'constants',
|
|
97
|
+
{
|
|
98
|
+
linePattern: /^(export\s+)?const\s+[A-Z][A-Z0-9_]+\s*=/,
|
|
99
|
+
getLabel: () => 'Constants'
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
]);
|
|
103
|
+
/**
|
|
104
|
+
* Pattern definitions for Python
|
|
105
|
+
*/
|
|
106
|
+
const PYTHON_PATTERNS = new Map([
|
|
107
|
+
[
|
|
108
|
+
'imports',
|
|
109
|
+
{
|
|
110
|
+
startPattern: /^(import\s|from\s+\w+\s+import)/,
|
|
111
|
+
endPattern: /^(?!import|from\s)/,
|
|
112
|
+
multiline: true,
|
|
113
|
+
getLabel: () => 'Import statements'
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
'function',
|
|
118
|
+
{
|
|
119
|
+
startPattern: /^(async\s+)?def\s+(\w+)/,
|
|
120
|
+
blockBased: true,
|
|
121
|
+
getLabel: (m) => `Function: ${m[2]}`
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
'class',
|
|
126
|
+
{
|
|
127
|
+
startPattern: /^class\s+(\w+)/,
|
|
128
|
+
blockBased: true,
|
|
129
|
+
getLabel: (m) => `Class: ${m[1]}`
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
'tests',
|
|
134
|
+
{
|
|
135
|
+
startPattern: /^def\s+test_\w+|^class\s+Test\w+/,
|
|
136
|
+
blockBased: true,
|
|
137
|
+
getLabel: () => 'Test'
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
'comments',
|
|
142
|
+
{
|
|
143
|
+
startPattern: /^\s*"""/,
|
|
144
|
+
endPattern: /"""\s*$/,
|
|
145
|
+
multiline: true,
|
|
146
|
+
getLabel: () => 'Docstring'
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
'error-handling',
|
|
151
|
+
{
|
|
152
|
+
startPattern: /^\s*try\s*:/,
|
|
153
|
+
blockBased: true,
|
|
154
|
+
getLabel: () => 'Error handling'
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
'private',
|
|
159
|
+
{
|
|
160
|
+
startPattern: /^\s*def\s+_\w+|^\s*_\w+\s*=/,
|
|
161
|
+
blockBased: true,
|
|
162
|
+
getLabel: () => 'Private member'
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
]);
|
|
166
|
+
/**
|
|
167
|
+
* Default patterns for unknown languages
|
|
168
|
+
*/
|
|
169
|
+
const DEFAULT_PATTERNS = new Map([
|
|
170
|
+
[
|
|
171
|
+
'comments',
|
|
172
|
+
{
|
|
173
|
+
startPattern: /^\s*\/\*|^\s*#|^\s*\/\//,
|
|
174
|
+
getLabel: () => 'Comment'
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
'function',
|
|
179
|
+
{
|
|
180
|
+
startPattern: /function\s+\w+|def\s+\w+|fn\s+\w+/,
|
|
181
|
+
blockBased: true,
|
|
182
|
+
getLabel: () => 'Function'
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
]);
|
|
186
|
+
/**
|
|
187
|
+
* Get patterns for a language
|
|
188
|
+
*/
|
|
189
|
+
function getPatternsForLanguage(language) {
|
|
190
|
+
const normalized = language.toLowerCase();
|
|
191
|
+
if (normalized === 'javascript' || normalized === 'typescript' || normalized === 'svelte') {
|
|
192
|
+
return JAVASCRIPT_PATTERNS;
|
|
193
|
+
}
|
|
194
|
+
if (normalized === 'python') {
|
|
195
|
+
return PYTHON_PATTERNS;
|
|
196
|
+
}
|
|
197
|
+
return DEFAULT_PATTERNS;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Semantic Analyzer class
|
|
201
|
+
*/
|
|
202
|
+
export class SemanticAnalyzer {
|
|
203
|
+
cache = new Map();
|
|
204
|
+
cacheKey = '';
|
|
205
|
+
/**
|
|
206
|
+
* Analyze lines and return semantic regions
|
|
207
|
+
*/
|
|
208
|
+
analyze(lines, language) {
|
|
209
|
+
// Simple cache check
|
|
210
|
+
const key = `${language}:${lines.length}:${lines[0]?.text ?? ''}`;
|
|
211
|
+
if (key === this.cacheKey && this.cache.has(key)) {
|
|
212
|
+
return this.cache.get(key);
|
|
213
|
+
}
|
|
214
|
+
const patterns = getPatternsForLanguage(language);
|
|
215
|
+
const regions = [];
|
|
216
|
+
// Track block depth for block-based patterns
|
|
217
|
+
const blockStack = [];
|
|
218
|
+
let currentDepth = 0;
|
|
219
|
+
// Track multiline regions
|
|
220
|
+
const multilineRegions = new Map();
|
|
221
|
+
for (let i = 0; i < lines.length; i++) {
|
|
222
|
+
const text = lines[i].text;
|
|
223
|
+
// Count braces for depth tracking
|
|
224
|
+
const opens = (text.match(/\{/g) || []).length;
|
|
225
|
+
const closes = (text.match(/\}/g) || []).length;
|
|
226
|
+
// Check for pattern matches
|
|
227
|
+
for (const [category, config] of patterns) {
|
|
228
|
+
// Line patterns (single line matches)
|
|
229
|
+
if (config.linePattern) {
|
|
230
|
+
if (config.linePattern.test(text)) {
|
|
231
|
+
// Find or create a contiguous region
|
|
232
|
+
const lastRegion = regions.find((r) => r.category === category &&
|
|
233
|
+
r.endLine === i - 1 &&
|
|
234
|
+
!config.blockBased);
|
|
235
|
+
if (lastRegion) {
|
|
236
|
+
lastRegion.endLine = i;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
regions.push({
|
|
240
|
+
category,
|
|
241
|
+
startLine: i,
|
|
242
|
+
endLine: i,
|
|
243
|
+
confidence: 0.9,
|
|
244
|
+
label: config.getLabel?.(text.match(config.linePattern)) ?? category
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Multiline patterns
|
|
250
|
+
if (config.multiline && config.startPattern && config.endPattern) {
|
|
251
|
+
if (!multilineRegions.has(category) && config.startPattern.test(text)) {
|
|
252
|
+
multilineRegions.set(category, {
|
|
253
|
+
startLine: i,
|
|
254
|
+
label: config.getLabel?.(text.match(config.startPattern))
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
else if (multilineRegions.has(category) && config.endPattern.test(text)) {
|
|
258
|
+
const start = multilineRegions.get(category);
|
|
259
|
+
regions.push({
|
|
260
|
+
category,
|
|
261
|
+
startLine: start.startLine,
|
|
262
|
+
endLine: i,
|
|
263
|
+
confidence: 0.85,
|
|
264
|
+
label: start.label ?? category
|
|
265
|
+
});
|
|
266
|
+
multilineRegions.delete(category);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Multiline without explicit end (ends when pattern stops matching)
|
|
270
|
+
if (config.multiline && config.startPattern && !config.endPattern) {
|
|
271
|
+
if (!multilineRegions.has(category) && config.startPattern.test(text)) {
|
|
272
|
+
multilineRegions.set(category, {
|
|
273
|
+
startLine: i,
|
|
274
|
+
label: config.getLabel?.(text.match(config.startPattern))
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
else if (multilineRegions.has(category)) {
|
|
278
|
+
if (!config.startPattern.test(text) && text.trim() !== '') {
|
|
279
|
+
// End the region
|
|
280
|
+
const start = multilineRegions.get(category);
|
|
281
|
+
regions.push({
|
|
282
|
+
category,
|
|
283
|
+
startLine: start.startLine,
|
|
284
|
+
endLine: i - 1,
|
|
285
|
+
confidence: 0.8,
|
|
286
|
+
label: start.label ?? category
|
|
287
|
+
});
|
|
288
|
+
multilineRegions.delete(category);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
// Block-based patterns
|
|
293
|
+
if (config.blockBased && config.startPattern) {
|
|
294
|
+
const match = text.match(config.startPattern);
|
|
295
|
+
if (match && opens > 0) {
|
|
296
|
+
blockStack.push({
|
|
297
|
+
category,
|
|
298
|
+
startLine: i,
|
|
299
|
+
depth: currentDepth + opens,
|
|
300
|
+
label: config.getLabel?.(match)
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// Update depth
|
|
306
|
+
currentDepth += opens - closes;
|
|
307
|
+
// Check if any blocks closed
|
|
308
|
+
while (blockStack.length > 0 && currentDepth < blockStack[blockStack.length - 1].depth) {
|
|
309
|
+
const block = blockStack.pop();
|
|
310
|
+
regions.push({
|
|
311
|
+
category: block.category,
|
|
312
|
+
startLine: block.startLine,
|
|
313
|
+
endLine: i,
|
|
314
|
+
confidence: 0.9,
|
|
315
|
+
label: block.label
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
// Close any remaining multiline regions
|
|
320
|
+
for (const [category, start] of multilineRegions) {
|
|
321
|
+
regions.push({
|
|
322
|
+
category,
|
|
323
|
+
startLine: start.startLine,
|
|
324
|
+
endLine: lines.length - 1,
|
|
325
|
+
confidence: 0.7,
|
|
326
|
+
label: start.label ?? category
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// Sort by start line
|
|
330
|
+
regions.sort((a, b) => a.startLine - b.startLine);
|
|
331
|
+
// Cache result
|
|
332
|
+
this.cacheKey = key;
|
|
333
|
+
this.cache.set(key, regions);
|
|
334
|
+
return regions;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Get regions by category
|
|
338
|
+
*/
|
|
339
|
+
getByCategory(regions, category) {
|
|
340
|
+
return regions.filter((r) => r.category === category);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Get all categories present in regions
|
|
344
|
+
*/
|
|
345
|
+
getCategories(regions) {
|
|
346
|
+
return [...new Set(regions.map((r) => r.category))];
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Clear cache
|
|
350
|
+
*/
|
|
351
|
+
clearCache() {
|
|
352
|
+
this.cache.clear();
|
|
353
|
+
this.cacheKey = '';
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Default fold presets
|
|
358
|
+
*/
|
|
359
|
+
export const DEFAULT_FOLD_PRESETS = [
|
|
360
|
+
{
|
|
361
|
+
id: 'code-review',
|
|
362
|
+
name: 'Code Review',
|
|
363
|
+
description: 'Hide tests, show implementation',
|
|
364
|
+
show: ['exports', 'public', 'function', 'class'],
|
|
365
|
+
hide: ['tests', 'setup', 'imports', 'comments'],
|
|
366
|
+
icon: '\u{1F50D}'
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
id: 'api-surface',
|
|
370
|
+
name: 'API Surface',
|
|
371
|
+
description: 'Show only public interface',
|
|
372
|
+
show: ['exports', 'types', 'public'],
|
|
373
|
+
hide: ['private', 'tests', 'error-handling', 'logging', 'comments'],
|
|
374
|
+
icon: '\u{1F4E4}'
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
id: 'debugging',
|
|
378
|
+
name: 'Debugging',
|
|
379
|
+
description: 'Show error handling and logging',
|
|
380
|
+
show: ['error-handling', 'logging'],
|
|
381
|
+
hide: ['comments', 'types', 'tests'],
|
|
382
|
+
icon: '\u{1F41B}'
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
id: 'tests-only',
|
|
386
|
+
name: 'Tests Only',
|
|
387
|
+
description: 'Show only test code',
|
|
388
|
+
show: ['tests', 'setup'],
|
|
389
|
+
hide: ['imports', 'comments', 'types'],
|
|
390
|
+
icon: '\u{1F9EA}'
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
id: 'minimal',
|
|
394
|
+
name: 'Minimal View',
|
|
395
|
+
description: 'Hide boilerplate and comments',
|
|
396
|
+
show: ['function', 'class', 'exports'],
|
|
397
|
+
hide: ['imports', 'comments', 'boilerplate', 'logging'],
|
|
398
|
+
icon: '\u{1F4CB}'
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: 'documentation',
|
|
402
|
+
name: 'Documentation',
|
|
403
|
+
description: 'Show types and comments',
|
|
404
|
+
show: ['types', 'comments', 'exports'],
|
|
405
|
+
hide: ['private', 'tests', 'error-handling', 'logging'],
|
|
406
|
+
icon: '\u{1F4D6}'
|
|
407
|
+
}
|
|
408
|
+
];
|
|
409
|
+
/**
|
|
410
|
+
* Singleton instance
|
|
411
|
+
*/
|
|
412
|
+
let defaultAnalyzer = null;
|
|
413
|
+
export function getSemanticAnalyzer() {
|
|
414
|
+
if (!defaultAnalyzer) {
|
|
415
|
+
defaultAnalyzer = new SemanticAnalyzer();
|
|
416
|
+
}
|
|
417
|
+
return defaultAnalyzer;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Create new analyzer instance
|
|
421
|
+
*/
|
|
422
|
+
export function createSemanticAnalyzer() {
|
|
423
|
+
return new SemanticAnalyzer();
|
|
424
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snippet Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages code snippets with tab stops, placeholders, and variable expansion.
|
|
5
|
+
* Supports VS Code-style snippet syntax.
|
|
6
|
+
*/
|
|
7
|
+
import type { Position } from './state';
|
|
8
|
+
/**
|
|
9
|
+
* Snippet definition
|
|
10
|
+
*/
|
|
11
|
+
export interface Snippet {
|
|
12
|
+
/** Unique ID */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Display name */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Trigger prefix (what user types to activate) */
|
|
17
|
+
prefix: string;
|
|
18
|
+
/** Snippet body (with placeholders) */
|
|
19
|
+
body: string;
|
|
20
|
+
/** Description */
|
|
21
|
+
description: string;
|
|
22
|
+
/** Languages this snippet applies to (empty = all) */
|
|
23
|
+
languages: string[];
|
|
24
|
+
/** Category for organization */
|
|
25
|
+
category: string;
|
|
26
|
+
/** Whether this is a user-defined snippet */
|
|
27
|
+
isUserDefined: boolean;
|
|
28
|
+
/** Usage count for sorting */
|
|
29
|
+
usageCount: number;
|
|
30
|
+
/** Last used timestamp */
|
|
31
|
+
lastUsed: Date | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Parsed placeholder/tab stop
|
|
35
|
+
*/
|
|
36
|
+
export interface SnippetTabStop {
|
|
37
|
+
/** Tab stop index (0 = final position, 1+ = visit order) */
|
|
38
|
+
index: number;
|
|
39
|
+
/** Start offset in expanded text */
|
|
40
|
+
start: number;
|
|
41
|
+
/** End offset in expanded text */
|
|
42
|
+
end: number;
|
|
43
|
+
/** Placeholder text (if any) */
|
|
44
|
+
placeholder: string;
|
|
45
|
+
/** Choices (if this is a choice placeholder) */
|
|
46
|
+
choices?: string[];
|
|
47
|
+
/** Variable name (if this is a variable) */
|
|
48
|
+
variable?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Expanded snippet ready for insertion
|
|
52
|
+
*/
|
|
53
|
+
export interface ExpandedSnippet {
|
|
54
|
+
/** Expanded text */
|
|
55
|
+
text: string;
|
|
56
|
+
/** Tab stops in order */
|
|
57
|
+
tabStops: SnippetTabStop[];
|
|
58
|
+
/** Current tab stop index */
|
|
59
|
+
currentTabStop: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Snippet session (active snippet editing)
|
|
63
|
+
*/
|
|
64
|
+
export interface SnippetSession {
|
|
65
|
+
/** Session ID */
|
|
66
|
+
id: string;
|
|
67
|
+
/** Snippet being edited */
|
|
68
|
+
snippet: Snippet;
|
|
69
|
+
/** Expanded content */
|
|
70
|
+
expanded: ExpandedSnippet;
|
|
71
|
+
/** Start position in document */
|
|
72
|
+
startPosition: Position;
|
|
73
|
+
/** Whether session is active */
|
|
74
|
+
isActive: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Snippet manager configuration
|
|
78
|
+
*/
|
|
79
|
+
export interface SnippetManagerConfig {
|
|
80
|
+
/** Maximum number of user snippets */
|
|
81
|
+
maxUserSnippets: number;
|
|
82
|
+
/** Built-in snippets */
|
|
83
|
+
builtInSnippets: Snippet[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Snippet Manager
|
|
87
|
+
*/
|
|
88
|
+
export declare class SnippetManager {
|
|
89
|
+
private config;
|
|
90
|
+
private snippets;
|
|
91
|
+
private userSnippets;
|
|
92
|
+
private activeSession;
|
|
93
|
+
private listeners;
|
|
94
|
+
constructor(config?: Partial<SnippetManagerConfig>);
|
|
95
|
+
/**
|
|
96
|
+
* Load built-in snippets
|
|
97
|
+
*/
|
|
98
|
+
private loadBuiltInSnippets;
|
|
99
|
+
/**
|
|
100
|
+
* Add a user-defined snippet
|
|
101
|
+
*/
|
|
102
|
+
addSnippet(snippet: Omit<Snippet, 'id' | 'isUserDefined' | 'usageCount' | 'lastUsed'>): Snippet;
|
|
103
|
+
/**
|
|
104
|
+
* Update a user-defined snippet
|
|
105
|
+
*/
|
|
106
|
+
updateSnippet(id: string, updates: Partial<Omit<Snippet, 'id' | 'isUserDefined'>>): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Delete a user-defined snippet
|
|
109
|
+
*/
|
|
110
|
+
deleteSnippet(id: string): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Get all snippets for a language
|
|
113
|
+
*/
|
|
114
|
+
getSnippetsForLanguage(language: string): Snippet[];
|
|
115
|
+
/**
|
|
116
|
+
* Find snippets matching a prefix
|
|
117
|
+
*/
|
|
118
|
+
findByPrefix(prefix: string, language: string): Snippet[];
|
|
119
|
+
/**
|
|
120
|
+
* Get snippet by ID
|
|
121
|
+
*/
|
|
122
|
+
getSnippet(id: string): Snippet | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Expand a snippet body with variables
|
|
125
|
+
*/
|
|
126
|
+
expand(snippet: Snippet, variables?: Record<string, string>): ExpandedSnippet;
|
|
127
|
+
/**
|
|
128
|
+
* Start a snippet session
|
|
129
|
+
*/
|
|
130
|
+
startSession(snippet: Snippet, startPosition: Position, variables?: Record<string, string>): SnippetSession;
|
|
131
|
+
/**
|
|
132
|
+
* Move to next tab stop
|
|
133
|
+
*/
|
|
134
|
+
nextTabStop(): SnippetTabStop | null;
|
|
135
|
+
/**
|
|
136
|
+
* Move to previous tab stop
|
|
137
|
+
*/
|
|
138
|
+
prevTabStop(): SnippetTabStop | null;
|
|
139
|
+
/**
|
|
140
|
+
* Get current tab stop
|
|
141
|
+
*/
|
|
142
|
+
getCurrentTabStop(): SnippetTabStop | null;
|
|
143
|
+
/**
|
|
144
|
+
* End the current snippet session
|
|
145
|
+
*/
|
|
146
|
+
endSession(): void;
|
|
147
|
+
/**
|
|
148
|
+
* Check if a session is active
|
|
149
|
+
*/
|
|
150
|
+
hasActiveSession(): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Get active session
|
|
153
|
+
*/
|
|
154
|
+
getActiveSession(): SnippetSession | null;
|
|
155
|
+
/**
|
|
156
|
+
* Get all categories
|
|
157
|
+
*/
|
|
158
|
+
getCategories(language?: string): string[];
|
|
159
|
+
/**
|
|
160
|
+
* Export user snippets as JSON
|
|
161
|
+
*/
|
|
162
|
+
exportUserSnippets(): string;
|
|
163
|
+
/**
|
|
164
|
+
* Import user snippets from JSON
|
|
165
|
+
*/
|
|
166
|
+
importUserSnippets(json: string): number;
|
|
167
|
+
/**
|
|
168
|
+
* Subscribe to events
|
|
169
|
+
*/
|
|
170
|
+
subscribe(listener: (event: SnippetEvent) => void): () => void;
|
|
171
|
+
/**
|
|
172
|
+
* Emit event
|
|
173
|
+
*/
|
|
174
|
+
private emit;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Snippet events
|
|
178
|
+
*/
|
|
179
|
+
export type SnippetEvent = {
|
|
180
|
+
type: 'snippet-added';
|
|
181
|
+
snippet: Snippet;
|
|
182
|
+
} | {
|
|
183
|
+
type: 'snippet-updated';
|
|
184
|
+
snippet: Snippet;
|
|
185
|
+
} | {
|
|
186
|
+
type: 'snippet-deleted';
|
|
187
|
+
snippetId: string;
|
|
188
|
+
} | {
|
|
189
|
+
type: 'session-started';
|
|
190
|
+
session: SnippetSession;
|
|
191
|
+
} | {
|
|
192
|
+
type: 'session-ended';
|
|
193
|
+
session: SnippetSession;
|
|
194
|
+
} | {
|
|
195
|
+
type: 'tabstop-changed';
|
|
196
|
+
tabStop: SnippetTabStop;
|
|
197
|
+
session: SnippetSession;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Create a snippet manager
|
|
201
|
+
*/
|
|
202
|
+
export declare function createSnippetManager(config?: Partial<SnippetManagerConfig>): SnippetManager;
|