Search in sources :

Example 21 with PubRoot

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PubRoot(io.flutter.pub.PubRoot) Nullable(org.jetbrains.annotations.Nullable)

Example 22 with PubRoot

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PubRoot(io.flutter.pub.PubRoot) Nullable(org.jetbrains.annotations.Nullable)

Example 23 with PubRoot

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PubRoot(io.flutter.pub.PubRoot) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with PubRoot

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;
}
Also used : PubRoot(io.flutter.pub.PubRoot)

Example 25 with PubRoot

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PubRoot(io.flutter.pub.PubRoot) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PubRoot (io.flutter.pub.PubRoot)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)16 Nullable (org.jetbrains.annotations.Nullable)9 FlutterSdk (io.flutter.sdk.FlutterSdk)7 Project (com.intellij.openapi.project.Project)4 ExecutionException (com.intellij.execution.ExecutionException)3 OutputListener (com.intellij.execution.OutputListener)2 ApplicationInfo (com.intellij.openapi.application.ApplicationInfo)2 Module (com.intellij.openapi.module.Module)2 DartFile (com.jetbrains.lang.dart.psi.DartFile)2 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 PsiDirectory (com.intellij.psi.PsiDirectory)1