Skip to content

Commit

Permalink
removed getClassTypes()
Browse files Browse the repository at this point in the history
  • Loading branch information
sahilagichani14 committed Nov 15, 2024
1 parent 51d68ba commit 66eadd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,4 @@ private synchronized void resolveAll() {
.forEach(this::buildClassFrom);
isFullyResolved = true;
}

/** This is expensive, don't use in production code. Use it only for test case for convenience. */
@Nonnull
public Optional<ClassType> getClassTypes(@Nonnull AnalysisInputLocation analysisInputLocation) {
Collection<? extends SootClassSource> classSources =
analysisInputLocation.getClassSources(this);
return classSources.stream().map(AbstractClassSource::getClassType).findAny();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
* #L%
*/

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

import java.util.Collections;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import sootup.core.model.SourceType;
import sootup.core.signatures.MethodSignature;
import sootup.core.types.VoidType;
import sootup.interceptors.DeadAssignmentEliminator;

@Tag("Java8")
public class JimpleStringAnalysisInputLocationTest {
Expand Down Expand Up @@ -61,15 +61,17 @@ public void test() {

JimpleStringAnalysisInputLocation analysisInputLocation =
new JimpleStringAnalysisInputLocation(
methodStr, SourceType.Application, Collections.emptyList());
methodStr,
SourceType.Application,
Collections.singletonList(new DeadAssignmentEliminator()));

JimpleView view = new JimpleView(Collections.singletonList(analysisInputLocation));
assertTrue(view.getClassTypes(analysisInputLocation).isPresent());
assertNotNull(view.getIdentifierFactory().getClassType("DummyClass"));

MethodSignature methodSig =
view.getIdentifierFactory()
.getMethodSignature(
view.getClassTypes(analysisInputLocation).get(),
view.getIdentifierFactory().getClassType("DummyClass"),
"banana",
VoidType.getInstance(),
Collections.emptyList());
Expand Down

0 comments on commit 66eadd3

Please sign in to comment.