Skip to content

Commit 7d0f5bf

Browse files
Merge pull request #8 from Luke-zhang-04/staging
2.3.0 Added - feat(py): add config option processing.py.isEnabled - feat(search): directly search processing reference if possible - feat(search): add py.processing.org search Changed - fix: add extra restrictions to commands
2 parents a232807 + be8dc3f commit 7d0f5bf

File tree

20 files changed

+400
-254
lines changed

20 files changed

+400
-254
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
"[typescript]": {
1010
"editor.defaultFormatter": "esbenp.prettier-vscode",
1111
"editor.formatOnSave": true,
12+
},
13+
"[json]": {
14+
"editor.defaultFormatter": "esbenp.prettier-vscode"
1215
}
1316
}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.3.0] - 2021-05-27
9+
10+
### Added
11+
12+
- feat(py): add config option processing.py.isEnabled
13+
- feat(search): directly search processing reference if possible
14+
- feat(search): add py.processing.org search
15+
16+
### Changed
17+
18+
- fix: add extra restrictions to commands
19+
820
## [2.2.0] - 2021-05-21
921

1022
### Added

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ This extension attempts to make Processing with Python easier to use. Follow the
103103
- Change the following configuration options
104104
- `processing.py.jarPath`: the path to your `processing-py.jar` file. Preferably, this is an absolute path. In this example, it will be `~/processing.py-linux64/processing.py-3056-linux64/processing-py.jar`
105105
- `processing.py.javaPath`: the path to your `java` executable. For example, `/usr/bin/java`
106+
- Make sure `processing.py.isEnabled` is set to `true` (true by default)
106107
4. Downloads stub definitions (optional)
107108
- Definitions can be found [here](https://github.com/Abdulla060/Processing.py-intellisense/blob/master/lib/Processing3.pyi)
108109
- After than, follow the imports in [this example](https://github.com/Abdulla060/Processing.py-intellisense/blob/master/Example.py)

package.json

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "processing-vscode",
33
"displayName": "Processing VSCode",
44
"description": "Processing Language Support for VSCode",
5-
"version": "2.2.0",
5+
"version": "2.3.0",
66
"publisher": "Luke-zhang-04",
77
"engines": {
88
"vscode": "^1.48.0"
@@ -33,6 +33,8 @@
3333
"onCommand:processing.OpenDocs",
3434
"onCommand:processing.SearchWebsite",
3535
"onCommand:processing.Run",
36+
"onCommand:processing.RunJava",
37+
"onCommand:processing.RunPy",
3638
"onLanguage:pde",
3739
"onLanguage:python"
3840
],
@@ -41,29 +43,35 @@
4143
"commands": [
4244
{
4345
"command": "processing.Run",
44-
"title": "Processing: Run Open Processing Project"
46+
"title": "Processing: Run Open Processing Project",
47+
"enablement": "resourceLangId == python || resourceLangId == pde"
4548
},
4649
{
4750
"command": "processing.RunPy",
4851
"title": "Processing: Run Open Processing Python Project",
49-
"icon": "./images/play-arrow-with-logo.svg"
52+
"icon": "./images/play-arrow-with-logo.svg",
53+
"enablement": "resourceLangId == python && config.processing.py.isEnabled"
5054
},
5155
{
5256
"command": "processing.RunJava",
53-
"title": "Processing: Run Open Processing Project",
54-
"icon": "./images/play-arrow.svg"
57+
"title": "Processing: Run Open Processing Java Project",
58+
"icon": "./images/play-arrow.svg",
59+
"enablement": "resourceLangId == pde"
5560
},
5661
{
5762
"command": "processing.OpenExtensionDocumentation",
58-
"title": "Processing: Open Extension Documentation"
63+
"title": "Processing: Open Extension Documentation",
64+
"enablement": "resourceLangId == pde"
5965
},
6066
{
6167
"command": "processing.OpenDocs",
62-
"title": "Processing: Open Documentation for Selection"
68+
"title": "Processing: Open Documentation for Selection",
69+
"enablement": "resourceLangId == pde || resourceLangId == python && config.processing.py.isEnabled"
6370
},
6471
{
6572
"command": "processing.SearchWebsite",
66-
"title": "Processing: Search Processing Website"
73+
"title": "Processing: Search Processing Website",
74+
"enablement": "resourceLangId == pde || resourceLangId == python && config.processing.py.isEnabled"
6775
}
6876
],
6977
"languages": [
@@ -105,7 +113,7 @@
105113
"group": "navigation"
106114
},
107115
{
108-
"when": "resourceLangId == python",
116+
"when": "resourceLangId == python && config.processing.py.isEnabled",
109117
"command": "processing.RunPy",
110118
"group": "navigation"
111119
}
@@ -117,7 +125,7 @@
117125
"group": "navigation"
118126
},
119127
{
120-
"when": "resourceLangId == python",
128+
"when": "resourceLangId == python && config.processing.py.isEnabled",
121129
"command": "processing.RunPy",
122130
"group": "navigation"
123131
}
@@ -134,16 +142,20 @@
134142
},
135143
"processing.docs": {
136144
"type": "string",
137-
"default": "processing.org",
145+
"default": "auto",
138146
"enum": [
139147
"processing.org",
140-
"p5js.org"
148+
"p5js.org",
149+
"py.processing.org",
150+
"auto"
141151
],
142152
"enumDescriptions": [
143153
"Use processing.org for documentation",
144-
"Use p5js for documentation"
154+
"Use p5js for documentation",
155+
"Use py.processing.org for documentation",
156+
"Automatically determine either processing.org or py.processing.org (never p5js) depending on the current file"
145157
],
146-
"description": "Which documentation should this extension use?"
158+
"description": "Which documentation this extension should use"
147159
},
148160
"processing.search": {
149161
"type": "string",
@@ -181,6 +193,11 @@
181193
"type": "string",
182194
"default": "java",
183195
"description": "Path to Java. Leave default if you've added java to your path, otherwise enter the path to `java` here. Example: `/usr/bin/java` for Unix, or `C:\\Program Files\\Java\\jdk1.8.0_202\\bin\\javac.exe` for Windows."
196+
},
197+
"processing.py.isEnabled": {
198+
"type": "boolean",
199+
"default": true,
200+
"description": "If processing.py features should be enabled or not."
184201
}
185202
}
186203
}

