;; Also, deal with the possible end of line obscured by a
;; trailing comment.
(goto-char (c-point 'iopl))
- (looking-at "^[^//]*new[^//]*;$")))
+ (when (looking-at-p ".*new.*")
+ (if (re-search-forward ";" (pos-eol) t 1)
+ ;; If the ';' is inside a comment, the statement hasn't
+ ;; likely ended, so we should accept as object init.
+ ;; Example:
+ ;; var x = new // This should return true ;
+ ;; var x = new(); // This should return false ;
+ (nth 4 (syntax-ppss (point)))
+ t))))
;; Line should not already be terminated
(save-excursion
(goto-char (c-point 'eopl))
} // [2]
}
}
+
+public class Foo {
+ void Bar () {
+ var x = new X();
+ for (;;) {
+ x();
+ } // [2]
+ }
+}
+
+public class Foo {
+ void Bar () {
+ var x = new X()
+ {
+ var b = 3;
+ };
+ for (;;) {
+ x();
+ } // [2]
+ }
+}
+
+public class Foo {
+ void Bar () {
+ var x = new X() // Hello
+ {
+ var b = 3;
+ };
+ for (;;) {
+ x();
+ } // [2]
+ }
+}
+
+public class Foo {
+ void Bar () {
+ var x = new X() // Hello ;
+ {
+ var b = 3;
+ };
+ for (;;) {
+ x();
+ } // [2]
+ }
+}
+
+public class Foo {
+ void Bar () {
+ var x = new X // Hello ;
+ {
+ var b = 3;
+ };
+ for (;;) {
+ x();
+ } // [2]
+ }
+}
+
+public class Foo {
+ void Bar () {
+ var x = new X(); // Hello ;
+ for (;;) {
+ x();
+ } // [2]
+ }
+}
+
+public class Foo
+{
+ void Bar ()
+ {
+ var x = new X(); // Hello ;
+ for (;;)
+ {
+ x();
+ } // [2]
+ }
+}
=-=-=