• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Camelcade / Perl5-IDEA / #525521705

10 Nov 2025 08:49AM UTC coverage: 75.92% (-0.05%) from 75.97%
#525521705

push

github

hurricup
Passed the reason to the daemon code analyzer

14750 of 22633 branches covered (65.17%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

82 existing lines in 10 files now uncovered.

31070 of 37720 relevant lines covered (82.37%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/plugin/profiler/src/main/java/com/perl5/lang/perl/profiler/parser/PerlProfilerDumpFileParser.java
1
/*
2
 * Copyright 2015-2025 Alexandr Evstigneev
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.perl5.lang.perl.profiler.parser;
18

19
import com.intellij.execution.ExecutionException;
20
import com.intellij.execution.process.BaseProcessHandler;
21
import com.intellij.execution.process.ProcessEvent;
22
import com.intellij.execution.process.ProcessListener;
23
import com.intellij.execution.process.ProcessOutputType;
24
import com.intellij.openapi.diagnostic.Logger;
25
import com.intellij.openapi.progress.ProgressIndicator;
26
import com.intellij.openapi.project.Project;
27
import com.intellij.openapi.util.Key;
28
import com.intellij.openapi.util.NlsSafe;
29
import com.intellij.openapi.util.Ref;
30
import com.intellij.profiler.api.*;
31
import com.intellij.profiler.ui.NativeCallStackElementRenderer;
32
import com.perl5.lang.perl.idea.project.PerlProjectManager;
33
import com.perl5.lang.perl.idea.sdk.host.PerlHostData;
34
import com.perl5.lang.perl.profiler.PerlProfilerBundle;
35
import com.perl5.lang.perl.util.PerlPluginUtil;
36
import com.perl5.lang.perl.util.PerlRunUtil;
37
import org.jetbrains.annotations.NotNull;
38
import org.jetbrains.annotations.Nullable;
39

40
import java.io.File;
41

42
/**
43
 * Parser for nytprof dump
44
 */
45
public class PerlProfilerDumpFileParser implements ProfilerDumpFileParser {
46
  private static final Logger LOG = Logger.getInstance(PerlProfilerDumpFileParser.class);
1✔
47
  private final @NotNull Project myProject;
48

49
  public PerlProfilerDumpFileParser(@NotNull Project project) {
1✔
50
    myProject = project;
1✔
51
  }
1✔
52

53
  @Override
54
  public @Nullable String getHelpId() {
55
    return null;
×
56
  }
57

58
  @Override
59
  public @NotNull ProfilerDumpFileParsingResult parse(@NotNull File file, @NotNull ProgressIndicator indicator) {
60
    var perlSdk = PerlProjectManager.getSdk(myProject);
1✔
61
    if (perlSdk == null) {
1!
62
      return new Failure(PerlProfilerBundle.message("perl.sdk.is.not.set.for.the.project.0", myProject.getName()));
×
63
    }
64

65
    var nytprofUtilPath = PerlPluginUtil.getHelperPath("nytprofcalls.pl");
1✔
66
    var perlCommandLine = PerlRunUtil.getPerlCommandLine(myProject, nytprofUtilPath);
1✔
67
    if (perlCommandLine == null) {
1!
68
      LOG.warn("Unable to create command line for parsing results in " + myProject);
×
69
      return new Failure(PerlProfilerBundle.message("failed.to.create.command.line.for.parsing.profiling.results"));
×
70
    }
71

72
    PerlHostData<?, ?> hostData = PerlHostData.notNullFrom(perlSdk);
1✔
73
    try {
74
      hostData.fixPermissionsRecursively(file.getAbsolutePath(), myProject);
1✔
75
    }
76
    catch (ExecutionException e) {
×
77
      LOG.warn("Failed to fix permissions for " + file, e);
×
78
      return new Failure(PerlProfilerBundle.message("failed.to.set.permissions.for.the.0", file));
×
79
    }
1✔
80

81
    var localPath = file.getAbsolutePath();
1✔
82
    var remotePath = hostData.getRemotePath(localPath);
1✔
83

84
    perlCommandLine.withParameters(remotePath);
1✔
85

86
    var dumpParser = new PerlCollapsedDumpParser();
1✔
87

88
    try {
89
      BaseProcessHandler<?> processHandler = PerlHostData.createProcessHandler(perlCommandLine);
1✔
90
      Ref<@NlsSafe String> errorRef = Ref.create();
1✔
91
      processHandler.addProcessListener(new ProcessListener() {
1✔
92
        @Override
93
        public void processTerminated(@NotNull ProcessEvent event) {
94
          if (event.getExitCode() != 0) {
1!
UNCOV
95
            var message = "Error parsing NYTProf output. Exit code: " + event.getExitCode() + ". Message: " + event.getText();
×
UNCOV
96
            errorRef.set(message);
×
UNCOV
97
            LOG.warn(message);
×
98
          }
99
        }
1✔
100

101
        @Override
102
        public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
103
          if (ProcessOutputType.isStderr(outputType)) {
1!
UNCOV
104
            LOG.warn("Error output: " + event.getText());
×
105
          }
106
          else if (ProcessOutputType.isStdout(outputType)) {
1✔
107
            dumpParser.consumeText(event.getText(), indicator);
1✔
108
          }
109
        }
1✔
110
      });
111
      processHandler.startNotify();
1✔
112
      while (!processHandler.waitFor(10)) {
1✔
113
        indicator.checkCanceled();
1✔
114
      }
115
      if (errorRef.isNull()) {
1!
116
        return new Success(
1✔
117
          new NewCallTreeOnlyProfilerData(dumpParser.getCallTreeBuilder(), NativeCallStackElementRenderer.Companion.getINSTANCE()));
1✔
118
      }
UNCOV
119
      return new Failure(errorRef.get());
×
120
    }
UNCOV
121
    catch (ExecutionException e) {
×
UNCOV
122
      LOG.warn("Error parsing results: " + e.getMessage());
×
UNCOV
123
      return new Failure(e.getMessage());
×
124
    }
125
  }
126
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc