1- import { anyClassOrFunctionName , PythonType } from "./python" ;
1+ import { simpleIdentifier , PythonType } from "./python" ;
22
33/**
44 * The source of a type estimation.
@@ -58,7 +58,7 @@ export class TypeSearch {
5858 return new VariableSearchResult ( typeName , EstimationSource . Value , valueAssignment ) ;
5959 }
6060
61- match = new RegExp ( `^ *(${ anyClassOrFunctionName } )\\(?` ) . exec ( valueAssignment ) ;
61+ match = new RegExp ( `^ *(${ simpleIdentifier } )\\(?` ) . exec ( valueAssignment ) ;
6262 if ( ! match ) {
6363 return null ;
6464 }
@@ -152,7 +152,7 @@ export class TypeSearch {
152152 * @returns The type hint of the found parameter or null.
153153 */
154154 public static hintOfSimilarParam ( param : string , src : string ) : string | null {
155- const m = new RegExp ( `^[ \t]*def ${ anyClassOrFunctionName } \\([^)]*\\b${ param } \\b: *([^), ]+)` , "m" ) . exec ( src ) ;
155+ const m = new RegExp ( `^[ \t]*def ${ simpleIdentifier } \\([^)]*\\b${ param } \\b: *([^),\\s ]+)` , "m" ) . exec ( src ) ;
156156 if ( m ) {
157157 let hint = m [ 1 ] . trim ( ) ;
158158 return hint ? hint : null ;
@@ -209,7 +209,7 @@ export class TypeSearch {
209209
210210 if ( s . length === 2 && module !== type ) {
211211 match = new RegExp (
212- `^[ \t]*import +${ module } |^[ \t]*from ${ anyClassOrFunctionName } import (${ module } )` , "m"
212+ `^[ \t]*import +${ module } |^[ \t]*from ${ simpleIdentifier } import (${ module } )` , "m"
213213 ) . exec ( src ) ;
214214 if ( match ) {
215215 // Return 'Object.Type' for 'from x import Object'
@@ -227,9 +227,9 @@ export class TypeSearch {
227227 */
228228 private static isImported ( value : string , src : string , checkForAsImports : boolean = true ) : boolean {
229229
230- let exp = `^[ \t]*(from +${ anyClassOrFunctionName } +import +${ value } ` ;
230+ let exp = `^[ \t]*(from +${ simpleIdentifier } +import +${ value } ` ;
231231 if ( checkForAsImports ) {
232- exp += `|from +${ anyClassOrFunctionName } +import +${ anyClassOrFunctionName } +as +${ value } ` ;
232+ exp += `|from +${ simpleIdentifier } +import +${ simpleIdentifier } +as +${ value } ` ;
233233 }
234234 exp += ")" ;
235235 return new RegExp ( exp , "m" ) . test ( src ) ;
0 commit comments