Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 442689

Summary: Save Action -> Code Indentation plus formatter causes incorrect indentation
Product: [Eclipse Project] JDT Reporter: Manoj N Palat <manoj.palat>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: manoj.palat, martin.wegner, noopur_gupta, sciccarelli
Version: 4.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Project with custom conf none

Description Manoj N Palat CLA 2014-08-27 07:03:06 EDT
Created attachment 246418 [details]
Project with custom conf

As an offshoot of bug 434962 -> An adapted minimal project with minimal custom setting included.

Issue: Add a space before the second parameter, and save [In Save Actions -> Code Indentation should be on plus the Format all source should be on -> these are set in the custom conf].The method declaration opening brace is preceded by two tabs instead of one. Since the formatter is on and the second parameter is moved to the same line as the first parameter, the tabs spaces are expected to remain unchanged, that is just one tab.

In the following stack of IndentAction, at this line:
StringBuffer computed= indenter.computeIndentation(offset);
computed gets two tabs instead of one.

org.eclipse.jdt.internal.ui.actions.IndentAction.computeReplaceData(IDocument, int, JavaIndenter, JavaHeuristicScanner, boolean, boolean, IJavaProject)


IndentAction.computeReplaceData(IDocument, int, JavaIndenter, JavaHeuristicScanner, boolean, boolean, IJavaProject) line: 350	
IndentAction.indent(IDocument, IJavaProject) line: 267	
CodeFormatFix.createCleanUp(ICompilationUnit, IRegion[], boolean, boolean, boolean, boolean) line: 142	
CodeFormatCleanUp.createFix(CleanUpContext) line: 67	
CleanUpRefactoring.calculateChange(CleanUpContext, ICleanUp[], List<ICleanUp>, HashSet<ICleanUp>) line: 809	
CleanUpPostSaveListener.saved(ICompilationUnit, IRegion[], IProgressMonitor) line: 396	
CompilationUnitDocumentProvider$5.run() line: 1598	
SafeRunner.run(ISafeRunnable) line: 42	
CompilationUnitDocumentProvider.notifyPostSaveListeners(CompilationUnitDocumentProvider$CompilationUnitInfo, IRegion[], IPostSaveListener[], IProgressMonitor) line: 1593	
CompilationUnitDocumentProvider.commitWorkingCopy(IProgressMonitor, Object, CompilationUnitDocumentProvider$CompilationUnitInfo, boolean) line: 1380	
CompilationUnitDocumentProvider$4.execute(IProgressMonitor) line: 1458	
CompilationUnitDocumentProvider$4(TextFileDocumentProvider$DocumentProviderOperation).run(IProgressMonitor) line: 132	
WorkspaceModifyDelegatingOperation.execute(IProgressMonitor) line: 69	
WorkspaceModifyOperation$1.run(IProgressMonitor) line: 106	
Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 2313	
WorkspaceModifyDelegatingOperation(WorkspaceModifyOperation).run(IProgressMonitor) line: 118	
WorkspaceOperationRunner.run(IRunnableWithProgress, ISchedulingRule) line: 75	
WorkspaceOperationRunner.run(boolean, boolean, IRunnableWithProgress) line: 65	
CompilationUnitDocumentProvider(TextFileDocumentProvider).executeOperation(TextFileDocumentProvider$DocumentProviderOperation, IProgressMonitor) line: 456	
CompilationUnitDocumentProvider(TextFileDocumentProvider).saveDocument(IProgressMonitor, Object, IDocument, boolean) line: 772	
CompilationUnitEditor(AbstractTextEditor).performSave(boolean, IProgressMonitor) line: 5076
Comment 1 Noopur Gupta CLA 2014-08-27 07:49:20 EDT
Looks similar to bug 439582.

*** This bug has been marked as a duplicate of bug 439582 ***