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 19288 Details for
Bug 49896
Formatters should have option to use tabs only for leading indents.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Apply on HEAD
patch_49896.txt (text/plain), 7.41 KB, created by
Olivier Thomann
on 2005-03-29 15:39:27 EST
(
hide
)
Description:
Apply on HEAD
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2005-03-29 15:39:27 EST
Size:
7.41 KB
patch
obsolete
>Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java,v >retrieving revision 1.59 >diff -u -r1.59 DefaultCodeFormatterOptions.java >--- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 28 Mar 2005 21:15:56 -0000 1.59 >+++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 29 Mar 2005 20:38:05 -0000 >@@ -286,7 +286,8 @@ > public final char filling_space = ' '; > public int page_width; > public int tab_char; >- >+ public boolean use_tabs_only_for_leading_indentations; >+ > public int initial_indentation_level; > public String line_separator; > >@@ -555,6 +556,7 @@ > break; > } > options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, Integer.toString(this.tab_size)); >+ options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, this.use_tabs_only_for_leading_indentations ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); > return options; > } > >@@ -1761,6 +1763,10 @@ > this.tab_size = 4; > } > } >+ final Object useTabsOnlyForLeadingIndentationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS); >+ if (useTabsOnlyForLeadingIndentationsOption != null) { >+ this.use_tabs_only_for_leading_indentations = DefaultCodeFormatterConstants.TRUE.equals(useTabsOnlyForLeadingIndentationsOption); >+ } > final Object pageWidthOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT); > if (pageWidthOption != null) { > try { >@@ -2022,6 +2028,7 @@ > this.tab_size = 4; > this.page_width = 80; > this.tab_char = TAB; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49081 >+ this.use_tabs_only_for_leading_indentations = false; > } > > public void setJavaConventionsSettings() { >@@ -2263,5 +2270,6 @@ > this.tab_size = 4; > this.page_width = 80; > this.tab_char = SPACE; >+ this.use_tabs_only_for_leading_indentations = false; > } > } >Index: formatter/org/eclipse/jdt/internal/formatter/Location.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Location.java,v >retrieving revision 1.10 >diff -u -r1.10 Location.java >--- formatter/org/eclipse/jdt/internal/formatter/Location.java 23 Feb 2005 02:47:58 -0000 1.10 >+++ formatter/org/eclipse/jdt/internal/formatter/Location.java 29 Mar 2005 20:38:05 -0000 >@@ -25,6 +25,7 @@ > public boolean pendingSpace; > public int nlsTagCounter; > public int lastLocalDeclarationSourceStart; >+ public int numberOfIndentations; > > // chunk management > public int lastNumberOfNewLines; >@@ -47,6 +48,7 @@ > this.pendingSpace = scribe.pendingSpace; > this.editsIndex = scribe.editsIndex; > this.nlsTagCounter = scribe.nlsTagCounter; >+ this.numberOfIndentations = scribe.numberOfIndentations; > textEdit = scribe.getLastEdit(); > } > } >Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v >retrieving revision 1.85 >diff -u -r1.85 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 28 Mar 2005 23:22:11 -0000 1.85 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 29 Mar 2005 20:38:06 -0000 >@@ -72,6 +72,8 @@ > private int textRegionEnd; > private int textRegionStart; > public int tabChar; >+ public int numberOfIndentations; >+ private boolean useTabsOnlyForLeadingIndents; > > Scribe(CodeFormatterVisitor formatter, Map settings, int offset, int length, CodeSnippetParsingUtil codeSnippetParsingUtil) { > if (settings != null) { >@@ -90,6 +92,8 @@ > this.pageWidth = formatter.preferences.page_width; > this.tabLength = formatter.preferences.tab_size; > this.indentationLevel= 0; // initialize properly >+ this.numberOfIndentations = 0; >+ this.useTabsOnlyForLeadingIndents = formatter.preferences.use_tabs_only_for_leading_indentations; > this.tabChar = formatter.preferences.tab_char; > if (this.tabChar == DefaultCodeFormatterOptions.MIXED) { > this.indentationSize = formatter.preferences.indentation_size; >@@ -322,6 +326,7 @@ > throw new AbortFormatting("could not find matching alignment: "+alignment); //$NON-NLS-1$ > } > this.indentationLevel = alignment.location.outputIndentationLevel; >+ this.numberOfIndentations = alignment.location.numberOfIndentations; > this.formatter.lastLocalDeclarationSourceStart = alignment.location.lastLocalDeclarationSourceStart; > if (discardAlignment){ > this.currentAlignment = alignment.enclosing; >@@ -338,6 +343,7 @@ > throw new AbortFormatting("could not find matching alignment: "+alignment); //$NON-NLS-1$ > } > this.indentationLevel = current.location.outputIndentationLevel; >+ this.numberOfIndentations = current.location.numberOfIndentations; > this.formatter.lastLocalDeclarationSourceStart = alignment.location.lastLocalDeclarationSourceStart; > this.memberAlignment = current.enclosing; > } >@@ -571,6 +577,7 @@ > > public void indent() { > this.indentationLevel += this.indentationSize; >+ this.numberOfIndentations++; > } > > private int indexOf(char[] toBeFound, char[] source, int start, int end) { >@@ -1086,12 +1093,30 @@ > private void printIndentationIfNecessary(StringBuffer buffer) { > switch(this.tabChar) { > case DefaultCodeFormatterOptions.TAB : >+ final boolean useTabsForLeadingIndents = this.useTabsOnlyForLeadingIndents; >+ final int numberOfLeadingIndents = this.numberOfIndentations; >+ int indentationsAsTab = 0; > while (this.column <= this.indentationLevel) { >- buffer.append('\t'); >- this.lastNumberOfNewLines = 0; >- int complement = this.tabLength - ((this.column - 1) % this.tabLength); // amount of space >- this.column += complement; >- this.needSpace = false; >+ if (useTabsForLeadingIndents) { >+ if (indentationsAsTab < numberOfLeadingIndents) { >+ buffer.append('\t'); >+ indentationsAsTab++; >+ this.lastNumberOfNewLines = 0; >+ int complement = this.tabLength - ((this.column - 1) % this.tabLength); // amount of space >+ this.column += complement; >+ this.needSpace = false; >+ } else { >+ buffer.append(' '); >+ this.column++; >+ this.needSpace = false; >+ } >+ } else { >+ buffer.append('\t'); >+ this.lastNumberOfNewLines = 0; >+ int complement = this.tabLength - ((this.column - 1) % this.tabLength); // amount of space >+ this.column += complement; >+ this.needSpace = false; >+ } > } > break; > case DefaultCodeFormatterOptions.SPACE : >@@ -1453,6 +1478,7 @@ > this.line = location.outputLine; > this.column = location.outputColumn; > this.indentationLevel = location.outputIndentationLevel; >+ this.numberOfIndentations = location.numberOfIndentations; > this.lastNumberOfNewLines = location.lastNumberOfNewLines; > this.needSpace = location.needSpace; > this.pendingSpace = location.pendingSpace; >@@ -1505,5 +1531,6 @@ > > public void unIndent() { > this.indentationLevel -= this.indentationSize; >+ this.numberOfIndentations--; > } > } >\ No newline at end of file
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 49896
:
19282
| 19288