Skip to content

Commit

Permalink
Merge pull request #8 from Luke-zhang-04/staging
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Luke-zhang-04 authored May 27, 2021
2 parents a232807 + be8dc3f commit 7d0f5bf
Show file tree
Hide file tree
Showing 20 changed files with 400 additions and 254 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.0] - 2021-05-27

### 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.2.0] - 2021-05-21

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ This extension attempts to make Processing with Python easier to use. Follow the
- Change the following configuration options
- `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`
- `processing.py.javaPath`: the path to your `java` executable. For example, `/usr/bin/java`
- Make sure `processing.py.isEnabled` is set to `true` (true by default)
4. Downloads stub definitions (optional)
- Definitions can be found [here](https://github.com/Abdulla060/Processing.py-intellisense/blob/master/lib/Processing3.pyi)
- After than, follow the imports in [this example](https://github.com/Abdulla060/Processing.py-intellisense/blob/master/Example.py)
Expand Down
45 changes: 31 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "processing-vscode",
"displayName": "Processing VSCode",
"description": "Processing Language Support for VSCode",
"version": "2.2.0",
"version": "2.3.0",
"publisher": "Luke-zhang-04",
"engines": {
"vscode": "^1.48.0"
Expand Down Expand Up @@ -33,6 +33,8 @@
"onCommand:processing.OpenDocs",
"onCommand:processing.SearchWebsite",
"onCommand:processing.Run",
"onCommand:processing.RunJava",
"onCommand:processing.RunPy",
"onLanguage:pde",
"onLanguage:python"
],
Expand All @@ -41,29 +43,35 @@
"commands": [
{
"command": "processing.Run",
"title": "Processing: Run Open Processing Project"
"title": "Processing: Run Open Processing Project",
"enablement": "resourceLangId == python || resourceLangId == pde"
},
{
"command": "processing.RunPy",
"title": "Processing: Run Open Processing Python Project",
"icon": "./images/play-arrow-with-logo.svg"
"icon": "./images/play-arrow-with-logo.svg",
"enablement": "resourceLangId == python && config.processing.py.isEnabled"
},
{
"command": "processing.RunJava",
"title": "Processing: Run Open Processing Project",
"icon": "./images/play-arrow.svg"
"title": "Processing: Run Open Processing Java Project",
"icon": "./images/play-arrow.svg",
"enablement": "resourceLangId == pde"
},
{
"command": "processing.OpenExtensionDocumentation",
"title": "Processing: Open Extension Documentation"
"title": "Processing: Open Extension Documentation",
"enablement": "resourceLangId == pde"
},
{
"command": "processing.OpenDocs",
"title": "Processing: Open Documentation for Selection"
"title": "Processing: Open Documentation for Selection",
"enablement": "resourceLangId == pde || resourceLangId == python && config.processing.py.isEnabled"
},
{
"command": "processing.SearchWebsite",
"title": "Processing: Search Processing Website"
"title": "Processing: Search Processing Website",
"enablement": "resourceLangId == pde || resourceLangId == python && config.processing.py.isEnabled"
}
],
"languages": [
Expand Down Expand Up @@ -105,7 +113,7 @@
"group": "navigation"
},
{
"when": "resourceLangId == python",
"when": "resourceLangId == python && config.processing.py.isEnabled",
"command": "processing.RunPy",
"group": "navigation"
}
Expand All @@ -117,7 +125,7 @@
"group": "navigation"
},
{
"when": "resourceLangId == python",
"when": "resourceLangId == python && config.processing.py.isEnabled",
"command": "processing.RunPy",
"group": "navigation"
}
Expand All @@ -134,16 +142,20 @@
},
"processing.docs": {
"type": "string",
"default": "processing.org",
"default": "auto",
"enum": [
"processing.org",
"p5js.org"
"p5js.org",
"py.processing.org",
"auto"
],
"enumDescriptions": [
"Use processing.org for documentation",
"Use p5js for documentation"
"Use p5js for documentation",
"Use py.processing.org for documentation",
"Automatically determine either processing.org or py.processing.org (never p5js) depending on the current file"
],
"description": "Which documentation should this extension use?"
"description": "Which documentation this extension should use"
},
"processing.search": {
"type": "string",
Expand Down Expand Up @@ -181,6 +193,11 @@
"type": "string",
"default": "java",
"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."
},
"processing.py.isEnabled": {
"type": "boolean",
"default": true,
"description": "If processing.py features should be enabled or not."
}
}
}
Expand Down
21 changes: 17 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ import {terser} from "rollup-plugin-terser"
import typescript from "@rollup/plugin-typescript"

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

