Java Code Examples for spoon.reflect.declaration.CtClass#getSuperclass()
The following examples show how to use
spoon.reflect.declaration.CtClass#getSuperclass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Spoonerism.java From spoon-examples with GNU General Public License v2.0 | 5 votes |
Spoonerism extendTestingClasses() { // Now we need to extend the classes. // WARNING: There is a small problem with this, can you spot it? // Answer at bottom CtTypeReference<?> baseTestingClassRef = baseTestingClass.getReference(); for (CtClass<?> ctClass: testingClasses) { if (ctClass.getSuperclass() == null) { ctClass.setSuperclass(baseTestingClassRef); } } return this; }
Example 2
Source File: FinderTestCases.java From astor with GNU General Public License v2.0 | 5 votes |
private static boolean isValidConstructor(CtType<?> type) { if (type instanceof CtClass<?>) { CtClass<?> ctClass = ((CtClass<?>) type); if (ctClass.getSuperclass() == null || !ctClass.getSuperclass().getSimpleName().equals("TestCase")) { return true; } return ((CtClass<?>) type).getConstructor() != null || ((CtClass<?>) type) .getConstructor(type.getFactory().Class().createReference(String.class)) != null; } return false; }
Example 3
Source File: WholeStatementAnalyzer.java From coming with MIT License | 4 votes |
private void analyzeS18_InSynchronizedMethod(CtElement element, Cntx<Object> context) { try { boolean S18Insynchronizedmethod = false; CtStatement parent = element.getParent(new LineFilter()); CtTry potentionalTryCatch = element.getParent(CtTry.class); if (potentionalTryCatch != null && whethereffectivetrycatch(potentionalTryCatch, parent)) { context.put(CodeFeatures.S18_In_Synchronized_Method, false); } else { CtMethod methodParent = element.getParent(CtMethod.class); CtClass parentClass = element.getParent(CtClass.class); if (methodParent != null) { if (methodParent.getModifiers().contains(ModifierKind.SYNCHRONIZED)) S18Insynchronizedmethod = true; } if (!S18Insynchronizedmethod && parentClass != null) { Set<CtTypeReference<?>> superInterfaces = parentClass.getSuperInterfaces(); CtTypeReference<?> superType = parentClass.getSuperclass(); if (superType != null && superType.getQualifiedName().toLowerCase().indexOf("thread") != -1) S18Insynchronizedmethod = true; if (superInterfaces.size() > 0) { for (CtTypeReference specificreference : superInterfaces) { if (specificreference != null && specificreference.getQualifiedName().toLowerCase().indexOf("thread") != -1) { S18Insynchronizedmethod = true; break; } } } } context.put(CodeFeatures.S18_In_Synchronized_Method, S18Insynchronizedmethod); } } catch (Throwable e) { e.printStackTrace(); } }
Example 4
Source File: WholeStatementAnalyzer.java From coming with MIT License | 4 votes |
/** * whether the associated method or class for the faulty line throws exception * * @param element * @param context */ @SuppressWarnings({ "unchecked", "rawtypes" }) private void analyzeS6S11_Method_Method_Features(CtElement element, Cntx<Object> context) { try { CtExecutable parentMethod = element.getParent(CtExecutable.class); CtClass parentClass = element.getParent(CtClass.class); CtStatement parent = element.getParent(new LineFilter()); CtTry potentionalTryCatch = element.getParent(CtTry.class); if (potentionalTryCatch != null && whethereffectivetrycatch(potentionalTryCatch, parent)) { context.put(CodeFeatures.S6_METHOD_THROWS_EXCEPTION, false); context.put(CodeFeatures.S11_FAULTY_CLASS_EXCEPTION_TYPE, false); } else { if (parentMethod != null) { // Exception context.put(CodeFeatures.S6_METHOD_THROWS_EXCEPTION, parentMethod.getThrownTypes().size() > 0); } boolean s11ExceptionType = false; if (parentClass != null) { Set<CtTypeReference<?>> superInterfaces = parentClass.getSuperInterfaces(); CtTypeReference<?> superType = parentClass.getSuperclass(); if (superType != null && superType.getQualifiedName().toLowerCase().indexOf("exception") != -1) s11ExceptionType = true; if (superInterfaces.size() > 0) { for (CtTypeReference specificreference : superInterfaces) { if (specificreference != null && specificreference.getQualifiedName().toLowerCase().indexOf("exception") != -1) { s11ExceptionType = true; break; } } } context.put(CodeFeatures.S11_FAULTY_CLASS_EXCEPTION_TYPE, s11ExceptionType); } } } catch (Throwable e) { e.printStackTrace(); } }