Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-04-18 09:37:26 +0000
committerHenrik Rentz-Reichert2012-04-18 09:37:26 +0000
commit09ba292189f8e67209121be821f087d4e57336af (patch)
treeaa728aca02dc585e2493213bb877aa3bc71bcf48 /plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend
parentfe90ec7b53c6aafa97ea38faf12c8a892ac66a8b (diff)
downloadorg.eclipse.etrice-09ba292189f8e67209121be821f087d4e57336af.tar.gz
org.eclipse.etrice-09ba292189f8e67209121be821f087d4e57336af.tar.xz
org.eclipse.etrice-09ba292189f8e67209121be821f087d4e57336af.zip
[generator, generator.*] some re-factorings
- moved classes to other packages - removed extensions package - better names for some classes - protected methods where possible
Diffstat (limited to 'plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend')
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend69
1 files changed, 69 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend
new file mode 100644
index 000000000..ecf1c8d3f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.generic
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import java.io.File
+import java.util.HashSet
+import java.util.Set
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.etrice.generator.base.ILogger
+import org.eclipse.etrice.generator.etricegen.Root
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.generic.RoomExtensions
+
+@Singleton
+class PrepareFileSystem {
+
+ @Inject extension RoomExtensions roomExt
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject ILogger logger
+
+ def void prepare(Resource resource) {
+ var Set<String> pathes = new HashSet<String>();
+ for (e: resource.contents){
+ if (e instanceof Root) {
+ for (mdl : (e as Root).usedRoomModels) {
+ pathes.add(mdl.generationTargetPath)
+ }
+ }
+ }
+ for (path : pathes) {
+ logger.logInfo("clearing "+path)
+ var f = new File(path)
+ f.eraseContents
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile("readme.txt", readmeText)
+ }
+ }
+
+ def void eraseContents(File f) {
+ if (f.directory) {
+ var children = f.listFiles
+ for (child : children) {
+ eraseContents(child)
+ child.delete
+ }
+ }
+ }
+
+ def readmeText() {
+ '''
+ This directory is an eTrice code generation target.
+ It will be erased every time the generator is executed.
+
+ DO NOT PLACE OTHER FILES HERE!
+ '''
+ }
+} \ No newline at end of file

Back to the top