rollup.config.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,21 @@ import {terser} from "rollup-plugin-terser"
55
import typescript from "@rollup/plugin-typescript"
66

77
const banner = `/**
8-
* processing-vscode - Processing Language Support for VSCode
9-
* @version 2.2.0
10-
* @copyright (C) 2016 - 2020 Tobiah Zarlez, 2021 Luke Zhang
8+
* Processing-vscode - Processing Language Support for VSCode
9+
* https://github.com/Luke-zhang-04/processing-vscode
10+
*
11+
* @license MIT
12+
* @version 2.3.0
1113
* @preserve
14+
* @copyright (C) 2016 - 2020 Tobiah Zarlez, 2021 Luke Zhang
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
1223
*/
1324
`
1425

@@ -28,7 +39,9 @@ const config = {
2839
progress(),
2940
typescript(),
3041
yaml(),
31-
resolve(),
42+
resolve({
43+
resolveOnly: [/^(?!vscode)$/],
44+
}),
3245
process.env.NODE_ENV === "dev"
3346
? undefined
3447
: terser({

scripts/fetchDocs.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const escapeHTML = (html) =>
115115
* Gets the documentation for a single link
116116
*
117117
* @param {string} link - Link to get doc from
118-
* @returns {Promise<import("./src/documentation").DocumentationVariable>}
118+
* @returns {Promise<import("../src/types").DocumentationVariable>}
119119
*/
120120
const documentVariable = async (link) => {
121121
const documentation = {
@@ -177,7 +177,7 @@ const documentVariable = async (link) => {
177177
* Gets the documentation for a single link
178178
*
179179
* @param {string} link - Link to get doc from
180-
* @returns {Promise<import("./src/documentation").DocumentationFunction>}
180+
* @returns {Promise<import("../src/types").DocumentationFunction>}
181181
*/
182182
const documentFunction = async (link) => {
183183
const documentation = {
@@ -246,7 +246,7 @@ const documentFunction = async (link) => {
246246
* Gets the documentation for a single link
247247
*
248248
* @param {string} link - Link to get doc from
249-
* @returns {Promise<import("./src/documentation").DocumentationClass>}
249+
* @returns {Promise<import("../src/types").DocumentationClass>}
250250
*/
251251
const documentClass = async (link) => {
252252
const documentation = {
@@ -328,7 +328,7 @@ const documentLinks = async ({classLinks, functionLinks, variableLinks}) => {
328328
/**
329329
* All documentation (final object dumped to JSON)
330330
*
331-
* @type {import("./src/documentation").Documentation}
331+
* @type {import("../src/types").Documentation}
332332
*/
333333
const documentation = {}
334334

src/commands/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66

77
import {openDocumentation, openProcessingDocs, searchUnityDocs} from "./search"
88
import {run as runProject} from "./run"
9+
import {shouldEnablePython} from "../config"
910
import vscode from "vscode"
1011

1112
export const subscribeCommands = (context: vscode.ExtensionContext): void => {
1213
context.subscriptions.push(vscode.commands.registerCommand("processing.Run", runProject))
13-
context.subscriptions.push(
14-
vscode.commands.registerCommand("processing.RunPy", () => runProject("py")),
15-
)
14+
15+
if (shouldEnablePython) {
16+
context.subscriptions.push(
17+
vscode.commands.registerCommand("processing.RunPy", () => runProject("py")),
18+
)
19+
}
20+
1621
context.subscriptions.push(
1722
vscode.commands.registerCommand("processing.RunJava", () => runProject("java")),
1823
)

src/commands/run.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,20 @@
44
* @copyright (C) 2021 Luke Zhang
55
*/
66

7-
import {
8-
getJarPath,
9-
getJavaCommand,
10-
getProcessingCommand,
11-
shouldAlwaysQuotePath,
12-
} from "../getConfig"
7+
import {jarPath, javaCommand, processingCommand, shouldAlwaysQuotePath} from "../config"
138
import path, {dirname} from "path"
149
import {isValidProcessingProject} from "../utils"
1510
import vscode from "vscode"
1611

17-
class RunManager {
18-
private static _pythonUtils = {
19-
getProjectFilename: ({fileName}: vscode.TextDocument): string =>
20-
shouldAlwaysQuotePath() || / |\\/u.test(fileName) ? `"${fileName}"` : fileName,
21-
22-
getJarFilename: (): string => {
23-
const jarPath = getJarPath()
12+
const pythonUtils = {
13+
getProjectFilename: ({fileName}: vscode.TextDocument): string =>
14+
shouldAlwaysQuotePath || / |\\/u.test(fileName) ? `"${fileName}"` : fileName,
2415

25-
return shouldAlwaysQuotePath() || / |\\/u.test(jarPath) ? `"${jarPath}"` : jarPath
26-
},
27-
}
16+
getJarFilename: (): string =>
17+
shouldAlwaysQuotePath || / |\\/u.test(jarPath) ? `"${jarPath}"` : jarPath,
18+
}
2819

20+
class RunManager {
2921
private _terminal?: vscode.Terminal = undefined
3022

3123
private _pythonTerminal?: vscode.Terminal = undefined
@@ -88,7 +80,7 @@ class RunManager {
8880

8981
let sketchName = dirname(editor.document.fileName)
9082
const isValidProjectName = isValidProcessingProject(sketchName.split(path.sep).pop())
91-
const shouldQuotePath = shouldAlwaysQuotePath() || / |\\/u.test(sketchName)
83+
const shouldQuotePath = shouldAlwaysQuotePath || / |\\/u.test(sketchName)
9284

9385
if (shouldQuotePath) {
9486
sketchName = `"${sketchName}"`
@@ -103,7 +95,7 @@ class RunManager {
10395
}
10496

10597
// If file is a processing project file
106-
const cmd = `${getProcessingCommand()} --sketch=${sketchName} --run`
98+
const cmd = `${processingCommand} --sketch=${sketchName} --run`
10799

108100
currentTerminal.sendText(cmd)
109101
}
@@ -119,7 +111,7 @@ class RunManager {
119111
currentTerminal.show()
120112

121113
// If file is a processing project file
122-
const cmd = `${getJavaCommand()} -jar ${RunManager._pythonUtils.getJarFilename()} ${RunManager._pythonUtils.getProjectFilename(
114+
const cmd = `${javaCommand} -jar ${pythonUtils.getJarFilename()} ${pythonUtils.getProjectFilename(
123115
editor.document,
124116
)}`
125117

src/commands/search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @copyright (C) 2016 - 2020 Tobiah Zarlez, 2021 Luke Zhang
55
*/
66

7-
import * as search from "../search"
7+
import {search} from "../utils"
88
import vscode from "vscode"
99

1010
const openDocErrorMessage = async (str: string) => {

0 commit comments

Comments
 (0)