Skip to content
This repository has been archived by the owner on Jan 30, 2021. It is now read-only.

stefanprisca/SnipEditor

Repository files navigation

SnipMatch

This project has moved to the eclipse repository: http://git.eclipse.org/c/recommenders.incubator/org.eclipse.recommenders.snipmatch.git/

SnipEditor

Working maven build and most of the JFace grammar.
The update site can be found here[1]. In order to use, please follow the instructions provided
in the update site readme file. It does not work directly from eclipse IDE(yet).

This build supports syntax for class declarations, method declarations, attribute declarations and assignments and
basic operations. Examples can be found in the update site repository.
<br> In order to open the projects in eclipse, simply clone the repo on the local computer and import the projects
in eclipse. You will also need to generate the language artifacts.

In order to build this, follow the steps:
(1)clone the repo to the local computer
(2)open the command line
(3)go to ../org.eclipse.recommenders.snipeditor.releng
(4)run the command mvn clean install.

The preference page and the view

The prefetence page can be used to set the locations of the snippets. This can be accessed from
Window -> Preferences -> SnipMatch Preferences.

In order to set it up:<br>
<br>
(1) Set the location of the local snippets in the <i>Local Snippets Directory</i> path location <br>
(2) Click the <i>Generate Index File</i> button.<br>
(3) Chose the index file in its alocated path.<br>
<br>
After the preference page is set up, you can access the local snippets through the snippets view:<br>
<br>
(1) Go to <i>Window -> Show View -> Other -> Other -> Snippets View </i> and open it.<br>
(2) If the snippets do not appear in the list, press the refresh button.<br>
(3) The snippets ahould be visible now, so in order to edit them, just press double click on the one <br>
to be edited :) <br>
<br>

The Editor

In order to allow all functionalities of the editor, the files are copied in the local workspace.
Therefor, a new project will be created in the workpsace with the snippets. Here, .cSnip files
will be created from the code in the .json files.

Some instructions on how to use the editor:

(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)} / ${varName:freeName(varName)}
~ ${newName(varName)} / ${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)} / ${typeName: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); } } }

[1]https://github.com/stefanprisca/SnipEditor_UpdateSite

4ce47ddfa933575c35a555a9ead1083b71151625

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •