Fixed test failures. Added "syntax = 'proto2'" to all proto code in
tests.
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_isDefaultValueOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_isDefaultValueOption_Test.java
index 6ae600f..71aa9c5 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_isDefaultValueOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_isDefaultValueOption_Test.java
@@ -32,6 +32,8 @@
fieldOptions = xtext.getInstanceOf(FieldOptions.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional boolean active = 1 [default = true, deprecated = false];
// }
@@ -40,6 +42,8 @@
assertTrue(fieldOptions.isDefaultValueOption(option));
}
+ // syntax = "proto2";
+ //
// message Person {
// optional boolean active = 1 [default = true, deprecated = false];
// }
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_lastFieldSourceFrom_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_lastFieldSourceFrom_Test.java
index 766733d..a106684 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_lastFieldSourceFrom_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_lastFieldSourceFrom_Test.java
@@ -13,14 +13,14 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
+import org.junit.*;
+
import com.google.eclipse.protobuf.junit.core.XtextRule;
import com.google.eclipse.protobuf.protobuf.*;
-import org.junit.*;
-
/**
* Tests for <code>{@link FieldOptions#lastFieldSourceFrom(CustomFieldOption)}</code>.
- *
+ *
* alruiz@google.com (Alex Ruiz)
*/
public class FieldOptions_lastFieldSourceFrom_Test {
@@ -32,20 +32,22 @@
@Before public void setUp() {
fieldOptions = xtext.getInstanceOf(FieldOptions.class);
}
-
- // import 'google/protobuf/descriptor.proto';
- //
- // message Custom {
- // optional int32 count = 1;
- // }
- //
- // extend google.protobuf.FieldOptions {
- // optional Custom custom = 1000;
- // }
- //
- // message Person {
- // optional boolean active = 1 [(custom).count = 6];
- // }
+
+ // syntax = "proto2";
+ //
+ // import 'google/protobuf/descriptor.proto';
+ //
+ // message Custom {
+ // optional int32 count = 1;
+ // }
+ //
+ // extend google.protobuf.FieldOptions {
+ // optional Custom custom = 1000;
+ // }
+ //
+ // message Person {
+ // optional boolean active = 1 [(custom).count = 6];
+ // }
@Test public void should_return_property_field() {
CustomFieldOption option = xtext.find("custom", ").", CustomFieldOption.class);
Property p = (Property) fieldOptions.lastFieldSourceFrom(option);
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_nameOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_nameOf_Test.java
index 530b3d7..de42f49 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_nameOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_nameOf_Test.java
@@ -13,11 +13,11 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
+import org.junit.*;
+
import com.google.eclipse.protobuf.junit.core.XtextRule;
import com.google.eclipse.protobuf.protobuf.FieldOption;
-import org.junit.*;
-
/**
* Tests for <code>{@link FieldOptions#nameOf(FieldOption)}</code>.
*
@@ -33,24 +33,28 @@
fieldOptions = xtext.getInstanceOf(FieldOptions.class);
}
- // message Person {
+ // syntax = "proto2";
+ //
+ // message Person {
// optional boolean active = 1 [deprecated = false];
- // }
+ // }
@Test public void should_return_name_of_native_field_option() {
FieldOption option = xtext.find("deprecated", FieldOption.class);
String name = fieldOptions.nameOf(option);
assertThat(name, equalTo("deprecated"));
}
- // import 'google/protobuf/descriptor.proto';
- //
- // extend google.protobuf.FieldOptions {
- // optional string encoding = 1000;
- // }
- //
- // message Person {
+ // syntax = "proto2";
+ //
+ // import 'google/protobuf/descriptor.proto';
+ //
+ // extend google.protobuf.FieldOptions {
+ // optional string encoding = 1000;
+ // }
+ //
+ // message Person {
// optional boolean active = 1 [(encoding) = 'UTF-8'];
- // }
+ // }
@Test public void should_return_name_of_custom_field_option() {
FieldOption option = xtext.find("encoding", ")", FieldOption.class);
String name = fieldOptions.nameOf(option);
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java
index c9a5470..a8e0c03 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java
@@ -13,11 +13,11 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
+import org.junit.*;
+
import com.google.eclipse.protobuf.junit.core.XtextRule;
import com.google.eclipse.protobuf.protobuf.*;
-import org.junit.*;
-
/**
* Tests for <code>{@link FieldOptions#sourceOf(FieldOption)}</code>.
*
@@ -33,6 +33,8 @@
fieldOptions = xtext.getInstanceOf(FieldOptions.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional boolean active = 1 [deprecated = false];
// }
@@ -42,6 +44,8 @@
assertThat(p.getName(), equalTo("deprecated"));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// extend google.protobuf.FieldOptions {
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java
index 0df73bd..4ffe347 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java
@@ -13,14 +13,14 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
+import org.junit.*;
+
import com.google.eclipse.protobuf.junit.core.XtextRule;
import com.google.eclipse.protobuf.protobuf.*;
-import org.junit.*;
-
/**
* Tests for <code>{@link Options#lastFieldSourceFrom(CustomOption)}</code>.
- *
+ *
* alruiz@google.com (Alex Ruiz)
*/
public class Options_lastFieldSourceFrom_Test {
@@ -32,17 +32,19 @@
@Before public void setUp() {
options = xtext.getInstanceOf(Options.class);
}
-
+
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// message Custom {
// optional int32 count = 1;
// }
- //
+ //
// extend google.protobuf.FileOptions {
// optional Custom custom = 1000;
// }
- //
+ //
// option (custom).count = 6;
@Test public void should_return_property_field() {
CustomOption option = xtext.find("custom", ")", CustomOption.class);
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java
index 55a084b..3becab9 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java
@@ -13,11 +13,11 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
+import org.junit.*;
+
import com.google.eclipse.protobuf.junit.core.XtextRule;
import com.google.eclipse.protobuf.protobuf.*;
-import org.junit.*;
-
/**
* Tests for <code>{@link Options#sourceOf(Option)}</code>.
*
@@ -33,6 +33,8 @@
options = xtext.getInstanceOf(Options.class);
}
+ // syntax = "proto2";
+ //
// option java_package = 'com.google.eclipse.protobuf.tests';
@Test public void should_return_property_of_native_option() {
Option option = xtext.find("java_package", Option.class);
@@ -40,12 +42,14 @@
assertThat(p.getName(), equalTo("java_package"));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
- //
+ //
// extend google.protobuf.FileOptions {
// optional string encoding = 1000;
// }
- //
+ //
// option (encoding) = 'UTF-8';
@Test public void should_return_property_of_custom_option() {
Option option = xtext.find("encoding", ")", Option.class);
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue131_AddOptionsForService_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue131_AddOptionsForService_Test.java
index dcd8633..13cb80f 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue131_AddOptionsForService_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue131_AddOptionsForService_Test.java
@@ -15,53 +15,54 @@
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.Option;
-import com.google.eclipse.protobuf.scoping.ProtobufScopeProvider;
-
import org.eclipse.emf.ecore.EReference;
import org.eclipse.xtext.scoping.IScope;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Option;
+
/**
* Tests fix for <a href="http://code.google.com/p/protobuf-dt/issues/detail?id=131">Issue 131</a>.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class Issue131_AddOptionsForService_Test {
private static EReference reference;
-
+
@BeforeClass public static void setUpOnce() {
reference = mock(EReference.class);
}
-
+
@Rule public XtextRule xtext = createWith(integrationTestSetup());
private ProtobufScopeProvider provider;
-
+
@Before public void setUp() {
provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
}
+ // syntax = "proto2";
+ //
// package com.google.proto;
- //
+ //
// import 'google/protobuf/descriptor.proto';
//
// extend google.protobuf.ServiceOptions {
// optional int32 code = 1000;
// optional int32 info = 1002;
// }
- //
+ //
// service ABC {
// option (code) = 68;
// }
@Test public void should_support_Service_options() {
Option option = xtext.find("code", ")", Option.class);
IScope scope = provider.scope_OptionSource_optionField(option.getSource(), reference);
- assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
+ assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
".com.google.proto.code",
- "info", "proto.info", "google.proto.info", "com.google.proto.info",
- ".com.google.proto.info"));
+ "info", "proto.info", "google.proto.info", "com.google.proto.info",
+ ".com.google.proto.info"));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue147_AddSupportForGroupOptions_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue147_AddSupportForGroupOptions_Test.java
index be37f9d..7cbc2c8 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue147_AddSupportForGroupOptions_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue147_AddSupportForGroupOptions_Test.java
@@ -47,6 +47,8 @@
provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// repeated group membership = 1 [deprecated = true] {
// required int64 groupId = 2;
@@ -64,6 +66,8 @@
return descriptorProvider.primaryDescriptor();
}
+ // syntax = "proto2";
+ //
// package com.google.proto;
// import 'google/protobuf/descriptor.proto';
//
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue156_AddSupportForEnumValueOptions_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue156_AddSupportForEnumValueOptions_Test.java
index df88541..eacee33 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue156_AddSupportForEnumValueOptions_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/Issue156_AddSupportForEnumValueOptions_Test.java
@@ -43,6 +43,8 @@
provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// extend google.protobuf.EnumValueOptions {
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_LiteralRef_literal_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_LiteralRef_literal_Test.java
index 5089b0b..d541111 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_LiteralRef_literal_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_LiteralRef_literal_Test.java
@@ -15,40 +15,42 @@
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
-import com.google.eclipse.protobuf.protobuf.Enum;
-
import org.eclipse.emf.ecore.EReference;
import org.eclipse.xtext.scoping.IScope;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Enum;
+
/**
* Tests for <code>{@link ProtobufScopeProvider#scope_LiteralRef_literal(LiteralRef, EReference)}</code>.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufScopeProvider_scope_LiteralRef_literal_Test {
private static EReference reference;
-
+
@BeforeClass public static void setUpOnce() {
reference = mock(EReference.class);
}
-
+
@Rule public XtextRule xtext = createWith(integrationTestSetup());
-
+
private ProtobufScopeProvider provider;
-
+
@Before public void setUp() {
provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
}
-
+
+ // syntax = "proto2";
+ //
// enum Type {
// ONE = 0;
// TWO = 1;
// }
- //
+ //
// message Person {
// optional Type type = 1 [default = ONE];
// }
@@ -58,7 +60,9 @@
Enum typeEnum = xtext.find("Type", " {", Enum.class);
assertThat(descriptionsIn(scope), containAllLiteralsIn(typeEnum));
}
-
+
+ // syntax = "proto2";
+ //
// option optimize_for = SPEED;
@Test public void should_provide_Literals_for_native_option() {
Option option = xtext.find("optimize_for", Option.class);
@@ -66,7 +70,9 @@
Enum optimizeModeEnum = descriptor().enumByName("OptimizeMode");
assertThat(descriptionsIn(scope), containAllLiteralsIn(optimizeModeEnum));
}
-
+
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// enum Type {
@@ -77,8 +83,8 @@
// extend google.protobuf.FileOptions {
// optional Type type = 1000;
// }
- //
- // option (type) = ONE;
+ //
+ // option (type) = ONE;
@Test public void should_provide_Literals_for_custom_option() {
Option option = xtext.find("type", ")", Option.class);
IScope scope = provider.scope_LiteralRef_literal(valueOf(option), reference);
@@ -86,6 +92,8 @@
assertThat(descriptionsIn(scope), containAllLiteralsIn(typeEnum));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// enum Type {
@@ -100,8 +108,8 @@
// extend google.protobuf.FileOptions {
// optional Info info = 1000;
// }
- //
- // option (info).type = ONE;
+ //
+ // option (info).type = ONE;
@Test public void should_provide_Literals_for_property_of_custom_option() {
Option option = xtext.find("info", ")", Option.class);
IScope scope = provider.scope_LiteralRef_literal(valueOf(option), reference);
@@ -112,7 +120,9 @@
private static LiteralRef valueOf(Option option) {
return (LiteralRef) option.getValue();
}
-
+
+ // syntax = "proto2";
+ //
// message Person {
// optional Type type = 1 [ctype = STRING];
// }
@@ -122,12 +132,14 @@
Enum cTypeEnum = descriptor().enumByName("CType");
assertThat(descriptionsIn(scope), containAllLiteralsIn(cTypeEnum));
}
-
+
private ProtoDescriptor descriptor() {
ProtoDescriptorProvider descriptorProvider = xtext.getInstanceOf(ProtoDescriptorProvider.class);
return descriptorProvider.primaryDescriptor();
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// enum Type {
@@ -138,7 +150,7 @@
// extend google.protobuf.FieldOptions {
// optional Type type = 1000;
// }
- //
+ //
// message Person {
// optional boolean active = 1 [(type) = ONE];
// }
@@ -149,6 +161,8 @@
assertThat(descriptionsIn(scope), containAllLiteralsIn(typeEnum));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// enum Type {
@@ -163,7 +177,7 @@
// extend google.protobuf.FieldOptions {
// optional Info info = 1000;
// }
- //
+ //
// message Person {
// optional boolean active = 1 [(info).type = ONE];
// }
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionExtendMessageFieldSource_optionExtendMessageField_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionExtendMessageFieldSource_optionExtendMessageField_Test.java
index 1e90c24..617f43e 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionExtendMessageFieldSource_optionExtendMessageField_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionExtendMessageFieldSource_optionExtendMessageField_Test.java
@@ -43,6 +43,8 @@
provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
}
+ // syntax = "proto2";
+ //
// package com.google.proto;
//
// import 'google/protobuf/descriptor.proto';
@@ -69,6 +71,8 @@
assertThat(descriptionsIn(scope), containAll("active", "com.google.proto.active", ".com.google.proto.active"));
}
+ // syntax = "proto2";
+ //
// package com.google.proto;
//
// import 'google/protobuf/descriptor.proto';
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionMessageFieldSource_optionMessageField_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionMessageFieldSource_optionMessageField_Test.java
index 3cb069f..592310f 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionMessageFieldSource_optionMessageField_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionMessageFieldSource_optionMessageField_Test.java
@@ -44,6 +44,8 @@
provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// message Type {
@@ -64,6 +66,8 @@
assertThat(descriptionsIn(scope), containAllFieldsIn(typeMessage));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// message Code {
@@ -88,6 +92,8 @@
assertThat(descriptionsIn(scope), containAllFieldsIn(codeMessage));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// extend google.protobuf.FileOptions {
@@ -106,6 +112,8 @@
assertThat(descriptionsIn(scope), containAllFieldsIn(groupMessage));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// message Type {
@@ -128,6 +136,8 @@
assertThat(descriptionsIn(scope), containAllFieldsIn(typeMessage));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// message Code {
@@ -154,6 +164,8 @@
assertThat(descriptionsIn(scope), containAllFieldsIn(codeMessage));
}
+ // syntax = "proto2";
+ //
// import 'google/protobuf/descriptor.proto';
//
// extend google.protobuf.FieldOptions {
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionSource_optionField_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionSource_optionField_Test.java
index c7f9721..8b0711a 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionSource_optionField_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_OptionSource_optionField_Test.java
@@ -17,36 +17,38 @@
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
+import java.util.Collection;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.xtext.scoping.IScope;
import org.junit.*;
-import java.util.Collection;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.*;
/**
* Tests for <code>{@link ProtobufScopeProvider#scope_OptionSource_optionField(OptionSource, EReference)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufScopeProvider_scope_OptionSource_optionField_Test {
private static EReference reference;
-
+
@BeforeClass public static void setUpOnce() {
reference = mock(EReference.class);
}
-
+
@Rule public XtextRule xtext = createWith(integrationTestSetup());
-
+
private ProtobufScopeProvider provider;
-
+
@Before public void setUp() {
provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
}
+ // syntax = "proto2";
+ //
// option optimize_for = SPEED;
@Test public void should_provide_Property_fields_for_native_option() {
Option option = xtext.find("optimize_for", Option.class);
@@ -54,7 +56,9 @@
Collection<Property> fileOptions = descriptor().optionsOfType(FILE);
assertThat(descriptionsIn(scope), containAll(fileOptions));
}
-
+
+ // syntax = "proto2";
+ //
// message Person {
// optional Type type = 1 [ctype = STRING];
// }
@@ -70,6 +74,8 @@
return descriptorProvider.primaryDescriptor();
}
+ // syntax = "proto2";
+ //
// package com.google.proto;
// import 'google/protobuf/descriptor.proto';
//
@@ -82,14 +88,15 @@
@Test public void should_provide_Property_fields_for_custom_option() {
Option option = xtext.find("code", ")", Option.class);
IScope scope = provider.scope_OptionSource_optionField(option.getSource(), reference);
- assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
+ assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
".com.google.proto.code",
- "info", "proto.info", "google.proto.info", "com.google.proto.info",
+ "info", "proto.info", "google.proto.info", "com.google.proto.info",
".com.google.proto.info"));
}
// // Create file custom-options.proto
- //
+ // syntax = "proto2";
+ //
// package test.proto;
//
// import "google/protobuf/descriptor.proto";
@@ -97,10 +104,10 @@
// extend google.protobuf.FileOptions {
// optional int32 code = 1000;
// optional int32 info = 1002;
- // }
-
+ // }
+
// package com.google.proto;
- //
+ //
// import 'custom-options.proto';
//
// option (test.proto.code) = 68;
@@ -112,7 +119,8 @@
}
// // Create file custom-options.proto
- //
+ // syntax = "proto2";
+ //
// package com.google.proto;
//
// import "google/protobuf/descriptor.proto";
@@ -120,39 +128,39 @@
// extend google.protobuf.FileOptions {
// optional int32 code = 1000;
// optional int32 info = 1002;
- // }
-
+ // }
+
// package com.google.proto;
- //
+ //
// import 'custom-options.proto';
//
// option (code) = 68;
@Test public void should_provide_imported_Property_fields_for_custom_option_with_equal_package() {
Option option = xtext.find("code", ")", Option.class);
IScope scope = provider.scope_OptionSource_optionField(option.getSource(), reference);
- assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
+ assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
".com.google.proto.code",
"info", "proto.info", "google.proto.info", "com.google.proto.info",
".com.google.proto.info"));
}
-
+
// package com.google.proto;
// import 'google/protobuf/descriptor.proto';
- //
+ //
// extend google.protobuf.FieldOptions {
// optional int32 code = 1000;
// optional int32 info = 1001;
// }
- //
+ //
// message Person {
// optional boolean active = 1 [(code) = 68];
// }
@Test public void should_provide_Property_fields_for_custom_field_option() {
CustomFieldOption option = xtext.find("code", ")", CustomFieldOption.class);
IScope scope = provider.scope_OptionSource_optionField(option.getSource(), reference);
- assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
+ assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
".com.google.proto.code",
- "info", "proto.info", "google.proto.info", "com.google.proto.info",
+ "info", "proto.info", "google.proto.info", "com.google.proto.info",
".com.google.proto.info"));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_TypeRef_type_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_TypeRef_type_Test.java
index 578d94c..8398201 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_TypeRef_type_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_TypeRef_type_Test.java
@@ -24,27 +24,29 @@
/**
* Tests for <code>{@link ProtobufScopeProvider#scope_TypeRef_type(TypeRef, EReference)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufScopeProvider_scope_TypeRef_type_Test {
private static EReference reference;
-
+
@BeforeClass public static void setUpOnce() {
reference = mock(EReference.class);
}
-
+
@Rule public XtextRule xtext = createWith(integrationTestSetup());
private ProtobufScopeProvider provider;
-
+
@Before public void setUp() {
provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
}
+ // syntax = "proto2";
+ //
// package com.google.proto;
- //
+ //
// enum Type {
// PERSONAL = 0;
// BUSINESS = 1;
@@ -56,23 +58,23 @@
// optional string city = 3;
// optional int32 zipCode = 4;
// }
- //
+ //
// message Contact {
- // optional Type type = 1;
+ // optional Type type = 1;
// }
@Test public void should_provide_Types() {
Property p = xtext.find("type", Property.class);
IScope scope = provider.scope_TypeRef_type(typeOf(p), reference);
- assertThat(descriptionsIn(scope), containAll("Type", "proto.Type", "google.proto.Type", "com.google.proto.Type",
+ assertThat(descriptionsIn(scope), containAll("Type", "proto.Type", "google.proto.Type", "com.google.proto.Type",
".com.google.proto.Type",
- "Address", "proto.Address", "google.proto.Address",
+ "Address", "proto.Address", "google.proto.Address",
"com.google.proto.Address", ".com.google.proto.Address",
"Contact", "proto.Contact", "google.proto.Contact",
"com.google.proto.Contact", ".com.google.proto.Contact"));
}
-
+
// // Create file types.proto
- //
+ //
// package test.proto;
//
// enum Type {
@@ -86,25 +88,25 @@
// optional string city = 3;
// optional int32 zipCode = 4;
// }
-
+
// package com.google.proto;
- //
+ //
// import "types.proto";
//
// message Contact {
- // optional com.google.test.Type type = 1;
+ // optional com.google.test.Type type = 1;
// }
@Test public void should_provide_imported_Types() {
Property p = xtext.find("type", " =", Property.class);
IScope scope = provider.scope_TypeRef_type(typeOf(p), reference);
assertThat(descriptionsIn(scope), containAll("test.proto.Type", ".test.proto.Type",
"test.proto.Address", ".test.proto.Address",
- "Contact", "proto.Contact", "google.proto.Contact",
+ "Contact", "proto.Contact", "google.proto.Contact",
"com.google.proto.Contact", ".com.google.proto.Contact"));
}
// // Create file types.proto
- //
+ //
// package com.google.proto;
//
// enum Type {
@@ -118,13 +120,13 @@
// optional string city = 3;
// optional int32 zipCode = 4;
// }
-
+
// package com.google.proto;
- //
+ //
// import "types.proto";
//
// message Contact {
- // optional com.google.test.Type type = 1;
+ // optional com.google.test.Type type = 1;
// }
@Test public void should_provide_imported_Types_with_equal_package() {
Property p = xtext.find("type", " =", Property.class);
@@ -133,12 +135,12 @@
".com.google.proto.Type",
"Address", "proto.Address", "google.proto.Address",
"com.google.proto.Address", ".com.google.proto.Address",
- "Contact", "proto.Contact", "google.proto.Contact",
+ "Contact", "proto.Contact", "google.proto.Contact",
"com.google.proto.Contact", ".com.google.proto.Contact"));
}
// // Create file types.proto
- //
+ //
// package test.proto;
//
// enum Type {
@@ -152,25 +154,25 @@
// optional string city = 3;
// optional int32 zipCode = 4;
// }
-
+
// package com.google.proto;
- //
+ //
// import public "types.proto";
//
// message Contact {
- // optional test.proto.Type type = 1;
+ // optional test.proto.Type type = 1;
// }
@Test public void should_provide_public_imported_Types() {
Property p = xtext.find("type", " =", Property.class);
IScope scope = provider.scope_TypeRef_type(typeOf(p), reference);
assertThat(descriptionsIn(scope), containAll("test.proto.Type", ".test.proto.Type",
"test.proto.Address", ".test.proto.Address",
- "Contact", "proto.Contact", "google.proto.Contact",
+ "Contact", "proto.Contact", "google.proto.Contact",
"com.google.proto.Contact", ".com.google.proto.Contact"));
}
// // Create file public-types.proto
- //
+ //
// package test.proto;
//
// enum Type {
@@ -186,24 +188,24 @@
// }
// // Create file types.proto
- //
+ //
// package com.google.proto;
- //
+ //
// import public "public-types.proto";
// package com.google.proto;
- //
+ //
// import "types.proto";
//
// message Contact {
- // optional test.proto.Type type = 1;
+ // optional test.proto.Type type = 1;
// }
@Test public void should_provide_public_imported_Types_with_more_than_one_level() {
Property p = xtext.find("type", " =", Property.class);
IScope scope = provider.scope_TypeRef_type(typeOf(p), reference);
assertThat(descriptionsIn(scope), containAll("test.proto.Type", ".test.proto.Type",
"test.proto.Address", ".test.proto.Address",
- "Contact", "proto.Contact", "google.proto.Contact",
+ "Contact", "proto.Contact", "google.proto.Contact",
"com.google.proto.Contact", ".com.google.proto.Contact"));
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue148_FixDuplicateNameError_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue148_FixDuplicateNameError_Test.java
index f9bc489..f3c6637 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue148_FixDuplicateNameError_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue148_FixDuplicateNameError_Test.java
@@ -26,13 +26,15 @@
public class Issue148_FixDuplicateNameError_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
private ProtobufJavaValidator validator;
-
+
@Before public void setUp() {
validator = xtext.getInstanceOf(ProtobufJavaValidator.class);
}
-
+
+ // syntax = "proto2";
+ //
// package abc;
//
// message abc {}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue150_AddSupportForExtendMessageToGroups_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue150_AddSupportForExtendMessageToGroups_Test.java
index 3ec92d4..778762b 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue150_AddSupportForExtendMessageToGroups_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue150_AddSupportForExtendMessageToGroups_Test.java
@@ -12,19 +12,21 @@
import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
import static org.junit.Assert.assertNotNull;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+
/**
* Tests fix for <a href="http://code.google.com/p/protobuf-dt/issues/detail?id=150">Issue 150</a>.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class Issue150_AddSupportForExtendMessageToGroups_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
+ // syntax = "proto2";
+ //
// message ABC {
// extensions 1000 to max;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue152_SupportEscapedCharactersInStrings_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue152_SupportEscapedCharactersInStrings_Test.java
index 236a9bb..547ba43 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue152_SupportEscapedCharactersInStrings_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue152_SupportEscapedCharactersInStrings_Test.java
@@ -12,23 +12,25 @@
import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
import static org.junit.Assert.assertNotNull;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+
/**
* Tests fix for <a href="http://code.google.com/p/protobuf-dt/issues/detail?id=152">Issue 152</a>.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class Issue152_SupportEscapedCharactersInStrings_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
- // message Foo {
- // optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
- // }
+
+ // syntax = "proto2";
+ //
+ // message Foo {
+ // optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
+ // }
@Test public void should_recognize_escaped_characters() {
assertNotNull(xtext.root());
- }
+ }
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue153_AddSupportForNegativeInf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue153_AddSupportForNegativeInf_Test.java
index 17553e1..89d1391 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue153_AddSupportForNegativeInf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue153_AddSupportForNegativeInf_Test.java
@@ -12,23 +12,25 @@
import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
import static org.junit.Assert.assertNotNull;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+
/**
* Tests fix for <a href="http://code.google.com/p/protobuf-dt/issues/detail?id=153">Issue 153</a>.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class Issue153_AddSupportForNegativeInf_Test {
-
+
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
- // message Foo {
- // optional double bar = 1 [default = -inf];
- // }
+
+ // syntax = "proto2";
+ //
+ // message Foo {
+ // optional double bar = 1 [default = -inf];
+ // }
@Test public void should_recognize_negative_inf() {
assertNotNull(xtext.root());
- }
+ }
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue91_AddSupportForUTF16Strings_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue91_AddSupportForUTF16Strings_Test.java
index 28089e9..57b5cf7 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue91_AddSupportForUTF16Strings_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue91_AddSupportForUTF16Strings_Test.java
@@ -12,22 +12,24 @@
import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
import static org.junit.Assert.assertNotNull;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+
/**
* Tests fix for <a href="http://code.google.com/p/protobuf-dt/issues/detail?id=91">Issue 91</a>.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class Issue91_AddSupportForUTF16Strings_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
- // message Foo {
- // optional string bar = 1 [default="\\302\\265"];
- // }
+
+ // syntax = "proto2";
+ //
+ // message Foo {
+ // optional string bar = 1 [default="\\302\\265"];
+ // }
@Test public void should_recognize_UTF16_strings() {
assertNotNull(xtext.root());
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/Finder.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/Finder.java
index 9b12965..9fb02e7 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/Finder.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/Finder.java
@@ -19,7 +19,8 @@
import org.eclipse.xtext.nodemodel.*;
import org.eclipse.xtext.nodemodel.impl.AbstractNode;
-import com.google.eclipse.protobuf.protobuf.DefaultValueFieldOption;
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Package;
/**
* @author alruiz@google.com (Alex Ruiz)
@@ -56,7 +57,7 @@
return type.cast(e);
}
if (type.isInstance(e)) {
- if (areNamesEqual(name, nameOf(e), options)) return type.cast(e);
+ if (areNamesEqual(name, e, options)) return type.cast(e);
}
}
String format = "Unable to find element. Text: '%s', count: %d, type: %s, options: %s";
@@ -67,6 +68,23 @@
return "default".equals(name) && type.isInstance(element) && element instanceof DefaultValueFieldOption;
}
+ private Object feature(EObject e, String featureName) {
+ EStructuralFeature f = e.eClass().getEStructuralFeature(featureName);
+ return (f != null) ? e.eGet(f) : null;
+ }
+
+ private boolean areNamesEqual(String expected, Object e, List<SearchOption> options) {
+ String realExpected = expected;
+ if (realExpected.indexOf(".") != -1 && !(e instanceof Package)) {
+ String[] segments = expected.split("\\.");
+ QualifiedName qualifiedName = QualifiedName.create(segments);
+ realExpected = qualifiedName.getLastSegment();
+ }
+ String actual = nameOf(e);
+ if (options.contains(IGNORE_CASE)) return realExpected.equalsIgnoreCase(actual);
+ return realExpected.equals(actual);
+ }
+
private String nameOf(Object o) {
if (!(o instanceof EObject)) return null;
EObject e = (EObject) o;
@@ -78,22 +96,6 @@
return null;
}
- private Object feature(EObject e, String featureName) {
- EStructuralFeature f = e.eClass().getEStructuralFeature(featureName);
- return (f != null) ? e.eGet(f) : null;
- }
-
- private boolean areNamesEqual(String expected, String actual, List<SearchOption> options) {
- String realExpected = expected;
- if (realExpected.indexOf(".") != -1) {
- String[] segments = expected.split("\\.");
- QualifiedName qualifiedName = QualifiedName.create(segments);
- realExpected = qualifiedName.getLastSegment();
- }
- if (options.contains(IGNORE_CASE)) return realExpected.equalsIgnoreCase(actual);
- return realExpected.equals(actual);
- }
-
ILeafNode find(String text) {
BidiTreeIterator<AbstractNode> iterator = root.basicIterator();
while (iterator.hasNext()) {
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToCommentOrString_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToCommentOrString_Test.java
index e3b60f6..05d8f25 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToCommentOrString_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToCommentOrString_Test.java
@@ -20,26 +20,30 @@
/**
* Test for <code>{@link INodes#belongsToCommentOrString(INode)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class INodes_belongsToCommentOrString_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
private INodes nodes;
-
+
@Before public void setUp() {
nodes = xtext.getInstanceOf(INodes.class);
}
+ // syntax = "proto2";
+ //
// // This is a test.
// message Person {}
@Test public void should_return_true_if_node_belongs_to_single_line_comment() {
ILeafNode commentNode = xtext.find("// This is a test.");
assertTrue(nodes.belongsToCommentOrString(commentNode));
}
-
+
+ // syntax = "proto2";
+ //
// /* This is a test. */
// message Person {}
@Test public void should_return_true_if_node_belongs_to_multiple_line_comment() {
@@ -47,6 +51,8 @@
assertTrue(nodes.belongsToCommentOrString(commentNode));
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1 [default = 'Alex'];
// }
@@ -55,6 +61,8 @@
assertTrue(nodes.belongsToCommentOrString(node));
}
+ // syntax = "proto2";
+ //
// message Person {}
@Test public void should_return_false_if_node_does_not_belong_to_any_comment_or_string() {
ICompositeNode node = getNode(xtext.root());
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToComment_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToComment_Test.java
index 6b8d178..22ef9e8 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToComment_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToComment_Test.java
@@ -20,26 +20,30 @@
/**
* Test for <code>{@link INodes#belongsToComment(INode)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class INodes_belongsToComment_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
private INodes nodes;
-
+
@Before public void setUp() {
nodes = xtext.getInstanceOf(INodes.class);
}
+ // syntax = "proto2";
+ //
// // This is a test.
// message Person {}
@Test public void should_return_true_if_node_belongs_to_single_line_comment() {
ILeafNode commentNode = xtext.find("// This is a test.");
assertTrue(nodes.belongsToComment(commentNode));
}
-
+
+ // syntax = "proto2";
+ //
// /* This is a test. */
// message Person {}
@Test public void should_return_true_if_node_belongs_to_multiple_line_comment() {
@@ -47,6 +51,8 @@
assertTrue(nodes.belongsToComment(commentNode));
}
+ // syntax = "proto2";
+ //
// message Person {}
@Test public void should_return_false_if_node_does_not_belong_to_any_comment() {
ICompositeNode node = getNode(xtext.root());
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToMultipleLineComment_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToMultipleLineComment_Test.java
index c948855..ecc1887 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToMultipleLineComment_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToMultipleLineComment_Test.java
@@ -20,19 +20,21 @@
/**
* Test for <code>{@link INodes#belongsToMultipleLineComment(INode)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class INodes_belongsToMultipleLineComment_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
private INodes nodes;
-
+
@Before public void setUp() {
nodes = xtext.getInstanceOf(INodes.class);
}
-
+
+ // syntax = "proto2";
+ //
// /* This is a test. */
// message Person {}
@Test public void should_return_true_if_node_belongs_to_multiple_line_comment() {
@@ -40,6 +42,8 @@
assertTrue(nodes.belongsToMultipleLineComment(commentNode));
}
+ // syntax = "proto2";
+ //
// message Person {}
@Test public void should_return_false_if_node_does_not_belong_to_single_line_comment() {
ICompositeNode node = getNode(xtext.root());
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToSingleLineComment_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToSingleLineComment_Test.java
index 1f715a0..d07d0e4 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToSingleLineComment_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToSingleLineComment_Test.java
@@ -20,19 +20,21 @@
/**
* Test for <code>{@link INodes#belongsToSingleLineComment(INode)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class INodes_belongsToSingleLineComment_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
private INodes nodes;
-
+
@Before public void setUp() {
nodes = xtext.getInstanceOf(INodes.class);
}
-
+
+ // syntax = "proto2";
+ //
// // This is a test.
// message Person {}
@Test public void should_return_true_if_node_belongs_to_single_line_comment() {
@@ -40,6 +42,8 @@
assertTrue(nodes.belongsToSingleLineComment(commentNode));
}
+ // syntax = "proto2";
+ //
// message Person {}
@Test public void should_return_false_if_node_does_not_belong_to_single_line_comment() {
ICompositeNode node = getNode(xtext.root());
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToString_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToString_Test.java
index c519fae..da828b4 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToString_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_belongsToString_Test.java
@@ -20,19 +20,21 @@
/**
* Tests for <code>{@link INodes#belongsToString(INode)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class INodes_belongsToString_Test {
-
+
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
private INodes nodes;
-
+
@Before public void setUp() {
nodes = xtext.getInstanceOf(INodes.class);
}
-
+
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1 [default = 'Alex'];
// }
@@ -41,6 +43,8 @@
assertTrue(nodes.belongsToString(node));
}
+ // syntax = "proto2";
+ //
// message Person {}
@Test public void should_return_false_if_node_does_not_belong_to_string() {
ICompositeNode node = getNode(xtext.root());
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_firstNodeForFeature_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_firstNodeForFeature_Test.java
index 8d9d9a8..83b7314 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_firstNodeForFeature_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/INodes_firstNodeForFeature_Test.java
@@ -14,13 +14,13 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.Property;
-
import org.eclipse.emf.ecore.*;
import org.eclipse.xtext.nodemodel.INode;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Property;
+
/**
* Tests for <code>{@link INodes#firstNodeForFeature(EObject, EStructuralFeature)}</code>
*
@@ -36,8 +36,10 @@
nodes = xtext.getInstanceOf(INodes.class);
}
+ // syntax = "proto2";
+ //
// message Person {
- // optional bool active = 1;
+ // optional bool active = 1;
// }
@Test public void should_return_first_node_for_feature() {
Property active = xtext.find("active", Property.class);
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
index c699f5d..fa92638 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
@@ -34,6 +34,8 @@
finder = xtext.getInstanceOf(ModelFinder.class);
}
+ // syntax = "proto2";
+ //
// enum PhoneType {
// MOBILE = 0;
// HOME = 1;
@@ -49,6 +51,8 @@
assertThat(phoneType.getName(), equalTo("PhoneType"));
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_extensionsFrom_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_extensionsFrom_Test.java
index a853ce7..56c1e07 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_extensionsFrom_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_extensionsFrom_Test.java
@@ -12,12 +12,12 @@
import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
import static org.junit.Assert.assertSame;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
+import java.util.*;
import org.junit.*;
-import java.util.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.*;
/**
* Tests for <code>{@link ModelFinder#extensionsOf(Message)}</code>.
@@ -34,6 +34,8 @@
finder = xtext.getInstanceOf(ModelFinder.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_importsIn_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_importsIn_Test.java
index d951ef1..fba62a9 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_importsIn_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_importsIn_Test.java
@@ -13,12 +13,12 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
+import java.util.List;
import org.junit.*;
-import java.util.List;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.*;
/**
* Tests for <code>{@link ModelFinder#importsIn(Protobuf)}</code>.
@@ -37,6 +37,8 @@
finder = xtext.getInstanceOf(ModelFinder.class);
}
+ // syntax = "proto2";
+ //
// import "luke.proto";
// import "leia.proto";
@Test public void should_return_all_imports() {
@@ -46,6 +48,8 @@
assertThat(allImports.get(1).getImportURI(), equalTo("leia.proto"));
}
+ // syntax = "proto2";
+ //
// enum PhoneType {
// MOBILE = 0;
// HOME = 1;
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_messageFrom_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_messageFrom_Test.java
index 88abdd9..037ff2d 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_messageFrom_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_messageFrom_Test.java
@@ -14,11 +14,11 @@
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
+import org.junit.*;
+
import com.google.eclipse.protobuf.junit.core.XtextRule;
import com.google.eclipse.protobuf.protobuf.*;
-import org.junit.*;
-
/**
* Tests for <code>{@link ModelFinder#messageFrom(ExtendMessage)}</code>.
*
@@ -34,6 +34,8 @@
finder = xtext.getInstanceOf(ModelFinder.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// }
@@ -44,7 +46,7 @@
Message message = finder.messageFrom(extension);
assertThat(message.getName(), equalTo("Person"));
}
-
+
@Test public void should_return_null_if_extension_is_not_referring_to_message() {
ExtendMessage extension = mock(ExtendMessage.class);
when(extension.getMessage()).thenReturn(null);
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_packageOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_packageOf_Test.java
index 6dc128f..0bb1bea 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_packageOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_packageOf_Test.java
@@ -35,8 +35,10 @@
finder = xtext.getInstanceOf(ModelFinder.class);
}
+ // syntax = "proto2";
+ //
// package person.test;
- //
+ //
// message Person {
// optional int32 id = 1;
// }
@@ -46,6 +48,8 @@
assertThat(aPackage.getName(), equalTo("person.test"));
}
+ // syntax = "proto2";
+ //
// message Person {
// optional int32 id = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_rootOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_rootOf_Test.java
index dcd2ec0..cec6fe4 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_rootOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_rootOf_Test.java
@@ -13,12 +13,12 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
-
import org.eclipse.emf.ecore.EObject;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Property;
+
/**
* Tests for <code>{@link ModelFinder#rootOf(EObject)}</code>.
*
@@ -34,6 +34,8 @@
finder = xtext.getInstanceOf(ModelFinder.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_scalarTypeOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_scalarTypeOf_Test.java
index a021e26..766d69a 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_scalarTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_scalarTypeOf_Test.java
@@ -33,6 +33,8 @@
finder = xtext.getInstanceOf(ModelFinder.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional int32 id = 1;
// }
@@ -42,6 +44,8 @@
assertThat(int32.getName(), equalTo("int32"));
}
+ // syntax = "proto2";
+ //
// enum PhoneType {
// MOBILE = 0;
// HOME = 1;
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isBool_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isBool_Test.java
index 0bb5a02..803d0ad 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isBool_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isBool_Test.java
@@ -32,6 +32,8 @@
properties = xtext.getInstanceOf(Properties.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional bool code = 1;
// }
@@ -40,6 +42,8 @@
assertTrue(properties.isBool(p));
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isPrimitive_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isPrimitive_Test.java
index 2e9a180..05132df 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isPrimitive_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isPrimitive_Test.java
@@ -33,6 +33,8 @@
properties = xtext.getInstanceOf(Properties.class);
}
+ // syntax = "proto2";
+ //
// message Primitives {
// optional float float_1 = 1;
// optional int32 int32_1 = 2;
@@ -43,19 +45,21 @@
// optional sint64 sint64_1 = 7;
// optional fixed32 fixed32_1 = 8;
// optional fixed64 fixed64_1 = 9;
- // optional bool bool_1 = 10;
+ // optional bool bool_1 = 10;
// }
@Test public void should_return_true_if_property_is_primitive() {
for (Property p : getAllContentsOfType(xtext.root(), Property.class))
assertTrue(properties.isPrimitive(p));
}
+ // syntax = "proto2";
+ //
// message Types {
// optional string string_1 = 1;
// optional bytes bytes_1 = 2;
// optional Person person = 3;
// }
- //
+ //
// message Person {
// optional string name = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isString_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isString_Test.java
index 95388ef..dd43c51 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isString_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_isString_Test.java
@@ -32,6 +32,8 @@
properties = xtext.getInstanceOf(Properties.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// }
@@ -40,6 +42,8 @@
assertTrue(properties.isString(p));
}
+ // syntax = "proto2";
+ //
// message Person {
// optional double code = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_typeNameOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_typeNameOf_Test.java
index def0447..22e1996 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_typeNameOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Properties_typeNameOf_Test.java
@@ -13,11 +13,11 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
-
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Property;
+
/**
* Tests for <code>{@link Properties#typeNameOf(Property)}</code>.
*
@@ -33,6 +33,8 @@
properties = xtext.getInstanceOf(Properties.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// }
@@ -41,6 +43,8 @@
assertThat(properties.typeNameOf(name), equalTo("string"));
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// optional PhoneNumber number = 2;
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
index 70a0fe2..c189190 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
@@ -13,12 +13,12 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
-
import org.eclipse.xtext.naming.*;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.*;
+
/**
* Tests for <code>{@link ProtobufQualifiedNameProvider}</code>.
*
@@ -34,6 +34,8 @@
provider = (ProtobufQualifiedNameProvider) xtext.getInstanceOf(IQualifiedNameProvider.class);
}
+ // syntax = "proto2";
+ //
// package fqn.test;
//
// message Person {
@@ -45,6 +47,8 @@
assertThat(fqn.toString(), equalTo("fqn.test.Person"));
}
+ // syntax = "proto2";
+ //
// package fqn.test;
//
// message Person {
@@ -56,6 +60,8 @@
assertThat(fqn.toString(), equalTo("fqn.test.Person.name"));
}
+ // syntax = "proto2";
+ //
// message Person {
// optional string name = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java
index da7d7ee..f44b7b6 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java
@@ -13,14 +13,14 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.Enum;
+import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.naming.QualifiedName;
import org.junit.*;
-import java.util.List;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Enum;
/**
* Tests for <code>{@link LocalNamesProvider#namesOf(EObject)}</code>.
@@ -37,6 +37,8 @@
namesProvider = xtext.getInstanceOf(LocalNamesProvider.class);
}
+ // syntax = "proto2";
+ //
// package test.alternative.names;
// message Person {
// message PhoneNumber {
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test.java
index 90dee78..bf2e636 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test.java
@@ -15,30 +15,32 @@
import static org.eclipse.xtext.validation.ValidationMessageAcceptor.INSIGNIFICANT_INDEX;
import static org.mockito.Mockito.*;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.Package;
-
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Package;
+
/**
* Tests for <code>{@link ProtobufJavaValidator#checkOnlyOnePackageDefinition(Package)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
private ValidationMessageAcceptor messageAcceptor;
private ProtobufJavaValidator validator;
-
+
@Before public void setUp() {
messageAcceptor = mock(ValidationMessageAcceptor.class);
validator = xtext.getInstanceOf(ProtobufJavaValidator.class);
validator.setMessageAcceptor(messageAcceptor);
}
+ // syntax = "proto2";
+ //
// package com.google.protobuf;
// package com.google.eclipse;
@Test public void should_create_error_if_there_are_more_than_one_package_definitions() {
@@ -48,6 +50,8 @@
verify(messageAcceptor).acceptError(message, p, PACKAGE__NAME, INSIGNIFICANT_INDEX, MORE_THAN_ONE_PACKAGE_ERROR);
}
+ // syntax = "proto2";
+ //
// package com.google.eclipse;
@Test public void should_not_create_error_if_there_is_only_one_package_definition() {
Package p = xtext.find("com.google.eclipse", Package.class);
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkTagNumberIsGreaterThanZero_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkTagNumberIsGreaterThanZero_Test.java
index af422e1..298e56e 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkTagNumberIsGreaterThanZero_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkTagNumberIsGreaterThanZero_Test.java
@@ -15,30 +15,32 @@
import static org.eclipse.xtext.validation.ValidationMessageAcceptor.INSIGNIFICANT_INDEX;
import static org.mockito.Mockito.*;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
-
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.*;
+
/**
* Tests for <code>{@link ProtobufJavaValidator#checkTagNumberIsGreaterThanZero(Field)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufJavaValidator_checkTagNumberIsGreaterThanZero_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
-
+
private ValidationMessageAcceptor messageAcceptor;
private ProtobufJavaValidator validator;
-
+
@Before public void setUp() {
messageAcceptor = mock(ValidationMessageAcceptor.class);
validator = xtext.getInstanceOf(ProtobufJavaValidator.class);
validator.setMessageAcceptor(messageAcceptor);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional long id = 0;
// }
@@ -48,7 +50,9 @@
String message = "Field numbers must be positive integers.";
verify(messageAcceptor).acceptError(message, id, FIELD__INDEX, INSIGNIFICANT_INDEX, INVALID_FIELD_TAG_NUMBER_ERROR);
}
-
+
+ // syntax = "proto2";
+ //
// message Person {
// optional long id = -1;
// }
@@ -59,6 +63,8 @@
verify(messageAcceptor).acceptError(message, id, FIELD__INDEX, INSIGNIFICANT_INDEX, INVALID_FIELD_TAG_NUMBER_ERROR);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional long id = 1;
// }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkTagNumberIsUnique_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkTagNumberIsUnique_Test.java
index 914be2d..7ce2e62 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkTagNumberIsUnique_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkTagNumberIsUnique_Test.java
@@ -15,15 +15,15 @@
import static org.eclipse.xtext.validation.ValidationMessageAcceptor.INSIGNIFICANT_INDEX;
import static org.mockito.Mockito.*;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
-
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.*;
+
/**
* Tests for <code>{@link ProtobufJavaValidator#checkTagNumberIsUnique(Field)}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufJavaValidator_checkTagNumberIsUnique_Test {
@@ -32,13 +32,15 @@
private ValidationMessageAcceptor messageAcceptor;
private ProtobufJavaValidator validator;
-
+
@Before public void setUp() {
messageAcceptor = mock(ValidationMessageAcceptor.class);
validator = xtext.getInstanceOf(ProtobufJavaValidator.class);
validator.setMessageAcceptor(messageAcceptor);
}
+ // syntax = "proto2";
+ //
// message Person {
// optional long id = 1;
// optional string name = 1;
@@ -49,7 +51,9 @@
String message = "Field number 1 has already been used in \"Person\" by field \"id\".";
verify(messageAcceptor).acceptError(message, name, FIELD__INDEX, INSIGNIFICANT_INDEX, INVALID_FIELD_TAG_NUMBER_ERROR);
}
-
+
+ // syntax = "proto2";
+ //
// message Person {
// optional long id = 1;
// optional string name = 2;
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
index 6db1908..8e19167 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
@@ -38,6 +38,8 @@
finder = xtext.getInstanceOf(CommentNodesFinder.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// // Next Id: 6
// optional bool active = 1;
@@ -49,6 +51,8 @@
assertThat(node.getText().trim(), equalTo("// Next Id: 6"));
}
+ // syntax = "proto2";
+ //
// message Person {
// /*
// * Next Id: 6
@@ -61,6 +65,8 @@
assertNotNull(match.getFirst());
}
+ // syntax = "proto2";
+ //
// message Person {
// // Next Id: 6
// optional bool active = 1;
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/MLCommentDocumentationProvider_getDocumentation_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/MLCommentDocumentationProvider_getDocumentation_Test.java
index 1ee0b70..f9b4896 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/MLCommentDocumentationProvider_getDocumentation_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/MLCommentDocumentationProvider_getDocumentation_Test.java
@@ -35,13 +35,15 @@
provider = xtext.getInstanceOf(MLCommentDocumentationProvider.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// /* This comment should be ignored. */
// /*
// * Indicates whether the person is active or not.
// * (Optional.)
// */
- // optional bool active = 1;
+ // optional bool active = 1;
// }
@Test public void should_return_single_line_comment_of_element() {
Property active = xtext.find("active", Property.class);
@@ -50,9 +52,9 @@
assertThat(lines[0], equalTo("Indicates whether the person is active or not."));
assertThat(lines[1], equalTo("(Optional.)"));
}
-
+
// message Person {
- // optional bool active = 1;
+ // optional bool active = 1;
// }
@Test public void should_return_empty_String_if_element_does_not_have_single_line_comment() {
Property active = xtext.find("active", Property.class);
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/SLCommentDocumentationProvider_getDocumentation_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/SLCommentDocumentationProvider_getDocumentation_Test.java
index ec32823..482f264 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/SLCommentDocumentationProvider_getDocumentation_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/SLCommentDocumentationProvider_getDocumentation_Test.java
@@ -34,19 +34,23 @@
provider = xtext.getInstanceOf(SLCommentDocumentationProvider.class);
}
+ // syntax = "proto2";
+ //
// message Person {
// // Indicates whether the person is active or not.
// // (Optional.)
- // optional bool active = 1;
+ // optional bool active = 1;
// }
@Test public void should_return_single_line_comment_of_element() {
Property active = xtext.find("active", Property.class);
String documentation = provider.getDocumentation(active);
assertThat(documentation, equalTo("Indicates whether the person is active or not. (Optional.)"));
}
-
+
+ // syntax = "proto2";
+ //
// message Person {
- // optional bool active = 1;
+ // optional bool active = 1;
// }
@Test public void should_return_empty_String_if_element_does_not_have_single_line_comment() {
Property active = xtext.find("active", Property.class);
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Fields_calculateTagNumberOf_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Fields_calculateTagNumberOf_Test.java
index e8e2bce..4a124d1 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Fields_calculateTagNumberOf_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Fields_calculateTagNumberOf_Test.java
@@ -13,11 +13,11 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
+import org.junit.*;
+
import com.google.eclipse.protobuf.junit.core.XtextRule;
import com.google.eclipse.protobuf.protobuf.*;
-import org.junit.*;
-
/**
* Tests for <code>{@link Fields#calculateTagNumberOf(Field)}</code>.
*
@@ -33,8 +33,10 @@
fields = xtext.getInstanceOf(Fields.class);
}
+ // syntax = "proto2";
+ //
// message Person {
- // required string name = 2;
+ // required string name = 2;
// }
@Test public void should_return_one_for_first_and_only_property() {
Property name = xtext.find("name", Property.class);
@@ -42,6 +44,8 @@
assertThat(index, equalTo(1L));
}
+ // syntax = "proto2";
+ //
// message Person {
// required string name = 6;
// required int32 id = 8;
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Literals_calculateIndexOf_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Literals_calculateIndexOf_Test.java
index dbc766b..ca666f7 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Literals_calculateIndexOf_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Literals_calculateIndexOf_Test.java
@@ -13,11 +13,11 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
-
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Literal;
+
/**
* Tests for <code>{@link Literals#calculateIndexOf(Literal)}</code>.
*
@@ -33,6 +33,8 @@
literals = xtext.getInstanceOf(Literals.class);
}
+ // syntax = "proto2";
+ //
// enum PhoneType {
// MOBILE = 1;
// }
@@ -42,6 +44,8 @@
assertThat(index, equalTo(0L));
}
+ // syntax = "proto2";
+ //
// enum PhoneType {
// MOBILE = 1;
// HOME = 5;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
index 8bd15d0..7a44282 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
@@ -1,33 +1,33 @@
/*
* 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.parser;
-import com.google.eclipse.protobuf.parser.antlr.ProtobufParser;
-import com.google.eclipse.protobuf.protobuf.Protobuf;
-
import org.antlr.runtime.CharStream;
import org.eclipse.xtext.nodemodel.*;
import org.eclipse.xtext.nodemodel.impl.NodeModelBuilder;
import org.eclipse.xtext.parser.*;
+import com.google.eclipse.protobuf.parser.antlr.ProtobufParser;
+import com.google.eclipse.protobuf.protobuf.Protobuf;
+
/**
* Parser that only parses protocol buffers with "proto2" syntax, older syntax is ignored completely.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class Proto2OnlyParser extends ProtobufParser {
- private static final String[] ERRORS_TO_IGNORE = {
+ private static final String[] ERRORS_TO_IGNORE = {
"missing EOF at 'c'", "missing EOF at 'parsed'", "missing EOF at 'python'", "no viable alternative at input '<'" };
-
- @Override
+
+ @Override
protected IParseResult doParse(String ruleName, CharStream in, NodeModelBuilder builder, int initialLookAhead) {
IParseResult result = super.doParse(ruleName, in, builder, initialLookAhead);
// TODO ignore this check via preferences in open source version.