Add source accessor to workspace
@@ -7,8 +7,7 @@ import com.github.javaparser.symbolsolver.JavaSymbolSolver;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
import me.coley.recaf.graph.flow.FlowGraph;
import me.coley.recaf.graph.inheritance.HierarchyGraph;
-import me.coley.recaf.parse.source.SourceCodeException;
-import me.coley.recaf.parse.source.WorkspaceTypeResolver;
+import me.coley.recaf.parse.source.*;
import org.objectweb.asm.ClassReader;
import java.util.*;
@@ -226,6 +225,22 @@ public class Workspace {
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
+ /**
+ * @param name
+ * Internal name of a Java class.
+ *
+ * @return Source wrapper of class.
+ */
+ public SourceCode getSource(String name) {
+ SourceCode code = primary.getClassSource(name);
+ if(code != null)
+ return code;
+ for(JavaResource resource : libraries)
+ if((code = resource.getClassSource(name)) != null)
+ break;
+ return code;
+ }
+
/**
* @return JavaParser config to assist in resolving symbols.
*/
