The following document contains the results of PMD's CPD 3.9.
| File | Line |
|---|---|
| spoon/template/Substitution.java | 62 |
| spoon/template/Substitution.java | 158 |
public static void insertAllSuperInterfaces(CtType<?> targetType,
Template template) {
CtClass<? extends Template> sourceClass = targetType.getFactory()
.Template().get(template.getClass());
// insert all the interfaces
for (CtTypeReference<?> t : sourceClass.getSuperInterfaces()) {
if (!t.equals(targetType.getFactory().Type().createReference(
Template.class))) {
CtTypeReference<?> t1 = t;
// substitute ref if needed
if (Parameters.getNames(sourceClass)
.contains(t.getSimpleName())) {
Object o = Parameters.getValue(template, t.getSimpleName(),
null);
if (o instanceof CtTypeReference) {
t1 = (CtTypeReference) o;
} else if (o instanceof Class) {
t1 = targetType.getFactory().Type().createReference(
(Class) o);
} else if (o instanceof String) {
t1 = targetType.getFactory().Type().createReference(
(String) o);
}
}
if (!t1.equals(targetType.getReference())) {
Class c = t1.getActualClass();
| |
| File | Line |
|---|---|
| spoon/support/reflect/eval/VisitorPartialEvaluator.java | 104 |
| spoon/support/reflect/eval/VisitorSymbolicEvaluator.java | 209 |
Number convert(CtTypeReference<?> type, Number n) {
if ((type.getActualClass() == int.class)
|| (type.getActualClass() == Integer.class)) {
return n.intValue();
}
if ((type.getActualClass() == byte.class)
|| (type.getActualClass() == Byte.class)) {
return n.byteValue();
}
if ((type.getActualClass() == long.class)
|| (type.getActualClass() == Long.class)) {
return n.longValue();
}
if ((type.getActualClass() == float.class)
|| (type.getActualClass() == Float.class)) {
return n.floatValue();
}
if ((type.getActualClass() == short.class)
|| (type.getActualClass() == Short.class)) {
return n.shortValue();
}
return n;
}
| |
| File | Line |
|---|---|
| spoon/support/QueueProcessingManager.java | 63 |
| spoon/support/RuntimeProcessingManager.java | 64 |
p.init();
addProcessor(p);
} catch (Exception e) {
factory
.getEnvironment()
.report(
null,
Severity.ERROR,
"Unable to instantiate processor \""
+ type.getName()
+ "\" - Your processor should have a constructor with no arguments");
}
}
public boolean addProcessor(Processor<?> p) {
p.setFactory(getFactory());
return getProcessors().add(p);
}
@SuppressWarnings("unchecked")
public void addProcessor(String qualifiedName) {
try {
addProcessor((Class<? extends Processor<?>>) Class
.forName(qualifiedName));
} catch (ClassNotFoundException e) {
factory.getEnvironment().report(
null,
Severity.ERROR,
"Unable to load processor \"" + qualifiedName
+ "\" - Check your classpath");
}
}
public Processor<?> getCurrentProcessor() {
return current;
}
public Factory getFactory() {
return factory;
}
public List<Processor<?>> getProcessors() {
| |
| File | Line |
|---|---|
| spoon/support/builder/SnippetBuilder.java | 21 |
| spoon/support/builder/SpoonBuildingManager.java | 87 |
factory.getEnvironment().debugMessage(
"compiling sources: " + sources.getAllJavaFiles());
long t = System.currentTimeMillis();
compiler = new JDTCompiler();
initCompiler();
srcSuccess = compiler.compileSrc(factory, sources.getAllJavaFiles());
if (!srcSuccess) {
for (CategorizedProblem[] cps : compiler.probs) {
for (int i = 0; i < cps.length; i++) {
CategorizedProblem problem = cps[i];
if (problem != null)
getProblems().add(problem.getMessage());
}
}
}
factory.getEnvironment().debugMessage(
"compiled in " + (System.currentTimeMillis() - t) + " ms");
factory.getEnvironment().debugMessage(
"compiling templates: " + templates.getAllJavaFiles());
t = System.currentTimeMillis();
| |
| File | Line |
|---|---|
| spoon/support/reflect/reference/CtExecutableReferenceImpl.java | 75 |
| spoon/support/reflect/reference/CtExecutableReferenceImpl.java | 105 |
}
// use reflection
Class<?> c = getDeclaringType().getActualClass();
for (Method m : RtHelper.getAllMethods(c)) {
if (!getSimpleName().equals(m.getName())) {
continue;
}
if (getParameterTypes().size() != m.getParameterTypes().length) {
continue;
}
int i = 0;
for (Class<?> t : m.getParameterTypes()) {
if (t != getParameterTypes().get(i).getActualClass()) {
break;
}
i++;
}
if (i == getParameterTypes().size()) {
m.setAccessible(true);
return m.getAnnotations();
| |
| File | Line |
|---|---|
| spoon/support/builder/JDTTreeBuilder.java | 1026 |
| spoon/support/reflect/cu/SourcePositionImpl.java | 39 |
private int searchLineNumber(int[] startLineIndexes, int position) {
if (startLineIndexes == null)
return 1;
int length = startLineIndexes.length;
if (length == 0)
return 1;
int g = 0, d = length - 1;
int m = 0, start;
while (g <= d) {
m = (g + d) / 2;
if (position < (start = startLineIndexes[m])) {
d = m - 1;
} else if (position > start) {
g = m + 1;
} else {
return m + 1;
}
}
if (position < startLineIndexes[m]) {
return m + 1;
}
return m + 2;
}
| |
| File | Line |
|---|---|
| spoon/support/reflect/code/CtNewClassImpl.java | 58 |
| spoon/support/reflect/code/CtUnaryOperatorImpl.java | 48 |
}
public String getLabel() {
return label;
}
public void insertAfter(CtStatement statement) {
CtStatementImpl.insertAfter(this, statement);
}
public void insertBefore(CtStatement statement) {
CtStatementImpl.insertBefore(this, statement);
}
public void insertAfter(CtStatementList<?> statements) {
CtStatementImpl.insertAfter(this, statements);
}
public void insertBefore(CtStatementList<?> statements) {
CtStatementImpl.insertBefore(this, statements);
}
public void replace(CtElement element) {
if (element instanceof CtStatementList) {
CtStatementImpl.replace(this, (CtStatementList<?>) element);
} else {
super.replace(element);
}
}
public void setOperand(CtExpression<T> expression) {
| |
| File | Line |
|---|---|
| spoon/support/reflect/code/CtInvocationImpl.java | 64 |
| spoon/support/reflect/code/CtUnaryOperatorImpl.java | 52 |
}
public void insertAfter(CtStatement statement) {
CtStatementImpl.insertAfter(this, statement);
}
public void insertBefore(CtStatement statement) {
CtStatementImpl.insertBefore(this, statement);
}
public void insertAfter(CtStatementList<?> statements) {
CtStatementImpl.insertAfter(this, statements);
}
public void insertBefore(CtStatementList<?> statements) {
CtStatementImpl.insertBefore(this, statements);
}
public void replace(CtElement element) {
if (element instanceof CtStatementList) {
CtStatementImpl.replace(this, (CtStatementList<?>) element);
} else {
super.replace(element);
}
}
public void setAnonymousClass(CtClass<?> annonymousClass) {
| |
| File | Line |
|---|---|
| spoon/support/QueueProcessingManager.java | 112 |
| spoon/support/RuntimeProcessingManager.java | 112 |
private ProcessingVisitor getVisitor() {
if (visitor == null)
visitor = new ProcessingVisitor(getFactory());
return visitor;
}
public boolean isToBeApplied(Class<? extends Processor<?>> type) {
for (Processor<?> p : getProcessors()) {
if (p.getClass() == type) {
return true;
}
}
return false;
}
public void process() {
Timer.start("process");
process(getFactory().Package().getAllRoots());
Timer.stop("process");
}
public void process(Collection<? extends CtElement> elements) {
| |
| File | Line |
|---|---|
| spoon/template/Substitution.java | 111 |
| spoon/template/Substitution.java | 265 |
if (targetType instanceof CtClass) {
for (CtConstructor c : sourceClass.getConstructors()) {
if (c.isImplicit())
continue;
if (c.getAnnotation(Local.class) != null)
continue;
insertConstructor((CtClass<?>) targetType, template, c);
}
}
// insert all the initialization blocks (only for classes)
if (targetType instanceof CtClass) {
for (CtAnonymousExecutable e : sourceClass
.getAnonymousExecutables()) {
((CtClass<?>) targetType).getAnonymousExecutables().add(
substitute(targetType, template, e));
}
}
| |
| File | Line |
|---|---|
| spoon/reflect/factory/ExecutableFactory.java | 165 |
| spoon/reflect/factory/ExecutableFactory.java | 197 |
List<CtTypeReference<?>> parameterTypes) {
CtExecutableReference<T> methodRef = factory.Core()
.createExecutableReference();
methodRef.setStatic(isStatic);
methodRef.setDeclaringType(declaringType);
methodRef.setSimpleName(methodName);
methodRef.setType(type);
List<CtTypeReference<?>> l = new ArrayList<CtTypeReference<?>>();
for (CtTypeReference<?> ref : parameterTypes) {
l.add(ref);
}
methodRef.setParameterTypes(l);
return methodRef;
}
/**
* Creates an executable reference.
*
* @param declaringType
* reference to the declaring type
* @param type
* the return type of the executable
* @param methodName
* simple name
* @param parameterTypes
* list of parameter's types
*/
public <T> CtExecutableReference<T> createReference(
CtTypeReference<?> declaringType, CtTypeReference<T> type,
| |