-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3544 from ingef/release
Merge Release
- Loading branch information
Showing
215 changed files
with
3,559 additions
and
3,300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...src/main/java/com/bakdata/conquery/introspection/AbstractNodeWithMemberIntrospection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.bakdata.conquery.introspection; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
|
||
import com.github.javaparser.ast.body.EnumDeclaration; | ||
import com.github.javaparser.ast.body.FieldDeclaration; | ||
import com.github.javaparser.ast.body.TypeDeclaration; | ||
import com.github.javaparser.ast.nodeTypes.NodeWithJavadoc; | ||
import com.github.javaparser.ast.nodeTypes.NodeWithMembers; | ||
import com.github.javaparser.ast.nodeTypes.NodeWithRange; | ||
import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; | ||
import com.google.common.collect.MoreCollectors; | ||
import io.github.classgraph.ArrayTypeSignature; | ||
import io.github.classgraph.BaseTypeSignature; | ||
import io.github.classgraph.ClassRefTypeSignature; | ||
import io.github.classgraph.FieldInfo; | ||
import io.github.classgraph.MethodInfo; | ||
import io.github.classgraph.MethodParameterInfo; | ||
import io.github.classgraph.TypeSignature; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class AbstractNodeWithMemberIntrospection<VALUE extends NodeWithJavadoc<?> & NodeWithRange<?> & NodeWithMembers<?>> extends AbstractJavadocIntrospection<VALUE> { | ||
|
||
public AbstractNodeWithMemberIntrospection(File file, VALUE nodeWithJavadoc) { | ||
super(file, nodeWithJavadoc); | ||
} | ||
|
||
@Override | ||
public Introspection findMethod(MethodInfo method) { | ||
var types = Arrays.stream(method.getParameterInfo()) | ||
.map(MethodParameterInfo::getTypeSignatureOrTypeDescriptor) | ||
.map(this::toClass) | ||
.toArray(Class[]::new); | ||
|
||
return new AbstractJavadocIntrospection<>( | ||
file, | ||
value | ||
.getMethodsByParameterTypes(types) | ||
.stream() | ||
.filter(md -> md.getNameAsString().equals(method.getName())) | ||
.collect(MoreCollectors.onlyElement()) | ||
); | ||
|
||
} | ||
|
||
@Override | ||
public Introspection findField(FieldInfo field) { | ||
|
||
var f = value.getFieldByName(field.getName()); | ||
if (f.isPresent()) { | ||
FieldDeclaration fieldDeclaration = f.get(); | ||
return new AbstractJavadocIntrospection<>(file, fieldDeclaration); | ||
} | ||
log.warn("Could not find field '{}'", field.getName()); | ||
return new SimpleIntrospection(file); | ||
} | ||
|
||
public Introspection findInnerType(String simpleName) { | ||
for (var decl : value.getMembers()) { | ||
if (decl instanceof NodeWithSimpleName<?> node) { | ||
if (!node.getNameAsString().equals(simpleName)) { | ||
continue; | ||
} | ||
} | ||
else { | ||
continue; | ||
} | ||
if (decl instanceof EnumDeclaration enumDeclaration) { | ||
return new EnumIntrospection(file, enumDeclaration); | ||
} | ||
if (decl instanceof TypeDeclaration<?> cType) { | ||
return new AbstractNodeWithMemberIntrospection<>(file, cType); | ||
} | ||
} | ||
throw new IllegalStateException(value.getNameAsString() + " has no inner type " + simpleName); | ||
} | ||
|
||
private Class<?> toClass(TypeSignature sig) { | ||
if (sig instanceof BaseTypeSignature) { | ||
return ((BaseTypeSignature) sig).getType(); | ||
} | ||
else if (sig instanceof ArrayTypeSignature) { | ||
return ((ArrayTypeSignature) sig).loadClass(); | ||
} | ||
else if (sig instanceof ClassRefTypeSignature) { | ||
return ((ClassRefTypeSignature) sig).loadClass(); | ||
} | ||
throw new IllegalStateException("Can't find class for signature " + sig); | ||
} | ||
|
||
} |
Oops, something went wrong.