use of com.jopdesign.common.type.MemberID in project jop by jop-devel.
the class DFATool method getReceiverMethods.
public Set<MethodInfo> getReceiverMethods(InstructionHandle stmt, CallString cs) {
Set<String> receivers = getReceivers(stmt, cs);
Set<MethodInfo> methods = new LinkedHashSet<MethodInfo>(receivers.size());
for (String rcv : receivers) {
MemberID mID = MemberID.parse(rcv);
methods.add(appInfo.getMethodInfoInherited(mID));
}
return methods;
}
use of com.jopdesign.common.type.MemberID in project jop by jop-devel.
the class SourceLineStorage method loadSourceInfos.
/**
* Load all source file and -line annotations for all classes from the storage file.
*/
public void loadSourceInfos() {
if (sourceLineMap == null) {
try {
readSourceInfos();
} catch (IOException e) {
logger.error("Error reading sourceline file " + storage, e);
}
}
Map<MethodInfo, List<SourceLineEntry>> methodMap = new HashMap<MethodInfo, List<SourceLineEntry>>(sourceLineMap.size());
for (MemberID mID : sourceLineMap.keySet()) {
try {
MethodInfo method = AppInfo.getSingleton().getMethodInfo(mID);
methodMap.put(method, sourceLineMap.get(mID));
} catch (MethodNotFoundException ignored) {
logger.warn("No method for entry " + mID + " in " + storage + " found!");
}
}
for (MethodInfo method : methodMap.keySet()) {
try {
if (AppInfo.getSingleton().getClassFile(method.getClassInfo()).getTime() > storage.lastModified()) {
logger.error("One or more class files are newer than annotation file " + storage + ", not loading source line annotations!");
return;
}
} catch (FileNotFoundException e) {
logger.error("Could not get class file for class " + method.getClassInfo() + ", not loading source lines!", e);
return;
}
}
for (Map.Entry<MethodInfo, List<SourceLineEntry>> entry : methodMap.entrySet()) {
MethodInfo method = entry.getKey();
applySourceInfos(method, entry.getValue());
}
}
use of com.jopdesign.common.type.MemberID in project jop by jop-devel.
the class SourceLineStorage method readSourceInfos.
private void readSourceInfos() throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(storage));
sourceLineMap = new HashMap<MemberID, List<SourceLineEntry>>();
String entry;
List<SourceLineEntry> entries = null;
//noinspection NestedAssignment
while ((entry = reader.readLine()) != null) {
entry = entry.trim();
if (entry.startsWith("[")) {
int p1 = entry.indexOf(']');
String methodID = entry.substring(1, p1);
entries = new ArrayList<SourceLineEntry>();
MemberID id = MemberID.parse(methodID);
sourceLineMap.put(id, entries);
} else if (!"".equals(entry)) {
assert entries != null;
entries.add(SourceLineEntry.readEntry(entry));
}
}
reader.close();
}
use of com.jopdesign.common.type.MemberID in project jop by jop-devel.
the class UsedCodeFinder method visitReferences.
private void visitReferences(Set<String> refs) {
for (String id : refs) {
// The member IDs returned by the reference finder use a syntax which is
// always unique, so if in doubt, we need to interpret it as a classname, not a fieldname
MemberID sig = MemberID.parse(id, false);
// find/load the corresponding classInfo
ClassInfo cls = getClassInfo(sig);
// class has been excluded from loading, skip this class
if (cls == null) {
continue;
}
// referenced class is used, visit it if it has not yet been visited, but skip its class members
// Note that this class might be different than the class containing the class member
markUsedMembers(cls, false);
// check if this id specifies a class member (or just a class, in this case we are done)
if (sig.hasMethodSignature()) {
// It's a method! mark the method as used (implementations are marked later)
MethodRef ref = appInfo.getMethodRef(sig);
MethodInfo method = ref.getMethodInfo();
// we keep the declarations. We mark it without following it and make it abstract later.
if (method != null) {
setMark(method, false);
}
} else if (sig.hasMemberName()) {
// It's a field! No need to look in subclasses, fields are not virtual
FieldRef ref = appInfo.getFieldRef(sig);
FieldInfo field = ref.getFieldInfo();
if (field != null) {
markUsedMembers(field);
}
}
}
}
use of com.jopdesign.common.type.MemberID in project jop by jop-devel.
the class ProjectConfig method getTargetClass.
public String getTargetClass() {
MemberID sig = MemberID.parse(getTargetMethodName(), true);
String measureClass = sig.getClassName();
if (measureClass == null)
return getAppClassName();
else
return measureClass;
}
Aggregations