import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import no.uio.ifi.refaktor.analyze.analyzers.LongestCommonPrefixAnalyzer;
-import no.uio.ifi.refaktor.analyze.collectors.SelectionInvalidException;
+import no.uio.ifi.refaktor.analyze.exceptions.SelectionInvalidException;
import no.uio.ifi.refaktor.examples.manager.ExampleCodeManager;
import no.uio.ifi.refaktor.utils.CompilationUnitTextSelection;
import no.uio.ifi.refaktor.utils.RefaktorHandleUtils;
+++ /dev/null
-package no.uio.ifi.refaktor.analyze;
-
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.ReturnStatement;
-
-public class ReturnStatementFinder extends ASTVisitor {
-
- private boolean returnFound = false;
-
- @Override
- public boolean visit(ReturnStatement node) {
- returnFound = true;
- return false;
- }
-
- public boolean hasFoundReturnStatement() {
- return returnFound;
- }
-
- public void reset() {
- returnFound = false;
- }
-
-}
import no.uio.ifi.refaktor.analyze.CollectorManager;
import no.uio.ifi.refaktor.analyze.checkers.LegalStatementsChecker;
import no.uio.ifi.refaktor.analyze.collectors.PrefixesCollector;
-import no.uio.ifi.refaktor.analyze.collectors.SelectionValidator;
import no.uio.ifi.refaktor.analyze.collectors.UnfixesCollector;
import no.uio.ifi.refaktor.analyze.exceptions.NoTargetFoundException;
import no.uio.ifi.refaktor.analyze.exceptions.RefaktorAnalyzerException;
import no.uio.ifi.refaktor.analyze.CollectorManager;
import no.uio.ifi.refaktor.analyze.collectors.LongestCommonPrefixCollector;
-import no.uio.ifi.refaktor.analyze.collectors.SelectionValidator;
import no.uio.ifi.refaktor.analyze.exceptions.RefaktorAnalyzerException;
import no.uio.ifi.refaktor.utils.CompilationUnitTextSelection;
-package no.uio.ifi.refaktor.analyze.collectors;
+package no.uio.ifi.refaktor.analyze.analyzers;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
+import no.uio.ifi.refaktor.analyze.exceptions.SelectionInvalidException;
import no.uio.ifi.refaktor.utils.CompilationUnitTextSelection;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-public class AmbiguousReturnValueChecker extends PropertyCollector implements Checker {
+class AmbiguousReturnValueChecker extends PropertyCollector implements Checker {
private class AssigneesUsedOutsideSelectionChecker extends PropertyCollector {
import org.eclipse.jdt.core.dom.Modifier;
// TODO: file bug report
-public class CallToProtectedOrPackagePrivateMethodChecker extends PropertyCollector implements Checker {
+class CallToProtectedOrPackagePrivateMethodChecker extends PropertyCollector implements Checker {
public CallToProtectedOrPackagePrivateMethodChecker(CompilationUnitTextSelection selection) {
super(selection);
import no.uio.ifi.refaktor.analyze.exceptions.IllegalExpressionFoundException;
import no.uio.ifi.refaktor.analyze.exceptions.IllegalStatementFoundException;
-public interface Checker {
+interface Checker {
void check() throws IllegalStatementFoundException, IllegalExpressionFoundException;
}
* with a few changes
*/
@SuppressWarnings("restriction")
-public class EnclosingInstanceReferenceChecker extends PropertyCollector implements Checker {
+class EnclosingInstanceReferenceChecker extends PropertyCollector implements Checker {
private final List<ITypeBinding> enclosingTypes= new ArrayList<ITypeBinding>(3);
-package no.uio.ifi.refaktor.analyze.collectors;
+package no.uio.ifi.refaktor.analyze.checkers;
import no.uio.ifi.refaktor.analyze.exceptions.IllegalStatementFoundException;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.ReturnStatement;
-public class IllegalReturnStatementChecker extends ASTVisitor {
+class IllegalReturnStatementChecker extends ASTVisitor {
@Override
public boolean visit(ReturnStatement node) {
import org.eclipse.jdt.core.dom.SuperFieldAccess;
import org.eclipse.jdt.core.dom.SuperMethodInvocation;
-public class IllegalStatementsChecker extends PropertyCollector implements Checker {
+class IllegalStatementsChecker extends PropertyCollector implements Checker {
public IllegalStatementsChecker(CompilationUnitTextSelection selection) {
super(selection);
import org.eclipse.jdt.core.dom.Modifier;
// TODO: file bug report
-public class InstantiationOfNonStaticInnerClassChecker extends PropertyCollector implements Checker {
+class InstantiationOfNonStaticInnerClassChecker extends PropertyCollector implements Checker {
public InstantiationOfNonStaticInnerClassChecker(CompilationUnitTextSelection selection) {
super(selection);
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.analyze.checkers;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.Statement;
-public class LastStatementFinder extends ASTVisitor {
+class LastStatementFinder extends ASTVisitor {
private final ASTNode parent;
private Statement lastStatement;
-package no.uio.ifi.refaktor.analyze.collectors;
+package no.uio.ifi.refaktor.analyze.checkers;
import java.util.List;
-import no.uio.ifi.refaktor.analyze.checkers.Checker;
+import no.uio.ifi.refaktor.analyze.collectors.LastStatementCollector;
+import no.uio.ifi.refaktor.analyze.collectors.PropertyCollector;
import no.uio.ifi.refaktor.analyze.exceptions.IllegalExpressionFoundException;
import no.uio.ifi.refaktor.analyze.exceptions.IllegalStatementFoundException;
import no.uio.ifi.refaktor.utils.CompilationUnitTextSelection;
-import no.uio.ifi.refaktor.utils.LastStatementFinder;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.ThrowStatement;
import org.eclipse.jdt.core.dom.TryStatement;
-public class LastStatementOfSelectionEndsInReturnOrThrowChecker extends PropertyCollector implements Checker {
+class LastStatementOfSelectionEndsInReturnOrThrowChecker extends PropertyCollector implements Checker {
public LastStatementOfSelectionEndsInReturnOrThrowChecker(CompilationUnitTextSelection selection) {
super(selection);
import java.util.LinkedList;
import java.util.List;
-import no.uio.ifi.refaktor.analyze.collectors.ReturnStatementsChecker;
import no.uio.ifi.refaktor.analyze.exceptions.CheckerException;
import no.uio.ifi.refaktor.utils.CompilationUnitTextSelection;
-package no.uio.ifi.refaktor.analyze.collectors;
+package no.uio.ifi.refaktor.analyze.checkers;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.ReturnStatement;
import org.eclipse.jdt.core.dom.ThrowStatement;
-public class ReturnOrThrowStatementFinder extends ASTVisitor {
+class ReturnOrThrowStatementFinder extends ASTVisitor {
private boolean returnOrThrowFound = false;
-package no.uio.ifi.refaktor.analyze.collectors;
+package no.uio.ifi.refaktor.analyze.checkers;
import no.uio.ifi.refaktor.analyze.CollectorManager;
-import no.uio.ifi.refaktor.analyze.checkers.Checker;
+import no.uio.ifi.refaktor.analyze.collectors.ContainsReturnStatementCollector;
import no.uio.ifi.refaktor.analyze.exceptions.IllegalExpressionFoundException;
import no.uio.ifi.refaktor.analyze.exceptions.IllegalStatementFoundException;
import no.uio.ifi.refaktor.utils.CompilationUnitTextSelection;
-public class ReturnStatementsChecker implements Checker {
+class ReturnStatementsChecker implements Checker {
private final CompilationUnitTextSelection selection;
-package no.uio.ifi.refaktor.analyze.collectors;
+package no.uio.ifi.refaktor.analyze.exceptions;
import no.uio.ifi.refaktor.change.exceptions.RefaktorChangerException;
import java.lang.ref.SoftReference;
import no.uio.ifi.refaktor.analyze.collectors.LastStatementCollector;
+import no.uio.ifi.refaktor.utils.nullobjects.NullSoftReference;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.ICompilationUnit;
package no.uio.ifi.refaktor.utils;
+import no.uio.ifi.refaktor.utils.caching.CompilationUnitCacheManager;
+
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
return CompilationUnitCacheManager.getParsedCompilationUnitFor(unit);
}
- static CompilationUnit parseUncached(ICompilationUnit unit) {
+ public static CompilationUnit parseUncached(ICompilationUnit unit) {
ASTParser parser = createParser();
parser.setSource(unit);
return (CompilationUnit) parser.createAST(null);
import java.util.regex.Pattern;
import no.uio.ifi.refaktor.exceptions.RefaktorException;
+import no.uio.ifi.refaktor.utils.nullobjects.NullCompilationUnit;
+import no.uio.ifi.refaktor.utils.nullobjects.NullPackageFragmentHandle;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.caching;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.CompilationUnit;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.caching;
+
+import no.uio.ifi.refaktor.utils.ParseUtils;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.CompilationUnit;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.caching;
+
+import no.uio.ifi.refaktor.utils.RefaktorDebug;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
-public class CacheCompilationUnitUtils {
+public class CompilationUnitCacheUtils {
static boolean hasMatchingModificationStamp(ICompilationUnit unit, Long modificationStamp) {
return getModificationStampOf(unit).equals(modificationStamp);
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.caching;
import java.util.HashMap;
import java.util.Map;
public boolean contains(ICompilationUnit unit) {
Long modificationStamp = modificationStamps.get(unit);
if (modificationStamp != null) {
- boolean modificationStampMatches = CacheCompilationUnitUtils.hasMatchingModificationStamp(unit, modificationStamp);
+ boolean modificationStampMatches = CompilationUnitCacheUtils.hasMatchingModificationStamp(unit, modificationStamp);
if (!modificationStampMatches)
cleanCache(unit);
return cache.containsKey(unit) && modificationStampMatches;
@Override
public void add(ICompilationUnit unit, CompilationUnit concreteCompilationUnit) {
cache.put(unit, concreteCompilationUnit);
- modificationStamps.put(unit, CacheCompilationUnitUtils.getModificationStampOf(unit));
+ modificationStamps.put(unit, CompilationUnitCacheUtils.getModificationStampOf(unit));
}
}
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.caching;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.CompilationUnit;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.caching;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.CompilationUnit;
if (!hasMatchingCompilationUnit(unit))
return false;
- if (CacheCompilationUnitUtils.hasMatchingModificationStamp(unit, modificationStamp)) {
+ if (CompilationUnitCacheUtils.hasMatchingModificationStamp(unit, modificationStamp)) {
return true;
}
public void add(ICompilationUnit unit, CompilationUnit concreteCompilationUnit) {
this.unit = unit;
this.concreteCompilationUnit = concreteCompilationUnit;
- modificationStamp = CacheCompilationUnitUtils.getModificationStampOf(unit);
+ modificationStamp = CompilationUnitCacheUtils.getModificationStampOf(unit);
}
}
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.caching;
import java.lang.ref.SoftReference;
import java.util.HashMap;
if (tmpStrongCURef != null) {
Long modificationStamp = modificationStamps.get(unit);
assert modificationStamp != null;
- boolean modificationStampMatches = CacheCompilationUnitUtils.hasMatchingModificationStamp(unit, modificationStamp);
+ boolean modificationStampMatches = CompilationUnitCacheUtils.hasMatchingModificationStamp(unit, modificationStamp);
if (!modificationStampMatches)
cleanCache(unit);
return modificationStampMatches;
@Override
public void add(ICompilationUnit unit, CompilationUnit concreteCompilationUnit) {
cache.put(unit, new SoftReference<CompilationUnit>(concreteCompilationUnit));
- modificationStamps.put(unit, CacheCompilationUnitUtils.getModificationStampOf(unit));
+ modificationStamps.put(unit, CompilationUnitCacheUtils.getModificationStampOf(unit));
}
}
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.caching;
import no.uio.ifi.refaktor.exceptions.RefaktorException;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.nullobjects;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.nullobjects;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.nullobjects;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.nullobjects;
import java.lang.ref.SoftReference;
-package no.uio.ifi.refaktor.utils;
+package no.uio.ifi.refaktor.utils.nullobjects;
public class UnsupportedNullObjectOperationException extends UnsupportedOperationException {
import no.uio.ifi.refaktor.analyze.analyzers.PrefixViewAnalyzer;
-import no.uio.ifi.refaktor.analyze.collectors.SelectionValidator;
+import no.uio.ifi.refaktor.analyze.analyzers.SelectionValidator;
import no.uio.ifi.refaktor.utils.CompilationUnitTextSelection;
import no.uio.ifi.refaktor.utils.DocumentUtils;
import no.uio.ifi.refaktor.utils.ParseUtils;