I'm looking for a way to verify Java code against an Eclipse code formatting profile from the command line. The goal is to create a Mercurial hook which rejects any commit that doesn't match the profile. Is there a way to do this?
I'm aware of the possibility to call Eclipse's formatter from the command line. What I'm looking for is something which just validates (yes/no). I guess I could use the formatter and then compare the two, but it seems like a clumsy approach.
Background: The reason we want to try this is because we currently get many unnecessary merge conflicts because of formatting differences. We have an environment where multiple IDE:s are used, although only one is officially supported. We want to enforce the official profile, and everyone can continue using the tools they prefer as long as they set it up to format the code correctly.
In brief, follow those steps:
Duplicate the original Java file in a temporary place ;
Format the temporary duplicate using the Eclipse Java code formatter ;
Check whether the files are identical or not.
Tricks to help you out:
To call the Eclipse Java code formatter from command line, see Formatting your code using the Eclipse code formatter.
To know whether files are identical, using the diff utility: diff --text --quiet >/dev/null, the error code will tell you what you're seeking for.
Related
I am trying to separate out internal and external documentation using the doxygen constructs of cond; but i just cant seem to get get it working. I would essentially like to exclude some files completely and not conditionally. Regardless of where i add the tag (before include, before header guards etc) , the files and source both show up.
What i have tried in vain is to take the test file from doxegen repo for
conditional test and add it to the project.
Steps to reproduce [Linux]
create a new directory.
copy paste the above file (had to rename it to .h as .c was passed over?).
generate dummy config via doxygen -g.
update Doxyfile ENABLED_SECTION = COND_ENABLED.
Run doxygen.
check html/index.html
This however is still visible in the html documentation it generates for the project. I have set the ENABLED_SECTION variable with other values , but cond_enabled function still shows up. Running the testing directory of the project (doxygen) it passes. So i am lost.
Any suggestions?
Tried with latest version 1.8.14.
Thanks!
Regarding the \cond problems (not an answer directly to the real problem you face, I think, but to long for a comment).
The mentioned file is used in the, limited, testing doxygen can do / does and the first lines contain some instructions on what to do. Furthermore there is a default Doxyfile with the tests in use. It is hard to run a separate test outside the doxygen build tree.
Regarding the remark "Running the testing directory of the project (doxygen) it passes." This is correct, here, at the moment, only testing is done against the XML output and the generated output is compared to a once created version of the XML output. No tests are done, at the moment, in respect to HTML or PDF / LaTeX. Recently the test framework has been slightly extended so in the future this should be possible (compare the xhtml and tex output, but some work has still to be done here).
The version of the parser sees the \cond in the first line (normal C comment) as a doxygen command and skips everything till the first \endcond (your friend in these cases is always doxygen -d preprocessor). I think that removing / modifying the first line will result in an already better result. There is however another hiccup for e.g. HTML output. As the function cond_enabled is not documented and EXPAND_ALL is not set to YES the function will not appear in the documentation. So best is also to add a line of documentation with the function cond_enabled.
Regarding the seen HTML problems I modified the the relevant test in doxygen slightly and pushed a proposed patch to github (pull request 714, https://github.com/doxygen/doxygen/pull/714).
Note: the problem of skipping the \cond in normal C comment is quite a bit harder to implement (seen the logical complexity of the doxygen code in pre.l and commentcnv.l.
EDIT: 2018/06/10: The push request has been integrated in the master version on github.
My team has been using Notepad for translation purposes so far. Recently, we decided to use one of the CAT tools available on the Internet - OmegaT.
We've got source and manually translated files, and only values were ever touched.
Is it possible to import both to the same project, so that source phrases stay source, and our phrases become their translated counterparts?
Note: I don't know if it matters, but files are formatted as INI (key=value).
What you need is an alignment. It takes source and target files and creates a translation memory.
In your specific case (INI files), you can use OmegaT to do an automatic alignment with a command line:
http://omegat.sourceforge.net/manual-standard/en/chapter.installing.and.running.html#omegat.command.arguments
Sample command line:
java -jar OmegaT.jar "C:\OmegaTProject" --mode=console-align --alignDir="C:\OmegaTProject\align"
For more general purposes, and with a GUI, there's a prototype version of OmegaT with an aligner:
https://omegat.ci.cloudbees.com/job/omegat-prototype/26/
See the OmegaT development mailing list for information about this.
Didier
With currently Beta version of 4.* releases (currently 4.1.5), you can use nice visual aligner - https://www.proz.com/forum/omegat_support/306343-new_interactive_aligner_in_omegat.html
I'm trying to configure the P4Eclipse plugin (2014.1.965331) to use Beyond Compare as external Merge tool.
I have configured the Bcomp.exe as Perforce Merge in Perferences -> Team -> Perforce ->External Tools. so right now when resolve is requested it's opens the Beyond compare, but without the content of the files.
I know there is a list of arguments that needed to be passed (in P4V it's passed in the argument line as %1 %2 %b %r), as documented here : Using Beyond Compare with Version Control Systems
But no luck with the arguments, the trick for adding the arguments is to create a .bat file that calles to Bcomp.exe with additional arguments and set external merge toll to run the .bat file.
Is there any chance to configure it to work fine with beyond compare. (for now only 2 way merge is requested)
The list of arguments is fixed in the P4Eclipse code.
You're right, you're going to have to write a .bat/.cmd to adjust the parameter list.
P4Eclipse code is in our workshop.
The class that runs the command:
https://swarm.workshop.perforce.com/projects/perforce-software-p4eclipse/files/2014-1/src/3.7/plugins/com.perforce.team.ui/src/com/perforce/team/ui/p4merge/MergeRunner.java
Note method getBuilder() that makes the argument list. The constructor too. That's what we've got for documentation right now.
What it passes to the constructor depends on what you're doing - like merge vs diff.
For example, see the "new MergeRunner(...)" in
https://swarm.workshop.perforce.com/projects/perforce-software-p4eclipse/files/2014-1/src/3.7/plugins/com.perforce.team.ui/src/com/perforce/team/ui/p4merge/P4MergeResolveAction.java
Here's an open ended question. I work on a lot of mssql files, and I like to have a date stamp on each. This is so I can know just by looking at the source of a stored procedure whether it's up to date or not.
I'd like to have a shortcut autocomplete key, that, if i type say, d-tab-tab, I get the current date printed to the file. And yes, I am that lazy. :)
So the question is:
Is there any way of getting around this problem entirely?
If not, how would you suggest solving it?
Clever ideas welcome.
Are these files in source control? If so, see whether your source control provider allows templates within the source file which get filled in with the time and date when you check in.
If you use Notepad (and this is possibly the only argument for using it) then F5 does the trick.
What about using version control for your files and including automatic keyword expansion.
Using CVS Keyword Expansion you could put $Date: $ in the file and it will get replaced with the date of the last checkin. No typing or updating needed, it's "auto-magic".
I need to merge a forked project.
Unfortunately, the CVS $Id lines are different so the merge tools I tried report that all the files are different (and 95% of them have only this line different)
Is there a merge tool that can be configured to ignore line comparison results based on a pattern ?
[edit]
I discovered that WinMerge has line filters - setting up them correctly actually works.
Francesco
I use meld, which can use regex filters to ignore.
It has some preset ones you can select including CVS keywords.
The regex it uses for that BTW is:
\$\w+(:[^\n$]+)?\$
You can get meld on any linux distro or
download from here: http://meld.sourceforge.net/
I'm not sure how it's supported on windos,
but I do know kdiff3 supports windows so you could
give it a try there: http://kdiff3.sourceforge.net/
well you could use
cvs update -kk
whick does not expand the $words.
of course this is still a problems the $log which is expanded on commits and not updates.
CompareIT allow to use regular expression matching. I used it for automatically generated code comparison and it was very useful.