1+ // Query deprecated type and member usage by non deprecated elements
2+
3+ MATCH (annotated )- [ : ANNOTATED_BY ] -> (:Annotation )- [ : OF_TYPE ] -> (:Type { fqn : 'java.lang.Deprecated' } )
4+ OPTIONAL MATCH (artifactReadsDeprecated :Artifact )- [ : CONTAINS ] -> (typeReadsDeprecated :Type )- [ : DECLARES ] -> (readsDeprecated :Method )- [ : READS ] -> (annotated :Field )
5+ OPTIONAL MATCH (artifactInvokesDeprecated :Artifact )- [ : CONTAINS ] -> (typeInvokesDeprecated :Type )- [ : DECLARES ] -> (invokesDeprecated :Method )- [ : INVOKES ] -> (annotated :Method )
6+ OPTIONAL MATCH (artifactInvokesParameterDeprecated :Artifact )- [ : CONTAINS ] -> (typeInvokesParameterDeprecated :Type )- [ : DECLARES ] -> (invokesParameterDeprecated :Method )- [ : INVOKES ] -> (parameterAnnotatedMethod :Method )- [ : HAS ] -> (annotated :Parameter )
7+ OPTIONAL MATCH (artifactDependsOnDeprecated :Artifact )- [ : CONTAINS ] -> (typeDependsOnDeprecated :Type )- [ : DEPENDS_ON ] -> (annotated :Type )
8+ WITH coalesce (artifactReadsDeprecated , artifactInvokesDeprecated , artifactInvokesParameterDeprecated , artifactDependsOnDeprecated ) AS artifact
9+ ,coalesce (typeReadsDeprecated , typeInvokesDeprecated , typeInvokesParameterDeprecated , typeDependsOnDeprecated ) AS type
10+ ,coalesce (readsDeprecated , invokesDeprecated , invokesParameterDeprecated ) AS method
11+ ,CASE WHEN 'Annotation' IN labels (annotated ) THEN 'Annotation'
12+ WHEN 'Parameter' IN labels (annotated ) THEN 'Parameter'
13+ WHEN 'Field' IN labels (annotated ) THEN 'Field'
14+ WHEN 'Constructor' IN labels (annotated ) THEN 'Constructor'
15+ WHEN 'Method' IN labels (annotated ) THEN 'Method'
16+ WHEN 'Member' IN labels (annotated ) THEN 'Member'
17+ WHEN 'Class' IN labels (annotated ) THEN 'Class'
18+ WHEN 'Interface' IN labels (annotated ) THEN 'Interface'
19+ WHEN 'Enum' IN labels (annotated ) THEN 'Enum'
20+ WHEN 'Type' IN labels (annotated ) THEN 'Type'
21+ ELSE 'Unexpected'
22+ END AS deprecatedElement
23+ ,coalesce (typeReadsDeprecated .fqn + '.' + readsDeprecated .name
24+ ,typeInvokesDeprecated .fqn + '.' + invokesDeprecated .name
25+ ,typeInvokesParameterDeprecated .fqn + '.' + invokesParameterDeprecated .name
26+ ,typeDependsOnDeprecated .fqn
27+ ) AS elementUsingDeprecatedElement
28+ WHERE artifact IS NOT NULL
29+ AND NOT (type )- [ : ANNOTATED_BY ] -> (:Annotation )- [ : OF_TYPE ] -> (:Type { fqn : 'java.lang.Deprecated' } )
30+ AND NOT (method )- [ : ANNOTATED_BY ] -> (:Annotation )- [ : OF_TYPE ] -> (:Type { fqn : 'java.lang.Deprecated' } )
31+ RETURN replace (last (split (artifact .fileName , '/' )), '.jar' , '' ) AS artifactName
32+ ,deprecatedElement
33+ ,count (DISTINCT elementUsingDeprecatedElement ) AS numberOfElementsUsingDeprecatedElements
34+ ,collect (DISTINCT elementUsingDeprecatedElement )[0 ..19 ] AS someElementsUsingDeprecatedElements
35+ ORDER BY artifactName ASCENDING
0 commit comments