[gwt-contrib] Change in gwt[master]: Allow line breaks and other whitespace in jsni method refere...
Roberto Lublinerman has uploaded a new change for review. https://gwt-review.googlesource.com/3100 Change subject: Allow line breaks and other whitespace in jsni method references. .. Allow line breaks and other whitespace in jsni method references. This allows for whitespace in the param list within jsni method references so long lines can be broken up. Adds several test cases for JSNI references. Original Author: Kelly Campbell kelly.a.campb...@gmail.com Change-Id: Iecacf3b8be1e512a5fdf3132245091b4ebea9c68 --- M dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java M dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java b/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java index 934eabb..a677b31 100644 --- a/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java +++ b/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java @@ -1343,6 +1343,15 @@ } } +private void skipWhitespace() throws IOException { + int tmp; + do { +tmp = in.read(); + } while (isJSSpace(tmp) || tmp == '\n'); + // Reposition back to first non whitespace char. + in.unread(); +} + private int jsniMatchReference() throws IOException { // First, read the type name whose member is being accessed. @@ -1359,9 +1368,11 @@ return ERROR; } addToString(c); - + + // Skip whitespace starting after ::. + skipWhitespace(); + // Finish by reading the field or method signature. - // if (!jsniMatchMethodSignatureOrFieldName()) { return ERROR; } @@ -1373,7 +1384,9 @@ private boolean jsniMatchParamListSignature() throws IOException { // Assume the opening '(' has already been read. // Read param type signatures until we see a closing ')'. - // + + skipWhitespace(); + // First check for the special case of * as the parameter list, indicating // a wildcard if (in.peek() == '*') { @@ -1384,20 +1397,24 @@ addToString(in.read()); return true; } - + // Otherwise, loop through reading one param type at a time do { +// Skip whitespace between parameters. +skipWhitespace(); + int c = in.read(); + if (c == ')') { // Finished successfully. // addToString(c); return true; } - + in.unread(); } while (jsniMatchParamTypeSignature()); - + // If we made it here, we can assume that there was an invalid type // signature that was already reported and that the offending char // was already unread. @@ -1443,7 +1460,8 @@ private boolean jsniMatchMethodSignatureOrFieldName() throws IOException { int c = in.read(); - + + // We must see an ident start here. // if (!Character.isJavaIdentifierStart((char)c)) { diff --git a/dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java b/dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java index 9f8db11..dabb98d 100644 --- a/dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java +++ b/dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java @@ -1,12 +1,12 @@ /* * Copyright 2009 Google Inc. - * + * * Licensed under the Apache License, Version 2.0 (the License); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -55,6 +55,7 @@ assertGoodJsni(@org.group.Foo::bar(I)); assertGoodJsni(@org.group.Foo::bar(IJ)); assertGoodJsni(@org.group.Foo::bar(Lorg/group/Foo;)); +assertGoodJsni(@org.group.Foo::bar(Lorg/group/Foo;Lorg/group/Bar;)); assertGoodJsni(@org.group.Foo::bar([I)); // The following is currently tolerated // assertBadJsni(@org.group.Foo::bar(Lorg/group/Foo)); @@ -64,6 +65,18 @@ // Method refs with * as the parameter list assertGoodJsni(@org.group.Foo::bar(*)); assertBadJsni(@org.group.Foo::bar(*); + +// Refs that span lines +assertGoodJsni(@org.group.Foo::bar(\nLorg/group/Foo;)); +assertGoodJsni(@org.group.Foo::bar(\nLorg/group/Foo;\n)); +assertGoodJsni(@org.group.Foo::bar(\n[I\n)); +assertGoodJsni(@org.group.Foo::bar(\nZ\nZ\n)); +assertGoodJsni(@org.group.Foo::bar(\nLorg/group/Foo;\nZ)); +assertGoodJsni(@org.group.Foo::\nbar()); + + +assertBadJsni(@org.group.Foo::bar(\nLorg/group/Foo;,\nZ)); +assertBadJsni(@org.group.Foo::bar(\nLorg/group/Foo,\nZ)); // bad references
[gwt-contrib] Change in gwt[master]: Allow line breaks and other whitespace in jsni method refere...
Thomas Broyer has posted comments on this change. Change subject: Allow line breaks and other whitespace in jsni method references. .. Patch Set 1: Code-Review+2 (1 comment) File dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java Line 78: assertBadJsni(@org.group.Foo::bar(\nLorg/group/Foo;,\nZ)); Should we add something with a line-break in the middle of a L? e.g. assertBadJsni(@org.group.Foo::bar(Lorg/group/\nFoo;)); -- To view, visit https://gwt-review.googlesource.com/3100 To unsubscribe, visit https://gwt-review.googlesource.com/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iecacf3b8be1e512a5fdf3132245091b4ebea9c68 Gerrit-PatchSet: 1 Gerrit-Project: gwt Gerrit-Branch: master Gerrit-Owner: Roberto Lublinerman rlu...@google.com Gerrit-Reviewer: Daniel Kurka danku...@google.com Gerrit-Reviewer: Leeroy Jenkins jenk...@gwtproject.org Gerrit-Reviewer: Thomas Broyer t.bro...@gmail.com Gerrit-HasComments: Yes -- http://groups.google.com/group/Google-Web-Toolkit-Contributors --- You received this message because you are subscribed to the Google Groups GWT Contributors group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[gwt-contrib] Change in gwt[master]: Allow line breaks and other whitespace in jsni method refere...
Roberto Lublinerman has submitted this change and it was merged. Change subject: Allow line breaks and other whitespace in jsni method references. .. Allow line breaks and other whitespace in jsni method references. This allows for whitespace in the param list within jsni method references so long lines can be broken up. Adds several test cases for JSNI references. Original Author: Kelly Campbell kelly.a.campb...@gmail.com Change-Id: Iecacf3b8be1e512a5fdf3132245091b4ebea9c68 --- M dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java M dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java 2 files changed, 43 insertions(+), 11 deletions(-) Approvals: Leeroy Jenkins: Verified Thomas Broyer: Looks good to me, approved diff --git a/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java b/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java index 934eabb..a677b31 100644 --- a/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java +++ b/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java @@ -1343,6 +1343,15 @@ } } +private void skipWhitespace() throws IOException { + int tmp; + do { +tmp = in.read(); + } while (isJSSpace(tmp) || tmp == '\n'); + // Reposition back to first non whitespace char. + in.unread(); +} + private int jsniMatchReference() throws IOException { // First, read the type name whose member is being accessed. @@ -1359,9 +1368,11 @@ return ERROR; } addToString(c); - + + // Skip whitespace starting after ::. + skipWhitespace(); + // Finish by reading the field or method signature. - // if (!jsniMatchMethodSignatureOrFieldName()) { return ERROR; } @@ -1373,7 +1384,9 @@ private boolean jsniMatchParamListSignature() throws IOException { // Assume the opening '(' has already been read. // Read param type signatures until we see a closing ')'. - // + + skipWhitespace(); + // First check for the special case of * as the parameter list, indicating // a wildcard if (in.peek() == '*') { @@ -1384,20 +1397,24 @@ addToString(in.read()); return true; } - + // Otherwise, loop through reading one param type at a time do { +// Skip whitespace between parameters. +skipWhitespace(); + int c = in.read(); + if (c == ')') { // Finished successfully. // addToString(c); return true; } - + in.unread(); } while (jsniMatchParamTypeSignature()); - + // If we made it here, we can assume that there was an invalid type // signature that was already reported and that the offending char // was already unread. @@ -1443,7 +1460,8 @@ private boolean jsniMatchMethodSignatureOrFieldName() throws IOException { int c = in.read(); - + + // We must see an ident start here. // if (!Character.isJavaIdentifierStart((char)c)) { diff --git a/dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java b/dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java index 9f8db11..dabb98d 100644 --- a/dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java +++ b/dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java @@ -1,12 +1,12 @@ /* * Copyright 2009 Google Inc. - * + * * Licensed under the Apache License, Version 2.0 (the License); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -55,6 +55,7 @@ assertGoodJsni(@org.group.Foo::bar(I)); assertGoodJsni(@org.group.Foo::bar(IJ)); assertGoodJsni(@org.group.Foo::bar(Lorg/group/Foo;)); +assertGoodJsni(@org.group.Foo::bar(Lorg/group/Foo;Lorg/group/Bar;)); assertGoodJsni(@org.group.Foo::bar([I)); // The following is currently tolerated // assertBadJsni(@org.group.Foo::bar(Lorg/group/Foo)); @@ -64,6 +65,18 @@ // Method refs with * as the parameter list assertGoodJsni(@org.group.Foo::bar(*)); assertBadJsni(@org.group.Foo::bar(*); + +// Refs that span lines +assertGoodJsni(@org.group.Foo::bar(\nLorg/group/Foo;)); +assertGoodJsni(@org.group.Foo::bar(\nLorg/group/Foo;\n)); +assertGoodJsni(@org.group.Foo::bar(\n[I\n)); +assertGoodJsni(@org.group.Foo::bar(\nZ\nZ\n)); +assertGoodJsni(@org.group.Foo::bar(\nLorg/group/Foo;\nZ)); +assertGoodJsni(@org.group.Foo::\nbar()); + + +assertBadJsni(@org.group.Foo::bar(\nLorg/group/Foo;,\nZ)); +
[gwt-contrib] Change in gwt[master]: Allow line breaks and other whitespace in jsni method refere...
Roberto Lublinerman has abandoned this change. Change subject: Allow line breaks and other whitespace in jsni method references. .. Abandoned Thanks, Kelly. I have submitted it as change Iecacf3b8be1e512a5fdf3132245091b4ebea9c68 -- To view, visit https://gwt-review.googlesource.com/2640 To unsubscribe, visit https://gwt-review.googlesource.com/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I64426b03f4cde2c84c2faf27a2e38aba4720f401 Gerrit-PatchSet: 2 Gerrit-Project: gwt Gerrit-Branch: master Gerrit-Owner: Kelly Campbell kelly.a.campb...@gmail.com Gerrit-Reviewer: Kelly Campbell kelly.a.campb...@gmail.com Gerrit-Reviewer: Leeroy Jenkins jenk...@gwtproject.org Gerrit-Reviewer: Matthew Dempsky mdemp...@gwtproject.org Gerrit-Reviewer: Roberto Lublinerman rlu...@gmail.com Gerrit-Reviewer: Thomas Broyer t.bro...@gmail.com -- http://groups.google.com/group/Google-Web-Toolkit-Contributors --- You received this message because you are subscribed to the Google Groups GWT Contributors group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[gwt-contrib] Change in gwt[master]: Allow line breaks and other whitespace in jsni method refere...
Matthew Dempsky has posted comments on this change. Change subject: Allow line breaks and other whitespace in jsni method references. .. Patch Set 2: Verified+1 Hoorays, this change passed the build and style presubmit. :D More details at http://build.gwtproject.org/job/gwt.presubmit/48 -- To view, visit https://gwt-review.googlesource.com/2640 To unsubscribe, visit https://gwt-review.googlesource.com/settings Gerrit-MessageType: comment Gerrit-Change-Id: I64426b03f4cde2c84c2faf27a2e38aba4720f401 Gerrit-PatchSet: 2 Gerrit-Project: gwt Gerrit-Branch: master Gerrit-Owner: Kelly Campbell kelly.a.campb...@gmail.com Gerrit-Reviewer: Kelly Campbell kelly.a.campb...@gmail.com Gerrit-Reviewer: Matthew Dempsky mdemp...@gwtproject.org Gerrit-Reviewer: Thomas Broyer t.bro...@gmail.com Gerrit-HasComments: No -- -- http://groups.google.com/group/Google-Web-Toolkit-Contributors --- You received this message because you are subscribed to the Google Groups Google Web Toolkit Contributors group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[gwt-contrib] Change in gwt[master]: Allow line breaks and other whitespace in jsni method refere...
Thomas Broyer has posted comments on this change. Change subject: Allow line breaks and other whitespace in jsni method references. .. Patch Set 1: (1 comment) File dev/core/test/com/google/gwt/dev/js/TokenStreamTest.java Line 69: assertGoodJsni(@org.group.Foo::bar(\nLorg/group/Foo;)); I think there should be more tests, of both GoodJsni and BadJsni (spaces in type name, before and after the '::', before and after the '(', in between parameters, before the ')') -- To view, visit https://gwt-review.googlesource.com/2640 To unsubscribe, visit https://gwt-review.googlesource.com/settings Gerrit-MessageType: comment Gerrit-Change-Id: I64426b03f4cde2c84c2faf27a2e38aba4720f401 Gerrit-PatchSet: 1 Gerrit-Project: gwt Gerrit-Branch: master Gerrit-Owner: Kelly Campbell kelly.a.campb...@gmail.com Gerrit-Reviewer: Thomas Broyer t.bro...@gmail.com Gerrit-HasComments: Yes -- -- http://groups.google.com/group/Google-Web-Toolkit-Contributors --- You received this message because you are subscribed to the Google Groups Google Web Toolkit Contributors group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.