Search in sources :

Example 6 with DartFile

use of com.jetbrains.lang.dart.psi.DartFile in project intellij-plugins by JetBrains.

the class DartCommandLineRuntimeConfigurationProducer method getRunnableDartFileFromContext.

@Nullable
public static VirtualFile getRunnableDartFileFromContext(@NotNull final ConfigurationContext context, final boolean checkBrowserSpecificImports) {
    final PsiElement psiLocation = context.getPsiLocation();
    final PsiFile psiFile = psiLocation == null ? null : psiLocation.getContainingFile();
    final VirtualFile virtualFile = DartResolveUtil.getRealVirtualFile(psiFile);
    if (psiFile instanceof DartFile && virtualFile != null && ProjectRootManager.getInstance(context.getProject()).getFileIndex().isInContent(virtualFile) && !DartWritingAccessProvider.isInDartSdkOrDartPackagesFolder(psiFile.getProject(), virtualFile) && DartResolveUtil.getMainFunction(psiFile) != null && (!checkBrowserSpecificImports || !hasImport((DartFile) psiFile, "dart:html", "dart:html_common", "dart:indexed_db", "dart:js", "dart:svg", "dart:web_audio", "dart:web_gl", "dart:web_sql"))) {
        return virtualFile;
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartFile(com.jetbrains.lang.dart.psi.DartFile) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DartFile (com.jetbrains.lang.dart.psi.DartFile)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 PsiFile (com.intellij.psi.PsiFile)4 Nullable (org.jetbrains.annotations.Nullable)3 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 PsiElement (com.intellij.psi.PsiElement)2 ASTNode (com.intellij.lang.ASTNode)1 DocumentBasedFormattingModel (com.intellij.psi.formatter.DocumentBasedFormattingModel)1 DartCallExpression (com.jetbrains.lang.dart.psi.DartCallExpression)1 DartSdk (com.jetbrains.lang.dart.sdk.DartSdk)1 NotNull (org.jetbrains.annotations.NotNull)1