Skip to content

Commit

Permalink
Address review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaohaizh committed Nov 27, 2018
1 parent ea7725c commit 2a2712c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.manipulation.CoreASTProvider;
import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder.OccurrenceLocation;
import org.eclipse.jdt.internal.core.manipulation.search.OccurrencesFinder;
Expand Down Expand Up @@ -56,8 +57,9 @@ public Either<Range, PrepareRenameResult> prepareRename(TextDocumentPositionPara
InnovationContext context = new InnovationContext(unit, loc.getOffset(), loc.getLength());
context.setASTRoot(ast);
ASTNode node = context.getCoveredNode();
// Rename package is not fully support yet.
if (!(node instanceof PackageDeclaration) && !(node instanceof QualifiedName && node.getParent() instanceof PackageDeclaration)) {
// Rename package is not fully supported yet.
if (!(node instanceof PackageDeclaration)
&& !(((node instanceof QualifiedName) || (node instanceof SimpleName)) && node.getParent() instanceof PackageDeclaration)) {
return Either.forLeft(JDTUtils.toRange(unit, loc.getOffset(), loc.getLength()));
}
}
Expand All @@ -67,9 +69,9 @@ public Either<Range, PrepareRenameResult> prepareRename(TextDocumentPositionPara
}

} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem with compute occurrences for" + unit.getElementName() + " in prepareRename", e);
JavaLanguageServerPlugin.logException("Problem computing occurrences for" + unit.getElementName() + " in prepareRename", e);
}
}
throw new ResponseErrorException(new ResponseError(ResponseErrorCode.InvalidRequest, "Rename this element is not supported yet.", null));
throw new ResponseErrorException(new ResponseError(ResponseErrorCode.InvalidRequest, "Renaming this element is not supported.", null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void testRenameTypeWithResourceChanges() throws JavaModelException, BadLo
Either<TextDocumentEdit, ResourceOperation> change = resourceChanges.get(2);
RenameFile resourceChange = (RenameFile) change.getRight();
assertEquals(JDTUtils.toURI(cu), resourceChange.getOldUri());
assertEquals(JDTUtils.toURI(cu).replace("E", "Newname"), resourceChange.getNewUri());
assertEquals(JDTUtils.toURI(cu).replaceFirst("(?s)E(?!.*?E)", "Newname"), resourceChange.getNewUri());

List<TextEdit> testChanges = new LinkedList<>();
testChanges.addAll(resourceChanges.get(0).getLeft().getEdits());
Expand Down

0 comments on commit 2a2712c

Please sign in to comment.