Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm trying to find a Java library to highlight code. I don't want to highlight Java code. I want a library that will easily allow me to highlight a macro language of my own, in a code editor of my own written in Java.
JSyntaxPane is decent. Advanced and decent IDEs use either Lexer/Parsers such as Antlr and Javacc or regular expressions. Implementing it correctly is not a trivial task.
As you mentioned "a macro language of my own", I suggest taking a look at Lexer/Parser generators for Java and maybe JEdit syntax package source code(google it, reached the maximum hyperlinks) for lexing strategies.
GesHi is pretty good. There is a list of highlighters here.
UPDATE: missed that you wanted a java lib. Try jedit syntax package.
You might look at the Java port of GeSHi named JaSHi. It looks like it is a complete rewrite of the popular PHP package, with Java bindings.
JSyntaxPane may be the way to go. It will highlight a number of languages and is extensible to handle others.
You may want to take a look at xtext - it does a lot more than syntax highlighting; in fact, you only have to define a grammar, and it will generate an eclipse editor plugin with outline, syntax highlighting, syntax checking and autocompletion automatically. It could save you a lot of work if an eclipse editor plugin is an acceptable end result for you.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I need tools to:
Conveniently parse Java source code and easily access given elements.
Easily generate source code files, to easily transform data structures into code
Any good tips, libraries, frameworks, tools? Thank you for help.
If you need to parse existing source code, use JavaParser. It gives you visitor-based access to the AST. You can write new code, but many things are a pain (e.g. referencing other classes)
If you need to generate source code use CodeModel. It lets you programmatically create classes, packages, methods etc, and it's very easy to use. However, I don't think it can import existing code.
Both are pretty awesome in their respective domains.
Since Java 6, the compiler has an API included in the JDK. Through it you can access the results of the Java parser through the javax.lang.model APIs. The same functionality was present with JDK5 in the form of the Mirror API. There's a good introductory article here.
The best code generation tool I've seen is CodeModel. It has a very simple API and can generate multiple Java source files at once.
Our DMS Software Reengineering Toolkit and its Java Front End can do this. They are designed to enable the construction of custom analyzers and code generators.
DMS provides generic parsing, abstract-syntax tree (with comments) and symbol table building, tree navigation/inspection/modification facilities, and the ability to regenerate the complete source code from the modified tree. Additional facilities includes source-to-source transformation rules ("if you see this syntax, replace it with that syntax"), and patterns (used to build or recognize subtree), attribute grammar evaluators, control and data flow analysis, and call-graph construction. The Java Front End specializes DMS to do all of this for Java 1.4-1.6 with 1.7 nearby.
(EDIT May 2016: Now handles Java 1.8)
DMS is also designed to handle scale: it is often used to process many compilation-units (source files) at the same time, enabling analysis and transformations that cross file boundaries. It can also handle multiple languages at the same time; DMS has front ends for a wide variety of languages.
Check out Antlr. One of its examples is a Java grammar.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am in a project where previous programmers have been copy-pasting codes all over the place. These codes are actually identical (or very similar) and they could have been refactored into one.
I have spent countless hours refactoring these codes manually but I think there must be a better way. Some are very trivial static methods that could have been moved into an ancestor class (but instead was copy pasted all over by previous junior programmers).
Is there a code analysis tool that can detect this and provide reports/recommendations? I prefer free/open source tool if possible.
I use the following tools:
PMD/CPD (BSD-style License).
Checkstyle (LGPL License) - support was removed, see details.
Both tools have code duplication detection support. But both of them lack the ability to advise you how to refactor your code.
JetBrains IntelliJ IDEA Ultimate has good static code analysis with code duplication support, but it is not free.
Most of the tools listed on the Wikipedia article on Duplicate Code Tools will detect duplicates in many different languages, including Java.
SonarQube can detect duplicated codes but does not give recommendation on eliminating them. It is free and - although with the default setup it can only detect lexically identical clones
Either Simian or PMD's CPD. The former supports a wider set of languages but is non free for commercial projects.
http://checkstyle.sourceforge.net/ has support for finding duplicates
See our SD Java CloneDR, a tool for detecting exact and near-miss duplicate code in large Java systems.
The CloneDR will find code clones in spite of whitespace changes, line breaks, comment insertions deletions, modification of constants or identifiers, and in a number of cases, even replacement of one statement by another or a block of statements.
It shows where each set of clones is found, each individual clone, an abstraction of the clones having their shared commonality and parameterization of the abstraction to show how each clone instance can be derived from the abstraction.
It finds 10-20% clones in most Java systems.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Does anyone know of a good online compiler/runtime (for C++, Java, Python, ObjC etc.) that I can access on the web?
What I'm looking for is something that would allow me to type in a program in a web form and to run the program and see the results online.
(Let's not get into the why for now. Suffice it to say for the moment that I don't always have access to a compiler/runtime, and firing up an IDE is just overkill for testing out some code snippets)
I know of codepad.org -- but I'm looking for something better.
ideone is something better but what particular advence do you need?
http://codepad.org/
codepad.org is an online
compiler/interpreter, and a simple
collaboration tool. Paste your code
below, and codepad will run it and
give you a short URL you can use to
share it in chat or email.
Languages:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
Right now, you can use http://sagenb.org. This is a free open source online Google Docs-like programming notebook environment, which I provide (thanks to a generous grant from the National Science Foundation). Once you create an account and create a new worksheet, click on the box (fourth from left) labeled "Sage" and change it to Python. Now all the code you type in is evaluated using Python. The main drawback is that there are well over 30,000 users of this resource, so sometimes it is slow.
I found this online java compiler and runner. It works in realtime and also with threads. Amazing !
http://www.browxy.com
For C++, you could try CodeControl, Comeau or the one from code.vcer.net.
This one is good for ruby.
Here is an open source one: http://codenode.org, which supports Python and Sage well, but also aims to support other languages like Ruby, R, etc. Probably the best description of Codenode is "Google docs combined with Mathematica Notebooks".
CodeIDE is an ok one: http://www.codeide.com/
You can practice your SQL here.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I've been digging through Stack Overflow as well as a number of Google searches, and I cannot find a satisfactory code formatter for JavaScript.
I have found several related tools, such as syntax highlighters and pretty-printers, but I am looking for a tool that I can ideally create a wrapper for in Eclipse and simply run from the menu bar. Hence, if any Java-based ones are available, that is a big plus. Free and/or open-source is preferred as well.
I am looking for something that my development group can use to maintain a consistent code style.
Edit: Thanks to kRON for linking to the format customizations page.
Edit: Related question on Stack Overflow.
This is by far the best I've come across: http://jsbeautifier.org/
Available as an online tool, or on the command-line using node.js or python.
The source code is available.
In one breath: Aptana Studio! Yes, it's Java based and free (Eclipse, as standalone or plugin).
You can also customize the formatting.
If you already use Eclipse, I recommend you to try Aptana, you can install it as an Eclipse Plugin.
For Eclipse IDE you can use JavaScript Code Formatter based on Goolge's Style Guide
For IntelliJ IDEA you can use the same js code formatter xml file , but previously you have to install a special plugin Eclipse Code Formatter Plugin, which solves the problem of maintaining a common code style in team environments where both IDEA and Eclipse are used
If you also need Java programming I can recommend 'IntelliJ IDEA'
It offers excellent JavaScript formatting and refactoring out of the box.
Have you tried jsfiddler. It's great for trying things out with Javascript. Built in JSLint & something called Tidy. Not sure whether that infers jstidy Piotr Zalewa is the guy who wrote it. May be worth giving him a Tweet #zalun to confirm.
If you are using notepad++, you can try jsminnpp plugin
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Is there a tool out there that can automatically convert Python to Java?
Can Jython do this?
Actually, this may or may not be much help but you could write a script which created a Java class for each Python class, including method stubs, placing the Python implementation of the method inside the Javadoc
In fact, this is probably pretty easy to knock up in Python.
I worked for a company which undertook a port to Java of a huge Smalltalk (similar-ish to Python) system and this is exactly what they did. Filling in the methods was manual but invaluable, because it got you to really think about what was going on. I doubt that a brute-force method would result in nice code.
Here's another possibility: can you convert your Python to Jython more easily? Jython is just Python for the JVM. It may be possible to use a Java decompiler (e.g. JAD) to then convert the bytecode back into Java code (or you may just wish to run on a JVM). I'm not sure about this however, perhaps someone else would have a better idea.
It may not be an easy problem.
Determining how to map classes defined in Python into types in Java will be a big challange because of differences in each of type binding time. (duck typing vs. compile time binding).
Yes Jython does this, but it may or may not be what you want
to clarify your question:
From Python Source code to Java source code? (I don't think so)
.. or from Python source code to Java Bytecode? (Jython does this under the hood)