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 54182 Details for
Bug 144355
[syntax highlighting] case insensitive WordRule
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
org.eclipse.jface.text.path
org.eclipse.jface.text.patch (text/plain), 8.86 KB, created by
Chris Aniszczyk
on 2006-11-20 12:40:04 EST
(
hide
)
Description:
org.eclipse.jface.text.path
Filename:
MIME Type:
Creator:
Chris Aniszczyk
Created:
2006-11-20 12:40:04 EST
Size:
8.86 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface.text.tests >Index: JFaceTextTestSuite.launch >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text.tests/JFaceTextTestSuite.launch,v >retrieving revision 1.4 >diff -u -r1.4 JFaceTextTestSuite.launch >--- JFaceTextTestSuite.launch 22 May 2005 20:16:30 -0000 1.4 >+++ JFaceTextTestSuite.launch 20 Nov 2006 17:32:53 -0000 >@@ -4,6 +4,9 @@ > <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> > <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.jface.text.tests.JFaceTextTestSuite"/> > <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> >+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> >+<listEntry value="4"/> >+</listAttribute> > <listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> > <listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="org.eclipse.jface.text.tests" path="1" type="4"/> "/> > <listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento project="org.eclipse.jface.text.tests"/> </runtimeClasspathEntry> "/> >@@ -12,6 +15,10 @@ > </listAttribute> > <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jface.text.tests"/> > <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Djava.library.path=${workspace_loc}/org.eclipse.swt.${system:OS}.${system:WS}.${system:ARCH}/"/> >+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> >+<listEntry value="/org.eclipse.jface.text.tests"/> >+</listAttribute> > <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> > <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> >+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/> > </launchConfiguration> >Index: src/org/eclipse/jface/text/tests/rules/WordRuleTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/rules/WordRuleTest.java,v >retrieving revision 1.1 >diff -u -r1.1 WordRuleTest.java >--- src/org/eclipse/jface/text/tests/rules/WordRuleTest.java 2 Nov 2006 08:48:21 -0000 1.1 >+++ src/org/eclipse/jface/text/tests/rules/WordRuleTest.java 20 Nov 2006 17:32:53 -0000 >@@ -55,4 +55,76 @@ > assertTrue(i < 1000); > > } >+ >+ /* >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=144355 >+ */ >+ public void testBug144355() throws Exception { >+ IWordDetector detector= new IWordDetector() { >+ >+ public boolean isWordPart(char c) { >+ return true; >+ } >+ >+ public boolean isWordStart(char c) { >+ return true; >+ } >+ >+ }; >+ >+ String defaultTokenString= "defaultToken"; >+ Token defaultToken= new Token(defaultTokenString); >+ >+ String testTokenStringNormal= "TestTokenString"; >+ String testTokenStringDifferentCapitalization= "TestTOKENString"; >+ String testTokenStringCompletelyDifferent= "XXX"; >+ Token normalToken= new Token(testTokenStringNormal); >+ >+ WordRule rule= new WordRule(detector, defaultToken, true); >+ rule.addWord(testTokenStringNormal, normalToken); >+ >+ // scenario 1 >+ // pre: pass in a normal string ("TestTokenString") >+ // post: expect the normal token to be returned >+ RuleBasedScanner scanner= new RuleBasedScanner(); >+ scanner.setRules(new IRule[] {rule}); >+ scanner.setRange(new Document(testTokenStringNormal), 0, testTokenStringNormal.length()); >+ assertTrue(scanner.nextToken().getData().equals(testTokenStringNormal)); >+ >+ // scenario 2 >+ // pre: pass in a normal string but different capitalization ("TestTOKENString") >+ // post: expect the normal token to be returned >+ scanner= new RuleBasedScanner(); >+ scanner.setRules(new IRule[] {rule}); >+ scanner.setRange(new Document(testTokenStringDifferentCapitalization), 0, testTokenStringDifferentCapitalization.length()); >+ assertTrue(scanner.nextToken().getData().equals(testTokenStringNormal)); >+ >+ // scenario 3 >+ // pre: pass in a completely different string ("XXX") >+ // post: expect the default token to be returned because the string can't be matched >+ scanner= new RuleBasedScanner(); >+ scanner.setRules(new IRule[] {rule}); >+ scanner.setRange(new Document(testTokenStringCompletelyDifferent), 0, testTokenStringCompletelyDifferent.length()); >+ assertTrue(scanner.nextToken().getData().equals(defaultTokenString)); >+ >+ WordRule ruleWithoutIgnoreCase= new WordRule(detector, defaultToken); >+ ruleWithoutIgnoreCase.addWord(testTokenStringNormal, normalToken); >+ >+ // scenario 4 >+ // pre: pass in a normal string ("TestTokenString") >+ // post: expect the normal token to be returned >+ scanner= new RuleBasedScanner(); >+ scanner.setRules(new IRule[] {ruleWithoutIgnoreCase}); >+ scanner.setRange(new Document(testTokenStringNormal), 0, testTokenStringNormal.length()); >+ assertTrue(scanner.nextToken().getData().equals(testTokenStringNormal)); >+ >+ // scenario 5 >+ // pre: pass in a normal string but different capitalization ("TestTOKENString") >+ // post: expect the default token to be returned >+ scanner= new RuleBasedScanner(); >+ scanner.setRules(new IRule[] {ruleWithoutIgnoreCase}); >+ scanner.setRange(new Document(testTokenStringDifferentCapitalization), 0, testTokenStringDifferentCapitalization.length()); >+ assertTrue(scanner.nextToken().getData().equals(defaultTokenString)); >+ } >+ > } >#P org.eclipse.jface.text >Index: src/org/eclipse/jface/text/rules/WordRule.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java,v >retrieving revision 1.14 >diff -u -r1.14 WordRule.java >--- src/org/eclipse/jface/text/rules/WordRule.java 2 Nov 2006 08:48:08 -0000 1.14 >+++ src/org/eclipse/jface/text/rules/WordRule.java 20 Nov 2006 17:32:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2006 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 >@@ -12,7 +12,9 @@ > > > import java.util.HashMap; >+import java.util.Iterator; > import java.util.Map; >+import java.util.Set; > > import org.eclipse.core.runtime.Assert; > >@@ -42,6 +44,8 @@ > protected Map fWords= new HashMap(); > /** Buffer used for pattern detection */ > private StringBuffer fBuffer= new StringBuffer(); >+ /** The boolean repsenting whether we should be case sensitive */ >+ private boolean fIgnoreCase= false; > > /** > * Creates a rule which, with the help of an word detector, will return the token >@@ -78,6 +82,29 @@ > } > > /** >+ * Creates a rule which, with the help of a word detector, will return the token >+ * associated with the detected word. If no token has been associated, the >+ * specified default token will be returned. >+ * >+ * @param detector the word detector to be used by this rule, may not be <code>null</code> >+ * @param defaultToken the default token to be returned on success >+ * if nothing else is specified, may not be <code>null</code> >+ * @param ignoreCase the case sensitivity associated with the rule >+ * >+ * @since 3.3 >+ * @see #addWord(String, IToken) >+ */ >+ public WordRule(IWordDetector detector, IToken defaultToken, boolean ignoreCase) { >+ >+ Assert.isNotNull(detector); >+ Assert.isNotNull(defaultToken); >+ >+ fDetector= detector; >+ fDefaultToken= defaultToken; >+ fIgnoreCase= ignoreCase; >+ } >+ >+ /** > * Adds a word and the token to be returned if it is detected. > * > * @param word the word this rule will search for, may not be <code>null</code> >@@ -119,7 +146,21 @@ > } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)); > scanner.unread(); > >- IToken token= (IToken) fWords.get(fBuffer.toString()); >+ String buffer = null; >+ >+ if(fIgnoreCase) { >+ Set entries= fWords.keySet(); >+ for (Iterator i = entries.iterator(); i.hasNext(); ) { >+ String s= (String) i.next(); >+ if(s.equalsIgnoreCase(fBuffer.toString())) { >+ buffer= s; >+ } >+ } >+ } else { >+ buffer= fBuffer.toString(); >+ } >+ >+ IToken token= (IToken) fWords.get(buffer); > if (token != null) > return token; > >@@ -143,4 +184,5 @@ > for (int i= fBuffer.length() - 1; i >= 0; i--) > scanner.unread(); > } >+ > }
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 144355
:
54028
| 54182