Make object init more robust (bug#69571)
* lisp/progmodes/csharp-mode.el (csharp-guess-basic-syntax): Make the regex same as before, but conditionally check other heuristics rather than crazy regex shenanigans.
This commit is contained in:
parent
946d4aad1d
commit
910ea5f1e5
2 changed files with 87 additions and 1 deletions
|
@ -500,7 +500,15 @@ compilation and evaluation time conflicts."
|
||||||
;; Also, deal with the possible end of line obscured by a
|
;; Also, deal with the possible end of line obscured by a
|
||||||
;; trailing comment.
|
;; trailing comment.
|
||||||
(goto-char (c-point 'iopl))
|
(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
|
;; Line should not already be terminated
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (c-point 'eopl))
|
(goto-char (c-point 'eopl))
|
||||||
|
|
|
@ -16,4 +16,82 @@ public class Foo {
|
||||||
} // [2]
|
} // [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]
|
||||||
|
}
|
||||||
|
}
|
||||||
=-=-=
|
=-=-=
|
||||||
|
|
Loading…
Add table
Reference in a new issue