Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313938

Summary: bracket matching fails to match in many cases
Product: [Modeling] TMF Reporter: Henrik Lindberg <henrik.lindberg>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, sven.efftinge
Version: 1.0.0Flags: sven.efftinge: indigo+
Target Milestone: M2   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Bug Depends on: 323817    
Bug Blocks:    

Description Henrik Lindberg CLA 2010-05-21 12:29:34 EDT
Hi,
the automatic bracket matching (i.e. matching bracket being highlighted)
only works for me in some situations.

As an example - in this b3 text:

repository svn MyRepo { connection : "http://abc.org"; }
resolution {
select-first {
repository MyRepo { path : "/features" ; }
}
}

the matching does not work for the outermost brackets.
(In fact, this part was the only part where it actually managed to match
brackets).

Wonders if the bracket matching is done with aid from the grammar and that the problems occur because of backtracking...

Seems like the matching of brackets should be done at the lexical level so should not really be affected by a complicated grammar.

The matching also breaks if there are syntax errors:
Here matching works (using | to highlight what it matches, and what I expect:
  select-first {
    repository  MyRepo {| path : "features" ; }|
  }

But not here:
  select-first {|
    repository  MyRepo  path : "features" ; }|
  }

I assume it is supposed to really show the lexical matching as this is very useful when there are matching errors.

Problem can be observed with latest b3, and input like:
function foo() { }
Comment 1 Henrik Lindberg CLA 2010-06-07 21:49:23 EDT
I think this is related to Unordered Group issues (bug 315581, bug 315335) since matching brackets works after I modified the grammar to not use Unordered Groups (the use of the unordered group is described in the two issues).
Comment 2 Sven Efftinge CLA 2010-08-03 05:17:27 EDT
We should rewrite bracket matching such that it doesn't rely on tokens but on simple characters and strings. Also we should have something like partitions, i.e. handling comments and string literals separately. Rescheduling for Indigo
Comment 3 Sven Efftinge CLA 2010-09-03 14:40:37 EDT
Bracket matching is now based on JFace's DefaultCharacterPairMatcher.
Comment 4 Karsten Thoms CLA 2017-09-19 16:22:37 EDT
Closing bug which were set to RESOLVED before Eclipse Neon.0.