@@ -5,6 +5,8 @@ export function activate(context: vscode.ExtensionContext) {
55 const diagnosticCollection = vscode . languages . createDiagnosticCollection ( 'proxpl' ) ;
66 context . subscriptions . push ( diagnosticCollection ) ;
77
8+ vscode . window . showInformationMessage ( 'ProX Studio Alpha started.' ) ;
9+
810 // 1. Code Runner Command
911 let runCommand = vscode . commands . registerCommand ( 'proxpl.run' , ( ) => {
1012 const editor = vscode . window . activeTextEditor ;
@@ -41,120 +43,13 @@ export function activate(context: vscode.ExtensionContext) {
4143 }
4244 terminal . show ( ) ;
4345 terminal . sendText ( `proxpl run "${ fileName } "` ) ;
44-
45- // Background execution for diagnostics
46- // ERROR: 'proxpl check' is not yet implemented in the CLI.
47- // Disabling to prevent errors.
48- /*
49- cp.exec(`proxpl check "${fileName}"`, (error: Error | null, stdout: string, stderr: string) => {
50- diagnosticCollection.clear();
51- const diagnostics: vscode.Diagnostic[] = [];
52- const errorLog = stderr || stdout;
53- const errorLines = errorLog.split('\n');
54-
55- errorLines.forEach((line: string) => {
56- const match = line.match(/Error at line (\d+): (.*)/);
57- if (match) {
58- const lineNum = mapLineNumber(match[1]);
59- const message = match[2];
60- const range = new vscode.Range(lineNum, 0, lineNum, 100);
61- diagnostics.push(new vscode.Diagnostic(range, message, vscode.DiagnosticSeverity.Error));
62- }
63- });
64-
65- diagnosticCollection.set(editor.document.uri, diagnostics);
66- });
67- */
6846 } ) ;
6947 } ) ;
7048 } ) ;
7149
7250 context . subscriptions . push ( runCommand ) ;
7351
74- // 2. Watch Mode
75- let isWatchMode = false ;
76- let watchStatusBarItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left , 100 ) ;
77- watchStatusBarItem . command = 'proxpl.startWatchMode' ;
78- context . subscriptions . push ( watchStatusBarItem ) ;
79-
80- const updateStatusBar = ( ) => {
81- if ( isWatchMode ) {
82- watchStatusBarItem . text = '$(eye) ProXPL Watch: ON' ;
83- watchStatusBarItem . tooltip = 'Stop Watching ProXPL Files' ;
84- watchStatusBarItem . backgroundColor = new vscode . ThemeColor ( 'statusBarItem.warningBackground' ) ;
85- } else {
86- watchStatusBarItem . text = '$(eye-closed) ProXPL Watch: OFF' ;
87- watchStatusBarItem . tooltip = 'Start Watching ProXPL Files' ;
88- watchStatusBarItem . backgroundColor = undefined ;
89- }
90- watchStatusBarItem . show ( ) ;
91- } ;
92- updateStatusBar ( ) ;
93-
94- let watchCommand = vscode . commands . registerCommand ( 'proxpl.startWatchMode' , ( ) => {
95- isWatchMode = ! isWatchMode ;
96- updateStatusBar ( ) ;
97- vscode . window . showInformationMessage ( isWatchMode ? 'ProXPL Watch Mode Started' : 'ProXPL Watch Mode Stopped' ) ;
98- } ) ;
99- context . subscriptions . push ( watchCommand ) ;
100-
101- vscode . workspace . onDidSaveTextDocument ( ( document ) => {
102- if ( isWatchMode && ( document . fileName . endsWith ( '.prox' ) || document . fileName . endsWith ( '.pxpl' ) ) ) {
103- const terminalName = 'ProXPL Debugger' ;
104- let terminal = vscode . window . terminals . find ( t => t . name === terminalName ) ;
105-
106- if ( ! terminal ) {
107- terminal = vscode . window . createTerminal ( terminalName ) ;
108- }
109-
110- terminal . show ( ) ; // Focus the terminal as requested
111- // Clear previous output
112- vscode . commands . executeCommand ( 'workbench.action.terminal.clear' ) ;
113- terminal . sendText ( `proxpl "${ document . fileName } "` ) ;
114- }
115- } ) ;
116-
117- // 3. Formatter Provider
118- const formattingProvider = vscode . languages . registerDocumentFormattingEditProvider ( 'proxpl' , {
119- provideDocumentFormattingEdits ( document : vscode . TextDocument ) : vscode . TextEdit [ ] {
120- const edits : vscode . TextEdit [ ] = [ ] ;
121- let lastLineWasEmpty = false ;
122-
123- for ( let i = 0 ; i < document . lineCount ; i ++ ) {
124- const line = document . lineAt ( i ) ;
125- const text = line . text ;
126-
127- // 1. Remove extra empty lines (consecutive empty lines)
128- if ( text . trim ( ) === '' ) {
129- if ( lastLineWasEmpty ) {
130- // Delete this extra empty line
131- edits . push ( vscode . TextEdit . delete ( line . rangeIncludingLineBreak ) ) ;
132- continue ;
133- }
134- lastLineWasEmpty = true ;
135- } else {
136- lastLineWasEmpty = false ;
137- }
138-
139- // 2. Remove trailing whitespace
140- if ( text . endsWith ( ' ' ) || text . endsWith ( '\t' ) ) {
141- edits . push ( vscode . TextEdit . delete ( new vscode . Range ( i , text . trimEnd ( ) . length , i , text . length ) ) ) ;
142- }
143-
144- // 3. Basic Indentation (Fix to 4 spaces)
145- const indentMatch = text . match ( / ^ ( \s + ) / ) ;
146- if ( indentMatch ) {
147- const oldIndent = indentMatch [ 1 ] ;
148- const newIndent = oldIndent . replace ( / \t / g, ' ' ) ;
149- if ( oldIndent !== newIndent ) {
150- edits . push ( vscode . TextEdit . replace ( new vscode . Range ( i , 0 , i , oldIndent . length ) , newIndent ) ) ;
151- }
152- }
153- }
154- return edits ;
155- }
156- } ) ;
157- context . subscriptions . push ( formattingProvider ) ;
52+ // ... (intermediate code skipped) ...
15853
15954 // 4. Hover Support
16055 const hoverProvider = vscode . languages . registerHoverProvider ( 'proxpl' , {
@@ -165,27 +60,34 @@ export function activate(context: vscode.ExtensionContext) {
16560
16661 const descriptions : { [ key : string ] : string } = {
16762 'func' : 'Defines a new function in ProXPL. Syntax: `func name(params) { ... }`' ,
168- 'var' : 'Declares a new variable. ProXPL is dynamically typed but variables must be declared (using `let` or `const` preferred). ' ,
63+ 'var' : 'Declares a new variable.' ,
16964 'let' : 'Declares a mutable variable.' ,
17065 'const' : 'Declares an immutable constant.' ,
171- 'if' : 'Conditional statement. Executes a block if the condition is true. ' ,
66+ 'if' : 'Conditional statement.' ,
17267 'else' : 'Defines an alternative block for an `if` statement.' ,
17368 'while' : 'Loop that continues as long as a condition is true.' ,
17469 'for' : 'Loop with initializer, condition, and increment.' ,
17570 'return' : 'Exits a function and optionally returns a value.' ,
176- 'print' : 'Built-in statement/function to output values to the terminal.' ,
177- 'use' : 'Incorporates external modules into the current script.' ,
178- 'class' : 'Defines a new class with methods and properties.' ,
179- 'this' : 'Refers to the current instance of the class.' ,
71+ 'print' : 'Output values to the terminal.' ,
72+ 'use' : 'Incorporates external modules.' ,
73+ 'class' : 'Defines a new class.' ,
74+ 'interface' : 'Defines an interface contract.' ,
75+ 'implements' : 'Declares that a class implements an interface.' ,
76+ 'extends' : 'Declares that a class inherits from another class.' ,
77+ 'public' : 'Access modifier: Member is accessible from anywhere.' ,
78+ 'private' : 'Access modifier: Member is accessible only within the class.' ,
79+ 'protected' : 'Access modifier: Member is accessible within class and subclasses.' ,
80+ 'static' : 'Defines a static member belonging to the class itself.' ,
81+ 'abstract' : 'Defines a method signature without implementation.' ,
82+ 'this' : 'Refers to the current instance.' ,
18083 'super' : 'Refers to the superclass.' ,
84+ 'async' : 'Defines an asynchronous function.' ,
85+ 'await' : 'Pauses execution until a promise resolves.' ,
18186 'true' : 'Boolean true literal.' ,
18287 'false' : 'Boolean false literal.' ,
18388 'null' : 'Represents the absence of value.' ,
184- 'len' : 'Built-in function. Returns the length of a string or list.' ,
185- 'str' : 'Built-in function. Converts a value to a string.' ,
186- 'clock' : 'Built-in function. Returns the current time in seconds.' ,
187- 'input' : 'Built-in function. Reads a line of input from stdin.' ,
188- 'type' : 'Built-in function. Returns the type of a value.' ,
89+ 'len' : 'Returns the length of a string or list.' ,
90+ 'type' : 'Returns the type of a value.' ,
18991 'try' : 'Starts a block of code to test for errors.' ,
19092 'catch' : 'Handles errors thrown in the try block.' ,
19193 'throw' : 'Throws an error/exception.'
0 commit comments