Bladeren bron

fix style

ruki 3 jaren geleden
bovenliggende
commit
105c4e0f17
5 gewijzigde bestanden met toevoegingen van 54 en 52 verwijderingen
  1. 0 2
      assets/toolchains.lua
  2. 6 4
      src/explorer.ts
  3. 15 15
      src/problem.ts
  4. 21 21
      src/status.ts
  5. 12 10
      src/xmake.ts

+ 0 - 2
assets/toolchains.lua

@@ -1,9 +1,7 @@
 import("core.base.json")
 import("core.tool.toolchain")
 
--- show all toolchains
 function main()
-
     local toolchains = {}
     for _, name in ipairs(toolchain.list()) do
         local t = os.isfile(os.projectfile()) and project.toolchain(name) or toolchain.load(name)

+ 6 - 4
src/explorer.ts

@@ -124,7 +124,7 @@ class XMakeExplorerItem extends vscode.TreeItem {
 
 // Node of an internal representation of the tree view hierarchy
 // This can be deeper than the tree that is shown to the user
-// This stores all nodes in the most primitive form so that each node 
+// This stores all nodes in the most primitive form so that each node
 // corresponds to single entity.
 // The main difference between this type and the tree view is that
 // empty folders in the tree view are concatenated together to reduce the depth.
@@ -170,7 +170,7 @@ class XMakeExplorerDataProvider implements vscode.TreeDataProvider<XMakeExplorer
         targets.sort((t1, t2) => {
             if(t1.group === t2.group)
                 return t1.name.localeCompare(t2.name);
-            
+
             return t1.group.localeCompare(t2.group);
         });
 
@@ -577,7 +577,9 @@ class XMakeOptionsProvider implements vscode.WebviewViewProvider {
         let cmd = "";
         if (this._optionValues) {
             this._optionValues.forEach(element => {
-                cmd += `--${element.name}=${element.value} `;
+                if (element.value) {
+                    cmd += `--${element.name}=${element.value} `;
+                }
             });
         }
         return cmd;
@@ -635,7 +637,7 @@ class XMakeOptionsProvider implements vscode.WebviewViewProvider {
 				<link href="${styleResetUri}" rel="stylesheet">
 				<link href="${styleVSCodeUri}" rel="stylesheet">
 				<link href="${styleMainUri}" rel="stylesheet">
-				
+
 				<title>Options</title>
 			</head>
 			<body>

+ 15 - 15
src/problem.ts

@@ -27,16 +27,16 @@ export class ProblemList implements vscode.Disposable {
         this._diagnosticCollection.dispose();
     }
 
-    // clear problems 
+    // clear problems
     public clear() {
-        
+
         // clear the previous problems first
         this._diagnosticCollection.clear();
     }
 
     // diagnose problems from the current logfile
     public diagnose(logfile: string) {
-        
+
         // clear the previous problems first
         this._diagnosticCollection.clear();
 
@@ -48,9 +48,9 @@ export class ProblemList implements vscode.Disposable {
 
             // read the log file
             fs.readFile(logfile, isWin? null : "utf8", (err, content) => {
-                    
+
                 if (!err && content) {
-                    
+
                     // convert gbk to utf8
                     let text = content;
                     if (isWin) {
@@ -59,19 +59,19 @@ export class ProblemList implements vscode.Disposable {
 
                     // init regex of gcc/clang output
                     const rOutputGcc: RegExp = new RegExp("^(error: )?(.*?):([0-9]*):([0-9]*): (.*?): (.*)$");
-                    
+
                     // init regex of msvc output
-                    const rOutputMsvc: RegExp = new RegExp("(.*?)\\(([0-9]*)\\): (.*?) .*?: (.*)");                    
+                    const rOutputMsvc: RegExp = new RegExp("(.*?)\\(([0-9]*)\\): (.*?) .*?: (.*)");
                     // init diagnostics map
                     let diagnosticsMap: Map<string, vscode.Diagnostic[]> = new Map();
-    
+
                     // parse errors and warnings
                     text.split("\n").forEach(textLine => {
                         if (textLine) {
 
                             // parse warning and error from the given text line
                             let matches: RegExpExecArray = isWin? rOutputMsvc.exec(textLine) : rOutputGcc.exec(textLine);
-                            if (matches) { 
+                            if (matches) {
 
                                 // get warning and error info
                                 let file = "";
@@ -99,8 +99,8 @@ export class ProblemList implements vscode.Disposable {
                                 let uri: vscode.Uri = vscode.Uri.file(path.isAbsolute(file)? file : path.join(config.workingDirectory, file));
 
                                 // get diagnostics of this file
-                                let diagnostics: vscode.Diagnostic[] = diagnosticsMap.get(uri.fsPath);                      
-                                // init severity 
+                                let diagnostics: vscode.Diagnostic[] = diagnosticsMap.get(uri.fsPath);
+                                // init severity
                                 let severity: vscode.DiagnosticSeverity = {error: vscode.DiagnosticSeverity.Error, warning: vscode.DiagnosticSeverity.Warning}[kind];
                                 if (severity != vscode.DiagnosticSeverity.Error && severity != vscode.DiagnosticSeverity.Warning) {
                                     severity = vscode.DiagnosticSeverity.Error;
@@ -118,14 +118,14 @@ export class ProblemList implements vscode.Disposable {
 
                                 // init range
                                 let range = new vscode.Range(startLine, startColumn, endLine, endColumn);
-                                
+
                                 // save diagnostic
                                 let diagnostic = new vscode.Diagnostic(range, message, severity);
                                 if (!diagnostics) {
                                     diagnostics = [];
                                     diagnosticsMap.set(uri.fsPath, diagnostics);
                                 }
-                                diagnostics.push(diagnostic);                         
+                                diagnostics.push(diagnostic);
                             }
                         }
                     });
@@ -137,8 +137,8 @@ export class ProblemList implements vscode.Disposable {
                 }
                 else if (err) {
                     log.error(err.message);
-                } 
+                }
             });
         }
     }
-}
+}

+ 21 - 21
src/status.ts

@@ -16,34 +16,34 @@ export class Status implements vscode.Disposable {
 
     // the architecture button
     private readonly _archButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 4.4);
-    
+
     // the mode button
     private readonly _modeButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 4.3);
-    
+
     // the build button
     private readonly _buildButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 4.2);
-    
+
     // the target button
     private readonly _targetButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 4.1);
 
     // the run button
     private readonly _runButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 4.0);
-    
+
     // the debug button
     private readonly _debugButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 3.9);
-    
+
     // the macro record button
     private readonly _macroRecordButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 3.8);
 
     // the macro playback button
     private readonly _macroPlaybackButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 3.7);
