File tree Expand file tree Collapse file tree 10 files changed +132
-2
lines changed
main/java/io/protostuff/jetbrains/plugin
java/io/protostuff/jetbrains/plugin/rename Expand file tree Collapse file tree 10 files changed +132
-2
lines changed Original file line number Diff line number Diff line change 2525import static io .protostuff .compiler .parser .ProtoParser .RULE_messageBlock ;
2626import static io .protostuff .compiler .parser .ProtoParser .RULE_messageName ;
2727import static io .protostuff .compiler .parser .ProtoParser .RULE_oneof ;
28+ import static io .protostuff .compiler .parser .ProtoParser .RULE_oneofName ;
2829import static io .protostuff .compiler .parser .ProtoParser .RULE_option ;
2930import static io .protostuff .compiler .parser .ProtoParser .RULE_optionEntry ;
3031import static io .protostuff .compiler .parser .ProtoParser .RULE_optionValue ;
@@ -294,6 +295,7 @@ public ProtoParserDefinition() {
294295 register (RULE_messageBlock , MessageNode ::new );
295296 register (RULE_messageName , GenericNameNode ::new );
296297 register (RULE_oneof , OneOfNode ::new );
298+ register (RULE_oneofName , GenericNameNode ::new );
297299 register (RULE_option , OptionNode ::new );
298300 register (RULE_optionEntry , OptionEntryNode ::new );
299301 register (RULE_optionValue , OptionValueNode ::new );
Original file line number Diff line number Diff line change 33import com .intellij .lang .ASTNode ;
44import java .util .Arrays ;
55import java .util .Collection ;
6- import org .antlr .jetbrains .adapter .psi .AntlrPsiNode ;
76import org .jetbrains .annotations .NotNull ;
87
98/**
109 * One-of node.
1110 *
1211 * @author Kostiantyn Shchepanovskyi
1312 */
14- public class OneOfNode extends AntlrPsiNode implements KeywordsContainer {
13+ public class OneOfNode extends AbstractNamedNode implements KeywordsContainer {
1514
1615 public OneOfNode (@ NotNull ASTNode node ) {
1716 super (node );
Original file line number Diff line number Diff line change @@ -67,4 +67,11 @@ public void testRenameMapField_caretAtOption() {
6767 Assert .assertNotNull (option );
6868 }
6969
70+ public void testRenameExtension_caretAtFieldName () {
71+ myFixture .configureByFiles ("rename/field/RenameExtension_CaretAtField.proto" );
72+ myFixture .renameElementAtCaret ("NewName" );
73+ FieldNode option = myFixture .findElementByText ("NewName" , FieldNode .class );
74+ Assert .assertNotNull (option );
75+ }
76+
7077}
Original file line number Diff line number Diff line change 1+ package io .protostuff .jetbrains .plugin .rename .field ;
2+
3+ import com .intellij .testFramework .fixtures .LightCodeInsightFixtureTestCase ;
4+ import io .protostuff .jetbrains .plugin .psi .OneOfNode ;
5+ import org .junit .Assert ;
6+
7+ /**
8+ * Tests for rename message refactoring.
9+ *
10+ * @author Kostiantyn Shchepanovskyi
11+ */
12+ public class RenameOneofTest extends LightCodeInsightFixtureTestCase {
13+
14+ @ Override
15+ protected String getTestDataPath () {
16+ return "src/test/resources/" ;
17+ }
18+
19+ public void testRenameField_caretAtFieldName () {
20+ myFixture .configureByFiles ("rename/field/RenameOneof.proto" );
21+ myFixture .renameElementAtCaret ("NewName" );
22+ OneOfNode option = myFixture .findElementByText ("NewName" , OneOfNode .class );
23+ Assert .assertNotNull (option );
24+ }
25+
26+ }
Original file line number Diff line number Diff line change 1+ package io .protostuff .jetbrains .plugin .rename .service ;
2+
3+ import com .intellij .testFramework .fixtures .LightCodeInsightFixtureTestCase ;
4+ import io .protostuff .jetbrains .plugin .psi .ServiceNode ;
5+ import org .junit .Assert ;
6+
7+ /**
8+ * Tests for rename message refactoring.
9+ *
10+ * @author Kostiantyn Shchepanovskyi
11+ */
12+ public class RenameServiceTest extends LightCodeInsightFixtureTestCase {
13+
14+ @ Override
15+ protected String getTestDataPath () {
16+ return "src/test/resources/" ;
17+ }
18+
19+ public void testRenameService () {
20+ myFixture .configureByFiles ("rename/service/RenameService.proto" );
21+ myFixture .renameElementAtCaret ("NewName" );
22+ ServiceNode option = myFixture .findElementByText ("NewName" , ServiceNode .class );
23+ Assert .assertNotNull (option );
24+ }
25+
26+ public void testRenameRpc () {
27+ myFixture .configureByFiles ("rename/service/RenameRpc.proto" );
28+ myFixture .renameElementAtCaret ("NewName" );
29+ ServiceNode option = myFixture .findElementByText ("NewName" , ServiceNode .class );
30+ Assert .assertNotNull (option );
31+ }
32+
33+ }
Original file line number Diff line number Diff line change 1+ syntax = "proto2" ;
2+
3+ package rename.field ;
4+
5+ import "google/protobuf/descriptor.proto" ;
6+
7+
8+ extend google.protobuf.FieldOptions {
9+ optional Foo foo<caret> = 52003;
10+ }
11+
12+ message Foo {
13+ optional int32 name = 1 ;
14+ }
15+
16+ message Bar {
17+ optional string field = 1 [(foo).name = 1 ];
18+ }
Original file line number Diff line number Diff line change 1+ syntax = "proto2" ;
2+
3+ package rename.field ;
4+
5+ import "google/protobuf/descriptor.proto" ;
6+
7+
8+ extend google.protobuf.FieldOptions {
9+ optional Foo foo = 52003 ;
10+ }
11+
12+ message Foo {
13+ optional int32 name = 1 ;
14+ }
15+
16+ message Bar {
17+ optional string field = 1 [(foo <caret >).name = 1 ];
18+ }
Original file line number Diff line number Diff line change 1+ syntax = "proto2" ;
2+
3+ package rename.field ;
4+
5+ message Foo {
6+ oneof oneof <caret> {
7+ int32 name = 1 ;
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ syntax = "proto3" ;
2+
3+ package rename.service ;
4+
5+ service TheService {
6+ rpc foo <caret > (Message ) returns (Message );
7+ }
8+
9+ message Message {
10+
11+ }
Original file line number Diff line number Diff line change 1+ syntax = "proto3" ;
2+
3+ package rename.type ;
4+
5+ service TheService <caret> {
6+
7+ }
You can’t perform that action at this time.
0 commit comments