Skip to content

Commit 5d3c902

Browse files
committed
Merge branch 'release/v3.3.0'
2 parents 99361e8 + a4caff0 commit 5d3c902

File tree

8 files changed

+93
-83
lines changed

8 files changed

+93
-83
lines changed
Loading

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Release Notes
22

3+
## 3.3.0 (2023-07-10)
4+
5+
* Enhanced the user experience in the "Project Tasks" explorer by displaying tasks specific to the selected environment by default
6+
* Introduced a new option that allows seamless switching between multi-environment project tasks
7+
* Expanded the functionality of the "Actvity Bar > PlatformIO IDE > Quick Access" menu by including a new item called [Serial & UDP Plotter](https://marketplace.visualstudio.com/items?itemName=alexnesnes.teleplot)
8+
* Updated the PlatformIO Core Installer Script to version [1.2.0](https://github.com/platformio/platformio-core-installer/releases/tag/v1.2.0)
9+
10+
![Toggle between Multi Environment Project Tasks](https://raw.githubusercontent.com/platformio/platformio-vscode-ide/develop/.github/media/platformio-toggle-multienv-tasks.gif)
11+
312
## 3.2.0 (2023-06-09)
413

514
* Introducing a powerful linting feature that highlights syntactical and stylistic issues in the ["platformio.ini"](https://docs.platformio.org/en/latest/projectconf/index.html) configuration file (issue [#3723](https://github.com/platformio/platformio-vscode-ide/issues/3723))

package.json

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "platformio-ide",
3-
"version": "3.2.0",
3+
"version": "3.3.0",
44
"publisher": "platformio",
55
"engines": {
66
"vscode": "^1.65.0"
@@ -142,40 +142,47 @@
142142
"icon": "$(plug)",
143143
"enablement": "pioProjectReady"
144144
},
145+
{
146+
"command": "platformio-ide.toggleMultiEnvProjectTasks",
147+
"title": "Toggle between Multi Environment Project Tasks",
148+
"category": "PlatformIO",
149+
"icon": "$(layers)",
150+
"enablement": "pioProjectTasksReady"
151+
},
145152
{
146153
"command": "platformio-ide.refreshProjectTasks",
147154
"title": "Refresh Project Tasks",
148155
"category": "PlatformIO",
149156
"icon": "$(refresh)",
150-
"enablement": "pioProjectReady"
157+
"enablement": "pioProjectTasksReady"
151158
},
152159
{
153160
"command": "platformio-ide.build",
154161
"title": "Build",
155162
"category": "PlatformIO",
156163
"icon": "$(check)",
157-
"enablement": "pioProjectReady"
164+
"enablement": "pioProjectTasksReady"
158165
},
159166
{
160167
"command": "platformio-ide.upload",
161168
"title": "Upload",
162169
"category": "PlatformIO",
163170
"icon": "$(arrow-right)",
164-
"enablement": "pioProjectReady"
171+
"enablement": "pioProjectTasksReady"
165172
},
166173
{
167174
"command": "platformio-ide.uploadAndMonitor",
168175
"title": "Upload and Monitor",
169176
"category": "PlatformIO",
170177
"icon": "$(arrow-right)",
171-
"enablement": "pioProjectReady"
178+
"enablement": "pioProjectTasksReady"
172179
},
173180
{
174181
"command": "platformio-ide.clean",
175182
"title": "Clean",
176183
"category": "PlatformIO",
177184
"icon": "$(trashcan)",
178-
"enablement": "pioProjectReady"
185+
"enablement": "pioProjectTasksReady"
179186
},
180187
{
181188
"command": "platformio-ide.serialMonitor",
@@ -189,13 +196,13 @@
189196
"title": "Test",
190197
"category": "PlatformIO",
191198
"icon": "$(beaker)",
192-
"enablement": "pioProjectReady"
199+
"enablement": "pioProjectTasksReady"
193200
},
194201
{
195202
"command": "platformio-ide.rebuildProjectIndex",
196203
"title": "Rebuild IntelliSense Index",
197204
"category": "PlatformIO",
198-
"enablement": "pioProjectReady"
205+
"enablement": "pioProjectTasksReady"
199206
},
200207
{
201208
"command": "platformio-ide.startDebugging",
@@ -444,12 +451,17 @@
444451
"view/title": [
445452
{
446453
"command": "platformio-ide.pickProjectEnv",
447-
"when": "pioMultiEnvProject && view == platformio-ide.projectTasks",
454+
"when": "pioProjectTasksReady && pioMultiEnvProject && view == platformio-ide.projectTasks",
455+
"group": "navigation"
456+
},
457+
{
458+
"command": "platformio-ide.toggleMultiEnvProjectTasks",
459+
"when": "pioProjectTasksReady && view == platformio-ide.projectTasks",
448460
"group": "navigation"
449461
},
450462
{
451463
"command": "platformio-ide.refreshProjectTasks",
452-
"when": "pioProjectReady && view == platformio-ide.projectTasks",
464+
"when": "pioProjectTasksReady && view == platformio-ide.projectTasks",
453465
"group": "navigation"
454466
},
455467
{
@@ -887,18 +899,18 @@
887899
},
888900
"dependencies": {
889901
"fs-plus": "~3.1.1",
890-
"platformio-node-helpers": "~11.0.1",
902+
"platformio-node-helpers": "~11.1.0",
891903
"platformio-vscode-debug": "~1.4.1"
892904
},
893905
"devDependencies": {
894906
"@types/node": "~14",
895907
"@types/vscode": "~1.65.0",
896908
"@vscode/vsce": "~2.19.0",
897-
"eslint": "~8.42.0",
909+
"eslint": "~8.44.0",
898910
"eslint-import-resolver-webpack": "~0.13.2",
899911
"eslint-plugin-import": "~2.27.5",
900912
"prettier": "~2.8.8",
901-
"webpack": "~5.85.1",
913+
"webpack": "~5.88.1",
902914
"webpack-cli": "~5.1.4"
903915
},
904916
"extensionDependencies": [

src/project/config.js

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -349,63 +349,11 @@ ${option.description}
349349
return;
350350
}
351351
const script = `
352-
import configparser
353-
import glob
354352
import json
355353
356-
from platformio import fs
357-
from platformio.project import exception
358354
from platformio.public import ProjectConfig
359355
360-
361-
# remove this code for PIO Core 6.1.8+
362-
class TmpProjectConfig(ProjectConfig):
363-
def read(self, path, parse_extra=True):
364-
if path in self._parsed:
365-
return
366-
self._parsed.append(path)
367-
try:
368-
self._parser.read(path, "utf-8")
369-
except configparser.Error as exc:
370-
raise exception.InvalidProjectConfError(path, str(exc)) from exc
371-
if not parse_extra:
372-
return
373-
# load extra configs
374-
for pattern in self.get("platformio", "extra_configs", []):
375-
if pattern.startswith("~"):
376-
pattern = fs.expanduser(pattern)
377-
for item in glob.glob(pattern, recursive=True):
378-
self.read(item)
379-
380-
381-
errors = []
382-
warnings = []
383-
384-
try:
385-
config = TmpProjectConfig()
386-
config.validate(silent=True)
387-
warnings = config.warnings
388-
config.as_tuple()
389-
except Exception as exc:
390-
if exc.__cause__:
391-
exc = exc.__cause__
392-
item = {"type": exc.__class__.__name__, "message": str(exc)}
393-
for attr in ("lineno", "source"):
394-
if hasattr(exc, attr):
395-
item[attr] = getattr(exc, attr)
396-
errors.append(item)
397-
if item["type"] == "ParsingError" and hasattr(exc, "errors"):
398-
for lineno, line in getattr(exc, "errors"):
399-
errors.append(
400-
{
401-
"type": item["type"],
402-
"message": f"Parsing error: {line}",
403-
"lineno": lineno,
404-
"source": item["source"]
405-
}
406-
)
407-
408-
print(json.dumps(dict(errors=errors, warnings=warnings)))
356+
print(json.dumps(ProjectConfig.lint()))
409357
`;
410358
this.diagnosticCollection.clear();
411359
const projectDir = path.dirname(uri.fsPath);

src/project/manager.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ export default class ProjectManager {
112112
vscode.commands.registerCommand('platformio-ide.refreshProjectTasks', () =>
113113
this._taskManager.refresh({ force: true })
114114
),
115+
vscode.commands.registerCommand('platformio-ide.toggleMultiEnvProjectTasks', () =>
116+
this._taskManager.toggleMultiEnvExplorer()
117+
),
115118
vscode.commands.registerCommand('platformio-ide._runProjectTask', (task) =>
116119
this._taskManager.runTask(task)
117120
),
@@ -192,15 +195,19 @@ export default class ProjectManager {
192195

193196
// validate configuration file
194197
const configUri = vscode.Uri.file(path.join(projectDir, 'platformio.ini'));
195-
const isConfigValid = await this._configProvider.lintConfig(configUri);
196-
if (!isConfigValid) {
197-
vscode.window.showErrorMessage(
198-
'The project configuration process has encountered an error due to ' +
199-
"a problem with the 'platformio.ini' file. " +
200-
'Please review the file and fix the issues.'
201-
);
202-
vscode.window.showTextDocument(configUri);
203-
return;
198+
try {
199+
const isConfigValid = await this._configProvider.lintConfig(configUri);
200+
if (!isConfigValid) {
201+
vscode.window.showErrorMessage(
202+
'The project configuration process has encountered an error due to ' +
203+
"a problem with the 'platformio.ini' file. " +
204+
'Please review the file and fix the issues.'
205+
);
206+
vscode.window.showTextDocument(configUri);
207+
return;
208+
}
209+
} catch (err) {
210+
console.error(err);
204211
}
205212

206213
if ('env' in options) {

src/project/task-tree.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,35 @@ import * as vscode from 'vscode';
1111
export default class ProjectTasksTreeProvider {
1212
static DEFAULT_ENV_NAME = 'Default';
1313

14-
constructor(id, envs, tasks, selectedEnv = undefined) {
14+
constructor(id, envs, tasks, selectedEnv = undefined, multiEnvExplorer = false) {
1515
this.id = id;
1616
this.envs = envs;
1717
this.tasks = tasks;
1818
this.selectedEnv = selectedEnv;
1919
this.multiEnvProject = this.envs.length > 1;
20+
this.multiEnvExplorer = multiEnvExplorer;
21+
}
22+
23+
getEnvTasks(env = undefined, group = undefined) {
24+
const cmpGroup = (task) => {
25+
if (!group) {
26+
return true;
27+
}
28+
return task.group === group;
29+
};
30+
const result = this.tasks.filter((task) => cmpGroup(task) && task.coreEnv === env);
31+
// merge default/env-independent tasks
32+
if (env) {
33+
result.push(
34+
...this.tasks.filter(
35+
(task) =>
36+
cmpGroup(task) &&
37+
env !== ProjectTasksTreeProvider.DEFAULT_ENV_NAME &&
38+
!task.multienv
39+
)
40+
);
41+
}
42+
return result;
2043
}
2144

2245
getTreeItem(item) {
@@ -40,9 +63,11 @@ export default class ProjectTasksTreeProvider {
4063

4164
getChildren(element) {
4265
if (element && element.group) {
43-
return this.getEnvGroupChildren(element.env, element.group);
66+
return this.getEnvTasks(element.env, element.group);
4467
} else if (element) {
4568
return this.getEnvChildren(element.env);
69+
} else if (this.selectedEnv && !this.multiEnvExplorer) {
70+
return this.getEnvChildren(this.selectedEnv);
4671
}
4772
return this.getRootChildren();
4873
}
@@ -64,12 +89,8 @@ export default class ProjectTasksTreeProvider {
6489
return result;
6590
}
6691

67-
getEnvGroupChildren(env, group) {
68-
return this.tasks.filter((task) => task.coreEnv === env && task.group === group);
69-
}
70-
7192
getEnvChildren(env) {
72-
const envTasks = this.tasks.filter((task) => task.coreEnv === env);
93+
const envTasks = this.getEnvTasks(env);
7394
if (!envTasks.length) {
7495
return [new vscode.TreeItem('Loading...')];
7596
}

src/project/tasks.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default class ProjectTaskManager {
2525
this.subscriptions = [];
2626

2727
this._sid = Math.random();
28+
this._multienvTaskExplorer = false;
2829
this._refreshTimeout = undefined;
2930
this._startedTask = undefined;
3031
this._tasksToRestore = [];
@@ -38,6 +39,11 @@ export default class ProjectTaskManager {
3839
disposeSubscriptions(this.subscriptions);
3940
}
4041

42+
toggleMultiEnvExplorer() {
43+
this._multienvTaskExplorer = !this._multienvTaskExplorer;
44+
this.refresh({ force: true });
45+
}
46+
4147
requestRefresh() {
4248
if (this._refreshTimeout) {
4349
clearTimeout(this._refreshTimeout);
@@ -67,7 +73,8 @@ export default class ProjectTaskManager {
6773
this._sid,
6874
projectEnvs,
6975
projectTasks,
70-
this.projectObserver.getSelectedEnv()
76+
this.projectObserver.getSelectedEnv(),
77+
this._multienvTaskExplorer
7178
),
7279
showCollapseAll: true,
7380
});
@@ -95,6 +102,7 @@ export default class ProjectTaskManager {
95102

96103
this.registerTaskBasedCommands(projectTasks);
97104
this.registerPortSwitcher();
105+
vscode.commands.executeCommand('setContext', 'pioProjectTasksReady', true);
98106
vscode.commands.executeCommand(
99107
'setContext',
100108
'pioMultiEnvProject',

src/views/quick-access-tree.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ export default class QuickAccessTreeProvider {
6262
undefined,
6363
vscode.TreeItemCollapsibleState.Expanded,
6464
[
65+
new QuickItem(
66+
'Serial & UDP Plotter',
67+
'workbench.extensions.action.showExtensionsWithIds',
68+
[['alexnesnes.teleplot']]
69+
),
6570
new QuickItem('PlatformIO Core CLI', 'platformio-ide.openPIOCoreCLI'),
6671
new QuickItem('Clone Git Project', 'git.clone'),
6772
new QuickItem('New Terminal', 'platformio-ide.newTerminal'),

0 commit comments

Comments
 (0)