In order to install and use this, follow the steps:
(1)clone the repo to the local pc
(2)open eclipse IDE
(3)go to Help->Install New Software
(4)Select Add Site->Local
(5)chose the downloaded folder "repository"
(6)click install
In order to create code snippets:
(1)Create a new Java Project
(2)Add new file
(3)Set the file name file_name.cSnip (must have .cSnip extension)
(4)Confirm XText usage.
Some using instructions:
(1) imports have the following format:
~ ${import(library.you.want.to.import.*)}
~ ${import(library.you.want.to.import.specificClass)}
(2) variables and attributes can be declared like in java(with a simple name) or using one
of the following expressions:
~ varName
~ ${varName}
~ ${freeName(varName)}
~ ${newName(varName)}
Each of the last three will be translated to ${varName}, so the variable / attribute will be accessed
through this id (new ids can be introduced at any time if needed)
(3) only java types are supported! in order to use a type, you must explicitly import it(except for basic String, Integer, etc.).
Some quick fixes will be available to ease codding.
Types can be accessed in the following manner:
~ type_name
~ ${elemType(type_name)}
Both access the same type ( type_name ). Maybe somewhere in the future, abstract types that will
be deduced from context will be availabe.(e.g.: ${some_Array_type})
(4) the rest of the expressions are similar to java, except for the for loop expression which supports only
the iterator syntax, the other one will come in a future update.
An example:
${import(org.eclipse.xtext.xbase.lib.*)} ${import(java.util.Locale.Builder)}class c1{ public void m1(){ String[] a=new String [2]; ${elemType(Builder)} ${freeName(b)}=new Builder(); ${b}.addUnicodeLocaleAttribute("MyBuilder"); System.out.print(a); if(a instanceof String[]){ super.toString(); } for(${s} : a){ System.out.println(${s}); ${cursor} } while('${dollar}' == '$' ){ System.out.println(a); } } }