Eclipse error constantly pops up while editing Javascript - javascript

I am working on relatively small (100-300 lines) Javascript files in Eclipse and periodically it gets really upset about some piece of code and pops up this error every time I place the cursor on that line. The error is:
'Requesting JavaScript AST from Selection' has encountered a problem.
An internal error occured during "Requesting JavaScript AST from selection".
java.lang.NullPointerException
While I am converting this:
if(p){
// enter code here
} else { return false; }
into this:
if(p){
// enter code here
} return false;
the error pops up several times. Each time it stops my typing and requires me to click the okay button. I then type two more characters and the error appears again.
Any ideas how to either prevent the error or disable whatever Javascript AST is?
This is on Eclipse Java EE, Indigo Service Release 2. It is almost a flat install, only two plugins installed and neither are for SVN and have nothing to do with Javascript.

An even better answer (from the bug report linked by Cliff Ribaudo, comment #10 and others):
Turn off Toggle Mark Occurrences (Alt-Shift-O or the paintbrush icon on the toolbar, which handily, will show you your current state).
Thanks Cliff!
Edited:

At first I thought this was just a trick, but it is working so well, I had to post it as an actual answer.
When the error window pops up, don't close it. Just drag it off to the side, focus back on the main window and keep editing.
When the error happens again Eclipse doesn't change the focus back to the error message. Focus stays in the editing window and you can continue to edit the document.

Likely an eclipse bug. See this thread:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=359005
There is a patch posted there which you might try.

Ironically, the solution for me was to install another plugin. After I installed VJET, and set up my JavaScript project to be a VJET-enabled project, the issue went away.

just replace the xml in your .project file (which lies in home directory of your eclipse workspace .
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>your Project Name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

I've been getting this error lately. I am writing Groovy scripts. The fix for me was to update the Groovy plugin.

I was getting same error with gc overhead limit exceeded description in details section of error. To take action on it I have added following in configuration and issue resolved.
Xms512m
Xmx2048m
Ref: GC overhead limit exceeded problem
In short, for me it was eclipse memory problem.

Related

Opencart - cant change js files. adding kind of reddots at the end

firstly very sorry, I cant find out what the real problem is.
I ll try to explain.
My client given code which is developed using opencart and nitropack.
he includes common.js in header, it is basic js file with some ajax calls, UI events etc which has 1297 lines(no formating in code, lots of blank spaces, blank lines etc).
my real problem is, when I made any changes in this file,
the browser console is throwing error invalid or unexpected token.
I checked the common.js file in browser console, seeing that some kind of reddots added at last of the file. I just added a alert() at the begining of file. nothing else.
very sorry, dont know how to explain more detaily.
This is the first time I have seen this kind of issue.
when I removed the alert(), the error gone.

casperjs exit()/die() doesn't return to current directory

I'm fairly new to casperjs (running on phantomjs) - I'm sure I'm probably missing a basic programming element here; looking to see if anyone has some insight. At the end of my script I call casper.exit(), which does exit the script and seemingly steps back into the current directory, however the current directory is not displayed in the command window.
I don't think it's related to the script itself and I can replicate with even the most basic scripts. Below is a screenshot of the outcome:
Where the yellow circle is after the .exit() call, and I would be expecting to see the cd (underlined in red)
I've tried using casper.die() with similar results.
Although it's not a big deal, it might be confusing to someone less familiar with casper/phantom and the script itself.. I guess I'm left with a few questions:
Is this expected behavior from how phantomjs/casperjs is built?
If not, is this a 'bad' thing? (affecting memory, stack, etc.)
Is there a way to return to the CD using casper/phantom or some other method in the script itself?
Bonus question.. is there a difference between using casper.die() and casper.exit()? I see that .die() logs a status message but other than that is there a preferred method to stop script execution or is it just syntactics, as in PHP ?
It is the normal behavior of the casperjs executable on windows. This has likely something to do with the python part of the executable since phantomjs does not have this behavior.
Another indicator is that when casperjs is run through phantomjs like described here, there is no such behavior and I get a normal prompt after exit.
I would say, this is a cosmetic problem that can throw you off when you first encounter it. This isn't really a problem.
Regarding the Bonus question: die can be seen as a fancier exit since it calls exit itself, but it is a more controlled way to exit casper. There is an optional message that is written to stout in red and an additional die event handler. die also sets the execution time of the script.

How to get PHP / JavaScript error popups to appear styled properly?

This is a beginner's question -- surely already answered but I don't know how to find it:
When a coding/system error message pops up during processing of a PHP script or possibly JavaScript, its title is usually "The page at localhost [or other URL] says:". Its content usually includes a load of non-rendered HTML code (<b>, <br>, etc), a long reference to a PHP manual, an actual error message, and a reference to where the error occurred. Because the HTML is being ignored, the whole dialog is hard to read.
How can I get such windows to appear styled properly, as surely intended by the "folks at PHP or JavaScript", or at least appear in simple text with line breaks?
Please note: It is not an error message that I am intending to pop up in response to any user action; I don't know what is causing the message. Also, I'm not seeking advice on how to make user-friendly software or on how to do continuous development-and-delivery
How can I get such windows to appear styled properly, as intended?
I don't know which window you are talking about, however from the rest of your description it sounds to me that you want to turn HTML error off so to get the plain text version of the error messages.
PHP has a setting for that Docs:
html_errors boolean
Turn off HTML tags in error messages. The new format for HTML errors produces clickable messages that direct the user to a page describing the error or function in causing the error. These references are affected by docref_root and docref_ext.
So all you need to do is to turn if off, either in your php.ini:
html_errors = 0
Or within your code:
<?php
ini_set('html_errors', 0);
You might also be interested in:
How to get useful error messages in PHP?
Never have your errors show up in a production website!!
If you're talking about dealing with errors while you're developing, then check out the Whoops library. It'll give you everything you want, plus much more.
Here's a quote from their homepage:
whoops is a nice little library that helps you develop and maintain your projects better, by helping you deal with errors and exceptions in a less painful way.
Check out their demo here. You can click on the left side to go through the stack. Really cool.

Eclipse is hanged on copy/paste in JavaScript files

I've been running Eclipse Helios 3.6 using the Java/CFEclipse IDEs, and finding some very strange and aggravating errors when trying to edit Javascript files. After the .js file reaches a certain size (~250 lines of code), Eclipse will randomly hang whenever I try to select, copy-paste selections, or save. Clicking after the hang starts will result in the "file edit source ... help" bar being whited out, and clicking again leads to the windows "(not responding)" message displayed in the program header. The hang then goes away after another 5-10 seconds of waiting. This is the case for all JavaScript files I try to edit, although shorter ones don't hang as long and don't bring up the "(not responding)" message.
I've thought it was a problem with the Javascript validation/autocomplete options, and have accordingly turned those off; however, the copy-paste hang problem still persists. I've also tried the Javascript IDE - same problem. Is this a problem with Eclipse Javascript handling, period? Has anyone else gotten errors like these? And if it's a fundamentally Eclipse problem, would anyone be able to suggest a better Javascript/Coldfusion editor?
EDIT: For more information, log output from the latest hang:
!ENTRY org.eclipse.wst.jsdt.ui 4 2 2010-08-18 11:25:54.699
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.wst.jsdt.ui".
!STACK 0
java.lang.NullPointerException
at org.eclipse.wst.jsdt.internal.compiler.lookup.ArrayBinding.getExactMethod(ArrayBinding.java:233)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.findExactMethod(Scope.java:401)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getMethod(Scope.java:1813)
at org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:307)
at org.eclipse.wst.jsdt.internal.compiler.ast.Expression.resolve(Expression.java:477)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement.resolve(ForStatement.java:280)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement.resolve(ForStatement.java:280)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.IfStatement.resolve(IfStatement.java:191)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:337)
at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:139)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:291)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:362)
at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:394)
at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.resolve(JavaScriptUnitResolver.java:859)
at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.resolve(JavaScriptUnitResolver.java:527)
at org.eclipse.wst.jsdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:862)
at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:647)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:581)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:574)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:509)
at org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:150)
at org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:135)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!ENTRY org.eclipse.wst.jsdt.ui 4 0 2010-08-18 11:25:54.824
!MESSAGE Error in JSDT Core during AST creation
!STACK 0
java.lang.NullPointerException
at org.eclipse.wst.jsdt.internal.compiler.lookup.ArrayBinding.getExactMethod(ArrayBinding.java:233)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.findExactMethod(Scope.java:401)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getMethod(Scope.java:1813)
at org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:307)
at org.eclipse.wst.jsdt.internal.compiler.ast.Expression.resolve(Expression.java:477)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement.resolve(ForStatement.java:280)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement.resolve(ForStatement.java:280)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.IfStatement.resolve(IfStatement.java:191)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:337)
at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:139)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:291)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:362)
at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:394)
at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.resolve(JavaScriptUnitResolver.java:859)
at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.resolve(JavaScriptUnitResolver.java:527)
at org.eclipse.wst.jsdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:862)
at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:647)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:581)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:574)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:509)
at org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:150)
at org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:135)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
For me the solution was disable this option...
Preferences/JavaScript/Editor/Typing{When pasting}/Update imports
Ok, I think I found a brute force solution to this. I went into windows>preferences>javascript>[all sub menus] and just unchecked as many things as I could stomach to uncheck. I did that a couple of weeks ago and it's only hung once since then (I think it was unrelated as I had to force quit after 5 minutes).
First time met as Eclipse hangs on copy/cut for JavaScript files, and https://github.com/Nodeclipse/nodeclipse-1/issues/159
Current summary:
size matters: big project can cause Eclipse JSDT to freeze (this is old issue as #andreialecu has collected https://github.com/Nodeclipse/nodeclipse-1/issues/159#issuecomment-68098716)
hammer 100% solution is to remove JsNature for that one project
more subtle is to disable only some JSDT features
Window>Preferences>JavaScript>Editor>Mark Occurrences
and maybe even Window->Preferences->General->Editors->Text Editors->Hyperlinking
recommended by JSDT maintainers (for further observation): (by #vrubezhny )
get latest JSDT version
increase available memory settings
use resource filters to hide more files in folders like build/dist/bower/vendor (by #ppartida )
And generally:
pay attention what step you have taken when working with any software.
experiment with little changes
Please add more answers here
(the first issue raised Aug 18 '10)

'Invalid Argument' Error in IE, in a line number that doesn't exist

I'm getting the following error in IE 6:
Line: 454
Char: 13
Error: Invalid Argument
Code: 0
URL: xxxxx/Iframe1.aspx
and I can't for the life of me find what's causing this.
This only happens in a situation where I have a main page that has several IFrames, and it only happens when I have one particular IFrame (the one pointed to by the URL in the error message), and that IFrame is invisible at the time of loading.
I've narrowed it up to there, but I still can't find anything more specific...
The IFrame in question doesn't have 454 lines in its HTML, nor do any of the JS files referred by it.
I tried attaching VS to iexplore.exe as a debugger, and it breaks when the error occurs, but then tells me "There is no source code available for the current location"...
Any suggestions on how I can go about chasing this one?
UPDATE: I found this problem through brute-force, basically, commenting everything out and uncommenting randomly...
But the question still stands: what is the rational way to find where the error is, when IE reports the wrong line number / file?
IE's Javascript engine is disgusting when it comes to debugging. You can try enabling script debugging in the Advanced Options, and then if you have Visual Studio installed it will jump to the place of error... if you're lucky. Other times you don't get anything, especially if the code was eval()'ed.
Another thing about these line numbers is that it doesn't reflect which file the error is happening in. I've had cases where the line number was actually correct, but it was in a linked .js file, not the main file.
Try using the Microsoft Script Debugger or DebugBar (http://www.debugbar.com) which may give you some better IE6 debugging tools. They always help me with IE6.
Also, does this happen in any newer versions of IE or just in IE6?
It's virtually impossible to debug this without a live example, but one thing that often causes an "Invalid Argument" error in Internet Explorer is trying to set an incorrect value for a style property.
So something like:
document.getElementById("foo").style.borderWidth = bar + "px";
when "bar" has the value null, or undefined, or is the string "grandma", will cause it, as "grandmapx" isn't a valid value for the borderWidth style property.
IE9 has a browser mode.
Open up Developer Tools, then select the version you want to emulate in the console, reload the page with errors, and the console will show you line numbers and the correct file where the error is.
I run into this problem a lot too, and I've also resorted to commenting everything out until I find the problem. One thing that I find to be useful is to add a try/catch block to every javascript method. Sometimes I add an alert to tell what method the error came from. Still tedious, but easier than trial and error commenting. And if you add them every time you write a new method it saves a lot of time in the event errors like those occur.
function TestMethod()
{
try
{
//whatever
}
catch (ex)
{
ShowError(ex.description);
//alert("TestMethod");
}
}
A note to other readers: I recently had this "Invalid argument." error reported in IE7-9 and eventually found that it was down to the way I was using setTimeout/setInterval.
This is wrong, in IE:
var Thing = {};
Thing.myFunc = function() { ... };
setTimeout(Thing.myFunc, 1000);
Instead, wrap the callback in an anonymous function like so:
var Thing = {};
Thing.myFunc = function() { ... };
setTimeout(function() { Thing.myFunc(); }, 1000);
and no more "invalid argument" errors.
Another possibility:
I do a lot of dev between two computers, at home and at work, so I often email myself or download pages from the server to work on. Recently I realised that Vista has a habit of unilaterally applying blocks to certain files when they are downloaded in certain ways, without notifying me that it is doing this.
The result is that, for example, an HTML page wants to access the .js file in its header, but it doesn't have permission to access local files. In this case, it doesn't matter what you write in the .js file, the browser will never even read it, and an irksome Line: 0 error will result.
So before you comb your code for an error, check your HTML page's properties, and see if it hasn't been blocked by the OS....
Like NickFitz pointed out, styling was an issue with my code.
document.getElementById('sums<%= event.id %>').style.border='1px solid #3b3b3b;'
I removed the border style and my IE issues were gone.

Categories

Resources