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 210646 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 jdt ui
jdt-Bug-9503-Brace-and-parenthesis-matching-is-oneoff.txt (text/plain), 8.48 KB, created by
Deepak Azad
on 2012-02-07 10:06:12 EST
(
hide
)
Description:
patch for jdt ui
Filename:
MIME Type:
Creator:
Deepak Azad
Created:
2012-02-07 10:06:12 EST
Size:
8.48 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPairMatcherTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPairMatcherTest.java >index 8009611..c15a54c 100644 >--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPairMatcherTest.java >+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPairMatcherTest.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -33,8 +33,6 @@ > * @since 3.3 > */ > public class JavaPairMatcherTest extends AbstractPairMatcherTest { >- >- private static boolean BEFORE_MATCHES_DISABLED= true; > > protected IDocument fDocument; > protected JavaPairMatcher fPairMatcher; >@@ -81,20 +79,10 @@ > > public void testBeforeOpeningMatch() { > IRegion match= fPairMatcher.match(fDocument, 2); >- if (BEFORE_MATCHES_DISABLED) { >- assertNull(match); >- } else { >- assertNotNull(match); >- assertTrue(match.getOffset() == 2 && match.getLength() == 10); >- } >+ assertNull(match); > > match= fPairMatcher.match(fDocument, 5); >- if (BEFORE_MATCHES_DISABLED) { >- assertNull(match); >- } else { >- assertNotNull(match); >- assertTrue(match.getOffset() == 5 && match.getLength() == 4); >- } >+ assertNull(match); > } > > public void testAfterOpeningMatch() { >@@ -109,66 +97,47 @@ > > public void testBeforeClosingMatch() { > IRegion match= fPairMatcher.match(fDocument, 11); >- if (BEFORE_MATCHES_DISABLED) { >- assertNull(match); >- } else { >- assertNotNull(match); >- assertTrue(match.getOffset() == 2 && match.getLength() == 10); >- } >+ assertNotNull(match); >+ assertTrue(match.getOffset() == 2 && match.getLength() == 10); > > match= fPairMatcher.match(fDocument, 8); >- if (BEFORE_MATCHES_DISABLED) { >- assertNull(match); >- } else { >- assertNotNull(match); >- assertTrue(match.getOffset() == 5 && match.getLength() == 4); >- } >+ assertNotNull(match); >+ assertTrue(match.getOffset() == 5 && match.getLength() == 4); >+ > } > > public void testAfterClosingMatch() { > IRegion match= fPairMatcher.match(fDocument, 12); >- assertNotNull(match); >- assertTrue(match.getOffset() == 2 && match.getLength() == 10); >+ assertNull(match); > > match= fPairMatcher.match(fDocument, 9); >- assertNotNull(match); >- assertTrue(match.getOffset() == 5 && match.getLength() == 4); >+ assertNull(match); > } > > public void testBeforeClosingMatchWithNL() { > fDocument.set("x(y\ny)x"); > IRegion match= fPairMatcher.match(fDocument, 5); >- if (BEFORE_MATCHES_DISABLED) { >- assertNull(match); >- } else { >- assertNotNull(match); >- assertTrue(match.getOffset() == 1 && match.getLength() == 5); >- } >+ assertNotNull(match); >+ assertTrue(match.getOffset() == 1 && match.getLength() == 5); > } > > public void testAfterClosingMatchWithNL() { > fDocument.set("x(y\ny)x"); > IRegion match= fPairMatcher.match(fDocument, 6); >- assertNotNull(match); >- assertTrue(match.getOffset() == 1 && match.getLength() == 5); >+ assertNull(match); > } > > public void testBeforeClosingMatchWithNLAndSingleLineComment() { > fDocument.set("x\nx(y\nx //(x\ny)x"); > IRegion match= fPairMatcher.match(fDocument, 14); >- if (BEFORE_MATCHES_DISABLED) { >- assertNull(match); >- } else { >- assertNotNull(match); >- assertTrue(match.getOffset() == 3 && match.getLength() == 12); >- } >+ assertNotNull(match); >+ assertTrue(match.getOffset() == 3 && match.getLength() == 12); > } > > public void testAfterClosingMatchWithNLAndSingleLineComment() { > fDocument.set("x\nx(y\nx //(x\ny)x"); > IRegion match= fPairMatcher.match(fDocument, 15); >- assertNotNull(match); >- assertTrue(match.getOffset() == 3 && match.getLength() == 12); >+ assertNull(match); > } > > public void testAngleBrackets1_4() { >@@ -189,11 +158,11 @@ > public void testAngleBrackets1_5() { > final JavaPairMatcher matcher= (JavaPairMatcher) createMatcher("(){}[]<>"); > matcher.setSourceVersion(JavaCore.VERSION_1_5); >- performMatch(matcher, " #<>% "); >+ performMatch(matcher, " #< %> "); > performMatch(matcher, " <%># "); > performMatch(matcher, " 2 < 3 || 4 >% 5 "); > performMatch(matcher, " 2 <% 3 || 4 > 5 "); >- performMatch(matcher, " List#<String>% "); >+ performMatch(matcher, " List#<String%> "); > performMatch(matcher, " foo < T >% "); > performMatch(matcher, " foo <% T > "); > performMatch(matcher, " foo < T >% "); >@@ -203,10 +172,16 @@ > > public void testBug209505() { > fDocument.set("(xny)/* */"); >- IRegion match= fPairMatcher.match(fDocument, 5); >+ IRegion match= fPairMatcher.match(fDocument, 4); > assertNotNull(match); > assertTrue(match.getOffset() == 0 && match.getLength() == 5); > } > >+ protected void checkResult(final PairMatcherTestCase test, final IRegion region, final boolean isForward) { >+ final int offset= isForward ? test.getOffset() : test.getOffset() - 1; >+ final int length= test.getLength() + 1; >+ assertEquals(length, region.getLength()); >+ assertEquals(offset, region.getOffset()); >+ } > > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java >index de0d07b..94d847e 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -3667,7 +3667,7 @@ > > int anchor= fBracketMatcher.getAnchor(); > // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195 >- int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length; >+ int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1 : offset + length - 1; > > boolean visible= false; > if (sourceViewer instanceof ITextViewerExtension5) { >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaPairMatcher.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaPairMatcher.java >index 7e99ac5..602e2ed 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaPairMatcher.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaPairMatcher.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -34,7 +34,7 @@ > > > public JavaPairMatcher(char[] pairs) { >- super(pairs, IJavaPartitions.JAVA_PARTITIONING); >+ super(pairs, IJavaPartitions.JAVA_PARTITIONING, true); > } > > /* @see ICharacterPairMatcher#match(IDocument, int) */ >@@ -53,13 +53,14 @@ > private IRegion performMatch(IDocument document, int offset) throws BadLocationException { > if (offset < 0 || document == null) return null; > final char prevChar= document.getChar(Math.max(offset - 1, 0)); >- if ((prevChar == '<' || prevChar == '>') && !fHighlightAngularBrackets) >+ final char currChar= document.getChar(offset); >+ if ((prevChar == '<' || currChar == '>') && !fHighlightAngularBrackets) > return null; > if (prevChar == '<' && isLessThanOperator(document, offset - 1)) > return null; > final IRegion region= super.match(document, offset); > if (region == null) return region; >- if (prevChar == '>') { >+ if (currChar == '>') { > final int peer= region.getOffset(); > if (isLessThanOperator(document, peer)) return null; > } >@@ -75,7 +76,7 @@ > * @param offset an offset within the document > * @return true if the character at the specified offset is not > * a type parameter start bracket >- * @throws BadLocationException >+ * @throws BadLocationException if offset is invalid in the document > */ > private boolean isLessThanOperator(IDocument document, int offset) throws BadLocationException { > if (offset < 0) return false;
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