Author: dazarov
Date: 2012-01-24 16:29:57 -0500 (Tue, 24 Jan 2012)
New Revision: 38119
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
Log:
Add the code which is supposed to be inserted by the Quick Fix into its description
https://issues.jboss.org/browse/JBIDE-10636
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-01-24
21:01:25 UTC (rev 38118)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-01-24
21:29:57 UTC (rev 38119)
@@ -555,7 +555,10 @@
String textBefore = buffer.getText(importSize, annotationStart-importSize);
String textAfter = buffer.getText(annotationEnd, buffer.getLength()-annotationEnd);
if(checkImport(textBefore, qualifiedName) && checkImport(textAfter,
qualifiedName)){
- int numberOfSpaces =
getNumberOfSpaces(importDeclaration.getSourceRange().getOffset() +
importDeclaration.getSourceRange().getLength(), buffer);
+ int numberOfSpaces = 0;
+ if(!isLastImport(importContainer, importDeclaration)){
+ numberOfSpaces = getNumberOfSpaces(importDeclaration.getSourceRange().getOffset()
+ importDeclaration.getSourceRange().getLength(), buffer);
+ }
TextEdit edit = new DeleteEdit(importDeclaration.getSourceRange().getOffset(),
importDeclaration.getSourceRange().getLength()+numberOfSpaces);
rootEdit.addChild(edit);
@@ -575,6 +578,17 @@
}
}
+ private static boolean isLastImport(IImportContainer importContainer, IImportDeclaration
importDeclaration) throws JavaModelException{
+ for(int index = 0; index < importContainer.getChildren().length; index++){
+ IJavaElement child = importContainer.getChildren()[index];
+
+ if(child.equals(importDeclaration) && index ==
importContainer.getChildren().length-1){
+ return true;
+ }
+ }
+ return false;
+ }
+
public static boolean checkImport(String text, String qualifiedName){
String name = getShortName(qualifiedName);