Skip to content

Commit

Permalink
[MSHARED-1407] Optimize imports, revert formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredstehler committed Jun 3, 2024
1 parent a8e809e commit 16fa4b0
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ public class DefaultProjectDependencyAnalyzer implements ProjectDependencyAnalyz
@Inject
private DependencyAnalyzer dependencyAnalyzer;

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public ProjectDependencyAnalysis analyze(MavenProject project, Collection<String> excludedClasses)
throws ProjectDependencyAnalyzerException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
*/
package org.apache.maven.shared.dependency.analyzer;

import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.maven.artifact.Artifact;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,29 @@ public DefaultAnnotationVisitor(ResultCollector resultCollector, String usedByCl
this.usedByClass = usedByClass;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visit(final String name, final Object value) {
if (value instanceof Type) {
resultCollector.addType(usedByClass, (Type) value);
}
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitEnum(final String name, final String desc, final String value) {
resultCollector.addDesc(usedByClass, desc);
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public AnnotationVisitor visitAnnotation(final String name, final String desc) {
resultCollector.addDesc(usedByClass, desc);

return this;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public AnnotationVisitor visitArray(final String name) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
*/
package org.apache.maven.shared.dependency.analyzer.asm;

import org.objectweb.asm.*;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;

Expand All @@ -44,11 +49,11 @@ public class DefaultClassVisitor extends ClassVisitor {
/**
* <p>Constructor for DefaultClassVisitor.</p>
*
* @param signatureVisitor a {@link org.objectweb.asm.signature.SignatureVisitor} object.
* @param signatureVisitor a {@link org.objectweb.asm.signature.SignatureVisitor} object.
* @param annotationVisitor a {@link org.objectweb.asm.AnnotationVisitor} object.
* @param fieldVisitor a {@link org.objectweb.asm.FieldVisitor} object.
* @param methodVisitor a {@link org.objectweb.asm.MethodVisitor} object.
* @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object.
* @param fieldVisitor a {@link org.objectweb.asm.FieldVisitor} object.
* @param methodVisitor a {@link org.objectweb.asm.MethodVisitor} object.
* @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object.
*/
public DefaultClassVisitor(
SignatureVisitor signatureVisitor,
Expand Down Expand Up @@ -92,19 +97,15 @@ public void visit(
}
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
resultCollector.addDesc(usedByClass, desc);

return annotationVisitor;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public FieldVisitor visitField(
final int access, final String name, final String desc, final String signature, final Object value) {
Expand All @@ -124,10 +125,10 @@ public FieldVisitor visitField(
/**
* <p>visitMethod.</p>
*
* @param access a int.
* @param name a {@link java.lang.String} object.
* @param desc a {@link java.lang.String} object.
* @param signature a {@link java.lang.String} object.
* @param access a int.
* @param name a {@link java.lang.String} object.
* @param desc a {@link java.lang.String} object.
* @param signature a {@link java.lang.String} object.
* @param exceptions an array of {@link java.lang.String} objects.
* @return a {@link org.objectweb.asm.MethodVisitor} object.
*/
Expand All @@ -145,17 +146,13 @@ public MethodVisitor visitMethod(
return methodVisitor;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitNestHost(final String nestHost) {
resultCollector.addName(usedByClass, nestHost);
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitNestMember(final String nestMember) {
resultCollector.addName(usedByClass, nestMember);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class DefaultFieldVisitor extends FieldVisitor {
* <p>Constructor for DefaultFieldVisitor.</p>
*
* @param annotationVisitor a {@link org.objectweb.asm.AnnotationVisitor} object.
* @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object.
* @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object.
*/
public DefaultFieldVisitor(
AnnotationVisitor annotationVisitor, ResultCollector resultCollector, String usedByClass) {
Expand All @@ -49,9 +49,7 @@ public DefaultFieldVisitor(
this.usedByClass = usedByClass;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
resultCollector.addDesc(usedByClass, desc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class DefaultMethodVisitor extends MethodVisitor {
* <p>Constructor for DefaultMethodVisitor.</p>
*
* @param annotationVisitor a {@link org.objectweb.asm.AnnotationVisitor} object.
* @param signatureVisitor a {@link org.objectweb.asm.signature.SignatureVisitor} object.
* @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object.
* @param signatureVisitor a {@link org.objectweb.asm.signature.SignatureVisitor} object.
* @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object.
*/
public DefaultMethodVisitor(
AnnotationVisitor annotationVisitor,
Expand All @@ -64,39 +64,31 @@ public DefaultMethodVisitor(
this.usedByClass = usedByClass;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
resultCollector.addDesc(usedByClass, desc);

return annotationVisitor;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
resultCollector.addDesc(usedByClass, desc);

return annotationVisitor;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public AnnotationVisitor visitParameterAnnotation(final int parameter, final String desc, final boolean visible) {
resultCollector.addDesc(usedByClass, desc);

return annotationVisitor;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public AnnotationVisitor visitLocalVariableAnnotation(
int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible) {
Expand All @@ -105,9 +97,7 @@ public AnnotationVisitor visitLocalVariableAnnotation(
return annotationVisitor;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitTypeInsn(final int opcode, final String desc) {
if (desc.charAt(0) == '[') {
Expand All @@ -117,9 +107,7 @@ public void visitTypeInsn(final int opcode, final String desc) {
}
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
resultCollector.addName(usedByClass, owner);
Expand All @@ -131,35 +119,27 @@ public void visitFieldInsn(final int opcode, final String owner, final String na
*/
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
resultCollector.addName(usedByClass, owner);
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitLdcInsn(final Object cst) {
if (cst instanceof Type) {
resultCollector.addType(usedByClass, (Type) cst);
}
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitMultiANewArrayInsn(final String desc, final int dims) {
resultCollector.addDesc(usedByClass, desc);
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitTryCatchBlock(final Label start, final Label end, final Label handler, final String type) {
resultCollector.addName(usedByClass, type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ public DefaultSignatureVisitor(ResultCollector resultCollector, String usedByCla
this.usedByClass = usedByClass;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitClassType(final String name) {
resultCollector.addName(usedByClass, name);
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitInnerClassType(final String name) {
resultCollector.addName(usedByClass, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
import org.apache.maven.shared.dependency.analyzer.ClassFileVisitor;
import org.apache.maven.shared.dependency.analyzer.ClassesPatterns;
import org.apache.maven.shared.dependency.analyzer.DependencyUsage;
import org.objectweb.asm.*;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.signature.SignatureVisitor;

/**
Expand Down Expand Up @@ -59,9 +63,7 @@ public DependencyClassFileVisitor() {
this(new ClassesPatterns());
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void visitClass(String className, InputStream in) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.objectweb.asm.*;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureVisitor;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down

0 comments on commit 16fa4b0

Please sign in to comment.