Initial code import. 

This plug-in is pretty functional already:

* Working editor with content-assist based on grammar, context and data type
* Imports of .proto files works
* Content-assist for common options
* Outline View
* Preferences for using protoc on save
* Error markers based on protoc's output
diff --git a/com.google.eclipse.protobuf/.antlr-generator-3.2.0.jar b/com.google.eclipse.protobuf/.antlr-generator-3.2.0.jar
new file mode 100644
index 0000000..4243492
--- /dev/null
+++ b/com.google.eclipse.protobuf/.antlr-generator-3.2.0.jar
Binary files differ
diff --git a/com.google.eclipse.protobuf/.classpath b/com.google.eclipse.protobuf/.classpath
new file mode 100644
index 0000000..7e8449d
--- /dev/null
+++ b/com.google.eclipse.protobuf/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="src-gen"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/com.google.eclipse.protobuf/.project b/com.google.eclipse.protobuf/.project
new file mode 100644
index 0000000..b524930
--- /dev/null
+++ b/com.google.eclipse.protobuf/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>com.google.eclipse.protobuf</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>
+		<buildCommand>
+			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+	</natures>
+</projectDescription>
diff --git a/com.google.eclipse.protobuf/.settings/org.eclipse.jdt.core.prefs b/com.google.eclipse.protobuf/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..002551b
--- /dev/null
+++ b/com.google.eclipse.protobuf/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,81 @@
+#Wed Apr 06 10:56:09 PDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..cbe1187
--- /dev/null
+++ b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0

+Bundle-ManifestVersion: 2

+Bundle-Name: %Bundle-Name

+Bundle-Vendor: %Bundle-Vendor

+Bundle-Version: 1.0.0

+Bundle-SymbolicName: com.google.eclipse.protobuf; singleton:=true

+Bundle-ActivationPolicy: lazy

+Require-Bundle: org.eclipse.xtext,

+ org.eclipse.xtext.generator;resolution:=optional,

+ org.eclipse.emf.codegen.ecore;resolution:=optional,

+ org.eclipse.emf.mwe.utils;resolution:=optional,

+ org.eclipse.emf.mwe2.launch;resolution:=optional,

+ com.ibm.icu;resolution:=optional,

+ org.eclipse.xtext.util,

+ org.eclipse.emf.ecore,

+ org.eclipse.emf.common,

+ org.antlr.runtime,

+ org.eclipse.core.runtime;bundle-version="3.7.0"

+Import-Package: org.apache.log4j,

+ org.apache.commons.logging

+Bundle-RequiredExecutionEnvironment: J2SE-1.5

+Export-Package: com.google.eclipse.protobuf,

+ com.google.eclipse.protobuf.parseTreeConstruction,

+ com.google.eclipse.protobuf.parser.antlr,

+ com.google.eclipse.protobuf.parser.antlr.internal,

+ com.google.eclipse.protobuf.protobuf,

+ com.google.eclipse.protobuf.protobuf.impl,

+ com.google.eclipse.protobuf.protobuf.util,

+ com.google.eclipse.protobuf.scoping,

+ com.google.eclipse.protobuf.services,

+ com.google.eclipse.protobuf.util,

+ com.google.eclipse.protobuf.validation

