Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 210597 Details for
Bug 9503
Brace and parenthesis matching is one-off
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch for platform text
text-Bug-9503-Brace-and-parenthesis-matching-is-oneoff.txt (text/plain), 9.43 KB, created by
Deepak Azad
on 2012-02-06 11:19:03 EST
(
hide
)
Description:
patch for platform text
Filename:
MIME Type:
Creator:
Deepak Azad
Created:
2012-02-06 11:19:03 EST
Size:
9.43 KB
patch
obsolete
>diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java >index 1d6e394..6957357 100644 >--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java >+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >+ * Copyright (c) 2006, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -62,9 +62,9 @@ > > /** Tests that the test case reader works */ > public void testTestCaseReader() { >- performReaderTest("#( )%", 3, 0, "( )"); >+ performReaderTest("#( %)", 2, 0, "( )"); > performReaderTest("%( )#", 0, 3, "( )"); >- performReaderTest("( )%", 3, -1, "( )"); >+ performReaderTest("( %)", 2, -1, "( )"); > performReaderTest("#%", 0, 0, ""); > } > >@@ -75,9 +75,9 @@ > */ > public void testSimpleMatchSameMatcher() throws BadLocationException { > final ICharacterPairMatcher matcher= createMatcher("()[]{}"); >- performMatch(matcher, "#( )%"); >- performMatch(matcher, "#[ ]%"); >- performMatch(matcher, "#{ }%"); >+ performMatch(matcher, "#( %)"); >+ performMatch(matcher, "#[ %]"); >+ performMatch(matcher, "#{ %}"); > performMatch(matcher, "(% )#"); > performMatch(matcher, "[% ]#"); > performMatch(matcher, "{% }#"); >@@ -90,9 +90,9 @@ > * @throws BadLocationException > */ > public void testSimpleMatchDifferentMatchers() throws BadLocationException { >- performMatch("()[]{}", "#( )%"); >- performMatch("()[]{}", "#[ ]%"); >- performMatch("()[]{}", "#{ }%"); >+ performMatch("()[]{}", "#( %)"); >+ performMatch("()[]{}", "#[ %]"); >+ performMatch("()[]{}", "#{ %}"); > performMatch("()[]{}", "(% )#"); > performMatch("()[]{}", "[% ]#"); > performMatch("()[]{}", "{% }#"); >@@ -105,12 +105,10 @@ > */ > public void testCloseMatches() throws BadLocationException { > final ICharacterPairMatcher matcher= createMatcher("()[]{}"); >- performMatch(matcher, "#()%"); > performMatch(matcher, "(%)#"); >- performMatch(matcher, "#(())%"); >+ performMatch(matcher, "#(()%)"); > performMatch(matcher, "(%())#"); > performMatch(matcher, "((%)#)"); >- performMatch(matcher, "(#()%)"); > matcher.dispose(); > } > >@@ -125,7 +123,7 @@ > performMatch(matcher, "(% "); > performMatch(matcher, "%( )"); > performMatch(matcher, "( % )"); >- performMatch(matcher, "( %)"); >+ performMatch(matcher, "( )%"); > performMatch(matcher, "%"); > matcher.dispose(); > } >@@ -138,13 +136,13 @@ > public void testPartitioned() throws BadLocationException { > final ICharacterPairMatcher matcher= createMatcher("()[]{}"); > performMatch(matcher, "(% |a a| )#"); >- performMatch(matcher, "#( |a a| )%"); >- performMatch(matcher, "|b #( )% b|"); >- performMatch(matcher, "( |b )% b|"); >+ performMatch(matcher, "#( |a a| %)"); >+ performMatch(matcher, "|b #( %) b|"); >+ performMatch(matcher, "( |b %) b|"); > performMatch(matcher, "(% |b ) b|"); >- performMatch(matcher, "|a ( a| )%"); >+ performMatch(matcher, "|a ( a| %)"); > performMatch(matcher, "|a (% a| )"); >- performMatch(matcher, "|c #( c| ) ( |c )% c|"); >+ performMatch(matcher, "|c #( c| ) ( |c %) c|"); > performMatch(matcher, "|c (% c| ) ( |c )# c|"); > performMatch(matcher, "(% |a ) a| |b ) b| |c ) c| )#"); > matcher.dispose(); >@@ -157,11 +155,11 @@ > */ > public void testTightPartitioned() throws BadLocationException { > final ICharacterPairMatcher matcher= createMatcher("()[]{}"); >- performMatch(matcher, "(|b)%b|"); >+ performMatch(matcher, "(|b%)b|"); > performMatch(matcher, "(%|b)b|"); >- performMatch(matcher, "|a(a|)%"); >+ performMatch(matcher, "|a(a|%)"); > performMatch(matcher, "|a(%a|)"); >- performMatch(matcher, "|c#(c|)(|c)%c|"); >+ performMatch(matcher, "|c#(c|)(|c%)c|"); > performMatch(matcher, "|c(%c|)(|c)#c|"); > performMatch(matcher, "(%|a)a||b)b||c)c|)#"); > matcher.dispose(); >@@ -170,17 +168,17 @@ > /** Test that nesting works properly */ > public void testNesting() { > final ICharacterPairMatcher matcher= createMatcher("()[]{}"); >- performMatch(matcher, " ( #( ( ( ) ) ( ) )% ) "); >+ performMatch(matcher, " ( #( ( ( ) ) ( ) %) ) "); > performMatch(matcher, " ( (% ( ( ) ) ( ) )# ) "); >- performMatch(matcher, " ( #( { ( ) } [ ] )% ) "); >+ performMatch(matcher, " ( #( { ( ) } [ ] %) ) "); > performMatch(matcher, " ( (% { ( ) } [ ] )# ) "); >- performMatch(matcher, " ( ( #{ ( ) }% [ ] ) ) "); >+ performMatch(matcher, " ( ( #{ ( ) %} [ ] ) ) "); > performMatch(matcher, " ( ( {% ( ) }# [ ] ) ) "); >- performMatch(matcher, "a(b#(c(d(e)f)g(h)i)%j)k"); >+ performMatch(matcher, "a(b#(c(d(e)f)g(h)i%)j)k"); > performMatch(matcher, "a(b(%c(d(e)f)g(h)i)#j)k"); >- performMatch(matcher, "a(b#(c{d(e)f}g[h]i)%j)k"); >+ performMatch(matcher, "a(b#(c{d(e)f}g[h]i%)j)k"); > performMatch(matcher, "a(b(%c{d(e)f}g[h]i)#j)k"); >- performMatch(matcher, "a(b(c#{d(e)f}%g[h]i)j)k"); >+ performMatch(matcher, "a(b(c#{d(e)f%}g[h]i)j)k"); > performMatch(matcher, "a(b(c{%d(e)f}#g[h]i)j)k"); > matcher.dispose(); > } >@@ -201,9 +199,9 @@ > > public void testBug156426() { > final ICharacterPairMatcher matcher= createMatcher("()[]{}<>"); >- performMatch(matcher, " #( a < b )% "); >+ performMatch(matcher, " #( a < b %) "); > performMatch(matcher, " (% a < b )# "); >- performMatch(matcher, " #( a > b )% "); >+ performMatch(matcher, " #( a > b %) "); > performMatch(matcher, " (% a > b )# "); > matcher.dispose(); > } >@@ -244,11 +242,11 @@ > assertNotNull(region); > final boolean isForward= test.fPos > test.fMatch; > assertEquals(isForward, matcher.getAnchor() == ICharacterPairMatcher.RIGHT); >- // If the match is forward, the curser is one character >+ // If the match is forward, the cursor is one character > // after the start of the match, so we need to count one > // step backwards > final int offset= isForward ? test.getOffset() : test.getOffset() - 1; >- final int length= isForward ? test.getLength() : test.getLength() + 1; >+ final int length= isForward ? test.getLength() + 1 : test.getLength() + 1; > assertEquals(length, region.getLength()); > assertEquals(offset, region.getOffset()); > } >diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java >index 6c8e26c..884c343 100644 >--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java >+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2010 IBM Corporation and others. >+ * Copyright (c) 2006, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -86,21 +86,28 @@ > * Performs the actual work of matching for #match(IDocument, int). > */ > private IRegion performMatch(IDocument doc, int caretOffset) throws BadLocationException { >- final int charOffset= caretOffset - 1; >- final char prevChar= doc.getChar(Math.max(charOffset, 0)); >- if (!fPairs.contains(prevChar)) return null; >- final boolean isForward= fPairs.isStartCharacter(prevChar); >+ final char prevChar= doc.getChar(Math.max(caretOffset - 1, 0)); >+ final char currChar= doc.getChar(caretOffset); >+ >+ boolean isForward= fPairs.contains(prevChar) && fPairs.isStartCharacter(prevChar); >+ boolean isBackward= fPairs.contains(currChar) && !fPairs.isStartCharacter(currChar); >+ if (!isForward && !isBackward) { >+ return null; >+ } >+ > fAnchor= isForward ? ICharacterPairMatcher.LEFT : ICharacterPairMatcher.RIGHT; >- final int searchStartPosition= isForward ? caretOffset : caretOffset - 2; >- final int adjustedOffset= isForward ? charOffset : caretOffset; >- final String partition= TextUtilities.getContentType(doc, fPartitioning, charOffset, false); >+ final int searchStartPosition= isForward ? caretOffset : caretOffset - 1; >+ final int adjustedOffset= isForward ? caretOffset - 1 : caretOffset + 1; >+ final String partition= TextUtilities.getContentType(doc, fPartitioning, isForward ? caretOffset - 1 : caretOffset, false); > final DocumentPartitionAccessor partDoc= new DocumentPartitionAccessor(doc, fPartitioning, partition); >- int endOffset= findMatchingPeer(partDoc, prevChar, fPairs.getMatching(prevChar), >- isForward, isForward ? doc.getLength() : -1, >- searchStartPosition); >- if (endOffset == -1) return null; >- final int adjustedEndOffset= isForward ? endOffset + 1: endOffset; >- if (adjustedEndOffset == adjustedOffset) return null; >+ final char ch= isForward ? prevChar : currChar; >+ int endOffset= findMatchingPeer(partDoc, ch, fPairs.getMatching(ch), >+ isForward, isForward ? doc.getLength() : -1, searchStartPosition); >+ if (endOffset == -1) >+ return null; >+ final int adjustedEndOffset= isForward ? endOffset + 1 : endOffset; >+ if (adjustedEndOffset == adjustedOffset) >+ return null; > return new Region(Math.min(adjustedOffset, adjustedEndOffset), > Math.abs(adjustedEndOffset - adjustedOffset)); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 9503
:
210597
|
210598
|
210603
|
210646
|
210651
|
210731
|
210732
|
210772
|
210773