Skip to content

Commit 8121c7f

Browse files
author
Stephan Brandauer
committed
Java: Automodel application mode: add method doc and class doc as related locations
1 parent 0115ba0 commit 8121c7f

4 files changed

+19
-4
lines changed

java/ql/automodel/src/AutomodelApplicationModeCharacteristics.qll

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ private import AutomodelSharedGetCallable as AutomodelSharedGetCallable
1919
import AutomodelSharedCharacteristics as SharedCharacteristics
2020
import AutomodelEndpointTypes as AutomodelEndpointTypes
2121

22-
newtype JavaRelatedLocationType = CallContext()
22+
newtype JavaRelatedLocationType =
23+
CallContext() or
24+
MethodDoc() or
25+
ClassDoc()
2326

2427
newtype TApplicationModeEndpoint =
2528
TExplicitArgument(Call call, DataFlow::Node arg) {
@@ -312,6 +315,12 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
312315
RelatedLocation getRelatedLocation(Endpoint e, RelatedLocationType type) {
313316
type = CallContext() and
314317
result = e.getCall()
318+
or
319+
type = MethodDoc() and
320+
result = e.getCallable().(Documentable).getJavadoc()
321+
or
322+
type = ClassDoc() and
323+
result = e.getCallable().getDeclaringType().(Documentable).getJavadoc()
315324
}
316325
}
317326

java/ql/automodel/src/AutomodelApplicationModeExtractCandidates.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ where
8989
sinkType, ", "
9090
)
9191
select endpoint.asNode(),
92-
message + "\nrelated locations: $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@, $@, $@.", //
92+
message + "\nrelated locations: $@, $@, $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@, $@, $@.", //
9393
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, CallContext()), "CallContext", //
94+
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, MethodDoc()), "MethodDoc", //
95+
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, ClassDoc()), "ClassDoc", //
9496
package, "package", //
9597
type, "type", //
9698
subtypes, "subtypes", //

java/ql/automodel/src/AutomodelApplicationModeExtractNegativeExamples.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ where
6666
) and
6767
message = characteristic
6868
select endpoint.asNode(),
69-
message + "\nrelated locations: $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@.", //
69+
message + "\nrelated locations: $@, $@, $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@.", //
7070
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, CallContext()), "CallContext", //
71+
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, MethodDoc()), "MethodDoc", //
72+
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, ClassDoc()), "ClassDoc", //
7173
package, "package", //
7274
type, "type", //
7375
subtypes, "subtypes", //

java/ql/automodel/src/AutomodelApplicationModeExtractPositiveExamples.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ where
2727
CharacteristicsImpl::isKnownAs(endpoint, endpointType, _) and
2828
exists(CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, CallContext()))
2929
select endpoint.asNode(),
30-
endpointType + "\nrelated locations: $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@.", //
30+
endpointType + "\nrelated locations: $@, $@, $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@.", //
3131
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, CallContext()), "CallContext", //
32+
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, MethodDoc()), "MethodDoc", //
33+
CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, ClassDoc()), "ClassDoc", //
3234
package, "package", //
3335
type, "type", //
3436
subtypes, "subtypes", //

0 commit comments

Comments
 (0)