Git Product home page Git Product logo

ls4p's Introduction

Processing Language Server

LS4P Port

What's Processing Language Server

Processing Language Server is a Language Server Protocol (LSP) implementation for Processing Programming Language. All the language specific features of Processing can now be extended to most the generic editors like VSCode, Atom, Sublime text and so on, by extending this Language Server. LS4P contains both Processing Language Server and a VSCode client. Refer SETUP.md to setup Processing Language Server locally and NEWCLIENT.md to create your own Processing Language Client.

  • Pre-note:

    • Save the sketch with the extension .pde to initiate the Processing Language Server.

  • Activation Event:

    • Processing should appear in the status bar of vscode - indicates Processing Language Server is active.

Current Capabilities of LS4P

  • Auto-completion:

    • Gives you context-aware suggestions to help you code faster.
    • Autocompletion will function as you enter your code in the workspace and can be explicitly triggered using the character . after an instance of a class.

  • Diagnostics:

    • Automatically detects the errors in your code in real-time.
    • Represented using squiggly lines.
    • Hover over the word that has squiggly lines to find out the cause of the error.

  • Go-to definition:

    • cmd+click on a variable, will move the cursor to the variable declaration.
    • This also works for method and class declarations
    • An alternate way of invocation: right-click on the variable name and click Go to Definition.

  • Hover Insights:

    • Hover mouse pointer over a keyword - this brings up a pop-up containing what that keyword means.

  • Finding References:

    • Helps you find all the references of a variable, class or a function used.
    • Can be invoked by clicking on the n References link that appears over all the Variable, Class or Method Declarations.
    • An alternate way of invocation: Right-click on a Variable, Class or Method name and click Peek References.

  • Running sketch:

    • cmd+shift+P to bring up the run console and type Run Processing sketch, press enter - runs the processing sketch.


ls4p's People

Contributors

dependabot[bot] avatar syamsundarkirubakaran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ls4p's Issues

[BUG] Escaped characters and addition of multiple lines in a string give compilation errors

Bug:

code like:

String s = "\n";
String s= "\"";

println("X" +
"X");

Give compilation errors due to the fact the quotation character is replaced with multiple escaped characters ("\"")