-    
+
     // is visible?
     private _visible: boolean = true;
 
-    // the toolchain 
+    // the toolchain
     private readonly _toolChainButton = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 4.3);
-    
+
     // the constructor
     constructor() {
 
@@ -110,10 +110,10 @@ export class Status implements vscode.Disposable {
     public dispose() {
 
         for (const item of [this._projectButton,
-                            this._platButton, 
+                            this._platButton,
                             this._archButton,
                             this._modeButton,
-                            this._buildButton, 
+                            this._buildButton,
                             this._targetButton,
                             this._runButton,
                             this._debugButton,
@@ -127,10 +127,10 @@ export class Status implements vscode.Disposable {
     // update visibility
     private updateVisibility() {
         for (const item of [this._projectButton,
-                            this._platButton, 
+                            this._platButton,
                             this._archButton,
                             this._modeButton,
-                            this._buildButton, 
+                            this._buildButton,
                             this._targetButton,
                             this._runButton,
                             this._debugButton,
@@ -150,18 +150,18 @@ export class Status implements vscode.Disposable {
         return this._visible;
     }
 
-    // set visible  
+    // set visible
     public set visible(v: boolean) {
         this._visible = v;
         this.updateVisibility();
     }
-    
-    // set the project root  
+
+    // set the project root
     public set project(value: string) {
         this._projectButton.text = `XMake: ${value}`;
     }
 
-    // set the target platform  
+    // set the target platform
     public set plat(value: string) {
         this._platButton.text = value;
     }
@@ -171,28 +171,28 @@ export class Status implements vscode.Disposable {
         this._toolChainButton.text = value;
     }
 
-    // set the target architecture  
+    // set the target architecture
     public set arch(value: string) {
         this._archButton.text = value;
     }
 
-    // set the build mode  
+    // set the build mode
     public set mode(value: string) {
         this._modeButton.text = value;
     }
 
-    // set the default target   
+    // set the default target
     public set target(value: string) {
         this._targetButton.text = value;
     }
 
-    // start to record  
+    // start to record
     public startRecord() {
         this._macroRecordButton.command = 'xmake.onMacroEnd';
         this._macroRecordButton.text = `$(primitive-dot)`;
     }
 
-    // stop to record  
+    // stop to record
     public stopRecord() {
         this._macroRecordButton.command = 'xmake.onMacroBegin';
         this._macroRecordButton.text = `$(primitive-square)`;

+ 12 - 10
src/xmake.ts

@@ -141,11 +141,11 @@ export class XMake implements vscode.Disposable {
         const mode = ("mode" in cacheJson && cacheJson["mode"] != "")? cacheJson["mode"] : "debug";
         this._option.set("mode", mode);
         this._status.mode = mode;
-    
+
         // init defaualt toolchain
         const toolchain = "toolchain";
         this._option.set("toolchain", toolchain);
-        this._status.toolchain = toolchain;        
+        this._status.toolchain = toolchain;
     }
 
     // update Intellisense
@@ -470,7 +470,7 @@ export class XMake implements vscode.Disposable {
 
             // get the toolchain
             let toolchain = this._option.get<string>("toolchain");
-             
+
             // make command
             let command = `${config.executable} f -p ${plat} -a ${arch} -m ${mode}`;
             if (this._option.get<string>("plat") == "android" && config.androidNDKDirectory != "") {
@@ -488,13 +488,11 @@ export class XMake implements vscode.Disposable {
             if (config.additionalConfigArguments) {
                 command += ` ${config.additionalConfigArguments}`
             }
-
             command += ` ${this._xmakeExplorer.getCommandOptions()}`
-
             if (toolchain != "toolchain") {
                 command += " --toolchain=" + toolchain;
             }
-            
+
             // configure it
             await this._terminal.execute("config", command);
 
@@ -949,7 +947,7 @@ export class XMake implements vscode.Disposable {
         }
     }
 
-    // set C/C++ toolchain
+    // set target toolchain
     async setTargetToolchain(target?: string) {
 
         // this plugin enabled?
@@ -957,17 +955,21 @@ export class XMake implements vscode.Disposable {
             return
         }
 
-        let getToolchainsPathScript = path.join(__dirname, `../../assets/toolchains.lua`);
         var tools;
+        let getToolchainsPathScript = path.join(__dirname, `../../assets/toolchains.lua`);
         if (fs.existsSync(getToolchainsPathScript)) {
             tools = JSON.parse((await process.iorunv(config.executable, ["l", getToolchainsPathScript, config.workingDirectory])).stdout.trim());
         }
+        if (!tools) {
+            return
+        }
+
         // select toolchain
         let items: vscode.QuickPickItem[] = [];
         items.push({label: "toolchain", description:"default toolchain for each platform or arch"})
         for (var i = 0; i < tools.length; i++){
             items.push({label: tools[i][0], description:tools[i][1]});
-        }        
+        }
 
         const chosen: vscode.QuickPickItem|undefined = await vscode.window.showQuickPick(items);
         if (chosen && chosen.label !== this._option.get<string>("toolchain")) {
@@ -975,7 +977,7 @@ export class XMake implements vscode.Disposable {
             this._option.set("toolchain", chosen.label);
             this._optionChanged = true;
             this._status.toolchain = chosen.label;
-        }   
+        }
     }
 
     // set target architecture