Skip to content

Commit

Permalink
If at least one of the clone fragments is inside an enum or annotatio…
Browse files Browse the repository at this point in the history
…n type declaration,

a precondition violation is added to the RefactoringStatus.

This is a fix for case 7272|1-2 found in project EMF-2.4.1 (CCFinder results)
org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.get(EStructuralFeature):FeatureKind  lines 290-309
org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.get(EStructuralFeature):FeatureKind  lines 270-289
  • Loading branch information
tsantalis committed Aug 10, 2016
1 parent 53161ea commit 7b9920c
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4941,6 +4941,13 @@ public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
try {
pm.beginTask("Checking preconditions...", 2);
AbstractMethodDeclaration methodObject1 = mapper.getPDG1().getMethod();
AbstractMethodDeclaration methodObject2 = mapper.getPDG2().getMethod();
MethodDeclaration methodDeclaration1 = methodObject1.getMethodDeclaration();
MethodDeclaration methodDeclaration2 = methodObject2.getMethodDeclaration();
if(!(methodDeclaration1.getParent() instanceof TypeDeclaration) || !(methodDeclaration2.getParent() instanceof TypeDeclaration)) {
status.merge(RefactoringStatus.createErrorStatus("At least one of the clone fragments is inside an enum or annotation type declaration"));
}
for(PreconditionViolation violation : mapper.getPreconditionViolations()) {
if(violation instanceof StatementPreconditionViolation) {
StatementPreconditionViolation statementViolation = (StatementPreconditionViolation)violation;
Expand Down

0 comments on commit 7b9920c

Please sign in to comment.