initial commit metrics xtext
diff --git a/org.eclipse.emf.refactor.metrics.xtext/.classpath b/org.eclipse.emf.refactor.metrics.xtext/.classpath
new file mode 100644
index 0000000..8a8f166
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<classpath>

+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>

+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>

+	<classpathentry kind="src" path="src"/>

+	<classpathentry kind="output" path="bin"/>

+</classpath>

diff --git a/org.eclipse.emf.refactor.metrics.xtext/.project b/org.eclipse.emf.refactor.metrics.xtext/.project
new file mode 100644
index 0000000..9b8947f
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<projectDescription>

+	<name>org.eclipse.emf.refactor.metrics.xtext</name>

+	<comment></comment>

+	<projects>

+	</projects>

+	<buildSpec>

+		<buildCommand>

+			<name>org.eclipse.jdt.core.javabuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+		<buildCommand>

+			<name>org.eclipse.pde.ManifestBuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+		<buildCommand>

+			<name>org.eclipse.pde.SchemaBuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+	</buildSpec>

+	<natures>

+		<nature>org.eclipse.pde.PluginNature</nature>

+		<nature>org.eclipse.jdt.core.javanature</nature>

+	</natures>

+</projectDescription>

diff --git a/org.eclipse.emf.refactor.metrics.xtext/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.emf.refactor.metrics.xtext/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f287d53
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1

+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled

+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6

+org.eclipse.jdt.core.compiler.compliance=1.6

+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error

+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error

+org.eclipse.jdt.core.compiler.source=1.6

diff --git a/org.eclipse.emf.refactor.metrics.xtext/META-INF/MANIFEST.MF b/org.eclipse.emf.refactor.metrics.xtext/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..c78a088
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: MetricsXtext
+Bundle-SymbolicName: org.eclipse.emf.refactor.metrics.xtext;singleton:=true
+Bundle-Version: 0.7.1
+Bundle-Activator: org.eclipse.emf.refactor.metrics.xtext.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text;bundle-version="3.8.1",
+ org.eclipse.emf.ecore;bundle-version="2.8.1",
+ org.eclipse.xtext;bundle-version="2.3.1",
+ org.eclipse.xtext.ui;bundle-version="2.3.1",
+ org.eclipse.emf.refactor.metrics;bundle-version="0.7.0",
+ org.eclipse.emf.refactor.metrics.runtime;bundle-version="0.7.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.eclipse.ui
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/Activator.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/Activator.class
new file mode 100644
index 0000000..ae777e4
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/Activator.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/XtextStartup.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/XtextStartup.class
new file mode 100644
index 0000000..56b559f
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/XtextStartup.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsOnElementCommandHandler.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsOnElementCommandHandler.class
new file mode 100644
index 0000000..e498b49
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsOnElementCommandHandler.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsTransitivelyCommandHandler.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsTransitivelyCommandHandler.class
new file mode 100644
index 0000000..38cf7ff
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsTransitivelyCommandHandler.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextHighlightManager.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextHighlightManager.class
new file mode 100644
index 0000000..05301a4
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextHighlightManager.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextProjectManager.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextProjectManager.class
new file mode 100644
index 0000000..b24951a
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextProjectManager.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager$1.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager$1.class
new file mode 100644
index 0000000..8a023ac
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager$1.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager.class
new file mode 100644
index 0000000..0e3b2f5
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/ui/XtextHighlighting.class b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/ui/XtextHighlighting.class
new file mode 100644
index 0000000..7853c27
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/bin/org/eclipse/emf/refactor/metrics/xtext/ui/XtextHighlighting.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.metrics.xtext/build.properties b/org.eclipse.emf.refactor.metrics.xtext/build.properties
new file mode 100644
index 0000000..6f20375
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/build.properties
@@ -0,0 +1,5 @@
+source.. = src/

+output.. = bin/

+bin.includes = META-INF/,\

+               .,\

+               plugin.xml

