Rewrote model post-processor in Java (was Xtend.)
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ExtendedGenerator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ExtendedGenerator.java
index ccd8037..b14a3c0 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ExtendedGenerator.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ExtendedGenerator.java
@@ -8,12 +8,12 @@
*/
package com.google.eclipse.protobuf;
-import com.google.inject.*;
-
import org.eclipse.xtext.*;
import org.eclipse.xtext.generator.Generator;
import org.eclipse.xtext.xtext.ecoreInference.IXtext2EcorePostProcessor;
+import com.google.inject.*;
+
/**
* @author alruiz@google.com (Alex Ruiz)
*/
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufEcorePostProcessor.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufEcorePostProcessor.java
new file mode 100644
index 0000000..cda0500
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufEcorePostProcessor.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * 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 com.google.eclipse.protobuf;
+
+import org.eclipse.emf.ecore.*;
+import org.eclipse.xtext.GeneratedMetamodel;
+import org.eclipse.xtext.xtext.ecoreInference.IXtext2EcorePostProcessor;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@SuppressWarnings("restriction")
+public class ProtobufEcorePostProcessor implements IXtext2EcorePostProcessor {
+
+ @Override public void process(GeneratedMetamodel metamodel) {
+ EPackage p = metamodel.getEPackage();
+ for (EClassifier c : p.getEClassifiers()) {
+ if (c instanceof EClass && "Literal".equals(c.getName())) {
+ setDefaultValueOfIndexInLiteral((EClass) c);
+ }
+ }
+ }
+
+ private void setDefaultValueOfIndexInLiteral(EClass c) {
+ for (EAttribute a : c.getEAllAttributes()) {
+ if ("index".equals(a.getName())) {
+ a.setDefaultValue(-1L);
+ break;
+ }
+ }
+ }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufEcorePostProcessor.xtend b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufEcorePostProcessor.xtend
deleted file mode 100644
index 9a53214..0000000
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufEcorePostProcessor.xtend
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011 Google Inc.
- *
- * 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 com.google.eclipse.protobuf
-
-import org.eclipse.xtext.xtext.ecoreInference.IXtext2EcorePostProcessor
-import org.eclipse.xtext.GeneratedMetamodel
-import org.eclipse.emf.ecore.EPackage
-import org.eclipse.emf.ecore.EClass
-
-/*
- * Author: alruiz@google.com (Alex Ruiz)
- */
-class ProtobufEcorePostProcessor implements IXtext2EcorePostProcessor {
- override process(GeneratedMetamodel metamodel) {
- metamodel.EPackage.process;
- }
-
- def process(EPackage p) {
- for (c : p.EClassifiers.filter(typeof(EClass))) {
- if (c.name == "Literal") {
- c.setDefaultValueOfLiteralIndex
- }
- }
- }
-
- def setDefaultValueOfLiteralIndex(EClass c) {
- for (attribute : c.EAllAttributes) {
- if (attribute.name == "index") {
- attribute.defaultValue = -1
- return
- }
- }
- }
-}
\ No newline at end of file