use of io.flutter.pub.PubRoot in project flutter-intellij by flutter.
the class TestFields method getRelativePath.
/**
* Returns the relative path to the file or directory from the pub root, or null if not in a pub root.
*/
@Nullable
public String getRelativePath(@NotNull Project project) {
final PubRoot root = getPubRoot(project);
if (root == null)
return null;
final VirtualFile fileOrDir = getFileOrDir();
if (fileOrDir == null)
return null;
return root.getRelativePath(fileOrDir);
}
use of io.flutter.pub.PubRoot in project flutter-intellij by flutter.
the class TestFields method getPubRoot.
/**
* Returns the PubRoot containing the file or directory being tested, or null if none.
*/
@Nullable
public PubRoot getPubRoot(@NotNull Project project) {
final VirtualFile dir = getFileOrDir();
final PubRoot root = PubRoot.forFile(dir);
return root != null ? root : PubRoot.forDescendant(dir, project);
}
use of io.flutter.pub.PubRoot in project flutter-intellij by flutter.
the class TestLaunchState method getBaseDir.
@Nullable
private String getBaseDir() {
final PubRoot root = config.getFields().getPubRoot(config.getProject());
if (root != null) {
return root.getPath();
}
final VirtualFile baseDir = config.getProject().getBaseDir();
return baseDir == null ? null : baseDir.getPath();
}
use of io.flutter.pub.PubRoot in project flutter-intellij by flutter.
the class FlutterPluginsLibraryManager method getFlutterPluginPaths.
private Set<String> getFlutterPluginPaths(List<PubRoot> roots) {
final Set<String> paths = new HashSet<>();
for (PubRoot pubRoot : roots) {
if (pubRoot.getPackages() == null) {
continue;
}
final Map<String, String> map = DotPackagesFileUtil.getPackagesMap(pubRoot.getPackages());
if (map == null) {
continue;
}
for (String packagePath : map.values()) {
final VirtualFile libFolder = LocalFileSystem.getInstance().findFileByPath(packagePath);
if (libFolder == null) {
continue;
}
final PubRoot pluginRoot = PubRoot.forDirectory(libFolder.getParent());
if (pluginRoot == null) {
continue;
}
if (pluginRoot.isFlutterPlugin()) {
paths.add(pluginRoot.getPath());
}
}
}
return paths;
}
use of io.flutter.pub.PubRoot in project flutter-intellij by flutter.
the class FlutterModuleUtils method findXcodeProjectFile.
@Nullable
public static VirtualFile findXcodeProjectFile(@NotNull Project project) {
// Look for XCode metadata file in `ios/`.
for (PubRoot root : PubRoots.forProject(project)) {
final VirtualFile dir = root.getiOsDir();
final VirtualFile file = findPreferedXcodeMetadataFile(dir);
if (file != null) {
return file;
}
}
// Look for XCode metadata in `example/ios/`.
for (PubRoot root : PubRoots.forProject(project)) {
final VirtualFile exampleDir = root.getExampleDir();
final VirtualFile iosDir = exampleDir == null ? null : exampleDir.findChild("ios");
final VirtualFile file = findPreferedXcodeMetadataFile(iosDir);
if (file != null) {
return file;
}
}
return null;
}
Aggregations