Anatomy of Menu - scala

I'm trying to understand how a basic Lift 2.5 project works. I'm working from the lift_basic application template, and going over the SimplyLift tutorial. When following the tutorial I find that most things seem to work fine, but I'm struggling to understand the why. In particular:
Menu.i("Home") / "index" >> User.AddUserMenusAfter
When I look at the Lift API for Menu, no function i is listed for Menu, nor any function that seems to define /. (This may refer to a function on String, but the API for that seems to only reference / as operating on a token that follows; I'm not sure if i produces a String.) My basic question is; how do I determine what i() is doing, both here in the specific (what is Menu doing at this point in the process) and in general (when I come across a clearly-working function that is not mentioned in the API)?
As an aside, I'm currently using Eclipse as my IDE, with an sbt build that is actually compiling and loading the webapp locally. Eclipse doesn't seem to do a good job of inferring what objects/functions mean, since the build path does not contain the Lift libraries - they're loaded by sbt. Is it possible to make Eclipse aware of these without polluting the repo and maintaining the library configuration in two places?

i is defined in the companion object, not in the actual class. You can see the definition in the source here Menu.i or in the scaladoc:
/**
* A convenient way to define a Menu item that has the same name as its localized LinkText.
* <pre>Menu.i("Home") / "index"</pre> is short-hand for <pre>Menu("Home", S.loc("Home", Text("Home")) / "index"</pre>
*/
def i(nameAndLink: String): PreMenu = Menu.apply(nameAndLink, S.loc(nameAndLink, scala.xml.Text(nameAndLink)))
/ is defined as part of PreMenu and it allows you to specify where the menu loc gets served from.
If you are using eclipse, you can try the sbteclipse plugin which should help make eclipse aware of your dependencies.

about the second issue. Did you generate the project structure with SBT? Here's the full info: https://github.com/typesafehub/sbteclipse/
In short, I'd remove anything already-created from the folder and launched eclipse with-source=true After that "imported the project" into eclipse and see it just working.)

Related

Output folder of the Kotlin compiler in Eclipse

The Jetbrains Kotlin compiler in Eclipse outputs to a hidden folder inside the Eclipse compiler plugin. This hidden folder is then made available through the Eclipse Kotlin classpath container.
In bndtools we need a normal file system folder since bnd can run both from the file system as well as in Eclipse. Since the folder is a linked resource there is no known way to translate it outside Eclipse.
Anybody knows how to tell the Kotlin compiler to just output it in the bin folder?
Currently, this is not possible in the Kotlin Eclipse plugin.
To make it possible that Kotlin code can be used from Java, Kotlin plugin produce so-called lightweight class files to this folder. These class files do not contain bodies for methods and they are stored in memory.
Actual class files, that are used to run an application, are being built only before launch and they are produced to the default output folder. For now, we cannot produce class files on each save reasonably fast as there is no incremental compilation in the plugin yet:
Feel free to upvote for this issue.
From the short analysis of the code of Kotlin plugin, it looks like the proper method is KotlinCompiler.compileKotlinFiles. It is being called in two contexts:
KotlinBuilder.build — this is the one called on the project build; it makes a call stack trick (or rather a hack...) to check if being called from the LaunchConfigurationDelegate, and depending on the results, either compiles whole project (via its own private fun compileKotlinFiles), or just makes stubs in memory.
KotlinCompilerUtils.compileWholeProject — this is in fact being called from 1.; nice static method, perfect for abuse until the problem is correctly solved in the plugin. :)
So, I'd use the method from 2. wrapped in a similar way as compileKotlinFiles from file in 1.

java documentation of several packages

I've been recently asked to create a full Java documentation of all our APIs.
well creating a documentation for single project is easy (open project then eclipse->project->Generate javadoc).however, I'm not quite sure how is it possible to create a documentation for all the projects so they will be able to point to eachother.
in short to break down my question:
while commenting a packageONE.classA from project1 how am I able to point to package2.classB in project2 (assuming pakcageONE.classA uses API of project2 packageTWO.classB now I want to simply point to it while writing the documentation.)
how is it possible (or is it at all possible) to create javadoc for all the projects at once. so index.html will show a list of projects and upon click on a project it opens all the packages/classes of that project (if javadoc is used for one project index.html points to all packages/classes of that project)
when creating a javadoc even for one project all the native java classes come as full path (e.g. instead of String it shows java.lang.String without links to http://docs.oracle.com/javase/7/docs/api/java/lang/String.html) so is it possible to first show it as String (instead of java.lang.String) and also link it to http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
I hope question is clear enough.
1-2 : did you try to select all projects before generating javadoc ?
3 : try using option -link or -noqualifier
see this for more explanation about options

Eclipse plugin for better JSP support

I'm looking for an eclipse plugin which can at least search where the current JSP is included (or the path mentioned for example in custom "include like" tags or comment or anything). Similar like doing copy qualified name and do a file search with the correct path.In IDEA it's called Analyze Backward Dependencies and it works for JSPs too (at least for the standard includes).
A better one would be to show all the JSPs where the current one is included and show all the included JSPs recursively as a tree maybe so I can navigate in it easily. I'm not sure if this can be done to be usable (I think it would be slow).
Another feature I would like if I click on a variable's name it jumps to where it's declared with even if it's declared in a different JSP.IDEA can do this too.
I have a simple solution for the first one but I can't add more functionality to it as I'm not familiar with the eclipse plugin system and RCP and I don't really have time to learn it.
And please don't tell me to use IDEA because unfortunately that's not an option at work.

GWT compiler doesn't create symbolMaps in the right place

I recently integrated gwt-log into my GWT and Maven based project mostly because of it's ability to automatically deobfuscate client side stack traces on the server. To make this possible gwt-log needs a so called symbol-map which maps all of the obfuscated symbol names to the original Java symbol names. The GWT compiler is capable of generating these symbol maps but for some reason they are saved to a strange location, eg.:
target/project-name-1.0-SNAPSHOT/project-name/.junit_symbolMaps/0F9FD6EF6A1BC63EA834AC33C7ED13F3.symbolMap
According to the GWT Maven Plugin Documentation the GWT compiler has a "-deploy" parameter which determines where to create files like that and which per default points to "WEB-INF/deploy". But even if I manually set this parameter to the correct location the compiler still creates the symbol-maps in the wrong folder.
I even downloaded the GWT Maven Plugin sources and added some log output to find out whether or not the "-deploy" parameter is passed correctly to the compiler but all seems fine.
Has anybody experienced a similar behavior?
Thanks!
Michael
Disable JUnit GWT Module.
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/552a9578a76587ae#

Jad/JadClipse for Scala?

Is there something equivalent or similar to Jad/JadClipse for Scala? It would be nice to be able to view the source for Lift from within Eclipse via "Open Declaration".
I don't know of any decompiler, but I think what you want to do just attach the source to the jar containing classes.
Just right-click on the lift-jar in the package explorer and choose properties. There you can specify a source location. I believe that an attached source location will override an installed jad-plugin.
If you're using maven and m2eclipse, you can simply right-click the lift-dep. -> Maven -> download sources. That will download the -sources.jar and automatically attach.
I man not sure you could get back the exact scala source, but at least you could try and see what the nsc bytecode looks like in Java.
This thread mentions (not tested myself) the Soot Eclipse plugin.
So I might settle on the Eclipse plugin for Soot, which can for example display bytecode using the Grimp notation (well, the following screenshot shows Jimple, but conveys the idea):