From a8706d51b9b0fcce1cf833aadd425638684bdae2 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Sat, 21 Sep 2024 13:56:10 -0300 Subject: [PATCH] wip4 --- .../UndefinedVariableQuickFixCreator.java | 9 +++++-- .../tdd/TddQuickFixParticipant.java | 26 ++++++++++--------- .../tdd/TddRefactorCompletion.java | 6 ++--- ...dRefactorCompletionInInexistentModule.java | 3 ++- .../AbstractAnalysisMarkersParticipants.java | 3 +-- .../ctrl_1/IAnalysisMarkersParticipant.java | 4 +-- .../ctrl_1/IgnoreErrorParticipant.java | 8 ++---- .../UndefinedVariableFixParticipant.java | 10 ++----- .../flake8/Flake8IgnoreErrorParticipant.java | 4 +-- .../pylint/PyLintIgnoreErrorParticipant.java | 4 +-- 10 files changed, 37 insertions(+), 40 deletions(-) diff --git a/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/quick_fixes/UndefinedVariableQuickFixCreator.java b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/quick_fixes/UndefinedVariableQuickFixCreator.java index e3ecf8d0af..4b805d71ad 100644 --- a/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/quick_fixes/UndefinedVariableQuickFixCreator.java +++ b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/quick_fixes/UndefinedVariableQuickFixCreator.java @@ -28,10 +28,15 @@ public class UndefinedVariableQuickFixCreator { - public static void createImportQuickProposalsFromMarkerSelectedText(IAdaptable projectAdaptable, PySelection ps, + public static void createImportQuickProposalsFromMarkerSelectedText( + IAdaptable projectAdaptable, + PySelection ps, int offset, IPythonNature initialNature, - List props, ICodeCompletionASTManager astManager, int start, int end, + List props, + ICodeCompletionASTManager astManager, + int start, + int end, boolean forceReparseOnApply) throws BadLocationException { ps.setSelection(start, end); diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddQuickFixParticipant.java b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddQuickFixParticipant.java index 21e45c8679..f734b882a0 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddQuickFixParticipant.java +++ b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddQuickFixParticipant.java @@ -29,6 +29,7 @@ import org.python.pydev.core.ICompletionState; import org.python.pydev.core.IDefinition; import org.python.pydev.core.IModule; +import org.python.pydev.core.IPyEdit; import org.python.pydev.core.IPythonNature; import org.python.pydev.core.docutils.ImportHandle; import org.python.pydev.core.docutils.ImportHandle.ImportHandleInfo; @@ -37,8 +38,8 @@ import org.python.pydev.core.log.Log; import org.python.pydev.core.preferences.FileTypesPreferences; import org.python.pydev.core.structure.CompletionRecursionException; -import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.codefolding.MarkerAnnotationAndPosition; +import org.python.pydev.parser.jython.SimpleNode; import org.python.pydev.parser.jython.ast.ClassDef; import org.python.pydev.parser.visitors.NodeUtils; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; @@ -76,7 +77,7 @@ public TddQuickFixParticipant() { @Override public void addProps(MarkerAnnotationAndPosition markerAnnotation, IAnalysisPreferences analysisPreferences, - String line, PySelection ps, int offset, IPythonNature nature, PyEdit edit, + String line, PySelection ps, int offset, IPythonNature nature, IPyEdit edit, List props) throws BadLocationException, CoreException { if (nature == null) { @@ -192,7 +193,8 @@ public void addProps(MarkerAnnotationAndPosition markerAnnotation, IAnalysisPref foundFromImportStr, currentModule, state, - new SourceModule(currentModule, edit.getEditorFile(), edit.getAST(), + new SourceModule(currentModule, edit.getEditorFile(), + (SimpleNode) edit.getAST(), null, nature)); } catch (Exception e) { Log.log(e); @@ -336,7 +338,7 @@ protected File getFileStructure(File file, String withoutLastPart) { return f; } - private void addCreateClassmethodOption(PySelection ps, PyEdit edit, List props, + private void addCreateClassmethodOption(PySelection ps, IPyEdit edit, List props, String markerContents, List parametersAfterCall, PyCreateMethodOrField pyCreateMethod, File file, String className) { props.add(new TddRefactorCompletionInModule(markerContents, imageMethod, "Create " + markerContents + @@ -349,7 +351,7 @@ private void addCreateClassmethodOption(PySelection ps, PyEdit edit, List props, + private void addCreateMethodOption(PySelection ps, IPyEdit edit, List props, String markerContents, List parametersAfterCall, File file) { props.add(new TddRefactorCompletionInModule(markerContents, imageMethod, "Create " + markerContents + " method at " + file.getName(), null, @@ -359,7 +361,7 @@ IPyCompletionProposal.PRIORITY_CREATE, edit, file, parametersAfterCall, new PyCr ps)); } - private void addCreateClassOption(PySelection ps, PyEdit edit, List props, + private void addCreateClassOption(PySelection ps, IPyEdit edit, List props, String markerContents, List parametersAfterCall, File file) { props.add(new TddRefactorCompletionInModule(markerContents, imageClass, "Create " + markerContents + " class at " + file.getName(), null, @@ -368,7 +370,7 @@ private void addCreateClassOption(PySelection ps, PyEdit edit, List props, + private void addCreateClassInNewModuleOption(PySelection ps, IPyEdit edit, List props, String markerContents, String moduleName, List parametersAfterCall, File file) { props.add(new TddRefactorCompletionInInexistentModule(markerContents, imageClass, "Create " + markerContents + " class at new module " + moduleName, null, @@ -379,7 +381,7 @@ private void addCreateClassInNewModuleOption(PySelection ps, PyEdit edit, List props, + private void addCreateMethodInNewModuleOption(PySelection ps, IPyEdit edit, List props, String markerContents, String moduleName, List parametersAfterCall, File file) { props.add(new TddRefactorCompletionInInexistentModule(markerContents, imageMethod, "Create " + markerContents + " method at new module " + moduleName, null, @@ -390,7 +392,7 @@ private void addCreateMethodInNewModuleOption(PySelection ps, PyEdit edit, List< new PyCreateMethodOrField(), ps)); } - private void addCreateModuleOption(PySelection ps, PyEdit edit, List props, + private void addCreateModuleOption(PySelection ps, IPyEdit edit, List props, String markerContents, File file) { props.add(new TddRefactorCompletionInInexistentModule(markerContents, imageModule, "Create " + markerContents + " module", null, @@ -401,7 +403,7 @@ private void addCreateModuleOption(PySelection ps, PyEdit edit, List props, + private void addCreateMethodOption(PySelection ps, IPyEdit edit, List props, String markerContents, List parametersAfterCall) { props.add(new TddRefactorCompletion(markerContents, imageMethod, "Create " + markerContents + " method", null, @@ -409,7 +411,7 @@ private void addCreateMethodOption(PySelection ps, PyEdit edit, List props, + private void addCreateClassOption(PySelection ps, IPyEdit edit, List props, String markerContents, List parametersAfterCall) { props.add(new TddRefactorCompletion(markerContents, imageClass, "Create " + markerContents + " class", null, @@ -417,7 +419,7 @@ private void addCreateClassOption(PySelection ps, PyEdit edit, List findDefinitions(IPythonNature nature, PyEdit edit, int start, IDocument doc) { + private ArrayList findDefinitions(IPythonNature nature, IPyEdit edit, int start, IDocument doc) { CompletionState completionState = new CompletionState(); ArrayList selected = new ArrayList(); diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletion.java b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletion.java index 04450d5a67..33ee0ab691 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletion.java +++ b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletion.java @@ -58,7 +58,7 @@ public boolean isAutoInsertable() { @Override public Point getSelection(IDocument document) { - TemplateProposal executed2 = getExecuted(); + TemplateProposal executed2 = getAsTemplateProposal(); if (executed2 != null) { return executed2.getSelection(document); } @@ -72,14 +72,14 @@ public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) { PyParser parser = (PyParser) edit.getParser(); parser.reparseDocument(); } - TemplateProposal executed2 = getExecuted(); + TemplateProposal executed2 = getAsTemplateProposal(); if (executed2 != null) { executed2.apply(viewer, trigger, stateMask, 0); forceReparseInBaseEditorAnd(); } } - private TemplateProposal getExecuted() { + public TemplateProposal getAsTemplateProposal() { if (executed == null) { pyCreateAction.setActiveEditor(null, edit); try { diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInInexistentModule.java b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInInexistentModule.java index 477c1abef1..8f2c50dfbd 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInInexistentModule.java +++ b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInInexistentModule.java @@ -25,6 +25,7 @@ import org.eclipse.swt.graphics.Point; import org.python.pydev.ast.item_pointer.ItemPointer; import org.python.pydev.ast.location.FindWorkspaceFiles; +import org.python.pydev.core.IPyEdit; import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.log.Log; import org.python.pydev.core.preferences.FileTypesPreferences; @@ -44,7 +45,7 @@ public final class TddRefactorCompletionInInexistentModule extends AbstractTddRe private PySelection ps; public TddRefactorCompletionInInexistentModule(String replacementString, IImageHandle image, String displayString, - IContextInformation contextInformation, String additionalProposalInfo, int priority, PyEdit edit, + IContextInformation contextInformation, String additionalProposalInfo, int priority, IPyEdit edit, File module, List parametersAfterCall, AbstractPyCreateAction pyCreateAction, PySelection ps) { super(edit, replacementString, 0, 0, 0, image, displayString, contextInformation, additionalProposalInfo, diff --git a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/AbstractAnalysisMarkersParticipants.java b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/AbstractAnalysisMarkersParticipants.java index cc944b0a94..f13555b97e 100644 --- a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/AbstractAnalysisMarkersParticipants.java +++ b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/AbstractAnalysisMarkersParticipants.java @@ -67,8 +67,7 @@ public List getProps(PySelection ps, IImageCache imag for (MarkerAnnotationAndPosition marker : markersAtLine) { for (IAnalysisMarkersParticipant participant : participants) { try { - participant.addProps(marker, analysisPreferences, currLine, ps, offset, nature, (PyEdit) edit, - props); + participant.addProps(marker, analysisPreferences, currLine, ps, offset, nature, edit, props); } catch (Exception e) { Log.log("Error when getting proposals.", e); } diff --git a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/IAnalysisMarkersParticipant.java b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/IAnalysisMarkersParticipant.java index ef8678cf00..7b89a3aeab 100644 --- a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/IAnalysisMarkersParticipant.java +++ b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/IAnalysisMarkersParticipant.java @@ -14,9 +14,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.text.BadLocationException; import org.python.pydev.ast.analysis.IAnalysisPreferences; +import org.python.pydev.core.IPyEdit; import org.python.pydev.core.IPythonNature; import org.python.pydev.core.docutils.PySelection; -import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.codefolding.MarkerAnnotationAndPosition; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; @@ -39,7 +39,7 @@ public interface IAnalysisMarkersParticipant { * @throws CoreException */ public abstract void addProps(MarkerAnnotationAndPosition marker, IAnalysisPreferences analysisPreferences, - String line, PySelection ps, int offset, IPythonNature nature, PyEdit edit, + String line, PySelection ps, int offset, IPythonNature nature, IPyEdit edit, List props) throws BadLocationException, CoreException; diff --git a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/IgnoreErrorParticipant.java b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/IgnoreErrorParticipant.java index 10bd1cfc97..b71052e3b9 100644 --- a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/IgnoreErrorParticipant.java +++ b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/IgnoreErrorParticipant.java @@ -19,11 +19,11 @@ import org.eclipse.jface.text.BadLocationException; import org.python.pydev.ast.analysis.IAnalysisPreferences; import org.python.pydev.core.CheckAnalysisErrors; +import org.python.pydev.core.IPyEdit; import org.python.pydev.core.IPythonNature; import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.formatter.FormatStd; import org.python.pydev.core.proposals.CompletionProposalFactory; -import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.codefolding.MarkerAnnotationAndPosition; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; import org.python.pydev.shared_core.code_completion.IPyCompletionProposal; @@ -50,13 +50,9 @@ public IgnoreErrorParticipant() { this.format = format; } - /** - * @throws CoreException - * @see org.python.pydev.ast.analysis.ctrl_1.IAnalysisMarkersParticipant#addProps(org.eclipse.core.resources.IMarker, org.python.pydev.ast.analysis.IAnalysisPreferences, java.lang.String, org.python.pydev.core.docutils.PySelection, int, org.python.pydev.editor.PyEdit, java.util.List) - */ @Override public void addProps(MarkerAnnotationAndPosition marker, IAnalysisPreferences analysisPreferences, - final String line, final PySelection ps, int offset, IPythonNature nature, final PyEdit edit, + final String line, final PySelection ps, int offset, IPythonNature nature, final IPyEdit edit, List props) throws BadLocationException, CoreException { Integer id = (Integer) marker.markerAnnotation.getMarker().getAttribute(AnalysisRunner.PYDEV_ANALYSIS_TYPE); diff --git a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/UndefinedVariableFixParticipant.java b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/UndefinedVariableFixParticipant.java index c78cc5a62a..3cbf00ef54 100644 --- a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/UndefinedVariableFixParticipant.java +++ b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/UndefinedVariableFixParticipant.java @@ -14,12 +14,11 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.text.BadLocationException; -import org.eclipse.ui.texteditor.MarkerAnnotation; import org.python.pydev.ast.analysis.IAnalysisPreferences; import org.python.pydev.core.ICodeCompletionASTManager; +import org.python.pydev.core.IPyEdit; import org.python.pydev.core.IPythonNature; import org.python.pydev.core.docutils.PySelection; -import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.codefolding.MarkerAnnotationAndPosition; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; @@ -46,14 +45,9 @@ public UndefinedVariableFixParticipant(boolean forceReparseOnApply) { this.forceReparseOnApply = forceReparseOnApply; } - /** - * @see IAnalysisMarkersParticipant#addProps(MarkerAnnotation, IAnalysisPreferences, String, PySelection, int, IPythonNature, - * PyEdit, List) - * - */ @Override public void addProps(MarkerAnnotationAndPosition markerAnnotation, IAnalysisPreferences analysisPreferences, - String line, PySelection ps, int offset, IPythonNature initialNature, PyEdit edit, + String line, PySelection ps, int offset, IPythonNature initialNature, IPyEdit edit, List props) throws BadLocationException, CoreException { IMarker marker = markerAnnotation.markerAnnotation.getMarker(); diff --git a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/flake8/Flake8IgnoreErrorParticipant.java b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/flake8/Flake8IgnoreErrorParticipant.java index 90d5016963..97d824690b 100644 --- a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/flake8/Flake8IgnoreErrorParticipant.java +++ b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/flake8/Flake8IgnoreErrorParticipant.java @@ -15,11 +15,11 @@ import org.eclipse.jface.text.BadLocationException; import org.python.pydev.ast.analysis.IAnalysisPreferences; import org.python.pydev.core.CheckAnalysisErrors; +import org.python.pydev.core.IPyEdit; import org.python.pydev.core.IPythonNature; import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.formatter.FormatStd; import org.python.pydev.core.proposals.CompletionProposalFactory; -import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.codefolding.MarkerAnnotationAndPosition; import org.python.pydev.shared_core.IMiscConstants; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; @@ -48,7 +48,7 @@ public Flake8IgnoreErrorParticipant() { @Override public void addProps(MarkerAnnotationAndPosition marker, IAnalysisPreferences analysisPreferences, - final String line, final PySelection ps, int offset, IPythonNature nature, final PyEdit edit, + final String line, final PySelection ps, int offset, IPythonNature nature, final IPyEdit edit, List props) throws BadLocationException, CoreException { IMarker m = marker.markerAnnotation.getMarker(); diff --git a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/pylint/PyLintIgnoreErrorParticipant.java b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/pylint/PyLintIgnoreErrorParticipant.java index 21e3557100..e450442698 100644 --- a/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/pylint/PyLintIgnoreErrorParticipant.java +++ b/plugins/org.python.pydev/src/com/python/pydev/analysis/ctrl_1/pylint/PyLintIgnoreErrorParticipant.java @@ -15,11 +15,11 @@ import org.eclipse.jface.text.BadLocationException; import org.python.pydev.ast.analysis.IAnalysisPreferences; import org.python.pydev.core.CheckAnalysisErrors; +import org.python.pydev.core.IPyEdit; import org.python.pydev.core.IPythonNature; import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.formatter.FormatStd; import org.python.pydev.core.proposals.CompletionProposalFactory; -import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.codefolding.MarkerAnnotationAndPosition; import org.python.pydev.shared_core.IMiscConstants; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; @@ -52,7 +52,7 @@ public PyLintIgnoreErrorParticipant() { */ @Override public void addProps(MarkerAnnotationAndPosition marker, IAnalysisPreferences analysisPreferences, - final String line, final PySelection ps, int offset, IPythonNature nature, final PyEdit edit, + final String line, final PySelection ps, int offset, IPythonNature nature, final IPyEdit edit, List props) throws BadLocationException, CoreException { IMarker m = marker.markerAnnotation.getMarker();