Skip to content

Commit 1811414

Browse files
#53: Support for oneof custom options
1 parent 2aedbe2 commit 1811414

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies {
3232
exclude group: 'com.jetbrains'
3333
}
3434
compile 'com.google.guava:guava:21.0'
35-
compile 'io.protostuff:protostuff-parser:2.1.9'
35+
compile 'io.protostuff:protostuff-parser:2.1.11'
3636
}
3737

3838
apply plugin: 'idea'

src/main/java/io/protostuff/jetbrains/plugin/reference/FieldReferenceProviderImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static io.protostuff.compiler.model.ProtobufConstants.MSG_FILE_OPTIONS;
77
import static io.protostuff.compiler.model.ProtobufConstants.MSG_MESSAGE_OPTIONS;
88
import static io.protostuff.compiler.model.ProtobufConstants.MSG_METHOD_OPTIONS;
9+
import static io.protostuff.compiler.model.ProtobufConstants.MSG_ONEOF_OPTIONS;
910
import static io.protostuff.compiler.model.ProtobufConstants.MSG_SERVICE_OPTIONS;
1011

1112
import com.google.common.base.Strings;
@@ -27,6 +28,7 @@
2728
import io.protostuff.jetbrains.plugin.psi.MapNode;
2829
import io.protostuff.jetbrains.plugin.psi.MessageField;
2930
import io.protostuff.jetbrains.plugin.psi.MessageNode;
31+
import io.protostuff.jetbrains.plugin.psi.OneOfNode;
3032
import io.protostuff.jetbrains.plugin.psi.ProtoPsiFileRoot;
3133
import io.protostuff.jetbrains.plugin.psi.ProtoRootNode;
3234
import io.protostuff.jetbrains.plugin.psi.RpcMethodNode;
@@ -66,6 +68,7 @@ public class FieldReferenceProviderImpl implements FieldReferenceProvider {
6668
.put(RpcMethodNode.class, MSG_METHOD_OPTIONS)
6769
.put(ServiceNode.class, MSG_SERVICE_OPTIONS)
6870
.put(ProtoRootNode.class, MSG_FILE_OPTIONS)
71+
.put(OneOfNode.class, MSG_ONEOF_OPTIONS)
6972
.build();
7073

7174
public FieldReferenceProviderImpl(Project project) {

src/test/java/io/protostuff/jetbrains/plugin/rename/field/RenameFieldTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ public void testRenameField_caretAtFieldName() {
2525
Assert.assertNotNull(option);
2626
}
2727

28+
public void testRenameField_caretAtFieldName_OneofOption() {
29+
myFixture.configureByFiles("rename/field/RenameField_CaretAtField_OneofOption.proto");
30+
myFixture.renameElementAtCaret("NewName");
31+
OptionNode option = myFixture.findElementByText("(foo).NewName", OptionNode.class);
32+
Assert.assertNotNull(option);
33+
}
34+
2835
public void testRenameField_caretAtOption() {
2936
myFixture.configureByFiles("rename/field/RenameField_CaretAtOption.proto");
3037
myFixture.renameElementAtCaret("NewName");
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
syntax = "proto2";
2+
3+
package rename.field;
4+
5+
import "google/protobuf/descriptor.proto";
6+
7+
8+
extend google.protobuf.OneofOptions {
9+
optional Foo foo = 52003;
10+
}
11+
12+
message Foo {
13+
optional int32 name<caret> = 1;
14+
}
15+
16+
message Bar {
17+
oneof oneof {
18+
option (foo).name = 1;
19+
optional string field = 1;
20+
}
21+
}

0 commit comments

Comments
 (0)