export function mapperPipeline(newUnProcessedText: String): string{
let localUnProcessedText = newUnProcessedText.replace(/([0-9]+\.[0-9]+)/g,'$1f')
conversionTuples.forEach(function(tuple){
localUnProcessedText = localUnProcessedText.replace(tuple[0],tuple[1])
})
localUnProcessedText = localUnProcessedText.replace(preprocessing.singleLineComment,``)
// localUnProcessedText = localUnProcessedText.replace(/[\']{1}/g,"\\\'")
localUnProcessedText = localUnProcessedText.replace(/[\"]{1}/g,"\\\"")
return localUnProcessedText
}

Possible Solution

I think the problem lies at the method to create the java file:

try{
childProcess.execSync(`echo \"${processedText}\" > ${__dirname}/compile/${pStandards.defaultClassName}.java`)
log.writeLog(`Java File creation successful`)
} catch(e) {
log.writeLog(`[[ERR]] - Error in Java File Creation`)
}
It now uses an echo command to create the file. If instead a method like fs.writeFileSync() is used there is no need for escaping quotation characters to write the java file. All characters should be written to the file "as is".

[BUG] npm client install error installing vscode.d.ts

Bug:

The npm client install command crashes due to an error while installing vscode.d.ts. Also the setup was a bit tedious due to missing a few required packages for Ubuntu.

Detected VS Code engine version: ^1.23.0
Error installing vscode.d.ts: Error: Request returned status code: 404
Details: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /api/releases/stable</pre>
</body>
</html>

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `vscode-install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Possible solution

Add a "Linux/Ubuntu" section to Setup.md. And change the package-lock.json from the client. to an update vscode package (1.1.37) which runs fine on my Ubuntu VM

[BUG] Singleline comments with some special characters aren't removed from proccesed text

Bug:

Using characters like for example "," and "@" result in a file creation or compile error due to the fact that the aren't removed from the processed text and are written to the java file.

Possible Solution:

Change the regex expression "singleLineComment" in server/src/preprocessing.ts

from: export let singleLineComment = /\/\/([ ]*([A-Za-z\"\.\(\)\'\=\<\>\!])\w*)*/g
to:ย ย ย ย ย export let singleLineComment = /\/\/(.)*/g

[FEATURE] Windows build support

Feature:

Currently there is no way to build the extension on Windows. Unless you have a bash terminal installed. It would be nice to be able to build using the native cmd.

Proposed:

  • add *.bat files
  • move all build scripts to a designated folder

[BUG] Error lines not displayed on windows

bug:

Error lines are not displayed on Windows.

println("x") (without semicolon) should result in an error but non is shown

possible solution(s):

  • Windows paths include a colon after the drive letter. In Diagnostics.ts the split position is hard-coded. Checking the OS-type and then setting the split position accordingly should solve the issue.
  • When checking if the line includes the path due to windows using backslashes instead of forward slashes the check will always be false. Also make the path to check OS-dependent in the caller (parser.ts)

[BUG] Can't run if Sketch involves P2D or P3D

This is one of the issues in Processing Core itself - compatibility issues with macOS Mojave.

Stack Trace:

	1   AppKit                              0x00007fff4568068c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1488
	2   AppKit                              0x00007fff456800b6 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
	3   libnativewindow_macosx.jnilib       0x000000011f3293fe Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398
	4   ???                                 0x000000010c99aa88 0x0 + 4506364552
)

Refer:

[BUG] Character range is offset sometimes

Bug:

Character positions on most language features can be offset by a few to the right. This comes from preprocessing adding a public access specifier when non is provided.

Possible solution:

Calculate the difference in string length from a line before and after preprocessing. After which the difference can be subtracted from the character position. If a access specifier is added in preprocessing the character position is offset to the correct location. If no keyword is added the lines are equal in length and no offset is required.

note: After some thought i won't be implementing this until tabs are supported (PR #29). Because it would need a refactor after merging.

[BUG] Server crashes due to not finding processing core maps

Bug:

With a fresh install of the ls and Ubuntu 20.04.4 LTS. The server comes with a error message and shuts down

internal/fs/utils.js:307
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/home/efratror/Downloads/LS4P-master/server/out/processing/extractor/processing/CORE/PApplet.class'
    at Object.openSync (fs.js:476:3)
    at Object.func [as openSync] (electron/js2c/asar_bundle.js:5:1846)
    at Object.readFileSync (fs.js:377:35)
    at Object.readFileSync (electron/js2c/asar_bundle.js:5:8872)
    at JavaClassFileReader.readFromFile (/home/efratror/Downloads/LS4P-master/server/node_modules/java-class-tools/lib/java-class-reader.js:97:29)
    at JavaClassFileReader.read (/home/efratror/Downloads/LS4P-master/server/node_modules/java-class-tools/lib/java-class-reader.js:50:21)
    at /home/efratror/Downloads/LS4P-master/server/out/completion.js:54:77
    at Array.forEach (<anonymous>)
    at /home/efratror/Downloads/LS4P-master/server/out/completion.js:53:29
    at Array.forEach (<anonymous>) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/efratror/Downloads/LS4P-master/server/out/processing/extractor/processing/CORE/PApplet.class'
}

These is because ubuntu has a case-sensitive filesystem and A.txt an a.txt are two different files.

Solution:

Rename the moduletypes to all lower-case so that the filesystem can find them

let extractionModuleType = [
'CORE',
'AWT',
'DATA',
'EVENT',
'JAVAFX',
'OPENGL'
]

[FEATURE] Run using Play button - Additional extension required

For running the Processing sketch directly from VScode workspace, a Java plugin has to be installed in VScode, so that it can run java code in the VScode sandboxed container.

Currently, the Preprocessed Processing file is run using shell commands on migrating to the above users will not be able to run Processing sketch until this extension is installed.!

Need Processing community's concern regarding this.

[FEATURE] Multiple tab support

Current behavior:
Currently the server only compiles the currently opened file on a file change event. Scripts that are divided in multiple files compile with missing symbol errors ect.

Wanted behavior:
It would be nice to be able to separate a sketch in to multiple files/tabs to simplify coding a bit.

Suggested implementation:
This is based on how the processing pde processes multiple files/tabs

  • Get the contents of all files in the directory and append them together to create one big unprocessed string
  • Keep track of which line in the unprocessed string corresponds to which line in a file/tab in a map
  • Use the map to send the correct filename and line number back to vs-code

As an addition the contents should be updated on every file or workspace change. Doing a file read won't work when the file isn't saved yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.