diff --git a/org.eclipse.emf.refactor.metrics.xtext/plugin.xml b/org.eclipse.emf.refactor.metrics.xtext/plugin.xml
new file mode 100644
index 0000000..5167e4a
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/plugin.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<?eclipse version="3.4"?>

+<plugin>

+   <extension

+         point="org.eclipse.ui.menus">

+	<menuContribution

+            allPopups="true"

+            locationURI="popup:org.eclipse.ui.popup.any?after=additions">

+         <menu

+               id="org.eclipse.emf.refactor.runtime.menu"

+               label="EMF Quality Assurance (use existing techniques)">

+            <command

+                  commandId="org.eclipse.emf.refactor.metrics.xtext.calculateMetricsOnElementCommand"

+                  label="Calculate Configured Metrics (on element)"

+                  style="push">

+               <visibleWhen

+                  checkEnabled="true">

+               <iterate

+                     ifEmpty="false">

+                  <instanceof

+                        value="org.eclipse.jface.text.TextSelection">

+                  </instanceof>

+               </iterate>

+            </visibleWhen>

+            </command>

+            <command

+                  commandId="org.eclipse.emf.refactor.metrics.xtext.calculateMetricsTransitivelyCommand"

+                  label="Calculate Configured Metrics (on model)"

+                  style="push">

+               <visibleWhen

+                  checkEnabled="true">

+               <iterate

+                     ifEmpty="false">

+                  <instanceof

+                        value="org.eclipse.jface.text.TextSelection">

+                  </instanceof>

+               </iterate>

+            </visibleWhen>

+            </command>

+         </menu>

+      </menuContribution>

+   </extension>

+   <extension

+         point="org.eclipse.ui.commands">

+      <command

+            id="org.eclipse.emf.refactor.metrics.xtext.calculateMetricsOnElementCommand"

+            name="CalculateMetricsOnElementCommand">

+      </command>

+      <command

+            id="org.eclipse.emf.refactor.metrics.xtext.calculateMetricsTransitivelyCommand"

+            name="CalculateMetricsTransitivelyCommand">

+      </command>

+   </extension>

+   <extension

+         point="org.eclipse.ui.handlers">

+      <handler

+            class="org.eclipse.emf.refactor.metrics.xtext.handler.CalculateMetricsOnElementCommandHandler"

+            commandId="org.eclipse.emf.refactor.metrics.xtext.calculateMetricsOnElementCommand">

+      </handler>

+      <handler

+            class="org.eclipse.emf.refactor.metrics.xtext.handler.CalculateMetricsTransitivelyCommandHandler"

+            commandId="org.eclipse.emf.refactor.metrics.xtext.calculateMetricsTransitivelyCommand">

+      </handler>

+   </extension>

+   <extension

+         point="org.eclipse.ui.startup">

+      <startup

+            class="org.eclipse.emf.refactor.metrics.xtext.XtextStartup">

+      </startup>

+   </extension>

+

+</plugin>

diff --git a/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/Activator.java b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/Activator.java
new file mode 100644
index 0000000..e4482fe
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.emf.refactor.metrics.xtext;

+

+import org.eclipse.ui.plugin.AbstractUIPlugin;

+import org.osgi.framework.BundleContext;

+

+/**

+ * The activator class controls the plug-in life cycle

+ */

+public class Activator extends AbstractUIPlugin {

+

+	// The plug-in ID

+	public static final String PLUGIN_ID = "org.eclipse.emf.refactor.metrics.xtext"; //$NON-NLS-1$

+

+	// The shared instance

+	private static Activator plugin;

+	

+	/**

+	 * The constructor

+	 */

+	public Activator() {

+	}

+

+	/*

+	 * (non-Javadoc)

+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)

+	 */

+	public void start(BundleContext context) throws Exception {

+		super.start(context);

+		plugin = this;

+	}

+

+	/*

+	 * (non-Javadoc)

+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)

+	 */

+	public void stop(BundleContext context) throws Exception {

+		plugin = null;

+		super.stop(context);

+	}

+

+	/**

+	 * Returns the shared instance

+	 *

+	 * @return the shared instance

+	 */

+	public static Activator getDefault() {

+		return plugin;

+	}

+

+}

