Search in sources :

Example 1 with JscsProjectComponent

use of com.jscs.JscsProjectComponent in project jscs-plugin by idok.

the class JscsFixAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return;
    final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE);
    JscsProjectComponent component = project.getComponent(JscsProjectComponent.class);
    //        JscsConfigFileListener.start(collectedInfo.project);
    //        actualFile = ActualFile2.getOrCreateActualFile(JSCS_TEMP_FILE_KEY, file, collectedInfo.fileContent);
    //        if (actualFile == null || actualFile.getActualFile() == null) {
    //            return null;
    //        }
    //            File cwd = new File(project.getBasePath());
    //            if (actualFile instanceof ActualFile2.TempActualFile) {
    //                cwd = ((ActualFile2.TempActualFile) actualFile).getTempFile().file.getParentFile();
    //            }
    //        String relativeFile = actualFile.getActualFile().getName();
    //        File cwd = actualFile.getActualFile().getParentFile();
    //            String relativeFile = FileUtils.makeRelative(cwd, actualFile.getActualFile());
    String rc = JscsExternalAnnotator.getRC(project, component.jscsRcFile);
    LintResult result = JscsRunner.fix(project.getBasePath(), file.getPath(), component.nodeInterpreter, component.jscsExecutable, rc, component.preset, component.settings.esnext, component.settings.esprima);
    file.refresh(true, false);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) LintResult(com.jscs.cli.data.LintResult) JscsProjectComponent(com.jscs.JscsProjectComponent)

Aggregations

Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JscsProjectComponent (com.jscs.JscsProjectComponent)1 LintResult (com.jscs.cli.data.LintResult)1