/** * @see me.seeber.gradle.ide.eclipse.annotations.Nullability#getReturnValueNullability(MethodDescription) */ @Override public Nullness getReturnValueNullability(MethodDescription method) { Nullness nullability = Nullness.UNDEFINED; for (Nullability provider : this.nullabilities) { Nullness override = provider.getReturnValueNullability(method); nullability = nullability.override(override); } return nullability; }
/** * @see me.seeber.gradle.ide.eclipse.annotations.Nullability#getParameterNullability(net.bytebuddy.description.method.ParameterDescription) */ @Override public Nullness getParameterNullability(ParameterDescription parameter) { Nullness nullability = Nullness.UNDEFINED; for (Nullability provider : this.nullabilities) { Nullness override = provider.getParameterNullability(parameter); nullability = nullability.override(override); } return nullability; }
/** * Override this nullability with another one * * @param override Override nullability * @return Nullability that overrides this with another nullability */ public default Nullability override(Nullability override) { return new CombinedNullability(this, override); }
/** * Append an array type signature * * @param type Array type to append * @param nullable Nullness of type * @param output Output to append to * @param <A> Type of output * @return Supplied output to append to */ public <A extends Appendable> A appendArrayTypeSignature(Generic type, Nullness nullable, A output) { try { output.append('[').append(nullable.getMarker()); appendJavaTypeSignature(Validate.notNull(type.getComponentType()), Nullness.UNDEFINED, output); return output; } catch (Exception e) { throw new RuntimeException(String.format("Could not write array type %s", type)); } }
/** * @see me.seeber.gradle.ide.eclipse.annotations.Nullability#getReturnValueNullability(net.bytebuddy.description.method.MethodDescription) */ @Override public Nullness getReturnValueNullability(MethodDescription method) { Nullness nullability = getNullability(method.getDeclaredAnnotations()); return nullability; }
/** * Create a new AnnotationsJarBuilder * * @param jarFile JAR file to read * @param classLoader Class loader to resolve types */ public JarReader(File jarFile, ClassLoader classLoader) { this.classLoader = classLoader; try { openJarFile(jarFile); } catch (IOException e) { throw new RuntimeException("Cannot create annotations JAR builder", e); } }
/** * Append type arguments * * @param buf Buffer to append to * @param typeArguments Type arguments * @return <code>true</code> if any nullability information was written * @throws IOException I'm sorry, this usually doesn't happen to me... */ protected boolean appendTypeArguments(StringBuilder buf, TypeList.Generic typeArguments) throws IOException { String plainTypeVariables = this.signatureWriter.appendTypeArguments(typeArguments, new StringBuilder()) .toString(); String annotatedTypeVariables = this.signatureWriter.appendTypeArguments(typeArguments, new StringBuilder()) .toString(); buf.append(plainTypeVariables).append("\n"); buf.append(annotatedTypeVariables).append("\n"); boolean annotated = plainTypeVariables.equals(annotatedTypeVariables); return annotated; }
/** * Append type parameters * * @param buf Buffer to append to * @param typeParameters Type parameters * @param annotatedSignatureWriter Signature writer * @return <code>true</code> if any nullability information was written * @throws IOException if we fail completely... */ protected boolean appendTypeParameters(StringBuilder buf, TypeList.Generic typeParameters, MethodSignatureWriter annotatedSignatureWriter) throws IOException { String plainTypeVariables = this.signatureWriter.appendTypeParameters(typeParameters, new StringBuilder()) .toString(); String annotatedTypeVariables = annotatedSignatureWriter .appendTypeParameters(typeParameters, new StringBuilder()).toString(); buf.append(plainTypeVariables).append("\n"); buf.append(annotatedTypeVariables).append("\n"); boolean annotated = !plainTypeVariables.equals(annotatedTypeVariables); return annotated; }
/** * Get the target file for an input file * * @param jarFile Source JAR file * @return Target file */ protected File getTargetFile(File jarFile) { String baseName = Files.getNameWithoutExtension(jarFile.getName()); File annotationJarFile = new File(getDestinationDir(), baseName + "-annotations.zip"); return annotationJarFile; }
/** * Create a new task */ public EclipseAnnotationsTask() { this.jars = Collections.emptySet(); this.destinationDir = new File(getProject().getBuildDir(), "annotations"); }
/** * @see me.seeber.gradle.ide.eclipse.annotations.Nullability#getReturnValueNullability(MethodDescription) */ @Override public Nullness getReturnValueNullability(MethodDescription method) { Nullness nullability = Nullness.UNDEFINED; for (Nullability provider : this.nullabilities) { Nullness override = provider.getReturnValueNullability(method); nullability = nullability.override(override); } return nullability; }
/** * @see me.seeber.gradle.ide.eclipse.annotations.Nullability#getParameterNullability(net.bytebuddy.description.method.ParameterDescription) */ @Override public Nullness getParameterNullability(ParameterDescription parameter) { Nullness nullability = Nullness.UNDEFINED; for (Nullability provider : this.nullabilities) { Nullness override = provider.getParameterNullability(parameter); nullability = nullability.override(override); } return nullability; }
/** * Append an array type signature * * @param type Array type to append * @param nullable Nullness of type * @param output Output to append to * @param <A> Type of output * @return Supplied output to append to */ public <A extends Appendable> A appendArrayTypeSignature(Generic type, Nullness nullable, A output) { try { output.append('[').append(nullable.getMarker()); appendJavaTypeSignature(Validate.notNull(type.getComponentType()), Nullness.UNDEFINED, output); return output; } catch (Exception e) { throw new RuntimeException(String.format("Could not write array type %s", type)); } }
/** * Override this nullability with another one * * @param override Override nullability * @return Nullability that overrides this with another nullability */ public default Nullability override(Nullability override) { return new CombinedNullability(this, override); }
/** * @see me.seeber.gradle.ide.eclipse.annotations.Nullability#getReturnValueNullability(net.bytebuddy.description.method.MethodDescription) */ @Override public Nullness getReturnValueNullability(MethodDescription method) { Nullness nullability = getNullability(method.getDeclaredAnnotations()); return nullability; }
/** * Create a new AnnotationsJarBuilder * * @param jarFile JAR file to read * @param classLoader Class loader to resolve types */ public JarReader(File jarFile, ClassLoader classLoader) { this.classLoader = classLoader; try { openJarFile(jarFile); } catch (IOException e) { throw new RuntimeException("Cannot create annotations JAR builder", e); } }
/** * Append type arguments * * @param buf Buffer to append to * @param typeArguments Type arguments * @return <code>true</code> if any nullability information was written * @throws IOException I'm sorry, this usually doesn't happen to me... */ protected boolean appendTypeArguments(StringBuilder buf, TypeList.Generic typeArguments) throws IOException { String plainTypeVariables = this.signatureWriter.appendTypeArguments(typeArguments, new StringBuilder()) .toString(); String annotatedTypeVariables = this.signatureWriter.appendTypeArguments(typeArguments, new StringBuilder()) .toString(); buf.append(plainTypeVariables).append("\n"); buf.append(annotatedTypeVariables).append("\n"); boolean annotated = plainTypeVariables.equals(annotatedTypeVariables); return annotated; }
/** * Append type parameters * * @param buf Buffer to append to * @param typeParameters Type parameters * @param annotatedSignatureWriter Signature writer * @return <code>true</code> if any nullability information was written * @throws IOException if we fail completely... */ protected boolean appendTypeParameters(StringBuilder buf, TypeList.Generic typeParameters, MethodSignatureWriter annotatedSignatureWriter) throws IOException { String plainTypeVariables = this.signatureWriter.appendTypeParameters(typeParameters, new StringBuilder()) .toString(); String annotatedTypeVariables = annotatedSignatureWriter .appendTypeParameters(typeParameters, new StringBuilder()).toString(); buf.append(plainTypeVariables).append("\n"); buf.append(annotatedTypeVariables).append("\n"); boolean annotated = !plainTypeVariables.equals(annotatedTypeVariables); return annotated; }
/** * Get the target file for an input file * * @param jarFile Source JAR file * @return Target file */ protected File getTargetFile(File jarFile) { String baseName = Files.getNameWithoutExtension(jarFile.getName()); File annotationJarFile = new File(getDestinationDir(), baseName + "-annotations.zip"); return annotationJarFile; }
/** * Create a new task */ public EclipseAnnotationsTask() { this.jars = Collections.emptySet(); this.destinationDir = new File(getProject().getBuildDir(), "annotations"); }