Package com.intellij.openapi.vfs

Examples of com.intellij.openapi.vfs.VirtualFile


    public static Sdk getModuleGhc(@NotNull Module module) {
        Sdk ghc = ModuleRootManager.getInstance(module).getSdk();
        if (ghc == null)
            return null;
        VirtualFile homeDirectory = ghc.getHomeDirectory();
        if (homeDirectory == null || !homeDirectory.isValid())
            return null;
        return ghc;
    }
View Full Code Here


        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < sourceRoots.length; i++) {
            if (i > 0) {
                buf.append(':');
            }
            VirtualFile root = sourceRoots[i];
            buf.append(root.getPath());
        }
        return buf.toString();
    }
View Full Code Here

        if (module == null)
            return null;
        Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
        if (sdk == null)
            return null;
        VirtualFile ghcHome = sdk.getHomeDirectory();
        if (ghcHome == null)
            return null;
        SdkAdditionalData sdkAdditionalData = sdk.getSdkAdditionalData();
        if (!(sdkAdditionalData instanceof HaskellSdkAdditionalData))
            return null;
View Full Code Here

        if (!(element instanceof HPAbstractIdent))
            return null;
        HPAbstractIdent ident = (HPAbstractIdent) element;
        TextRange range = ident.getTextRange();
        PsiFile psiFile = element.getContainingFile();
        VirtualFile file = psiFile.getVirtualFile();
        if (file == null)
            return null;
        // todo: run in event-dispatch thread
        //fdm.saveAllDocuments();
        // try this: PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
        int offset = range.getStartOffset();
        LineCol coord = LineCol.fromOffset(psiFile, offset);
        Module module = DeclarationPosition.getDeclModule(psiFile);
        if (module == null)
            return null;
        CompilerLocation compiler = CompilerLocation.get(module);
        if (compiler == null) {
            return null;
        }
        try {
            String sourcePath = GHCUtil.rootsAsString(module, false);
            List<String> compilerArgs = compiler.getCompileOptionsList(
                "-m", "GetIdType",
                "-s", sourcePath,
                "--line-number", String.valueOf(coord.line), "--column-number", String.valueOf(coord.column),
                file.getPath()
            );
            ProcessLauncher idLauncher = new ProcessLauncher(false, null, compilerArgs);
            String stdOut = idLauncher.getStdOut();
            if (stdOut.trim().isEmpty())
                return null;
View Full Code Here

    @Nullable
    public static DeclarationPosition get(@NotNull PsiFile psiFile, @Nullable LineCol coord) throws IOException, InterruptedException {
        if (coord == null)
            return null;
        VirtualFile file = psiFile.getVirtualFile();
        if (file == null)
            return null;
        Module module = getDeclModule(psiFile);
        CompilerLocation compiler = CompilerLocation.get(module);
        if (compiler == null)
            return null;
        String sourcePath = GHCUtil.rootsAsString(module, false);
        List<String> args = compiler.getCompileOptionsList(
            "-m", "GetDeclPos",
            "-s", sourcePath,
            "--line-number", String.valueOf(coord.line), "--column-number", String.valueOf(coord.column),
            "-f", file.getPath()
        );
        final List<String> srcFiles = new ArrayList<String>();
        ProjectFileIndex fileIndex = ProjectRootManager.getInstance(module.getProject()).getFileIndex();
        fileIndex.iterateContent(new ContentIterator() {
            public boolean processFile(VirtualFile virtualFile) {
View Full Code Here

    public static Module getDeclModule(PsiFile psiFile) {
        return getDeclModule(psiFile.getProject(), psiFile);
    }

    public static Module getDeclModule(Project project, PsiFileSystemItem psiFile) {
        VirtualFile file = psiFile.getVirtualFile();
        if (file == null)
            return null;
        return getModule(project, file);
    }
View Full Code Here

        );
        return rangeMarker.getStartOffset();
    }

    public static LineCol fromOffset(PsiFile psiFile, int offset) {
        VirtualFile file = psiFile.getVirtualFile();
        if (file == null)
            return null;
        FileDocumentManager fdm = FileDocumentManager.getInstance();
        Document doc = fdm.getCachedDocument(file);
        if (doc == null)
View Full Code Here

    @Nullable
    private static String suggestLibPath(@Nullable Sdk sdk) {
        if (sdk == null)
            return null;
        VirtualFile ghcHome = sdk.getHomeDirectory();
        if (ghcHome == null)
            return null;
        String ghcLib = null;
        try {
            String ghcCommandPath = GHCUtil.getGhcCommandPath(ghcHome);
View Full Code Here

        try {
            DeclarationPosition declaration = DeclarationPosition.get(file, LineCol.fromOffset(file, element.getTextOffset()));
            if (declaration == null)
                return;
            LineCol coord = declaration.coord;
            VirtualFile virtualFile = file.getVirtualFile();
            Project project = file.getProject();
            ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
            if (virtualFile == null)
                return;
            Module module = fileIndex.getModuleForFile(virtualFile);
            CompilerLocation compiler = CompilerLocation.get(module);
            if (compiler == null)
                return;
            List<String> args = compiler.getCompileOptionsList(
                "-m", "FindUsages",
                "-s", GHCUtil.rootsAsString(module, false),
                "--line-number", String.valueOf(coord.line), "--column-number", String.valueOf(coord.column),
                "-f", virtualFile.getPath()
            );
            final List<String> srcFiles = new ArrayList<String>();
            fileIndex.iterateContent(new ContentIterator() {
                public boolean processFile(VirtualFile virtualFile) {
                    if (HaskellCompiler.isCompilableFile(virtualFile)) {
                        srcFiles.add(virtualFile.getPath());
                    }
                    return true;
                }
            });
            args.addAll(srcFiles);
View Full Code Here

            needsModuleName
                ? "module " + packages + moduleName + " where\n\n"
                : ""
        );
        file = (PsiFile) moduleDir.add(file);
        VirtualFile virtualFile = file.getVirtualFile();
        if (virtualFile != null) {
            FileEditorManager.getInstance(directory.getProject()).openFile(virtualFile, true);
        }
        return new PsiElement[] {file};
    }
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.