public static IImportSearchResult FindImports(this PathResolverSnapshot pathResolver, string modulePath, FromImportStatement fromImportStatement)
        {
            var rootNames = fromImportStatement.Root.Names.Select(n => n.Name);
            var dotCount  = fromImportStatement.Root is RelativeModuleName relativeName ? relativeName.DotCount : 0;

            return(pathResolver.FindImports(modulePath, rootNames, dotCount, fromImportStatement.ForceAbsolute));
        }
        public static IImportSearchResult FindImports(this PathResolverSnapshot pathResolver, string modulePath, FromImportStatement fromImportStatement)
        {
            var rootNames = fromImportStatement.Root.Names.Select(n => n.Name);

            return(fromImportStatement.Root is RelativeModuleName relativeName
                ? pathResolver.GetImportsFromRelativePath(modulePath, relativeName.DotCount, rootNames)
                : pathResolver.GetImportsFromAbsoluteName(modulePath, rootNames, fromImportStatement.ForceAbsolute));
        }
 public static IImportSearchResult FindImports(this PathResolverSnapshot pathResolver, string modulePath, IEnumerable <string> rootNames, int dotCount, bool forceAbsolute)
 => dotCount > 0
         ? pathResolver.GetImportsFromRelativePath(modulePath, dotCount, rootNames)
         : pathResolver.GetImportsFromAbsoluteName(modulePath, rootNames, forceAbsolute);
Example #4
0
 public PathResolver(PythonLanguageVersion pythonLanguageVersion)
 {
     _currentSnapshot = new PathResolverSnapshot(pythonLanguageVersion);
 }
 public static IImportSearchResult FindImports(this PathResolverSnapshot pathResolver, string modulePath, ModuleName importName, bool forceAbsolute)
 => pathResolver.GetImportsFromAbsoluteName(modulePath, importName.Names.Select(n => n.Name), forceAbsolute);
 public ChildrenSource(PathResolverSnapshot snapshot, ImmutableArray <Edge> edges)
 {
     _snapshot = snapshot;
     _edges    = edges;
 }
 public ChildrenSource(PathResolverSnapshot snapshot, Edge edge)
     : this(snapshot, ImmutableArray <Edge> .Create(edge))
 {
 }