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 183642 Details for
Bug 330556
[typing] Indentation is messed up on paste
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]
Patch
330556 (text/plain), 8.61 KB, created by
Rajesh
on 2010-11-23 03:48:05 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rajesh
Created:
2010-11-23 03:48:05 EST
Size:
8.61 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java,v >retrieving revision 1.28 >diff -u -r1.28 JavaHeuristicScanner.java >--- ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java 4 Nov 2010 16:35:20 -0000 1.28 >+++ ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java 23 Nov 2010 08:46:25 -0000 >@@ -61,6 +61,8 @@ > private static final char LANGLE= '<'; > private static final char RANGLE= '>'; > >+ private static final char DOUBLEQUOTE= '"'; >+ > /** > * Specifies the stop condition, upon which the <code>scanXXX</code> methods will decide whether > * to keep scanning or not. This interface may implemented by clients. >@@ -334,6 +336,8 @@ > return TokenLESSTHAN; > case RANGLE: > return TokenGREATERTHAN; >+ case DOUBLEQUOTE: >+ return TokenDOUBLEQUOTE; > } > > // else >@@ -406,6 +410,8 @@ > return TokenLESSTHAN; > case RANGLE: > return TokenGREATERTHAN; >+ case DOUBLEQUOTE: >+ return TokenDOUBLEQUOTE; > } > > // else >Index: ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java,v >retrieving revision 1.64 >diff -u -r1.64 JavaIndenter.java >--- ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java 4 Nov 2010 16:35:20 -0000 1.64 >+++ ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java 23 Nov 2010 08:46:25 -0000 >@@ -22,6 +22,8 @@ > > import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil; > >+import org.eclipse.jdt.internal.ui.JavaPlugin; >+ > > /** > * Uses the {@link org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner} to >@@ -856,6 +858,13 @@ > fAlign= JavaHeuristicScanner.NOT_FOUND; > fPosition= offset; > >+ int lineForStartingOffset= 0; >+ try { >+ lineForStartingOffset= fDocument.getLineOfOffset(offset); >+ } catch (BadLocationException e) { >+ JavaPlugin.log(e); >+ } >+ > // forward cases > // an unindentation happens sometimes if the next token is special, namely on braces, parens and case labels > // align braces, but handle the case where we align with the method declaration start instead of >@@ -961,6 +970,11 @@ > > case Symbols.TokenTRY: > return skipToStatementStart(danglingElse, false); >+ >+ case Symbols.TokenRBRACKET: >+ fIndent= fPrefs.prefContinuationIndent; >+ return fPosition; >+ > case Symbols.TokenRPAREN: > if (throwsClause) { > fIndent= fPrefs.prefContinuationIndent; >@@ -990,10 +1004,14 @@ > fPosition= offset; > fLine= line; > >- return skipToPreviousListItemOrListStart(); >+ return skipToPreviousListItemOrListStart(lineForStartingOffset); > case Symbols.TokenRETURN: > fIndent= fPrefs.prefContinuationIndent; > return fPosition; >+ case Symbols.TokenDOUBLEQUOTE: >+ if (handleString(lineForStartingOffset)) >+ return fPosition; >+ return skipToPreviousListItemOrListStart(lineForStartingOffset); > case Symbols.TokenCOMMA: > // inside a list of some type > // easy if there is already a list item before with its own indentation - we just align >@@ -1003,7 +1021,7 @@ > // inside whatever we don't know about: similar to the list case: > // if we are inside a continued expression, then either align with a previous line that has indentation > // or indent from the expression start line (either a scope introducer or the start of the expr). >- return skipToPreviousListItemOrListStart(); >+ return skipToPreviousListItemOrListStart(lineForStartingOffset); > } > } > >@@ -1277,17 +1295,17 @@ > } > > /** >- * Returns the reference position for a list element. The algorithm >- * tries to match any previous indentation on the same list. If there is none, >- * the reference position returned is determined depending on the type of list: >- * The indentation will either match the list scope introducer (e.g. for >- * method declarations), so called deep indents, or simply increase the >- * indentation by a number of standard indents. See also {@link #handleScopeIntroduction(int)}. >- * >- * @return the reference position for a list item: either a previous list item >- * that has its own indentation, or the list introduction start. >+ * Returns the reference position for a list element. The algorithm tries to match any previous >+ * indentation on the same list. If there is none, the reference position returned is determined >+ * depending on the type of list: The indentation will either match the list scope introducer >+ * (e.g. for method declarations), so called deep indents, or simply increase the indentation by >+ * a number of standard indents. See also {@link #handleScopeIntroduction(int)}. >+ * >+ * @param lineForStartingOffset The line for which we are trying to compute the indentation >+ * @return the reference position for a list item: either a previous list item that has its own >+ * indentation, or the list introduction start. > */ >- private int skipToPreviousListItemOrListStart() { >+ private int skipToPreviousListItemOrListStart(int lineForStartingOffset) { > int startLine= fLine; > int startPosition= fPosition; > while (true) { >@@ -1340,6 +1358,11 @@ > return fPosition; > case Symbols.TokenEQUAL: > return handleEqual(); >+ case Symbols.TokenDOUBLEQUOTE: >+ if (handleString(lineForStartingOffset)) >+ return fPosition; >+ break; >+ > case Symbols.TokenEOF: > return 0; > >@@ -1348,6 +1371,58 @@ > } > > /** >+ * Called when a double quote is encountered. Handles skipping of strings so that we don't scan >+ * for tokens inside of it, and indents the string if there is continuation. >+ * >+ * @param lineForStartingOffset The line for which we are trying to compute the indentation >+ * @return <code>true</code> if the string was skipped and continuation indentation set. >+ * @since 3.7 >+ */ >+ private boolean handleString(int lineForStartingOffset) { >+ int savedPosition= fPosition; >+ if (skipString()) { >+ int nonWSCharBackward= fScanner.findNonWhitespaceBackward(fPosition - 1, JavaHeuristicScanner.UNBOUND); >+ try { >+ if (nonWSCharBackward != JavaHeuristicScanner.NOT_FOUND && fDocument.getChar(nonWSCharBackward) != '+' && fDocument.getLineOfOffset(nonWSCharBackward) < fLine) { >+ int nonWSCharForward= fScanner.findNonWhitespaceForward(savedPosition + 1, JavaHeuristicScanner.UNBOUND); >+ if (nonWSCharForward != JavaHeuristicScanner.NOT_FOUND && fDocument.getChar(nonWSCharForward) == '+' && fLine < lineForStartingOffset) { >+ fIndent= fPrefs.prefContinuationIndent; >+ return true; >+ } >+ } >+ } catch (BadLocationException e) { >+ JavaPlugin.log(e); >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Skip the string backwards in the current line when a double quote is encountered. >+ * >+ * @return <code>true</code> if the string was successfully >+ */ >+ private boolean skipString() { >+ boolean stringSkipped= false; >+ try { >+ int lineOffset= fDocument.getLineOffset(fLine); >+ int positionOfDoubleQuote= fScanner.scanBackward(fPosition - 1, lineOffset, '"'); >+ while (positionOfDoubleQuote != JavaHeuristicScanner.NOT_FOUND) { >+ fPosition= positionOfDoubleQuote; >+ stringSkipped= true; >+ if (positionOfDoubleQuote != lineOffset && fDocument.getChar(positionOfDoubleQuote - 1) == '\\') { >+ positionOfDoubleQuote= fScanner.scanBackward(fPosition - 1, lineOffset, '"'); >+ } else { >+ break; >+ } >+ } >+ } catch (BadLocationException e) { >+ JavaPlugin.log(e); >+ } >+ return stringSkipped; >+ } >+ >+ /** > * Skips a scope and positions the cursor (<code>fPosition</code>) on the > * token that opens the scope. Returns <code>true</code> if a matching peer > * could be found, <code>false</code> otherwise. The current token when calling >Index: ui/org/eclipse/jdt/internal/ui/text/Symbols.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/Symbols.java,v >retrieving revision 1.11 >diff -u -r1.11 Symbols.java >--- ui/org/eclipse/jdt/internal/ui/text/Symbols.java 4 Nov 2010 16:35:20 -0000 1.11 >+++ ui/org/eclipse/jdt/internal/ui/text/Symbols.java 23 Nov 2010 08:46:25 -0000 >@@ -32,6 +32,7 @@ > int TokenEQUAL= 12; > int TokenLESSTHAN= 13; > int TokenGREATERTHAN= 14; >+ int TokenDOUBLEQUOTE= 15; > int TokenIF= 109; > int TokenDO= 1010; > int TokenFOR= 1011;
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 330556
:
183376
|
183642
|
183875
|
184050
|
184229
|
184390