misdocumeno

Untitled

Nov 27th, 2020 (edited)
742
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // The module 'vscode' contains the VS Code extensibility API
  2. // Import the module and reference it with the alias vscode in your code below
  3. import * as vscode from 'vscode';
  4.  
  5. // this method is called when your extension is activated
  6. // your extension is activated the very first time the command is executed
  7. export function activate(context: vscode.ExtensionContext) {
  8.  
  9.     // Use the console to output diagnostic information (console.log) and errors (console.error)
  10.     // This line of code will only be executed once when your extension is activated
  11.     console.log('Congratulations, your extension "testexttypescript" is now active!');
  12. }
  13.  
  14. // this method is called when your extension is deactivated
  15. export function deactivate() {}
  16.  
  17.  
  18. const onDidOpenTextDocument = vscode.workspace.onDidOpenTextDocument((document: vscode.TextDocument) => {
  19.  
  20.     if (document.fileName.endsWith('.sp')) {
  21.  
  22.         let compilerPath = 'D:\\Documentos\\Sourcemod scripting\\spcomp.exe';
  23.         getCompileErrorsAndWarnings(compilerPath, document.fileName.replace(/\\/g, '/'));
  24.     }
  25. });
  26.  
  27. // run compiler and read errors and warnings
  28. function getCompileErrorsAndWarnings(compiler: string, file: string) {
  29.  
  30.     console.log('getCompileErrorsAndWarnings called');
  31.  
  32.     let destinationFolder = String(require('path').join(require('os').tmpdir(), '_vscode.smx.tmp'));
  33.  
  34.     require('child_process').execFile(compiler, [file, '-o', destinationFolder], (err: any, stdout: string, stderr: string) => {
  35.  
  36.         console.log('---------------------------------------------');
  37.  
  38.         console.log(stdout);
  39.  
  40.         console.log('---------------------------------------------');
  41.  
  42.         stdout.split('\n').forEach((line) => {
  43.  
  44.             if (line.startsWith(file)) {
  45.  
  46.                 let matches = line.match(new RegExp(`^${file}\\(([0-9]+)\\) : (error|warning|fatal error) ([0-9]+): (.*)`));
  47.  
  48.                 // separate each part
  49.                 let linenum = matches![1];
  50.                 let typemsg = matches![2];
  51.                 let typenum = matches![3];
  52.                 let message = matches![4];
  53.  
  54.                 // get the piece of code with the warning/error
  55.                 let piece = message.match(new RegExp('"(.*?)"'))![1];
  56.                 console.log(piece);
  57.             }
  58.         });
  59.     });
  60. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×