Ignore java comments with JFlex - jflex

Hi I am trying to ignore java comments using JFlex but I can't manage to make it working, I always have an error in execution. I used these two lines:
commentary = "//"[\r\n]*(\r|\n|\r\n)
<YYINITIAL> {commentary} {}
I also tried different things like commentary = [/][/].* but without success.

commentary = (/*([^]|[\r\n]|(*+([^/]|[\r\n])))*+/)|(//.)
Please try this

Related

There is a way to use lsp4e for calling language server methods directly?

I'm new to the lsp4e & lsp technologies and as far as I have seen the framework provides almost everything for working with eclipse. However there is a way to use this features at will? i.e I would like to use the LS to get all the functions on a file, I think this will be done with textDocument/documentSymbol but how can I get this using the lsp4e framework?
NOTE:
I checked for SymbolKind and seems it was not the one I was looking for however that input helped me finding a sample of DocumentSymbol
DocumentSymbolParams params = new DocumentSymbolParams(
new TextDocumentIdentifier(documentUri.toString()));
CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> symbols =
languageServer.getTextDocumentService().documentSymbol(params);
I checked for SymbolKind and seems it was not the one I was looking for. However that input helped me finding a sample of DocumentSymbol
DocumentSymbolParams params = new DocumentSymbolParams(
new TextDocumentIdentifier(documentUri.toString()));
CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> symbols =
languageServer.getTextDocumentService().documentSymbol(params);

problems with prefs.get and set ImageJ Macro

I'm trying to write a macro to save preferences and read them after closing and reopening ImageJ.
The saving works, but the macro isn't reading the file. Moreover when I try to use one of these two lines an error occurs that the variable "Prefs" is unknown.
int myNumber = Prefs.get("my.persistent.number", 0);
Prefs.savePreferences();
What am I doing wrong? please help me :-)
The ImageJ macro language itself does not support storing custom preferences. (Only the set of built-in options (accessible via Edit > Options in the menu) can be saved, restored and adjusted.) You need to resort to calling the Java class via call("ij.Prefs.get", "my.persistent.number", "0");.
The following ImageJ macro works in an up-to-date Fiji/ImageJ installation:
myNumber = call("ij.Prefs.get", "my.persistent.number", "0");
print(myNumber);
call("ij.Prefs.set", "my.persistent.number", 3);
In the first run, it prints 0; every following run will print 3; after restarting Fiji, it will print 3 again. In case it does not work for you even after updating to the newest version, please report a bug via Help > Report a bug, which will also submit essential information about your installation to the developers to help them fix the issue.
Using one of the many scripting languages however, you can access the ij.Prefs java class directly, as you are trying to do it. Just do not forget to import the class before using it. This is an example Javascript:
importClass(Packages.ij.Prefs);
myNumber = Prefs.get("my.persistent.number", 0);
Prefs.set("my.persistent.number", myNumber);
Hope that helps.

ImageJ - Accessing the results log

This might be a very simple question, but I am writing a little Macro for ImageJ and I cannot access the values in the Results log. Here is the code that does NOT work:
selectWindow("Results");
test=getResult("channel",0);
print("test");
Any tips on how this could be done? Thanks.
You were correct in pointing out that it might be due to a plugin not using the standard results table of ImageJ. The Color_Histogram plugin uses a non-standard way to report the results.
I filed a pull request on github.com that fixes this. When this pull request is merged and uploaded to the Fiji updater, the following macro code works as expected after running Analyze > Color Histogram:
test1 = getResultString("channel", 0);
print(test1);
test2 = getResult("mean", 0);
print(test2);

cfscript Code Assist in CFBuilder

I'm increasingly using cfscript, and like it where appropriately used.
One problem is that there doesn't appear to be any code assist for cfscript in CF Builder, so I find myself writing the tag of a function to leverage the code Assist, then converting to cfscript (which is silly).
For example:
addParam() is the cfscript equivalent of <cfqueryparam >. I get code assist when writing the the tag version, but not the script equivalent.
Does anyone know if there is a code assist library available for cfscript in cfBuilder? Or is this just a downside of working with cfscript?
Many Thanks in advance!
Jason
Your example is not using native CFScript, it's using the hack-solution Adobe provided for some shortcomings of CFScript's coverage of CF tags, which are implemented as a bunch of CFCs in the custom tags dir of your install. This stuff is not representative of CFML & its CFScript support as a whole.
I find that CFB gives hinting for most native functionality... is this not the case for you? What if you try listAppend() for example? Do you get code-assist for that?
UPDATE
I wonder if you get a warning in CFB on your line equivalent to this:
o = new Query();
? I do, by default. I have to make a link to the CustomTags/com dir, and then use this syntax:
o = new com.adobe.Query();
Then I don't get a warning, and indeed I get the code assist you're expecting. I cannot get it to give me hinting on just the non-qualified path to Query.cfc though.
Not ideal. Or maybe I'm missing something, too.

Customize Error Reporting via E-mail in Pylons

I am sending myself WebApp error reports from Pylons when users hit critical errors and I would love to be able to get the full output of session[] in the reports and customize it to my liking, but I've got no idea how to do that, or where the report is actually created / put together.
Anyone know how I can accomplish that?
The short answer is that you will have to roll your own for this functionality. WebError is the package used to handle this, and it doesn't provide any extension points. Your best bet may be to use a fork of it with your changes, although even then the code is not pretty.
I thank Michael for answering me, without really giving me anything to build on. That meant I had to figure it out myself, and that's always a good thing :)
What I did was, I looked at /config/middleware.py in my Pylons project and found this line:
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
I made my own ErrorHandler def and my own ErrorMiddleware class at the top of the middleware.py file:
class ClaraErrorMiddleware(ErrorMiddleware):
def exception_handler(self, exc_info, environ):
# do what ever you want with the exc_info or environ vars
super(ClaraErrorMiddleware, self).exception_handler(exc_info, environ) # call parent
pass
def ClaraErrorHandler(app, global_conf, **errorware):
if asbool(global_conf.get('debug')):
return ErrorHandler(app, global_conf, **errorware)
else:
return ClaraErrorMiddleware(app, global_conf, **errorware)
So now, I can throw in some extra variables I want to be sent with my error emails. Simple enough ...