Skip to content

fsteeg/SnipEditor

 
 

Repository files navigation

SnipMatch Editor and teamplates project

This repository contains the snippet editor and the grammar that stands behind it

The meaning of the projects is the following:

-> o.e.r.snipmatch.feature: feature project for the snipmatch editor and view
-> o.e.r.snipmatch.rcp.repository: the updatesite project for o.e.r.snipmatch.rcp. Because of gitignore file,
this repository can be found here [1]
->o.e.r.snipmatch.rcp: the snipmatch project, contains the multi page editor, the view and other necessary packages
like content assist, quick fixes, etc.
->o.e.r.templates : is the project that contains the grammar, code compiler, type computer, and other core elements
-> o.e.r.templates.rcp: is a basic ui for o.e.r.templates. it contains a simple editor that allows manipulation
of .cSnip files. (file extension used for code snippets)
->o.e.r.templates.tests: the test project for o.e.r.templates.

Installation and build instructions:

In order to install it as an eclipse update site, follow the next steps:

1) clone/download the updatesite repository
2) add the repository folder as local update site in eclipse
3) confirm.

In order to build it with maven, follow the next steps:

1)clone the repository
2) cd to the cloned repository location
3) run the following command in the main folder of the project:

$ set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m
$ mvn clean install -Dlicense.failIfMissing=false

How to use:

The plug-in from the update site contains only the features for snipmatch
project. This means the multipage editor, snippet view and a preference page.

First of all, a set of snippets is needed. This can be found here[1]. Clone this repository on the local machine.
After the installation, and once the snippets are cloned, follow the next steps to properly set up and use this plug-in:

The Preference Page set-up:

1) From the eclipse IDE, go to : Window->Preferences->SnipMatch Preferences
2) Set the path to the local code snippets in the Local Snippets Directory.
3) Click the Generate Index File button
4) Select the index file that was generated (this is found in the same folder as the snippets)


The Snippets view:
This contains all the snippets that are on the path selected in the preference
page. In order to use it:

1) Go to Window -> Show View -> Other -> Other -> Snippets View and open it
2) If the snippets do not appear in the list, hit the refresh button.
3) double click on any snippet and the editor will pop-up.


The Editor:
This a a multi-page editor that allows to modify both the snippet code
as well as the snippets metadata (name, search phrases, etc).
It supports the jFace template language syntax [3], and makes use of
a bunch of XText tools to allow an easy edition of code snippets.

An example of a code snippet that includes some template syntax is
the following:
${imp:import (org.eclipse.swt.widgets.Button)}
${array_type} arr = new ${array_type}();
arr.get(0);
${iterable_type} iter = new ${iterable_type}();
iter = ${iterable}
Object [] p = ${array}.toArray();
System.out.println(${iterable});
${collection}.isEmpty();
${type:newType(array)} elemnt;
p.add(${arr:var(java.lang.reflect.AccessibleObject)});
${type:elemType(java.lang.String)} elem = new

${type:elemType(java.lang.Integer)}(new ${type:newType(java.lang.String)}("This is my name"))
else{
this.main();
}
for(${iterator}:${iterable}){

}

catch(Exception e){

}

[1] https://github.com/stefanprisca/SnipMatch_UpdateSite
[2] https://git.eclipse.org/c/recommenders.incubator/org.eclipse.recommenders.snipmatch.snippets.git/tree/

[3] http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Fconcepts%2Fconcept-template-variables.htm

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 93.7%
  • Xtend 6.3%