I started learning p5.js some days ago, and now I wanted to use IntelliJ IDEA instead of the p5.js online editor. Most things like the setup(), draw() and ellipse() functions work as expected, but the createCanvas() function doesn't - it is underlined green and the error message says "Unresolved function or method createCanvas()".
I tried using VSCode, and there it worked perfectly, but I prefer to use IntelliJ, and so I wanted to know if and if yes how I can get it to work in IntelliJ.
<script src="p5.js"></script> //p5.js is the file with all the code from the official p5js.org homepage.
<script src="sketch.js"></script> //sketch.js is the file where my code that should be executed is located
function setup() { //The setup() function is recognized as expected,
createCanvas(1000, 1000); //But the createCanvas() function isn't.
}
p5 functions are defined as p5.prototype.<function name> = function(){}, so the IDE expects a namespace here... As a workaround, please try installing p5 typings: in Preferences | Languages & Frameworks | JavaScript | Libraries, press Downloads..., select p5 from the list. This should solve the problem
I used to mimic the p5js online editor in IntelliJ IDEA by using the Live Edit plugin in combination with split screening Chrome and IntelliJ. The plugin will automatically update your HTML/JS in the Chrome window, s.t. you can instantly see the effects of your changes to your p5js code. It will only work when you run your HTML/JS file in debug mode.
Here's an example:
Related
I have a WASM project. I have a site.js file in the wwwroot/js folder.
I already had a javascript function here and it works fine.
I added two new functions:
function LoadLog(logValue) {
logTa = document.getElementById("logTextArea")
logTa.value = logValue;
ScrollLogToBottom()
}
function ScrollLogToBottom() {
logTa = document.getElementById("logTextArea")
logTa.scrollTop = logTa.scrollHeight;
}
The WASM project would error out when calling these functions, and I went into debug mode.
When I looked at the site.js file - these functions were not present. The other function was present, but these were not. The file is saved (it saves automatically when you run anyway but I double checked it).
This is the debug view:
This is the file in Visual Studio:
As you can see, the Download file appears in the debugger fine - but the rest...not so much.
Is there something I am missing here?
As a further update - I deleted the Download function. I cleaned my solution. I rebuilt my solution, and then ran the solution.
The DownloadFile function was still in the js file - without the other functions...it appears as if the JS file is not being updated.
Further Further update - I deleted the entire JS folder from the Solution, and from the location on my hard drive.
When I run the Blazor app using the Chrome Extension requirement:
chrome --remote-debugging-port=9222 --user-data-dir="C:\Users.....\AppData\Local\Temp\blazor-chrome-debug" https://localhost:7054/
The JS file is still there....appears that this location is holding onto a version of the WASM application?
For anyone that happens across this.
I ran it in Edge and it was fine - no issues. It appears that Chrome is keeping a version on hand and building the solution from that.
I cleared my cache and tried again, and the functions now work as intended.
However, the debugger still showed the old JS File. It seems you have to clear the cache on the debugger Chrome as well - once this was done, the JS file appeared as updated.
I searched for many hours for a solution and found nothing. So, I hope you can help me.
I using the latest version of Visual Studio Code (1.61.0) for Linux: In Atom or WebStorm was it possible, to type in the script tags of a HTML file the first letters of a function or writing the name of an object with a dot and the IDE opens a tool tip to show the possible functions in other JS files. But this don't work in VS Code. Also it is not possible to go to a function source via CTRL + Click. If I go with my mouse over the in HTML written function call, the tool tip displays "any".
My installed extensions (which have maybe influence with the problem):
HTML CSS Support
JavaScript and TypeScript Nightly
Visual Studio IntelliCode
Here are the files and a Screenshot of the "any" dialog. I hope someone knows a solution. Thank you!
index.html:
<script src="./js/hello.js">
document.getElementById("display-div").innerHTML = helloWorld();
</script>
js/hello.js:
function getMessage() {
return "Hi there...";
}
In pure Java or pure JavaScript I am able to use Ctrl+B to jump to a declaration. But when I'm invoking Java from within a JavaScript file, IntelliJ cannot resolve my Java references.
These 3 lines execute no problem, but I cannot press "Ctrl+B" on the "out" or "println" parts of these lines. I want Ctrl+B to jump to the java.lang.System class in my editor like it does when I do the same in a Java file.
// test.js
Java.type("java.lang.System").out.println("howdy");
Packages.java.lang.System.out.println("doody");
java.lang.System.out.println("mister");
I use the following Java to invoke my script:
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
FileReader myScript = new FileReader("test.js");
engine.eval(myScript);
And the output is:
howdy
doody
mister
Does anyone know how to get Ctrl+B (Go To Declaration) to work with IntelliJ in this context?
Out of the box, IntelliJ IDEA has no support for resolving references between JavaScript and Java. Someone from the community was working on a plugin which supported that, but as far as I know the plugin wasn't released.
I`m using phpstorm with protactor for angular and for some reason the IDE doesnt recognize some
functions. but the functions is working fine when i`m running the test.
for example:
element(by.buttonText('toggle')).click();
expect(element(by.css('.net-fade')).getText()).
toEqual('something');
})
The IDE tell me that the method by.css is "unresolved function or method".
Someone know how to fix it?
I'm not familiar with PHPStorm, so this won't be a full-answer:
But I'd say the basic problem is that Protractor binary auto-inserts protractor.js and other dependencies into the environment for you. This is what gives you by (along with other helper variables browser, element, etc).
You may want to insert protractor.js yourself, you can find it in
node_modules/protractor/lib/protractor.js
(And again, I am unsure of how PHPStorm includes files, but you might want to only manually add protractor.js if it is not running in test mode. And to this end, you could set flag in protractors onPrepare() function to check against).
So I downloaded Aptana because many people have said it is the best IDE for javascript. Grabbed a project off github, went to a line in the code that was a method call, right clicked on it and noticed 'open declaration - F3'. Tried both it and F3 with absolutely no response from Aptana....Aptana uninstalled.
Out of curiosity is there any way in Aptana to go from a method call or variable to its declaration? If something that is version 3 cannot do this out-of-the-box, makes me wonder why the hype?
I too recently tried out version 3 after being dissapointed with v2 a while ago.
Open declaration works, if the method is in the same file.. otherwise it fails across multiple files in the same project.
That concludes the answer portion, rest is just my angry rant:
What is even worse that with HOVER on the function call it actually shows the location where the function is located, that is it shows exact directory and file name, yet F3 or open declaration does nothing as OP said.
This means, that there has to be some way of triggering the function lookup across other files in the same project.
How can it be that Aptana knows where the function is located, yet is unable to open it within the same project?
Where are you APTANA developers?
Actually, you can do this though it's not perfect. If you see that it's finding a path to the function, ctrl+hover over the function and it should pop down a list of paths to places where the function was defined in your workspace. Click on one and it will jump you to that declaration.