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 17061 Details for
Bug 73104
[format] indentation amount tied to tab size
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
jdt-ui_mixed-indents.diff
jdt-ui_mixed-indents.diff (text/plain), 11.01 KB, created by
Tom Hofmann
on 2005-01-10 16:27:58 EST
(
hide
)
Description:
jdt-ui_mixed-indents.diff
Filename:
MIME Type:
Creator:
Tom Hofmann
Created:
2005-01-10 16:27:58 EST
Size:
11.01 KB
patch
obsolete
>Index: core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java,v >retrieving revision 1.49 >diff -u -r1.49 CodeFormatterUtil.java >--- core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java 8 Dec 2004 17:42:45 -0000 1.49 >+++ core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java 10 Jan 2005 21:25:50 -0000 >@@ -75,9 +75,29 @@ > public static int getTabWidth(IJavaProject project) { > String tabSize; > if (project != null) { >- tabSize= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, true); >+ tabSize= project.getOption(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, true); > } else { >- tabSize= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE); >+ tabSize= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE); >+ } >+ try { >+ return Integer.parseInt(tabSize); >+ } catch (NumberFormatException e) { >+ return 4; >+ } >+ } >+ >+ /** >+ * Gets the current tab width. >+ * @param project The project where the source is used, used for project specific options or <code>null</code> if >+ * the project is unknown and the workspace default should be used >+ * @return The indent width >+ */ >+ public static int getTabLength(IJavaProject project) { >+ String tabSize; >+ if (project != null) { >+ tabSize= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_LENGTH, true); >+ } else { >+ tabSize= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_LENGTH); > } > try { > return Integer.parseInt(tabSize); >Index: ui/org/eclipse/jdt/internal/ui/JavaPlugin.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java,v >retrieving revision 1.148 >diff -u -r1.148 JavaPlugin.java >--- ui/org/eclipse/jdt/internal/ui/JavaPlugin.java 3 Jan 2005 15:55:28 -0000 1.148 >+++ ui/org/eclipse/jdt/internal/ui/JavaPlugin.java 10 Jan 2005 21:25:50 -0000 >@@ -684,6 +684,18 @@ > } catch (IOException e) { > log(e); > } >+ >+ getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() { >+ public void propertyChange(PropertyChangeEvent event) { >+ if (TEMPLATES_KEY.equals(event.getProperty())) >+ try { >+ fTemplateStore.load(); >+ } catch (IOException e) { >+ log(e); >+ } >+ } >+ }); >+ > } > > return fTemplateStore; >@@ -729,9 +741,17 @@ > log(e); > } > >- // compatibility / bug fixing code for duplicated templates >- // TODO remove for 3.0 >- CompatibilityTemplateStore.pruneDuplicates(fCodeTemplateStore, true); >+ getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() { >+ public void propertyChange(PropertyChangeEvent event) { >+ if (CODE_TEMPLATES_KEY.equals(event.getProperty())) >+ try { >+ fCodeTemplateStore.load(); >+ } catch (IOException e) { >+ log(e); >+ } >+ } >+ }); >+ > } > > return fCodeTemplateStore; >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java,v >retrieving revision 1.261 >diff -u -r1.261 CompilationUnitEditor.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java 5 Jan 2005 10:11:59 -0000 1.261 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java 10 Jan 2005 21:25:51 -0000 >@@ -1108,7 +1108,7 @@ > } > > /** Preference key for code formatter tab size */ >- private final static String CODE_FORMATTER_TAB_SIZE= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE; >+ private final static String CODE_FORMATTER_TAB_SIZE= DefaultCodeFormatterConstants.FORMATTER_TAB_LENGTH; > /** Preference key for inserting spaces rather than tabs */ > private final static String SPACES_FOR_TABS= DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR; > /** Preference key for automatically closing strings */ >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java,v >retrieving revision 1.328 >diff -u -r1.328 JavaEditor.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java 10 Jan 2005 14:18:14 -0000 1.328 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java 10 Jan 2005 21:25:52 -0000 >@@ -2413,7 +2413,7 @@ > return; > } > >- if (DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)) { >+ if (DefaultCodeFormatterConstants.FORMATTER_TAB_LENGTH.equals(property)) { > sourceViewer.getTextWidget().setTabs(getSourceViewerConfiguration().getTabWidth(sourceViewer)); > return; > } >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/IndentationTabPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/IndentationTabPage.java,v >retrieving revision 1.12 >diff -u -r1.12 IndentationTabPage.java >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/IndentationTabPage.java 9 Sep 2004 17:25:27 -0000 1.12 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/IndentationTabPage.java 10 Jan 2005 21:25:52 -0000 >@@ -59,7 +59,8 @@ > protected void doCreatePreferences(Composite composite, int numColumns) { > > final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.getString("IndentationTabPage.general_group.title")); //$NON-NLS-1$ >- createNumberPref(generalGroup, numColumns, FormatterMessages.getString("IndentationTabPage.general_group.option.tab_size"), DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 999); //$NON-NLS-1$ >+ createNumberPref(generalGroup, numColumns, "Indentation Size", DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, 0, 999); //$NON-NLS-1$ >+ createNumberPref(generalGroup, numColumns, FormatterMessages.getString("IndentationTabPage.general_group.option.tab_size"), DefaultCodeFormatterConstants.FORMATTER_TAB_LENGTH, 1, 999); //$NON-NLS-1$ > createCheckboxPref(generalGroup, numColumns, FormatterMessages.getString("IndentationTabPage.general_group.option.use_tab_char"), DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, new String [] {JavaCore.SPACE, JavaCore.TAB}); //$NON-NLS-1$ > > final Group typeMemberGroup= createGroup(numColumns, composite, FormatterMessages.getString("IndentationTabPage.field_alignment_group.title")); //$NON-NLS-1$ >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/JavaPreview.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/JavaPreview.java,v >retrieving revision 1.13 >diff -u -r1.13 JavaPreview.java >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/JavaPreview.java 4 Jan 2005 10:57:21 -0000 1.13 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/JavaPreview.java 10 Jan 2005 21:25:52 -0000 >@@ -148,7 +148,7 @@ > fMarginPainter.setMarginRulerColumn(lineWidth); > > // update the tab size >- final int tabSize= getPositiveIntValue((String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0); >+ final int tabSize= getPositiveIntValue((String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_LENGTH), 0); > if (tabSize != fTabSize) fSourceViewer.getTextWidget().setTabs(tabSize); > fTabSize= tabSize; > >Index: ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java,v >retrieving revision 1.37 >diff -u -r1.37 JavaIndenter.java >--- ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java 9 Dec 2004 11:47:06 -0000 1.37 >+++ ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java 10 Jan 2005 21:25:53 -0000 >@@ -1091,6 +1091,21 @@ > } > > /** >+ * Skips a generic type definition between "<>". The current token >+ * is expected to be a ">". If <code>true</code> is returned, the current >+ * token points to a "<"; >+ * >+ * @return <code>true</code> if a <code>[]</code> could be scanned, the >+ * current token is left at the LANGULAR. >+ */ >+ private boolean skipAngularBrackets() { >+ if (fToken == Symbols.TokenGREATERTHAN) { >+ return skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN); >+ } >+ return false; >+ } >+ >+ /** > * Reads the next token in backward direction from the heuristic scanner > * and sets the fields <code>fToken, fPreviousPosition</code> and <code>fPosition</code> > * accordingly. >@@ -1133,15 +1148,20 @@ > * TODO This heuristic does not recognize package private constructors > * since those do have neither type nor visibility keywords. > * One option would be to go over the parameter list, but that might >- * be empty as well - hard to do without an AST... >+ * be empty as well, or not typed in yet - hard to do without an AST... > */ > > nextToken(); > if (fToken == Symbols.TokenIDENT) { // method name > do nextToken(); > while (skipBrackets()); // optional brackets for array valued return types >- // [1.5] TODO also need to skip angular brackets for generic return types >- return fToken == Symbols.TokenIDENT; // type name >+ >+ if (hasGenerics()) { >+ // [1.5] also skip angular brackets for generic return types >+ do nextToken(); >+ while (skipAngularBrackets()); >+ } >+ return fToken == Symbols.TokenIDENT; // return type name > > } > return false; >@@ -1158,6 +1178,7 @@ > * header. > */ > private boolean looksLikeMethodCall() { >+ // TODO [5.0] add awareness for constructor calls with generic types: new ArrayList<String>() > nextToken(); > return fToken == Symbols.TokenIDENT; // method name > } >@@ -1492,4 +1513,7 @@ > return JavaCore.getPlugin() == null; > } > >+ private boolean hasGenerics() { >+ return JavaCore.VERSION_1_5.compareTo(getCoreFormatterOption(JavaCore.COMPILER_SOURCE)) <= 0; >+ } > } >Index: ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java,v >retrieving revision 1.114 >diff -u -r1.114 JavaSourceViewerConfiguration.java >--- ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java 10 Jan 2005 14:18:14 -0000 1.114 >+++ ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java 10 Jan 2005 21:25:53 -0000 >@@ -492,7 +492,7 @@ > // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces > > IJavaProject project= getProject(); >- int tabWidth= CodeFormatterUtil.getTabWidth(project); >+ int tabWidth= CodeFormatterUtil.getTabLength(project); > boolean useSpaces; > if (project == null) > useSpaces= JavaCore.SPACE.equals(JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
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 Raw
Actions:
View
Attachments on
bug 73104
:
17059
|
17060
| 17061 |
17818
|
18667