Skip to content

Commit

Permalink
make rider better about process failing to start (#1235)
Browse files Browse the repository at this point in the history
  • Loading branch information
belav authored Apr 19, 2024
1 parent 31e0868 commit a2a547a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Src/CSharpier.Rider/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# csharpier-rider Changelog

## [1.7.2]
- Better error message when csharpier server fails to start

## [1.7.1]
- Fix unicode issue with csharpier 0.28.0+

Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Rider/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = com.intellij.csharpier
pluginName = csharpier
pluginVersion = 1.7.1
pluginVersion = 1.7.2

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CSharpierProcessPipeMultipleFiles implements ICSharpierProcess, Dis
private Process process = null;
private OutputStreamWriter stdin;
private BufferedReader stdOut;
public boolean processFailedToStart;
private boolean processFailedToStart;

public CSharpierProcessPipeMultipleFiles(String csharpierPath, boolean useUtf8, String version, Project project) {
this.csharpierPath = csharpierPath;
Expand Down Expand Up @@ -58,6 +58,11 @@ public String getVersion() {
return this.version;
}

@Override
public boolean getProcessFailedToStart() {
return this.processFailedToStart;
}

@Override
public String formatFile(String content, String filePath) {
if (this.processFailedToStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,15 @@ private ICSharpierProcess setupCSharpierProcess(String directory, String version
var installedVersion = version.split("\\.");
var versionWeCareAbout = Integer.parseInt(installedVersion[1]);

ICSharpierProcess csharpierProcess;
if (versionWeCareAbout >= 28) {
return new CSharpierProcessServer(customPath, version, this.project);
}
csharpierProcess = new CSharpierProcessServer(customPath, version, this.project);
} else if (versionWeCareAbout >= 12) {
var useUtf8 = versionWeCareAbout >= 14;

if (versionWeCareAbout < 12) {
csharpierProcess = new CSharpierProcessPipeMultipleFiles(customPath, useUtf8, version, this.project);
}
else {
if (!this.warnedForOldVersion) {
var content = "Please upgrade to CSharpier >= 0.12.0 for bug fixes and improved formatting speed.";
NotificationGroupManager.getInstance().getNotificationGroup("CSharpier")
Expand All @@ -234,14 +238,10 @@ private ICSharpierProcess setupCSharpierProcess(String directory, String version
this.warnedForOldVersion = true;
}


return new CSharpierProcessSingleFile(customPath, version, this.project);
csharpierProcess = new CSharpierProcessSingleFile(customPath, version, this.project);
}

var useUtf8 = versionWeCareAbout >= 14;

var csharpierProcess = new CSharpierProcessPipeMultipleFiles(customPath, useUtf8, version, this.project);
if (csharpierProcess.processFailedToStart) {
if (csharpierProcess.getProcessFailedToStart()) {
this.displayFailureMessage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CSharpierProcessServer implements ICSharpierProcess2, Disposable {
private Logger logger = CSharpierLogger.getInstance();
private int port;
private Process process = null;
public boolean processFailedToStart;
private boolean processFailedToStart;

public CSharpierProcessServer(String csharpierPath, String version, Project project) {
this.csharpierPath = csharpierPath;
Expand Down Expand Up @@ -131,6 +131,11 @@ public String getVersion() {
return this.version;
}

@Override
public boolean getProcessFailedToStart() {
return this.processFailedToStart;
}

@Override
public String formatFile(String content, String fileName) {
var parameter = new FormatFileParameter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public String getVersion() {
return this.version;
}

@Override
public boolean getProcessFailedToStart() {
return false;
}

@Override
public String formatFile(String content, String fileName) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

interface ICSharpierProcess {
String getVersion();
boolean getProcessFailedToStart();
String formatFile(String content, String fileName);
void dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public String getVersion() {
return "NULL";
}

@Override
public boolean getProcessFailedToStart() {
return false;
}

@Override
public String formatFile(String content, String fileName) {
return "";
Expand Down

0 comments on commit a2a547a

Please sign in to comment.