diff --git a/com.google.eclipse.protobuf/OSGI-INF/l10n/bundle.properties b/com.google.eclipse.protobuf/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000..a8b3cdb
--- /dev/null
+++ b/com.google.eclipse.protobuf/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,3 @@
+#Properties file for com.google.eclipse.protobuf
+Bundle-Vendor = Google Inc.
+Bundle-Name = com.google.eclipse.protobuf
\ No newline at end of file
diff --git a/com.google.eclipse.protobuf/build.properties b/com.google.eclipse.protobuf/build.properties
new file mode 100644
index 0000000..300fb1a
--- /dev/null
+++ b/com.google.eclipse.protobuf/build.properties
@@ -0,0 +1,6 @@
+source.. = src/,\
+          src-gen/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               OSGI-INF/
diff --git a/com.google.eclipse.protobuf/global.proto b/com.google.eclipse.protobuf/global.proto
new file mode 100644
index 0000000..294cd0e
--- /dev/null
+++ b/com.google.eclipse.protobuf/global.proto
@@ -0,0 +1,22 @@
+message FileOptions {
+
+  optional string java_package = 1;
+  optional string java_outer_classname = 8;
+  optional bool java_multiple_files = 10 [default=false];
+  optional bool java_generate_equals_and_hash = 20 [default=false];
+
+  enum OptimizeMode {
+    SPEED = 1;        // Generate complete code for parsing, serialization, etc.
+    CODE_SIZE = 2;    // Use ReflectionOps to implement these methods.
+    LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
+  }
+
+  optional OptimizeMode optimize_for = 9 [default=SPEED];
+  optional bool cc_generic_services = 16 [default=false];
+  optional bool java_generic_services = 17 [default=false];
+  optional bool py_generic_services = 18 [default=false];
+
+  repeated UninterpretedOption uninterpreted_option = 999;
+
+  extensions 1000 to max;
+}
diff --git a/com.google.eclipse.protobuf/plugin.xml b/com.google.eclipse.protobuf/plugin.xml
new file mode 100644
index 0000000..c9018bb
--- /dev/null
+++ b/com.google.eclipse.protobuf/plugin.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+
+  <extension point="org.eclipse.emf.ecore.generated_package">
+    <package 
+       uri = "http://www.google.com/eclipse/protobuf/Protobuf" 
+       class = "com.google.eclipse.protobuf.protobuf.ProtobufPackage"
+       genModel = "com/google/eclipse/protobuf/Protobuf.genmodel" /> 
+	
+  </extension>
+
+
+
+
+</plugin>
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/GenerateProtobuf.mwe2 b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/GenerateProtobuf.mwe2
new file mode 100644
index 0000000..a954940
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/GenerateProtobuf.mwe2
@@ -0,0 +1,109 @@
+/*
+ * 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
+ * 
+ * Generated by Xtext
+ */
+module com.google.eclipse.protobuf.Protobuf
+
+import org.eclipse.emf.mwe.utils.*
+import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.ui.generator.*
+
+var grammarURI = "classpath:/com/google/eclipse/protobuf/Protobuf.xtext"
+var file.extensions = "proto"
+var projectName = "com.google.eclipse.protobuf"
+var runtimeProject = "../${projectName}"
+
+Workflow {
+    bean = StandaloneSetup {
+		platformUri = "${runtimeProject}/.."
+	}
+
+	component = DirectoryCleaner {
+		directory = "${runtimeProject}/src-gen"
+	}
+
+	component = DirectoryCleaner {
+		directory = "${runtimeProject}.ui/src-gen"
+	}
+
+	component = Generator {
+		pathRtProject = runtimeProject
+		pathUiProject = "${runtimeProject}.ui"
+		projectNameRt = projectName
+		projectNameUi = "${projectName}.ui"
+		language = {
+			uri = grammarURI
+			fileExtensions = file.extensions
+
+			// Java API to access grammar elements (required by several other fragments)
+			fragment = grammarAccess.GrammarAccessFragment {}
+
+			// generates Java API for the generated EPackages 
+			fragment = ecore.EcoreGeneratorFragment {
+			// referencedGenModels = "uri to genmodel, uri to next genmodel"
+			}
+
+			// the serialization component
+			fragment = parseTreeConstructor.ParseTreeConstructorFragment {}
+
+			// a custom ResourceFactory for use with EMF 
+			fragment = resourceFactory.ResourceFactoryFragment {
+				fileExtensions = file.extensions
+			}
+
+			// The antlr parser generator fragment.
+			fragment = parser.antlr.XtextAntlrGeneratorFragment {
+			//  options = {
+			//		backtrack = true
+			//	}
+			}
+
+			// java-based API for validation 
+			fragment = validation.JavaValidatorFragment {
+				composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
+				composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
+				// registerForImportedPackages = true
+			}
+
+			// scoping and exporting API
+			// fragment = scoping.ImportURIScopingFragment {}
+			// fragment = exporting.SimpleNamesFragment {}
+
+			// scoping and exporting API 
+			fragment = scoping.ImportNamespacesScopingFragment {}
+			fragment = exporting.QualifiedNamesFragment {}
+			fragment = builder.BuilderIntegrationFragment {}
+
+			// formatter API 
+			fragment = formatting.FormatterFragment {}
+
+			// labeling API 
+			fragment = labeling.LabelProviderFragment {}
+
+			// outline API 
+			fragment = outline.OutlineTreeProviderFragment {}
+			fragment = outline.QuickOutlineFragment {}
+
+			// quickfix API 
+			fragment = quickfix.QuickfixProviderFragment {}
+
+			// content assist API  
+			fragment = contentAssist.JavaBasedContentAssistFragment {}
+
+			// generates a more lightweight Antlr parser and lexer tailored for content assist  
+			fragment = parser.antlr.XtextAntlrUiGeneratorFragment {}
+
+			// project wizard (optional) 
+			// fragment = projectWizard.SimpleProjectWizardFragment {
+			// 		generatorProjectName = "${projectName}.generator" 
+			//		modelFileExtension = file.extensions
+			// }
+		}
+	}
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
new file mode 100644
index 0000000..944e1b2
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
@@ -0,0 +1,126 @@
+/*
+ * 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
+ * 
+ * Author: alruiz@google.com (Alex Ruiz)
+ */
+
+grammar com.google.eclipse.protobuf.Protobuf with org.eclipse.xtext.common.Terminals
+
+import "http://www.eclipse.org/emf/2002/Ecore" as ecore
+generate protobuf "http://www.google.com/eclipse/protobuf/Protobuf"
+
+Protobuf:
+  (package=Package)?
+  (imports+=Import)*
+  (options+=Option)*
+  (elements+=ProtobufElement)*;
+  
+Package:
+  'package' name=QualifiedName ';';
+
+Import: 
+  'import' importURI=STRING ';';
+
+QualifiedName:
+  ID ('.' ID)*;
+
+Option:
+  'option' name=ID '=' value=ValueRef ';';
+
+ProtobufElement:
+  Type | ExtendMessage;
+
+Type:
+  Message | Enum;
+
+Message:
+  'message' name=ID '{'
+  elements+=MessageElement*
+  ('extensions' extensionsFrom=INT 'to' (extensionsTo=INT | 'max') ';')?
+  '}';
+
+MessageElement:
+  Type | Property;
+
+Property:
+  modifier=Modifier type=AbstractTypeReference name=ID '=' index=INT (('[' 'default' '=' default=ValueRef
+  ']') | ('[' 'packed' '=' packed=BooleanRef ']'))? ';';
+
+enum Modifier:
+  required
+  | optional
+  | repeated;
+
+AbstractTypeReference:
+  ScalarTypeReference | TypeReference;
+
+ScalarTypeReference:
+  scalar=ScalarType;
+
+enum ScalarType:
+  double
+  | float
+  | int32
+  | int64
+  | uint32
+  | uint64
+  | sint32
+  | sint64
+  | fixed32
+  | fixed64
+  | sfixed32
+  | sfixed64
+  | bool
+  | string
+  | bytes;
+
+TypeReference:
+  type=[Type | QualifiedName];
+
+ValueRef:
+  LiteralRef
+  | BooleanRef
+  | IntRef
+  | FloatRef
+  | StringRef;
+
+LiteralRef:
+  literal=[Literal];
+
+BooleanRef:
+  boolean=BOOL;
+
+enum BOOL:
+  true
+  | false;
+
+IntRef:
+  int=INT;
+
+FloatRef:
+  float=FLOAT;
+
+StringRef:
+  string=STRING;
+
+Enum:
+  'enum' name=ID '{'
+  literals+=Literal*
+  '}' ';'?;
+
+Literal:
+  name=ID '=' index=INT ';';
+
+ExtendMessage:
+  'extend' message=[Message] '{'
+  elements+=MessageElement*
+  '}';
+
+terminal INT returns ecore::EInt: ('0'..'9')+;  
+terminal FLOAT returns ecore::EFloat: ('0'..'9')* ('.' ('0'..'9')+)?;
+  
\ No newline at end of file
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java
new file mode 100644
index 0000000..5492360
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java
@@ -0,0 +1,37 @@
+/*
+ * 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.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.scoping.IGlobalScopeProvider;
+import org.eclipse.xtext.scoping.impl.*;
+
+import com.google.eclipse.protobuf.naming.ProtobufQualifiedNameProvider;
+import com.google.eclipse.protobuf.scoping.SimpleImportUriResolver;
+import com.google.inject.Binder;
+
+/**
+ * Use this class to register components to be used at runtime / without the Equinox extension registry.
+ */
+public class ProtobufRuntimeModule extends com.google.eclipse.protobuf.AbstractProtobufRuntimeModule {
+
+  /** {@inheritDoc} */
+  @Override public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
+    return ImportUriGlobalScopeProvider.class;
+  }
+
+  /** {@inheritDoc} */
+  @Override public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
+    return ProtobufQualifiedNameProvider.class;
+  }
+
+  public void configureImportUriResolver(Binder binder) {
+    binder.bind(ImportUriResolver.class).to(SimpleImportUriResolver.class);
+  }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufStandaloneSetup.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufStandaloneSetup.java
new file mode 100644
index 0000000..ac0af7c
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufStandaloneSetup.java
@@ -0,0 +1,20 @@
+/*
+ * 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;
+
+/**
+ * Initialization support for running Xtext languages without Equinox extension registry.
+ */
+public class ProtobufStandaloneSetup extends ProtobufStandaloneSetupGenerated{
+
+	public static void doSetup() {
+		new ProtobufStandaloneSetup().createInjectorAndDoEMFRegistration();
+	}
+}
+
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter.java
new file mode 100644
index 0000000..10d911a
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter.java
@@ -0,0 +1,28 @@
+/*
+ * 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.formatting;
+
+import org.eclipse.xtext.formatting.impl.*;
+
+import com.google.eclipse.protobuf.services.ProtobufGrammarAccess;
+
+/**
+ * This class contains custom formatting description.
+ *
+ * @see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting on how and when to use it
+ * @see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
+ */
+public class ProtobufFormatter extends AbstractDeclarativeFormatter {
+
+	@Override
+	protected void configureFormatting(FormattingConfig c) {
+	  ProtobufGrammarAccess g = (ProtobufGrammarAccess) getGrammarAccess();
+	  c.setLinewrap(0, 1, 2).before(g.getSL_COMMENTRule());
+	}
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java
new file mode 100644
index 0000000..2019edc
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java
@@ -0,0 +1,41 @@
+/*
+ * 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.naming;
+
+import java.util.*;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.naming.*;
+
+import com.google.eclipse.protobuf.protobuf.Package;
+import com.google.eclipse.protobuf.util.EObjectFinder;
+import com.google.inject.Inject;
+
+/**
+ * Provides fully-qualified names for protobuf elements.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class ProtobufQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {
+
+  @Inject private EObjectFinder finder;
+
+  /** {@inheritDoc} */
+  @Override public QualifiedName getFullyQualifiedName(EObject obj) {
+    QualifiedName fqn = super.getFullyQualifiedName(obj);
+    if (fqn == null || obj instanceof Package) return fqn;
+    Package p = finder.findPackage(obj);
+    if (p == null) return fqn;
+    List<String> segments = new ArrayList<String>(fqn.getSegments());
+    String packageName = p.getName();
+    if (packageName != null && !segments.isEmpty() && !packageName.equals(segments.get(0))) 
+      segments.add(0, packageName);
+    return QualifiedName.create(segments.toArray(new String[segments.size()]));
+  }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/GlobalScope.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/GlobalScope.java
new file mode 100644
index 0000000..0e3dfc2
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/GlobalScope.java
@@ -0,0 +1,114 @@
+/*
+ * 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.scoping;
+
+import static java.util.Collections.unmodifiableCollection;
+import static org.eclipse.core.runtime.FileLocator.*;
+
+import java.io.*;
+import java.net.URL;
+import java.util.*;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.xtext.parser.IParseResult;
+import org.eclipse.xtext.parser.IParser;
+import org.eclipse.xtext.resource.XtextResource;
+import org.osgi.framework.Bundle;
+
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Enum;
+import com.google.eclipse.protobuf.util.EObjectFinder;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * Protobuf elements accesible to any .proto file.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@Singleton
+public class GlobalScope {
+
+  private Protobuf root;
+
+  private boolean initialized;
+  private Map<String, Property> fileOptions = new LinkedHashMap<String, Property>();
+  private Enum optimizedMode;
+
+  @Inject EObjectFinder finder;
+
+  @Inject public GlobalScope(IParser parser) {
+    try {
+      XtextResource resource = new XtextResource(URI.createURI(""));
+      IParseResult result = parser.parse(new InputStreamReader(globalScopeContents(), "UTF-8"));
+      root = (Protobuf) result.getRootASTElement();
+      resource.getContents().add(root);
+    } catch (IOException e) {
+      throw new IllegalStateException("Unable to parse global scope", e);
+    }
+  }
+
+  private static InputStream globalScopeContents() throws IOException {
+    Bundle bundle = Platform.getBundle("com.google.eclipse.protobuf");
+    Path originPath = new Path("global.proto");
+    URL bundledFileURL = find(bundle, originPath, null);
+    return (InputStream) resolve(bundledFileURL).getContent();
+  }
+
+  private void init() {
+    if (initialized) return;
+    initialized = true;
+    Message m = fileOptionsMessage();
+    for (MessageElement e : m.getElements()) {
+      if (e instanceof Property) {
+        addFileOption((Property) e);
+        continue;
+      }
+      if (e instanceof Enum && "OptimizeMode".equals(e.getName())) {
+        optimizedMode = (Enum) e;
+        continue;
+      }
+    }
+  }
+
+  private Message fileOptionsMessage() {
+    for (ProtobufElement e : root.getElements()) {
+      if (!(e instanceof Message)) continue;
+      Message m = (Message) e;
+      if ("FileOptions".equals(m.getName())) return m;
+    }
+    return null;
+  }
+
+  private void addFileOption(Property p) {
+    fileOptions.put(p.getName(), p);
+  }
+
+  public Collection<Property> fileOptions() {
+    init();
+    return unmodifiableCollection(fileOptions.values());
+  }
+
+  public Enum optimizedMode() {
+    init();
+    return optimizedMode;
+  }
+
+  public boolean isOptimizeForOption(Option option) {
+    init();
+    return "optimize_for".equals(option.getName());
+  }
+
+  public Property lookupFileOption(String name) {
+    init();
+    return fileOptions.get(name);
+  }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider.java
new file mode 100644
index 0000000..2a32b85
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider.java
@@ -0,0 +1,64 @@
+/*
+ * 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.scoping;
+
+import static org.eclipse.xtext.resource.EObjectDescription.create;
+
+import java.util.*;
+
+import org.eclipse.emf.ecore.*;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.scoping.IScope;
+import org.eclipse.xtext.scoping.impl.*;
+
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Enum;
+import com.google.eclipse.protobuf.util.EObjectFinder;
+import com.google.inject.Inject;
+
+/**
+ * Custom scoping description.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ *
+ * @see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping
+ */
+public class ProtobufScopeProvider extends AbstractDeclarativeScopeProvider {
+
+  private static final boolean DO_NOT_IGNORE_CASE = false;
+
+  @Inject private EObjectFinder finder;
+  @Inject private GlobalScope globalScope;
+
+  @SuppressWarnings("unused")
+  IScope scope_LiteralRef_literal(LiteralRef literalRef, EReference reference) {
+    EObject container = literalRef.eContainer();
+    if (container instanceof Property) {
+      Enum enumType = finder.enumTypeOfProperty((Property) container);
+      if (enumType != null) return scopeForLiteralsIn(enumType);
+    }
+    if (container instanceof Option && globalScope.isOptimizeForOption((Option) container)) {
+      Enum optimizedMode = globalScope.optimizedMode();
+      return scopeForLiteralsIn(optimizedMode);
+    }
+    return null;
+  }
+
+  private static IScope scopeForLiteralsIn(Enum enumType) {
+    List<IEObjectDescription> descriptions = descriptionsFrom(enumType);
+    return new SimpleScope(descriptions, DO_NOT_IGNORE_CASE);
+  }
+
+  private static List<IEObjectDescription> descriptionsFrom(Enum enumType) {
+    List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();
+    for (Literal literal : enumType.getLiterals())
+      descriptions.add(create(literal.getName(), literal));
+    return descriptions;
+  }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/SimpleImportUriResolver.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/SimpleImportUriResolver.java
new file mode 100644
index 0000000..4e57e85
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/SimpleImportUriResolver.java
@@ -0,0 +1,72 @@
+/*
+ * 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.scoping;
+
+import java.util.List;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.scoping.impl.ImportUriResolver;
+
+import com.google.eclipse.protobuf.protobuf.Import;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class SimpleImportUriResolver extends ImportUriResolver {
+
+  private static final String PREFIX = "platform:/resource";
+
+  /**
+   * Prefix used by EMF for resource URIs: "platform:/resource/".
+   */
+  public static final String URI_PREFIX = PREFIX + "/";
+
+  /** {@inheritDoc} */
+  @Override public String apply(EObject from) {
+    if (from instanceof Import)
+      fixUri((Import) from);
+    return super.apply(from);
+  }
+
+  /*
+   * The import URI is relative to the file where the import is. Protoc works fine, but the editor doesn't.
+   * In order for the editor to see the import, we need to add to the import URI "platform:resource" and the parent
+   * folder of the file containing the import.
+   *
+   * For example: given the following file hierarchy:
+   *
+   * - protobuf-test (project)
+   *   - folder
+   *     - proto2.proto
+   *   - proto1.proto
+   *
+   * If we import "folder/proto2.proto" into proto1.proto, proto1.proto will compile fine, but the editor will complain.
+   * We need to have the import URI as "platform:/resource/protobuf-test/folder/proto2.proto" for the editor to see it.
+   */
+  private void fixUri(Import i) {
+    String prefix = uriPrefix(i.eResource().getURI());
+    String uri = i.getImportURI();
+    if (!uri.startsWith(prefix)) {
+      if (!uri.startsWith(prefix)) prefix += "/";
+      i.setImportURI(prefix + uri);
+    }
+  }
+
+  private String uriPrefix(URI containerUri) {
+    StringBuilder prefix = new StringBuilder();
+    prefix.append(PREFIX);
+    int start = (containerUri.scheme() == null) ? 0 : 1; // ignore the scheme if present (e.g. "resource")
+    List<String> segments = containerUri.segmentsList();
+    int end = segments.size() - 1; // ignore file name (at the end of the URI)
+    for (int j = start; j < end; j++)
+      prefix.append("/").append(segments.get(j));
+    return prefix.toString();
+  }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/EObjectFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/EObjectFinder.java
new file mode 100644
index 0000000..82c470a
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/EObjectFinder.java
@@ -0,0 +1,48 @@
+/*
+ * 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.util;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Enum;
+import com.google.eclipse.protobuf.protobuf.Package;
+import com.google.inject.Singleton;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@Singleton
+public class EObjectFinder {
+
+  public Enum enumTypeOfProperty(Property p) {
+    AbstractTypeReference aTypeRef = (p).getType();
+    if (aTypeRef instanceof TypeReference) {
+      Type type = ((TypeReference) aTypeRef).getType();
+      if (type instanceof Enum) return (Enum) type;
+    }
+    return null;
+  }
+
+  public ScalarType scalarTypeOfProperty(Property p) {
+    AbstractTypeReference aTypeRef = (p).getType();
+    if (aTypeRef instanceof ScalarTypeReference)
+      return ((ScalarTypeReference) aTypeRef).getScalar();
+    return null;
+  }
+
+  public Package findPackage(EObject o) {
+    EObject current = o;
+    while (current != null) {
+      if (current instanceof Protobuf) return ((Protobuf) current).getPackage();
+      current = current.eContainer();
+    }
+    return null;
+  }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
new file mode 100644
index 0000000..5932ad4
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
@@ -0,0 +1,23 @@
+/*
+ * 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.validation;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class ProtobufJavaValidator extends AbstractProtobufJavaValidator {
+
+//	@Check
+//	public void checkGreetingStartsWithCapital(Greeting greeting) {
+//		if (!Character.isUpperCase(greeting.getName().charAt(0))) {
+//			warning("Name should start with a capital", MyDslPackage.GREETING__NAME);
+//		}
+//	}
+
+}