| Summary: | StringIndexOutOfBoundsException in Reindenter | ||
|---|---|---|---|
| Product: | [Tools] PTP | Reporter: | Rajashekhar Arasanal <rajashekharma> |
| Component: | Photran.Refactoring Engine | Assignee: | Photran Inbox <photran-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | a.merry.giraffe, com-eclipse-dot-org, hammonds.john9, paramvir.singh, rockmylife |
| Version: | unspecified | ||
| Target Milestone: | 7.0 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Please note that the problem #2 appears only when the statement is labeled. Ex:
! before comment
1 goto anotherlabel ! line comment
|
Build Identifier: 20100617-1415 This report lists two issues with the indenter: 1. The indenter crashes with string out of range exception when it was called from the editor on the following program: program comment_surrounding_goto implicit none integer anotherlabel ! before comment assign 10000 to anotherlabel ! line comment ! after comment ! before comment 10000 goto anotherlabel ! line comment ! after comment end program comment_surrounding_goto The stack trace is below: Root exception: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(Unknown Source) at org.eclipse.photran.internal.core.reindenter.StartOfLine.setIndentation(StartOfLine.java:234) at org.eclipse.photran.internal.core.reindenter.StartOfLine.reindentStatement(StartOfLine.java:220) at org.eclipse.photran.internal.core.reindenter.StartOfLine.reindent(StartOfLine.java:170) at org.eclipse.photran.internal.core.reindenter.ShiftBlockVisitor.updateIndentation(ShiftBlockVisitor.java:68) at org.eclipse.photran.internal.core.reindenter.ReindentingVisitor.visitToken(ReindentingVisitor.java:83) at org.eclipse.photran.internal.core.lexer.Token.accept(Token.java:348) at org.eclipse.photran.internal.core.parser.ASTVisitor.traverseChildren(ASTVisitor.java:21) at org.eclipse.photran.internal.core.parser.ASTVisitor.visitASTSelectCaseStmtNode(ASTVisitor.java:335) at org.eclipse.photran.internal.core.parser.ASTSelectCaseStmtNode.accept(ASTSelectCaseStmtNode.java:81) at org.eclipse.photran.internal.core.parser.ASTVisitor.traverseChildren(ASTVisitor.java:21) at org.eclipse.photran.internal.core.parser.ASTVisitor.visitASTCaseConstructNode(ASTVisitor.java:74) at org.eclipse.photran.internal.core.parser.ASTCaseConstructNode.accept(ASTCaseConstructNode.java:74) at org.eclipse.photran.internal.core.parser.ASTVisitor.traverseChildren(ASTVisitor.java:21) at org.eclipse.photran.internal.core.parser.ASTVisitor.visitASTListNode(ASTVisitor.java:26) at org.eclipse.photran.internal.core.parser.ASTListNode.accept(ASTListNode.java:130) at org.eclipse.photran.internal.core.parser.ASTVisitor.traverseChildren(ASTVisitor.java:21) at org.eclipse.photran.internal.core.parser.ASTVisitor.visitASTMainProgramNode(ASTVisitor.java:251) at org.eclipse.photran.internal.core.parser.ASTMainProgramNode.accept(ASTMainProgramNode.java:100) at org.eclipse.photran.internal.core.parser.ASTVisitor.traverseChildren(ASTVisitor.java:21) at org.eclipse.photran.internal.core.parser.ASTVisitor.visitASTListNode(ASTVisitor.java:26) at org.eclipse.photran.internal.core.parser.ASTListNode.accept(ASTListNode.java:130) at org.eclipse.photran.internal.core.parser.ASTVisitor.traverseChildren(ASTVisitor.java:21) at org.eclipse.photran.internal.core.parser.ASTVisitor.visitASTExecutableProgramNode(ASTVisitor.java:175) at org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode.accept(ASTExecutableProgramNode.java:61) at org.eclipse.photran.internal.core.FortranAST.accept(FortranAST.java:53) at org.eclipse.photran.internal.core.reindenter.Reindenter.reindent(Reindenter.java:107) at org.eclipse.photran.internal.core.reindenter.Reindenter.reindent(Reindenter.java:86) at org.eclipse.photran.internal.core.refactoring.RemoveAssignedGotoRefactoring.makeChangesTo(RemoveAssignedGotoRefactoring.java:586) at org.eclipse.photran.internal.core.refactoring.RemoveAssignedGotoRefactoring.doCreateChange(RemoveAssignedGotoRefactoring.java:635) at org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring.createChange(VPGRefactoring.java:196) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:124) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:209) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) 2. Consider the following program: program comment_surrounding_goto implicit none integer anotherlabel ! before comment assign 1 to anotherlabel ! line comment ! after comment ! before comment 1 goto anotherlabel ! line comment ! after comment end program comment_surrounding_goto When the reindenter is called, the comment before the "goto anotherlabel" is lost. Below is the result program: program comment_surrounding_goto implicit none integer anotherlabel ! before comment assign 1 to anotherlabel ! line comment 1 goto anotherlabel ! line comment ! after comment end program comment_surrounding_goto Reproducible: Always Steps to Reproduce: 1. Copy the sample programs (details section) into the photran editor. 2. Press Ctrl + I 3. For the first issue, the exception StringIndexOutOfBoundsException is thrown. 4. For the second issue, the comments after the ASSIGN statement and before the GOTO statements are lost.