diff --git a/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/XtextStartup.java b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/XtextStartup.java
new file mode 100644
index 0000000..ac42b66
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/XtextStartup.java
@@ -0,0 +1,15 @@
+package org.eclipse.emf.refactor.metrics.xtext;

+

+import org.eclipse.emf.refactor.metrics.runtime.managers.RuntimeManager;

+import org.eclipse.emf.refactor.metrics.xtext.ui.XtextHighlighting;

+import org.eclipse.ui.IStartup;

+

+public class XtextStartup implements IStartup {

+

+	@Override

+	public void earlyStartup() {

+		RuntimeManager.getInstance(new XtextHighlighting());

+		System.out.println("Started");

+	}

+

+}

diff --git a/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsOnElementCommandHandler.java b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsOnElementCommandHandler.java
new file mode 100644
index 0000000..024b645
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsOnElementCommandHandler.java
@@ -0,0 +1,61 @@
+package org.eclipse.emf.refactor.metrics.xtext.handler;

+

+import java.util.List;

+

+import org.eclipse.core.commands.ExecutionEvent;

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.commands.IHandler;

+import org.eclipse.core.commands.IHandlerListener;

+import org.eclipse.core.resources.IProject;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.refactor.metrics.runtime.managers.RuntimeManager;

+import org.eclipse.emf.refactor.metrics.xtext.managers.XtextProjectManager;

+import org.eclipse.emf.refactor.metrics.xtext.managers.XtextSelectionManager;

+import org.eclipse.jface.dialogs.MessageDialog;

+import org.eclipse.jface.viewers.ISelection;

+import org.eclipse.swt.SWT;

+import org.eclipse.swt.graphics.Cursor;

+import org.eclipse.ui.PlatformUI;

+

+public class CalculateMetricsOnElementCommandHandler implements IHandler {

+

+	@Override

+	public void addHandlerListener(IHandlerListener handlerListener) {	}

+

+	@Override

+	public void dispose() {	}

+

+	@Override

+	public Object execute(ExecutionEvent event) throws ExecutionException {

+		Cursor oldCursor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getCursor();

+		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setCursor(new Cursor(null,SWT.CURSOR_WAIT));

+		ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();

+		List<EObject> context = XtextSelectionManager.getESelection(selection);

+		IProject project = XtextProjectManager.getActualProject(selection);

+		if (project == null) {

+			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setCursor(oldCursor);

+			MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 

+					"EMF Quality Assurance", "Can not calculate metrics: project is " + project);

+			return null;

+		}

+		System.out.println("context: " + context);

+		RuntimeManager.getInstance();

+		RuntimeManager.calculateConfiguredMetricsOnElement(project, context);

+		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setCursor(oldCursor);

+		return null;

+	}

+

+	@Override

+	public boolean isEnabled() {

+		return true;

+	}

+

+	@Override

+	public boolean isHandled() {

+		return true;

+	}

+

+	@Override

+	public void removeHandlerListener(IHandlerListener handlerListener) { }

+

+}

diff --git a/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsTransitivelyCommandHandler.java b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsTransitivelyCommandHandler.java
new file mode 100644
index 0000000..32390cf
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/handler/CalculateMetricsTransitivelyCommandHandler.java
@@ -0,0 +1,61 @@
+package org.eclipse.emf.refactor.metrics.xtext.handler;

+

+import java.util.List;

+

+import org.eclipse.core.commands.ExecutionEvent;

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.commands.IHandler;

+import org.eclipse.core.commands.IHandlerListener;

+import org.eclipse.core.resources.IProject;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.ecore.util.EcoreUtil;

+import org.eclipse.emf.refactor.metrics.runtime.managers.RuntimeManager;

+import org.eclipse.emf.refactor.metrics.xtext.managers.XtextProjectManager;

+import org.eclipse.emf.refactor.metrics.xtext.managers.XtextSelectionManager;

