Again great queries. Here is another view of the same queries:
Query 1:
class InputStreamReaderRefType extends RefType {
InputStreamReaderRefType() {
this.getASupertype*().hasQualifiedName("java.io","InputStreamReader")
}
Constructor getInputStreamReaderConstructor() {
result.getDeclaringType() = this and
result.getNumberOfParameters() = 1 and
((Class)result.getAParameter().getType()).
hasQualifiedName("java.io", "InputStream")
}
}
from Callable m
where m.fromSource() and
exists(InputStreamReaderRefType t | m.calls(t.getInputStreamReaderConstructor()))
select m.getDeclaringType(), m
Query 2:
class OutputStreamWriterRefType extends RefType {
OutputStreamWriterRefType() {
this.getASupertype*().hasQualifiedName("java.io","OutputStreamWriter")
}
Constructor getOutputStreamWriterConstructor() {
result.getDeclaringType() = this and
result.getNumberOfParameters() = 1 and
((Class)result.getAParameter().getType()).
hasQualifiedName("java.io", "OutputStream")
}
}
from Callable m
where m.fromSource() and
exists(OutputStreamWriterRefType t | m.calls(t.getOutputStreamWriterConstructor()))
select m.getDeclaringType(), m
If you are using an introduced class just for one query, there is no need to put it into the default.ql library. You can define and use new .QL classes as well directly in the quick query editor.
Looking forward to some more cool queries!
