Package com.intellij.openapi.vfs

Examples of com.intellij.openapi.vfs.VirtualFile


                                     final String beforeText,
                                     String textAfter,
                                     LanguageFileType templateDataLanguageType) {
    PsiFile baseFile = createFile("A.hbs", beforeText);

    VirtualFile virtualFile = baseFile.getVirtualFile();
    assert virtualFile != null;
    TemplateDataLanguageMappings.getInstance(getProject()).setMapping(virtualFile, templateDataLanguageType.getLanguage());

    // fetch a fresh instance of the file -- the template data mapping creates a new instance,
    // which was causing problems in PsiFileImpl.isValid()
View Full Code Here


  private Color getBackgroundColor(boolean isSelected, Usage usage) {
    Color fileBgColor = null;
    if (isSelected) {
      fileBgColor = UIUtil.getListSelectionBackground();
    } else {
      VirtualFile virtualFile =
          usage instanceof UsageInFile ? ((UsageInFile) usage).getFile() : null;
      if (virtualFile != null) {
        Project project = myUsageView.getProject();
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
        if (psiFile != null && psiFile.isValid()) {
View Full Code Here

    Color color = null;
    final PsiElement psi = converter.fun(object);
    if (psi != null) {
      if (!psi.isValid()) return null;

      final VirtualFile file = PsiUtilCore.getVirtualFile(psi);

      if (file != null) {
        color = FileColorManager.getInstance(project).getFileColor(file);
      } else if (psi instanceof PsiDirectory) {
        color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
View Full Code Here

                FileDocumentManager fdm = FileDocumentManager.getInstance();
                fdm.saveAllDocuments();
            }
        }, ModalityState.any());

        VirtualFile file = psiFile.getVirtualFile();
        if (file == null)
            return null;
        Module module = DeclarationPosition.getDeclModule(psiFile);
        if (module == null)
            return null;
        List<GHCMessage> ghcMessages = LaunchGHC.compile(null, file.getPath(), module, true);
        return new AnnotationResult(file, ghcMessages);
    }
View Full Code Here

    private static void compileFiles(CompileContext context, Module module, List<VirtualFile> toCompile,
                                     OutputSink sink, boolean tests) {
        if (CompilerLocation.get(module) == null)
            return; // todo: produce error
        VirtualFile outputDir = getMainOutput(context, module, tests);
        List<OutputItem> output = new ArrayList<OutputItem>();
        // todo: pass all files to compiler at once (more effective?)
        for (VirtualFile file : toCompile) {
            for (GHCMessage message : LaunchGHC.compile(outputDir, file.getPath(), module, tests)) {
                VirtualFile errFile = LocalFileSystem.getInstance().findFileByPath(message.getFileName());
                String url = errFile == null ? message.getFileName() : errFile.getUrl();
                LineCol coord = message.getRange().start;
                context.addMessage(
                    message.getCategory(), message.getErrorMessage(),
                    url,
                    coord.line, coord.column
View Full Code Here

        return new DocumentBasedFormattingModel(root, file.getProject(), settings, file.getFileType(), file);
    }

    private static Block doCreateModel(PsiElement element) throws IOException, InterruptedException, NoMatchException {
        final PsiFile file = element.getContainingFile();
        VirtualFile virtualFile = file.getVirtualFile();
        if (virtualFile == null)
            return null;
        Module module = DeclarationPosition.getDeclModule(file);
        CompilerLocation compiler = CompilerLocation.get(module);
        if (compiler == null)
            return null;
        List<String> args = compiler.getCompileOptionsList(
            "-m", "ParseTree",
            virtualFile.getPath()
        );
        ProcessLauncher launcher = new ProcessLauncher(false, virtualFile.getInputStream(), args);
        String stdOut = launcher.getStdOut();
        if (stdOut.trim().isEmpty())
            return null;
        RangeFactory factory = new RangeFactory() {
View Full Code Here

    }

    @Override
    public void checkConfiguration() throws RuntimeConfigurationException {
        super.checkConfiguration();
        VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(this.mainFile);
        if (file == null || !file.exists())
            throw new RuntimeConfigurationException("Main file does not exist");
        boolean hasMain = false;
        try {
            hasMain = HaskellRunConfigurationProducer.hasMain(file, getModule());
        } catch (Exception e) {
            LOG.error(e.getMessage());
        }
        if (!hasMain)
            throw new RuntimeConfigurationException(file.getName() + " is not a valid main file (does not have `main' function)");
    }
View Full Code Here

    public String getMainFile() {
        return ExternalizablePath.localPathValue(mainFile);
    }

    public void setMainFile(HaskellFile mainFile) {
        VirtualFile file = mainFile.getVirtualFile();
        if (file != null) {
            this.mainFile = file.getUrl();
            Module module = DeclarationPosition.getDeclModule(mainFile);
            setModule(module);
        }
    }
View Full Code Here

    // end of getters/setters

    @Override
    public String suggestedName() {
        VirtualFile file;
        if (mainFile == null) {
            file = null;
        } else {
            file = VirtualFileManager.getInstance().findFileByUrl(mainFile);
        }
        if (file == null) {
            return "Unnamed";
        } else {
            return file.getName();
        }
    }
View Full Code Here

        PsiFile file = psiElement.getContainingFile();
        if (!(file instanceof HaskellFile))
            return false;
        HaskellFile hsFile = (HaskellFile) file;
        try {
            VirtualFile virtualFile = file.getVirtualFile();
            if (virtualFile == null)
                return false;
            if (!hasMain(virtualFile, context.getModule()))
                return false;
            runFile = hsFile;
            Project project = file.getProject();
            configuration.setMainFile(runFile);
            VirtualFile baseDir = project.getBaseDir();
            if (baseDir != null) {
                configuration.setWorkingDirectory(baseDir.getPath());
            }
            configuration.setName(configuration.suggestedName());
            return true;
        } catch (Exception ex) {
            LOG.error(ex);
View Full Code Here

TOP

Related Classes of com.intellij.openapi.vfs.VirtualFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.