+import org.eclipse.jface.dialogs.MessageDialog;

+import org.eclipse.jface.viewers.ISelection;

+import org.eclipse.swt.SWT;

+import org.eclipse.swt.graphics.Cursor;

+import org.eclipse.ui.PlatformUI;

+

+public class CalculateMetricsTransitivelyCommandHandler implements IHandler {

+

+	@Override

+	public void addHandlerListener(IHandlerListener handlerListener) { }

+

+	@Override

+	public void dispose() {	}

+

+	@Override

+	public Object execute(ExecutionEvent event) throws ExecutionException {

+		Cursor oldCursor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getCursor();

+		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setCursor(new Cursor(null,SWT.CURSOR_WAIT));

+		ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();

+		List<EObject> context = XtextSelectionManager.getESelection(selection);

+		IProject project = XtextProjectManager.getActualProject(selection);

+		if (project == null) {

+			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setCursor(oldCursor);

+			MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 

+					"EMF Metrics", "Can not calculate metrics: project is " + project);

+			return null;

+		}

+		RuntimeManager.getInstance();

+		RuntimeManager.calculateConfiguredMetricsTransitively(project, EcoreUtil.getRootContainer(context.get(0)));

+		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setCursor(oldCursor);

+		return null;

+	}

+

+	@Override

+	public boolean isEnabled() {

+		return true;

+	}

+

+	@Override

+	public boolean isHandled() {

+		return true;

+	}

+

+	@Override

+	public void removeHandlerListener(IHandlerListener handlerListener) { }

+

+}

