How to create custom terminal grammar for xtext? - eclipse

My grammar file is already too large and is causing the error:
The code for the static initializer is exceeding the 65535 bytes limit.
So, I want to split my grammar into 2 xtext files, and create a separate custom terminal.xtext to lower down the size of my grammar file.
I have an xtext project in org.xtext.rpcIDL, where my RpcIDL.xtext is in its src directory.
I have read here that its possible to have 2 grammar files in one project. But I cannot add another grammar file in my current project. When I right-click, then go to New, there is no option there to add a new xtext file.
How can I add a custom xtext file in my project?

I don't know if you already found out the solution by yourself but in case you didn't:
To create a new Xtext-File in your project right click in your org.xtext.rpcIDLwhich should be in your text-project under src (The one with the package symbol in front of it), then go to New->File and then you just have to give it a name and add the extension .xtext. That will add the xtext-nature to your project. After that you have to add the line grammar ... (just copy this line of your other file and change the last element to the name of your new File). Then add with and enter the name of your other xtext-file (this is the one which stands after the generate in your other file. Then you should be able to use the elements of all the features which you have declared in your original File.
I hope I could help you.
Greets Krzmbrzl

Related

paste a file with existing file name in vscode cause them to rename instead of replace existing file

when I copy a file to a folder that a file with same name exist, the new file get renamed instead of replacing the existing file.
for example if I copy a file abc.jpg from one folder into another folder that abc.jpg exist. i will end up with two files that the old one is abc.jpg and new one is abc copy.jpg
it's new feature and wasn't like this before. unfortunately I can't find any configuration to change it, also keywords such as "copy", "file", "replace" is too generic that I can't find a solution for this problem by just googling it.
Update
if anyone land in here from google, it's a feature that the vscode team need to consider, please vote/comment in here
Vscode update of september 2022 adds this behaviour.
https://code.visualstudio.com/updates/v1_72#_disable-incremental-naming
just change in your settings : "explorer.incrementalNaming": "disabled".
You get propmted if you want to replace or not

How to find and replace a string in all files of a project using netBeans

I have a PHP project in NetBeans
I have a constant named KEY and I want to change it to SECURE . This constant is spread through out many files of my project. How can I approach this very quickly. I've heard of refactoring, and even tried it but it only renamed the current file and not the whole project's files.
Use Ctrl+Shift+H, after clicked on project folder. Lower in dialog you may specify all needed params. As far as it's a constant, you may prefer to specify case match, or if needed, use regular expressions

Automating Localizable.strings?

So, in my project I have 10 languages, and 10 Localizable.strings files.
I just created Localizable.strings files, a file for each language. Now they contain "key" = "value" pairs, and both keys and values are in English (default language).
My languages are all translated and stay in Excel files.
The question is, how can I insert all my languages in those files faster than just copying each word manually or writing a script for that?
Maybe there is a existing tool for this already?
Thanks.
I found an easy way to compose localizable.strings files from Excel documents.
In the Excel document, in specific columns I insert " " = " " symbols. It's easy to do for all the words by dragging Excel cell down from the corner, so that it copies stuff from that cell to all the cells you drag it to. (sorry for messy explanation)
Thus the document contains the same symbols and words as localizable.strings does.
Than I just copy everything to the text file, remove tabs, change extension to .strings.
(no comments saved unfortunately).
EDIT:
You can copy the stuff from Excel to Sublime Text, then Find & Replace tabs if any. Copy resulted stuff into proper Xcode .string file.
One application that will really save you a lot of time by automating and streamlining localization procedure is Localization Suite. I do not know if they support importing from excel (to save you time transferring your string pairs) but it's free and seems like a complete solution.
I had an internal script at work for doing that tasks in iOS and Android, and I've just opensourced it as a Gem. You can take a look at it here: http://github.com/mrmans0n/localio
It can open spreadsheets from Google Drive and local Excel files as well, like requested.
You just would have to install the gem
gem install localio
And have a custom DSL file in your project directory, called Locfile, with the info referring to your project and the localization files. An example in your case, where an Excel file is used, could be as simple as:
platform :ios
source :xls, :path => 'YourExcelFileGoesInHere.xls'
output_path 'Resources/Localizables/'
The .xls file should have a certain format, that probably is very similar to what you have right now. You just have to clone the contents of this one and fill it with your translations: https://docs.google.com/spreadsheet/ccc?key=0AmX_w4-5HkOgdFFoZ19iSUlRSERnQTJ4NVZiblo2UXc
Hope this helps.
Here are the steps i followed:
change the extension of .strings to .txt on windows
open excel and go to File > Open
Choose the file to open. This should present an import wizard
Follow the steps and specify the delimiting character as =
You're done

Excluding file extension in TFS2010 version control

I generate with T4 templates some file (*.generated.sql, *.generated.cs).
How can i exclude files with this extension from TFS 2010 version control.
(no explicit excluding for a file - looking for excluding foe 'all files with extension *.blabla)
The simplest way to manage this is with the exclusion filter in TFS' source control explorer.
To access it open the source control explorer, and choose to Add File. It doesn't matter how you do it, as long as the Add to Source Control form opens. At the bottom of the form, in the second to last textbox ("Automatically exclude from source control"), add the file types you want to exclude. To exclude a file type, just add *.filetype. All filters are delimited by semicolons (;).
Hope this helps
Unless you transform your templates during each build, I would argue that these generated files do belong in source control. They are source in the sense that they are used to generate binary (they are compiled).
On the other hand, if these files are generated during a build, then I would argue that they not only don't belong in source control; they also don't belong in the same folders as the rest of your source code. They should reside in something like "obj\GeneratedSource", which would be used as a source for compilation, but which would be cleaned after the build.
You can specify the file masks that are used to automatically exclude files from source control: http://www.ewaldhofman.nl/post/2009/08/02/Change-the-file-masks-that-are-excluded-by-Source-Control.aspx

auto-import of packages across project in eclipse

I have used file search functionality in eclipse to replace a specific occurrence of text with a replace text which contains a java method name in all files across the workspace.
But now in all those files I have to add the import statement (for the method name to resolve).
Is there an automatic way of doing this instead of manually searching and importing the package myself in all files?
P.S.: I can't use java refactoring since the text I have changed is not a java element and Organize import option will make changes to lot of files (re-ordering imports) which will be problematic when I need to commit, I again have to manually check differences to see which files have actual changes instead of just organize import statements.
Instead of doing this with search and replace, try to use Refactor->rename which will do it correctly.
another options is to use organize imports, you can do it for an entire project as well (source -> organize imports).