Search in sources :

Example 21 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoPathLibraryTest method createGoPath.

private VirtualFile createGoPath() throws IOException {
    VirtualFile goPath = VfsUtil.findFileByIoFile(FileUtil.createTempDirectory("go", "path"), true);
    tempRootsToClean.add(goPath);
    return goPath;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 22 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoConsoleFilterTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    VirtualFile workingDirectory = createTestRoot("workingDirectory");
    VirtualFile goPath = createTestRoot("goPath");
    GoApplicationLibrariesService.getInstance().setLibraryRootUrls(goPath.getUrl());
    myFilter = new GoConsoleFilter(myFixture.getProject(), myFixture.getModule(), workingDirectory.getUrl());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 23 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoCreateFileAction method postProcess.

@Override
protected void postProcess(PsiFile createdElement, String templateName, Map<String, String> customProperties) {
    if (createdElement instanceof GoFile) {
        GoPackageClause packageClause = ((GoFile) createdElement).getPackage();
        if (packageClause == null) {
            return;
        }
        Project project = createdElement.getProject();
        Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
        if (editor == null) {
            return;
        }
        VirtualFile virtualFile = createdElement.getContainingFile().getVirtualFile();
        if (virtualFile == null) {
            return;
        }
        if (FileDocumentManager.getInstance().getDocument(virtualFile) == editor.getDocument()) {
            editor.getCaretModel().moveToOffset(packageClause.getTextRange().getEndOffset());
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GoFile(com.goide.psi.GoFile) Project(com.intellij.openapi.project.Project) GoPackageClause(com.goide.psi.GoPackageClause) Editor(com.intellij.openapi.editor.Editor)

Example 24 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoDownloadableFileAction method doSomething.

@Override
protected boolean doSomething(@NotNull VirtualFile virtualFile, @Nullable Module module, @NotNull Project project, @NotNull String title) throws ExecutionException {
    VirtualFile executable = getExecutable(project, module);
    if (executable == null) {
        String message = "Can't find `" + myExecutableName + "` in GOPATH. Try to invoke <a href=\"" + GO_GET_LINK + "\">go get " + myExecutableName + "</a>";
        NotificationListener listener = new MyNotificationListener(project, module);
        Notifications.Bus.notify(GoConstants.GO_NOTIFICATION_GROUP.createNotification(title, message, NotificationType.WARNING, listener), project);
        return false;
    }
    return super.doSomething(virtualFile, module, project, title);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NotificationListener(com.intellij.notification.NotificationListener)

Example 25 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoExternalToolsAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    VirtualFile file = e.getRequiredData(CommonDataKeys.VIRTUAL_FILE);
    assert project != null;
    String title = StringUtil.notNullize(e.getPresentation().getText());
    Module module = ModuleUtilCore.findModuleForFile(file, project);
    try {
        doSomething(file, module, project, title);
    } catch (ExecutionException ex) {
        error(title, project, ex);
        LOG.error(ex);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) ExecutionException(com.intellij.execution.ExecutionException)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)5443 File (java.io.File)757 Nullable (org.jetbrains.annotations.Nullable)719 Project (com.intellij.openapi.project.Project)718 NotNull (org.jetbrains.annotations.NotNull)703 PsiFile (com.intellij.psi.PsiFile)564 Module (com.intellij.openapi.module.Module)495 IOException (java.io.IOException)327 ArrayList (java.util.ArrayList)258 Document (com.intellij.openapi.editor.Document)241 PsiElement (com.intellij.psi.PsiElement)205 Test (org.junit.Test)193 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)124 PsiDirectory (com.intellij.psi.PsiDirectory)124 XmlFile (com.intellij.psi.xml.XmlFile)124 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)116 Editor (com.intellij.openapi.editor.Editor)114 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)100 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)91 List (java.util.List)90