From 1ca974821f8738bcfc31cb3f6c12ad6c53892daf Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Thu, 4 Jun 2015 15:07:20 +0200 Subject: [PATCH] [idea] introduced URIHandler that works with VirtualFileSystem and Documents --- plugins/org.eclipse.xtext.util/.classpath | 3 +- plugins/org.eclipse.xtext.util/.project | 6 +++ .../META-INF/MANIFEST.MF | 3 +- .../org.eclipse.xtext.util/build.properties | 3 +- .../org/eclipse/xtext/util/internal/Log.xtend | 37 +++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 plugins/org.eclipse.xtext.util/src/org/eclipse/xtext/util/internal/Log.xtend diff --git a/plugins/org.eclipse.xtext.util/.classpath b/plugins/org.eclipse.xtext.util/.classpath index c72d35a04..358df1bc1 100644 --- a/plugins/org.eclipse.xtext.util/.classpath +++ b/plugins/org.eclipse.xtext.util/.classpath @@ -1,7 +1,8 @@ + - + diff --git a/plugins/org.eclipse.xtext.util/.project b/plugins/org.eclipse.xtext.util/.project index 29e4483a5..dbdac6f39 100644 --- a/plugins/org.eclipse.xtext.util/.project +++ b/plugins/org.eclipse.xtext.util/.project @@ -5,6 +5,11 @@ + + org.eclipse.xtext.ui.shared.xtextBuilder + + + org.eclipse.jdt.core.javabuilder @@ -36,5 +41,6 @@ org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature org.eclipse.pde.api.tools.apiAnalysisNature + org.eclipse.xtext.ui.shared.xtextNature diff --git a/plugins/org.eclipse.xtext.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.xtext.util/META-INF/MANIFEST.MF index 5a962679a..8ad8773d7 100644 --- a/plugins/org.eclipse.xtext.util/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.xtext.util/META-INF/MANIFEST.MF @@ -21,5 +21,6 @@ Export-Package: org.eclipse.xtext.util; Require-Bundle: org.eclipse.emf.ecore;bundle-version="2.10.2", com.google.guava;bundle-version="[10.0.1,19.0.0)";visibility:=reexport, com.google.inject;bundle-version="3.0.0";visibility:=reexport, - javax.inject;bundle-version="1.0.0";resolution:=optional;visibility:=reexport;x-installation:=greedy + javax.inject;bundle-version="1.0.0";resolution:=optional;visibility:=reexport;x-installation:=greedy, + org.eclipse.xtend.lib;bundle-version="2.9.0" Import-Package: org.apache.log4j;version="1.2.15" diff --git a/plugins/org.eclipse.xtext.util/build.properties b/plugins/org.eclipse.xtext.util/build.properties index 2b112c461..ab39f02e2 100644 --- a/plugins/org.eclipse.xtext.util/build.properties +++ b/plugins/org.eclipse.xtext.util/build.properties @@ -1,4 +1,5 @@ -source.. = src/ +source.. = src/,\ + xtend-gen/ output.. = bin/ bin.includes = META-INF/,\ .,\ diff --git a/plugins/org.eclipse.xtext.util/src/org/eclipse/xtext/util/internal/Log.xtend b/plugins/org.eclipse.xtext.util/src/org/eclipse/xtext/util/internal/Log.xtend new file mode 100644 index 000000000..b279321cc --- /dev/null +++ b/plugins/org.eclipse.xtext.util/src/org/eclipse/xtext/util/internal/Log.xtend @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.xtext.util.internal + +import com.google.common.annotations.Beta +import java.lang.annotation.Target +import org.apache.log4j.Logger +import org.eclipse.xtend.lib.macro.AbstractClassProcessor +import org.eclipse.xtend.lib.macro.Active +import org.eclipse.xtend.lib.macro.TransformationContext +import org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration + +@Beta +@Target(TYPE) +@Active(LogProcessor) +annotation Log { +} + +class LogProcessor extends AbstractClassProcessor { + + override doTransform(MutableClassDeclaration cls, extension TransformationContext context) { + cls.addField("LOG") [ + static = true + final = true + type = Logger.newTypeReference + initializer = ''' + «Logger».getLogger(«cls.simpleName».class) + ''' + primarySourceElement = cls + ] + } +} \ No newline at end of file