Skip to content

Commit

Permalink
Analysis indicator percentage, name change to MTA, and multiple target
Browse files Browse the repository at this point in the history
  • Loading branch information
hhpatel14 committed Jan 10, 2024
1 parent 360e2e8 commit b797815
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
Binary file added kantra
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public static List<String> buildParams(WindupConfiguration config) {
target = Lists.newArrayList();
target.add("eap7");
}
params.add("--target");
// params.add("--target");

for (String aTarget : target) {
params.add("--target");
params.add(aTarget);
}
// params.add(String.join(",", target));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.CharsetToolkit;
import org.jboss.tools.intellij.windup.explorer.actions.RunConfigurationAction;
import org.jetbrains.annotations.NotNull;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.nio.charset.Charset;
import java.util.Arrays;


import static org.jboss.tools.intellij.windup.cli.ProgressMonitor.PROGRESS;

Expand Down Expand Up @@ -74,7 +74,8 @@ else if (text.contains("rules parsed")) {
progressIndicator.setFraction(0.10);
}
else if (text.contains("rule response received")) {
progressIndicator.setText("Running Analysis...");
int progress = calculateWorkDonePercentage(text);
progressIndicator.setText("Running Analysis (" + progress + "%)");
progressIndicator.setFraction(0.25);
}
else if (text.contains("running dependency analysis")) {
Expand All @@ -91,6 +92,12 @@ else if (text.contains("Static report created.")) {
progressMonitor.handleMessage(msg);
progressIndicator.setFraction(1);
}
else if (text.contains("Error")) {
System.out.println(text + "---------------------------------------: detected ");
ProgressMonitor.ProgressMessage msg = new ProgressMonitor.ProgressMessage("complete", "", 20, "");
progressMonitor.handleMessage(msg);
progressIndicator.setFraction(1);
}
else if (text.contains(PROGRESS)) {
JsonObject json = ProgressMonitor.parseProgressMessage(text);
if (json != null) {
Expand Down Expand Up @@ -119,4 +126,26 @@ else if (text.contains(PROGRESS)) {
public Charset getCharset() {
return CharsetToolkit.UTF8_CHARSET;
}

public static int calculateWorkDonePercentage(String log) {
// Regex pattern to extract the relevant numbers from the log string
String pattern = "failed=(\\d+) matched=(\\d+) total=(\\d+) unmatched=(\\d+)";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(log);

if (m.find()) {
// Parse numbers from the log string
int failed = Integer.parseInt(m.group(1));
int matched = Integer.parseInt(m.group(2));
int total = Integer.parseInt(m.group(3));
int unmatched = Integer.parseInt(m.group(4));

// Calculate the work done percentage
double workDone = (double) (failed + matched + unmatched) / total;
return (int) Math.round(workDone * 100);
} else {
// If the pattern does not match, return an error code or throw an exception
return -1; // Or you could throw an exception
}
}
}
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<idea-plugin>
<id>org.jboss.tools.intellij.mtr</id>
<name>Migration Toolkit for Runtimes (MTR) by Red Hat</name>
<name>Migration Toolkit for Applications (MTA) by Red Hat</name>
<vendor email="[email protected]" url="http://www.redhat.com">Red-Hat</vendor>

<description><![CDATA[
<h2>Overview</h2>
<p>The Migration Toolkit for Runtimes (MTR) plugin for IntelliJ Platform-based IDEs.</p>
<p>The Migration Toolkit for Applications (MTA) plugin for IntelliJ Platform-based IDEs.</p>
<p>Provides tooling to accelerate application migration by marking migration issues in the source code, provides guidance to fix the issues, and offers automatic code replacement when possible.</p>
<p>Read more about MTR <a href="https://developers.redhat.com/products/mtr/download">here</a>.</p>
]]></description>
Expand All @@ -19,7 +19,7 @@
<depends>com.intellij.modules.platform</depends>

<extensions defaultExtensionNs="com.intellij">
<toolWindow id="Migration Toolkit for Runtimes"
<toolWindow id="Migration Toolkit for Applications"
anchor="left"
icon="/META-INF/web/webroot/migration_toolkit_tool_window_icon.png"
factoryClass="org.jboss.tools.intellij.windup.explorer.WindupExplorerFactory"/>
Expand Down

0 comments on commit b797815

Please sign in to comment.