Expand All @@ -28,7 +39,9 @@ const config = {
progress(),
typescript(),
yaml(),
resolve(),
resolve({
resolveOnly: [/^(?!vscode)$/],
}),
process.env.NODE_ENV === "dev"
? undefined
: terser({
Expand Down
8 changes: 4 additions & 4 deletions scripts/fetchDocs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const escapeHTML = (html) =>
* Gets the documentation for a single link
*
* @param {string} link - Link to get doc from
* @returns {Promise<import("./src/documentation").DocumentationVariable>}
* @returns {Promise<import("../src/types").DocumentationVariable>}
*/
const documentVariable = async (link) => {
const documentation = {
Expand Down Expand Up @@ -177,7 +177,7 @@ const documentVariable = async (link) => {
* Gets the documentation for a single link
*
* @param {string} link - Link to get doc from
* @returns {Promise<import("./src/documentation").DocumentationFunction>}
* @returns {Promise<import("../src/types").DocumentationFunction>}
*/
const documentFunction = async (link) => {
const documentation = {
Expand Down Expand Up @@ -246,7 +246,7 @@ const documentFunction = async (link) => {
* Gets the documentation for a single link
*
* @param {string} link - Link to get doc from
* @returns {Promise<import("./src/documentation").DocumentationClass>}
* @returns {Promise<import("../src/types").DocumentationClass>}
*/
const documentClass = async (link) => {
const documentation = {
Expand Down Expand Up @@ -328,7 +328,7 @@ const documentLinks = async ({classLinks, functionLinks, variableLinks}) => {
/**
* All documentation (final object dumped to JSON)
*
* @type {import("./src/documentation").Documentation}
* @type {import("../src/types").Documentation}
*/
const documentation = {}

Expand Down
11 changes: 8 additions & 3 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@

import {openDocumentation, openProcessingDocs, searchUnityDocs} from "./search"
import {run as runProject} from "./run"
import {shouldEnablePython} from "../config"
import vscode from "vscode"

export const subscribeCommands = (context: vscode.ExtensionContext): void => {
context.subscriptions.push(vscode.commands.registerCommand("processing.Run", runProject))
context.subscriptions.push(
vscode.commands.registerCommand("processing.RunPy", () => runProject("py")),
)

if (shouldEnablePython) {
context.subscriptions.push(
vscode.commands.registerCommand("processing.RunPy", () => runProject("py")),
)
}

context.subscriptions.push(
vscode.commands.registerCommand("processing.RunJava", () => runProject("java")),
)
Expand Down
30 changes: 11 additions & 19 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,20 @@
* @copyright (C) 2021 Luke Zhang
*/

import {
getJarPath,
getJavaCommand,
getProcessingCommand,
shouldAlwaysQuotePath,
} from "../getConfig"
import {jarPath, javaCommand, processingCommand, shouldAlwaysQuotePath} from "../config"
import path, {dirname} from "path"
import {isValidProcessingProject} from "../utils"
import vscode from "vscode"

class RunManager {
private static _pythonUtils = {
getProjectFilename: ({fileName}: vscode.TextDocument): string =>
shouldAlwaysQuotePath() || / |\\/u.test(fileName) ? `"${fileName}"` : fileName,

getJarFilename: (): string => {
const jarPath = getJarPath()
const pythonUtils = {
getProjectFilename: ({fileName}: vscode.TextDocument): string =>
shouldAlwaysQuotePath || / |\\/u.test(fileName) ? `"${fileName}"` : fileName,

return shouldAlwaysQuotePath() || / |\\/u.test(jarPath) ? `"${jarPath}"` : jarPath
},
}
getJarFilename: (): string =>
shouldAlwaysQuotePath || / |\\/u.test(jarPath) ? `"${jarPath}"` : jarPath,
}

class RunManager {
private _terminal?: vscode.Terminal = undefined

private _pythonTerminal?: vscode.Terminal = undefined
Expand Down Expand Up @@ -88,7 +80,7 @@ class RunManager {

let sketchName = dirname(editor.document.fileName)
const isValidProjectName = isValidProcessingProject(sketchName.split(path.sep).pop())
const shouldQuotePath = shouldAlwaysQuotePath() || / |\\/u.test(sketchName)
const shouldQuotePath = shouldAlwaysQuotePath || / |\\/u.test(sketchName)

if (shouldQuotePath) {
sketchName = `"${sketchName}"`
Expand All @@ -103,7 +95,7 @@ class RunManager {
}

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

currentTerminal.sendText(cmd)
}
Expand All @@ -119,7 +111,7 @@ class RunManager {
currentTerminal.show()

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

Expand Down
2 changes: 1 addition & 1 deletion src/commands/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright (C) 2016 - 2020 Tobiah Zarlez, 2021 Luke Zhang
*/

import * as search from "../search"
import {search} from "../utils"
import vscode from "vscode"

const openDocErrorMessage = async (str: string) => {
Expand Down
Loading

0 comments on commit 7d0f5bf

Please sign in to comment.