diff --git a/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextHighlightManager.java b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextHighlightManager.java
new file mode 100644
index 0000000..3f8a148
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextHighlightManager.java
@@ -0,0 +1,66 @@
+package org.eclipse.emf.refactor.metrics.xtext.managers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.refactor.metrics.runtime.core.Result;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.xtext.nodemodel.ICompositeNode;
+import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
+import org.eclipse.xtext.ui.editor.XtextEditor;
+import org.eclipse.xtext.ui.editor.utils.EditorUtils;
+
+import com.google.inject.Inject;
+
+public class XtextHighlightManager {
+	
+	private static XtextHighlightManager instance = null;	
+	private List<EObject> selected; 
+	
+	private XtextHighlightManager() {
+		selected = new ArrayList<EObject>();
+	}
+	
+	public static XtextHighlightManager getInstance() {
+		if(instance == null) {
+			instance = new XtextHighlightManager();
+		}
+		return instance;
+	}
+	
+	@Inject 
+	public void highlight(Object selection) {
+		// clear former selected eObjects
+		selected.clear();
+		// set selected eObjects from selection
+		if (selection instanceof StructuredSelection) {		
+			StructuredSelection ss = (StructuredSelection) selection;
+			@SuppressWarnings("unchecked")
+			Iterator<Object> it = ss.iterator();
+			while (it.hasNext()) {
+				Object o = it.next();
+				if (o instanceof Result) {
+					selected.addAll(((Result) o).getContext());
+				}
+			}
+		}
+		// highlight each eObject in editor
+		for (EObject eObject : selected) {
+			XtextEditor xEditor = EditorUtils.getActiveXtextEditor();
+			ICompositeNode node = NodeModelUtils.findActualNodeFor(eObject);
+    		int offset = node.getOffset();
+			int length = node.getLength();
+    		ISourceViewer textViewer = xEditor.getInternalSourceViewer();
+			textViewer.setRangeIndication(offset, length, true);
+			textViewer.revealRange(offset, length);
+			textViewer.setSelectedRange(offset, length);
+		}
+	}
+
+	public List<EObject> getSelected() {
+		return selected;
+	}		
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextProjectManager.java b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextProjectManager.java
new file mode 100644
index 0000000..44e62f9
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextProjectManager.java
@@ -0,0 +1,35 @@
+package org.eclipse.emf.refactor.metrics.xtext.managers;

+

+import org.eclipse.core.resources.IProject;

+import org.eclipse.emf.refactor.metrics.managers.ProjectManager;

+import org.eclipse.jface.viewers.ISelection;

+import org.eclipse.ui.IEditorInput;

+import org.eclipse.ui.IFileEditorInput;

+import org.eclipse.xtext.ui.editor.XtextEditor;

+import org.eclipse.xtext.ui.editor.utils.EditorUtils;

+

+public class XtextProjectManager extends ProjectManager {

+	

+	@SuppressWarnings("finally")

+	public static IProject getActualProject(ISelection selection) {

+		IProject actualProject = ProjectManager.getActualProject();

+		System.out.println("Project: " + actualProject);

+		try {

+			XtextEditor editor = EditorUtils.getActiveXtextEditor();

+			if (editor != null) {

+				IEditorInput input = editor.getEditorInput();

+				System.out.println("Editor Input: " + input);

+				if (input instanceof IFileEditorInput) {

+					IFileEditorInput fileInput = (IFileEditorInput) input;

+					actualProject = fileInput.getFile().getProject();

+					System.out.println("Project: " + actualProject);

+				}

+			}

+		} catch (Exception e) {

+			e.printStackTrace();

+		} finally {

+			return actualProject;

+		}

+	}

+

+}

diff --git a/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager.java b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager.java
new file mode 100644
index 0000000..1fe25e2
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/managers/XtextSelectionManager.java
@@ -0,0 +1,45 @@
+package org.eclipse.emf.refactor.metrics.xtext.managers;

+

+import java.util.ArrayList;

+import java.util.List;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.jface.text.TextSelection;

+import org.eclipse.jface.viewers.ISelection;

+import org.eclipse.xtext.resource.EObjectAtOffsetHelper;

+import org.eclipse.xtext.resource.XtextResource;

+import org.eclipse.xtext.ui.editor.XtextEditor;

+import org.eclipse.xtext.ui.editor.model.IXtextDocument;

+import org.eclipse.xtext.ui.editor.model.XtextDocumentUtil;

+import org.eclipse.xtext.ui.editor.utils.EditorUtils;

+import org.eclipse.xtext.util.concurrent.IUnitOfWork;

+

+public class XtextSelectionManager {

+	

+	public static List<EObject> getESelection(ISelection selection) {

+		List<EObject> list = new ArrayList<EObject>();

+		if (null != selection && selection instanceof TextSelection) {

+    		TextSelection tSelection = (TextSelection) selection;

+    		XtextEditor xEditor = EditorUtils.getActiveXtextEditor();

+    		if (null != xEditor) {

+	    		IXtextDocument doc = XtextDocumentUtil.get(xEditor);

+	    		if (null != doc) {

+		    		XtextResource resource;

+		    		resource = doc.readOnly(new IUnitOfWork<XtextResource, XtextResource>() {

+			    		public XtextResource exec(XtextResource state) throws Exception {

+			    			return state;

+			    		}

+			    	});

+		    		EObjectAtOffsetHelper helper = new EObjectAtOffsetHelper();

+		    		EObject eObject = helper.resolveElementAt(resource , tSelection.getOffset());

+		    		System.out.println("EObject: " +  eObject);

+		    		if (eObject != null) {

+		    			list.add(eObject);

+		    		}

+	    		}

+    		}

+    	}

+		return list;

+	}

+

+}

diff --git a/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/ui/XtextHighlighting.java b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/ui/XtextHighlighting.java
new file mode 100644
index 0000000..e584e6e
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.xtext/src/org/eclipse/emf/refactor/metrics/xtext/ui/XtextHighlighting.java
@@ -0,0 +1,13 @@
+package org.eclipse.emf.refactor.metrics.xtext.ui;

+

+import org.eclipse.emf.refactor.metrics.interfaces.IHighlighting;

+import org.eclipse.emf.refactor.metrics.xtext.managers.XtextHighlightManager;

+

+public class XtextHighlighting implements IHighlighting {

+

+	@Override

+	public void highlight(Object selection) {

+		XtextHighlightManager.getInstance().highlight(selection);

+	}

+

+}