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 188926 Details for
Bug 335309
[formatter] FUP of bug 332843: add regression test
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_335309.txt (text/plain), 7.14 KB, created by
Olivier Thomann
on 2011-02-14 12:47:38 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2011-02-14 12:47:38 EST
Size:
7.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java,v >retrieving revision 1.264 >diff -u -r1.264 FormatterRegressionTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 25 Jan 2011 20:15:22 -0000 1.264 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 14 Feb 2011 17:46:26 -0000 >@@ -62,7 +62,7 @@ > Map formatterOptions; > > static { >-// TESTS_NUMBERS = new int[] { 736 }; >+// TESTS_NUMBERS = new int[] { 738 }; > // TESTS_RANGE = new int[] { 734, -1 }; > } > public static Test suite() { >@@ -11102,4 +11102,14 @@ > "}\n" > ); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=332843 >+public void test738() { >+ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); >+ IRegion[] regions = new IRegion[] { >+ new Region(705, 0) >+ }; >+ runTest(codeFormatter, "test738", "RecipeDocumentProvider.java", CodeFormatter.K_COMPILATION_UNIT, 0, true, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ >+} > } >Index: workspace/Formatter/test738/RecipeDocumentProvider_in.java >=================================================================== >RCS file: workspace/Formatter/test738/RecipeDocumentProvider_in.java >diff -N workspace/Formatter/test738/RecipeDocumentProvider_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test738/RecipeDocumentProvider_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,62 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.recipeeditor; >+ >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IDocumentExtension3; >+import org.eclipse.jface.text.IDocumentPartitioner; >+import org.eclipse.jface.text.rules.FastPartitioner; >+import org.eclipse.jface.text.rules.IPredicateRule; >+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; >+import org.eclipse.jface.text.rules.SingleLineRule; >+import org.eclipse.jface.text.rules.Token; >+import org.eclipse.ui.editors.text.FileDocumentProvider; >+ >+public class RecipeDocumentProvider extends FileDocumentProvider { >+ /** >+ * The recipe partitioning. It contains two partition types: {@link #RECIPE_CODE} and >+ * {@link #RECIPE_COMMENT}. >+ */ >+ public static final String RECIPE_PARTITIONING= "org.recipeeditor.recipepartitioning"; //$NON-NLS-1$ >+ >+ /** >+ * The identifier of the comment body type. >+ */ >+ public static final String RECIPE_CODE= IDocument.DEFAULT_CONTENT_TYPE; >+ /** >+ * The identifier of the comment partition type. >+ */ >+ public static final String RECIPE_COMMENT= "RECIPE_COMMENT"; //$NON-NLS-1$ >+ >+ private static final String[] CONTENT_TYPES= { >+ RECIPE_CODE, >+ RECIPE_COMMENT >+ }; >+ >+ protected void setupDocument(Object element,IDocument document) { >+ if (document instanceof IDocumentExtension3) { >+ IDocumentExtension3 ext= (IDocumentExtension3) document; >+ IDocumentPartitioner partitioner= createRecipePartitioner(); >+ ext.setDocumentPartitioner(RECIPE_PARTITIONING, partitioner); >+ partitioner.connect(document); >+ } >+ } >+ >+ private IDocumentPartitioner createRecipePartitioner() { >+ IPredicateRule[] rules= { new SingleLineRule("#", null, new Token(RECIPE_COMMENT), (char) 0, true, false) }; //$NON-NLS-1$ >+ >+ RuleBasedPartitionScanner scanner= new RuleBasedPartitionScanner(); >+ scanner.setPredicateRules(rules); >+ >+ return new FastPartitioner(scanner, CONTENT_TYPES); >+ } >+ >+} >Index: workspace/Formatter/test738/RecipeDocumentProvider_out.java >=================================================================== >RCS file: workspace/Formatter/test738/RecipeDocumentProvider_out.java >diff -N workspace/Formatter/test738/RecipeDocumentProvider_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test738/RecipeDocumentProvider_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,62 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.recipeeditor; >+ >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IDocumentExtension3; >+import org.eclipse.jface.text.IDocumentPartitioner; >+import org.eclipse.jface.text.rules.FastPartitioner; >+import org.eclipse.jface.text.rules.IPredicateRule; >+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; >+import org.eclipse.jface.text.rules.SingleLineRule; >+import org.eclipse.jface.text.rules.Token; >+import org.eclipse.ui.editors.text.FileDocumentProvider; >+ >+public class RecipeDocumentProvider extends FileDocumentProvider { >+ /** >+ * The recipe partitioning. It contains two partition types: {@link #RECIPE_CODE} and >+ * {@link #RECIPE_COMMENT}. >+ */ >+ public static final String RECIPE_PARTITIONING= "org.recipeeditor.recipepartitioning"; //$NON-NLS-1$ >+ >+ /** >+ * The identifier of the comment body type. >+ */ >+ public static final String RECIPE_CODE= IDocument.DEFAULT_CONTENT_TYPE; >+ /** >+ * The identifier of the comment partition type. >+ */ >+ public static final String RECIPE_COMMENT= "RECIPE_COMMENT"; //$NON-NLS-1$ >+ >+ private static final String[] CONTENT_TYPES= { >+ RECIPE_CODE, >+ RECIPE_COMMENT >+ }; >+ >+ protected void setupDocument(Object element,IDocument document) { >+ if (document instanceof IDocumentExtension3) { >+ IDocumentExtension3 ext= (IDocumentExtension3) document; >+ IDocumentPartitioner partitioner= createRecipePartitioner(); >+ ext.setDocumentPartitioner(RECIPE_PARTITIONING, partitioner); >+ partitioner.connect(document); >+ } >+ } >+ >+ private IDocumentPartitioner createRecipePartitioner() { >+ IPredicateRule[] rules= { new SingleLineRule("#", null, new Token(RECIPE_COMMENT), (char) 0, true, false) }; //$NON-NLS-1$ >+ >+ RuleBasedPartitionScanner scanner= new RuleBasedPartitionScanner(); >+ scanner.setPredicateRules(rules); >+ >+ return new FastPartitioner(scanner, CONTENT_TYPES); >+ } >+ >+}
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 335309
: 188926