Search in sources :

Example 1 with ApplicationInfoImpl

use of com.intellij.openapi.application.impl.ApplicationInfoImpl in project intellij-community by JetBrains.

the class Pep8ExternalAnnotator method doAnnotate.

@Nullable
@Override
public Results doAnnotate(State collectedInfo) {
    if (collectedInfo == null)
        return null;
    ArrayList<String> options = Lists.newArrayList();
    if (!collectedInfo.ignoredErrors.isEmpty()) {
        options.add("--ignore=" + DEFAULT_IGNORED_ERRORS + "," + StringUtil.join(collectedInfo.ignoredErrors, ","));
    }
    if (collectedInfo.hangClosingBrackets) {
        options.add("--hang-closing");
    }
    options.add("--max-line-length=" + collectedInfo.margin);
    options.add("-");
    GeneralCommandLine cmd = PythonHelper.PYCODESTYLE.newCommandLine(collectedInfo.interpreterPath, options);
    ProcessOutput output = PySdkUtil.getProcessOutput(cmd, new File(collectedInfo.interpreterPath).getParent(), ImmutableMap.of("PYTHONBUFFERED", "1"), 10000, collectedInfo.fileText.getBytes(), false);
    Results results = new Results(collectedInfo.level);
    if (output.isTimeout()) {
        LOG.info("Timeout running pycodestyle.py");
    } else if (output.getStderrLines().isEmpty()) {
        for (String line : output.getStdoutLines()) {
            final Problem problem = parseProblem(line);
            if (problem != null) {
                results.problems.add(problem);
            }
        }
    } else if (((ApplicationInfoImpl) ApplicationInfo.getInstance()).isEAP()) {
        LOG.info("Error running pycodestyle.py: " + output.getStderr());
    }
    return results;
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ProcessOutput(com.intellij.execution.process.ProcessOutput) ApplicationInfoImpl(com.intellij.openapi.application.impl.ApplicationInfoImpl) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ApplicationInfoImpl

use of com.intellij.openapi.application.impl.ApplicationInfoImpl in project intellij-community by JetBrains.

the class Pep8ExternalAnnotator method parseProblem.

@Nullable
private static Problem parseProblem(String s) {
    Matcher m = PROBLEM_PATTERN.matcher(s);
    if (m.matches()) {
        int line = Integer.parseInt(m.group(1));
        int column = Integer.parseInt(m.group(2));
        return new Problem(line, column, m.group(3), m.group(4));
    }
    if (((ApplicationInfoImpl) ApplicationInfo.getInstance()).isEAP()) {
        LOG.info("Failed to parse problem line from pycodestyle.py: " + s);
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) ApplicationInfoImpl(com.intellij.openapi.application.impl.ApplicationInfoImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with ApplicationInfoImpl

use of com.intellij.openapi.application.impl.ApplicationInfoImpl in project intellij-community by JetBrains.

the class StatisticsUploadAssistant method getStatisticsService.

public static StatisticsService getStatisticsService() {
    String key = ((ApplicationInfoImpl) ApplicationInfoImpl.getShadowInstance()).getStatisticsServiceKey();
    StatisticsService service = key == null ? null : COLLECTOR.findSingle(key);
    if (service != null) {
        return service;
    }
    return new RemotelyConfigurableStatisticsService(new StatisticsConnectionService(), new StatisticsHttpClientSender(), new StatisticsUploadAssistant());
}
Also used : RemotelyConfigurableStatisticsService(com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService) StatisticsService(com.intellij.internal.statistic.connect.StatisticsService) StatisticsConnectionService(com.intellij.internal.statistic.connect.StatisticsConnectionService) ApplicationInfoImpl(com.intellij.openapi.application.impl.ApplicationInfoImpl) StatisticsHttpClientSender(com.intellij.internal.statistic.connect.StatisticsHttpClientSender) RemotelyConfigurableStatisticsService(com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService)

Aggregations

ApplicationInfoImpl (com.intellij.openapi.application.impl.ApplicationInfoImpl)3 Nullable (org.jetbrains.annotations.Nullable)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 ProcessOutput (com.intellij.execution.process.ProcessOutput)1 RemotelyConfigurableStatisticsService (com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService)1 StatisticsConnectionService (com.intellij.internal.statistic.connect.StatisticsConnectionService)1 StatisticsHttpClientSender (com.intellij.internal.statistic.connect.StatisticsHttpClientSender)1 StatisticsService (com.intellij.internal.statistic.connect.StatisticsService)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 File (java.io.File)1 Matcher (java.util.regex.Matcher)1