@ SuppressWarnings ( "static-method" ) protected Map < XVariableDeclaration , XFeatureCall > getReferencedLocalVariable ( XExpression expression , boolean onlyWritable ) { final Map < XVariableDeclaration , XFeatureCall > localVariables = new TreeMap <> ( ( k1 , k2 ) -> { return k1 . getIdentifier ( ) . compareTo ( k2 . getIdentifier ( ) ) ; } ) ; for ( final XFeatureCall featureCall : EcoreUtil2 . getAllContentsOfType ( expression , XFeatureCall . class ) ) { if ( featureCall . getFeature ( ) instanceof XVariableDeclaration ) { final XVariableDeclaration localVariable = ( XVariableDeclaration ) featureCall . getFeature ( ) ; if ( ( ! onlyWritable || localVariable . isWriteable ( ) ) && ! localVariables . containsKey ( localVariable ) ) { localVariables . put ( localVariable , featureCall ) ; } } } return localVariables ; }
Replies all the variables that are referenced into the given expression .