Skip to content

Commit

Permalink
A few minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed May 1, 2024
1 parent 3dbcef9 commit 3aa0977
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ public void afterRunProcess(String output, String errors, IExternalCodeAnalysisS
WriteToStreamHelper.write("Mypy: The stderr of the command line is:\n", out, errors);
}

if (output.indexOf("Traceback (most recent call last):") != -1) {
if (logStream(output)) {
Throwable e = new RuntimeException("Mypy ERROR: \n" + output);
Log.log(e);
return;
}
if (errors.indexOf("Traceback (most recent call last):") != -1) {
if (logStream(errors)) {
Throwable e = new RuntimeException("Mypy ERROR: \n" + errors);
Log.log(e);
return;
Expand Down Expand Up @@ -438,6 +438,12 @@ public void afterRunProcess(String output, String errors, IExternalCodeAnalysisS
}
}

private boolean logStream(String output) {
// usage: mypy [-h] [-v] [-V] [more options; see below]
return output.contains("Traceback (most recent call last):")
|| (output.contains("mypy: error: unrecognized arguments:") && output.contains("usage:"));
}

private static Pattern MYPY_MATCH_PATTERN1 = Pattern
.compile("\\A" // start of input
+ "\\s*(.*)" // filename (1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
import org.python.pydev.ast.codecompletion.PyCodeCompletionPreferences;
import org.python.pydev.ast.simpleassist.ISimpleAssistParticipant;
import org.python.pydev.ast.simpleassist.ISimpleAssistParticipant2;
import org.python.pydev.core.IGrammarVersionProvider;
import org.python.pydev.core.IPySyntaxHighlightingAndCodeCompletionEditor;
import org.python.pydev.core.IPythonNature;
import org.python.pydev.core.MisconfigurationException;
import org.python.pydev.core.docutils.PySelection;
import org.python.pydev.core.proposals.CompletionProposalFactory;
import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle;
Expand Down Expand Up @@ -69,19 +66,7 @@ public class KeywordsSimpleAssist implements ISimpleAssistParticipant, ISimpleAs
@Override
public Collection<ICompletionProposalHandle> computeCompletionProposals(String activationToken, String qualifier,
PySelection ps, IPySyntaxHighlightingAndCodeCompletionEditor edit, int offset) {
boolean isPy3Syntax = false;
if (PyCodeCompletionPreferences.forcePy3kPrintOnPy2()) {
isPy3Syntax = true;

} else {
try {
IPythonNature nature = edit.getPythonNature();
if (nature != null) {
isPy3Syntax = nature.getGrammarVersion() >= IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_5;
}
} catch (MisconfigurationException e) {
}
}
boolean isPy3Syntax = true;
return innerComputeProposals(activationToken, qualifier, offset, false, isPy3Syntax);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.attribute.FileTime;
import java.util.List;
Expand Down Expand Up @@ -42,6 +43,16 @@ public boolean exists() {
return file.isFile();
}

@Override
public URI getLocationURI() {
return file.toURI();
}

@Override
public IPath getLocation() {
return Path.fromOSString(file.toString());
}

@Override
public String getFileExtension() {
String name = this.file.getName();
Expand Down

0 comments on commit 3aa0977

Please sign in to comment.