Search in sources :

Example 6 with JavaClassDescriptor

use of com.tngtech.archunit.core.domain.JavaClassDescriptor in project ArchUnit by TNG.

the class ImportedClasses method stubClassOf.

private static JavaClass stubClassOf(String typeName) {
    JavaClassDescriptor descriptor = JavaClassDescriptor.From.name(typeName);
    JavaClassBuilder builder = JavaClassBuilder.forStub().withDescriptor(descriptor);
    addModifiersIfPossible(builder, descriptor);
    return builder.build();
}
Also used : JavaClassBuilder(com.tngtech.archunit.core.importer.DomainBuilders.JavaClassBuilder) JavaClassDescriptor(com.tngtech.archunit.core.domain.JavaClassDescriptor)

Example 7 with JavaClassDescriptor

use of com.tngtech.archunit.core.domain.JavaClassDescriptor in project ArchUnit by TNG.

the class JavaClassProcessor method visitMethod.

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    if (importAborted()) {
        return super.visitMethod(access, name, desc, signature, exceptions);
    }
    LOG.trace("Analyzing method {}.{}:{}", className, name, desc);
    CodeUnit codeUnit = new CodeUnit(name, desc, className);
    accessHandler.setContext(codeUnit);
    JavaClassDescriptor rawReturnType = JavaClassDescriptorImporter.importAsmMethodReturnType(desc);
    DomainBuilders.JavaCodeUnitBuilder<?, ?> codeUnitBuilder = addCodeUnitBuilder(name, codeUnit.getRawParameterTypeNames(), rawReturnType.getFullyQualifiedClassName());
    JavaCodeUnitSignature codeUnitSignature = JavaCodeUnitSignatureImporter.parseAsmMethodSignature(signature, declarationHandler);
    List<JavaClassDescriptor> throwsDeclarations = typesFrom(exceptions);
    codeUnitBuilder.withName(name).withModifiers(JavaModifier.getModifiersForMethod(access)).withTypeParameters(codeUnitSignature.getTypeParameterBuilders()).withParameterTypes(codeUnitSignature.getParameterTypes(), codeUnit.getRawParameterTypes()).withReturnType(codeUnitSignature.getReturnType(), rawReturnType).withDescriptor(desc).withThrowsClause(throwsDeclarations);
    declarationHandler.onDeclaredThrowsClause(fullyQualifiedClassNamesOf(throwsDeclarations));
    return new MethodProcessor(className, accessHandler, codeUnitBuilder, declarationHandler);
}
Also used : JavaCodeUnitSignature(com.tngtech.archunit.core.importer.JavaCodeUnitSignatureImporter.JavaCodeUnitSignature) JavaClassDescriptor(com.tngtech.archunit.core.domain.JavaClassDescriptor) CodeUnit(com.tngtech.archunit.core.importer.RawAccessRecord.CodeUnit)

Example 8 with JavaClassDescriptor

use of com.tngtech.archunit.core.domain.JavaClassDescriptor in project ArchUnit by TNG.

the class JavaClassProcessor method visitOuterClass.

@Override
public void visitOuterClass(String owner, String name, String desc) {
    if (importAborted()) {
        return;
    }
    declarationHandler.registerEnclosingClass(className, createTypeName(owner));
    if (name != null && desc != null) {
        JavaClassDescriptor ownerType = JavaClassDescriptorImporter.createFromAsmObjectTypeName(owner);
        CodeUnit codeUnit = new CodeUnit(name, desc, ownerType.getFullyQualifiedClassName());
        declarationHandler.registerEnclosingCodeUnit(className, codeUnit);
    }
}
Also used : JavaClassDescriptor(com.tngtech.archunit.core.domain.JavaClassDescriptor) CodeUnit(com.tngtech.archunit.core.importer.RawAccessRecord.CodeUnit)

Example 9 with JavaClassDescriptor

use of com.tngtech.archunit.core.domain.JavaClassDescriptor in project ArchUnit by TNG.

the class JavaClassProcessor method handleAnnotationEnumProperty.

private static ValueBuilder handleAnnotationEnumProperty(String desc, String value, DeclarationHandler declarationHandler) {
    JavaClassDescriptor enumType = JavaClassDescriptorImporter.importAsmTypeFromDescriptor(desc);
    declarationHandler.onDeclaredAnnotationValueType(enumType.getFullyQualifiedClassName());
    return ValueBuilder.fromEnumProperty(enumType, value);
}
Also used : JavaClassDescriptor(com.tngtech.archunit.core.domain.JavaClassDescriptor)

Example 10 with JavaClassDescriptor

use of com.tngtech.archunit.core.domain.JavaClassDescriptor in project ArchUnit by TNG.

the class SignatureTypeParameterProcessor method visitClassType.

@Override
public void visitClassType(String internalObjectName) {
    JavaClassDescriptor type = JavaClassDescriptorImporter.createFromAsmObjectTypeName(internalObjectName);
    log.trace("Encountered upper bound for {}: Class type {}", currentType.getName(), type.getFullyQualifiedClassName());
    currentBound = new JavaParameterizedTypeBuilder<>(type);
    declarationHandler.onDeclaredGenericSignatureType(type.getFullyQualifiedClassName());
}
Also used : JavaClassDescriptor(com.tngtech.archunit.core.domain.JavaClassDescriptor)

Aggregations

JavaClassDescriptor (com.tngtech.archunit.core.domain.JavaClassDescriptor)11 CodeUnit (com.tngtech.archunit.core.importer.RawAccessRecord.CodeUnit)2 Test (org.junit.Test)2 JavaClassBuilder (com.tngtech.archunit.core.importer.DomainBuilders.JavaClassBuilder)1 JavaTypeCreationProcess (com.tngtech.archunit.core.importer.DomainBuilders.JavaTypeCreationProcess)1 JavaCodeUnitSignature (com.tngtech.archunit.core.importer.JavaCodeUnitSignatureImporter.JavaCodeUnitSignature)1 Type (org.objectweb.asm.Type)1