Skip to content

Commit

Permalink
wip4
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Sep 21, 2024
1 parent a76255a commit a8706d5
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ICompletionProposalHandle> props, ICodeCompletionASTManager astManager, int start, int end,
List<ICompletionProposalHandle> props,
ICodeCompletionASTManager astManager,
int start,
int end,
boolean forceReparseOnApply)
throws BadLocationException {
ps.setSelection(start, end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<ICompletionProposalHandle> props)
throws BadLocationException, CoreException {
if (nature == null) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -336,7 +338,7 @@ protected File getFileStructure(File file, String withoutLastPart) {
return f;
}

private void addCreateClassmethodOption(PySelection ps, PyEdit edit, List<ICompletionProposalHandle> props,
private void addCreateClassmethodOption(PySelection ps, IPyEdit edit, List<ICompletionProposalHandle> props,
String markerContents, List<String> parametersAfterCall, PyCreateMethodOrField pyCreateMethod, File file,
String className) {
props.add(new TddRefactorCompletionInModule(markerContents, imageMethod, "Create " + markerContents +
Expand All @@ -349,7 +351,7 @@ private void addCreateClassmethodOption(PySelection ps, PyEdit edit, List<ICompl
file, parametersAfterCall, pyCreateMethod, ps));
}

private void addCreateMethodOption(PySelection ps, PyEdit edit, List<ICompletionProposalHandle> props,
private void addCreateMethodOption(PySelection ps, IPyEdit edit, List<ICompletionProposalHandle> props,
String markerContents, List<String> parametersAfterCall, File file) {
props.add(new TddRefactorCompletionInModule(markerContents, imageMethod, "Create " + markerContents +
" method at " + file.getName(), null,
Expand All @@ -359,7 +361,7 @@ IPyCompletionProposal.PRIORITY_CREATE, edit, file, parametersAfterCall, new PyCr
ps));
}

private void addCreateClassOption(PySelection ps, PyEdit edit, List<ICompletionProposalHandle> props,
private void addCreateClassOption(PySelection ps, IPyEdit edit, List<ICompletionProposalHandle> props,
String markerContents, List<String> parametersAfterCall, File file) {
props.add(new TddRefactorCompletionInModule(markerContents, imageClass, "Create " + markerContents +
" class at " + file.getName(), null,
Expand All @@ -368,7 +370,7 @@ private void addCreateClassOption(PySelection ps, PyEdit edit, List<ICompletionP
IPyCompletionProposal.PRIORITY_CREATE, edit, file, parametersAfterCall, new PyCreateClass(), ps));
}

private void addCreateClassInNewModuleOption(PySelection ps, PyEdit edit, List<ICompletionProposalHandle> props,
private void addCreateClassInNewModuleOption(PySelection ps, IPyEdit edit, List<ICompletionProposalHandle> props,
String markerContents, String moduleName, List<String> parametersAfterCall, File file) {
props.add(new TddRefactorCompletionInInexistentModule(markerContents, imageClass, "Create " + markerContents +
" class at new module " + moduleName, null,
Expand All @@ -379,7 +381,7 @@ private void addCreateClassInNewModuleOption(PySelection ps, PyEdit edit, List<I
new PyCreateClass(), ps));
}

private void addCreateMethodInNewModuleOption(PySelection ps, PyEdit edit, List<ICompletionProposalHandle> props,
private void addCreateMethodInNewModuleOption(PySelection ps, IPyEdit edit, List<ICompletionProposalHandle> props,
String markerContents, String moduleName, List<String> parametersAfterCall, File file) {
props.add(new TddRefactorCompletionInInexistentModule(markerContents, imageMethod, "Create " + markerContents +
" method at new module " + moduleName, null,
Expand All @@ -390,7 +392,7 @@ private void addCreateMethodInNewModuleOption(PySelection ps, PyEdit edit, List<
new PyCreateMethodOrField(), ps));
}

private void addCreateModuleOption(PySelection ps, PyEdit edit, List<ICompletionProposalHandle> props,
private void addCreateModuleOption(PySelection ps, IPyEdit edit, List<ICompletionProposalHandle> props,
String markerContents, File file) {
props.add(new TddRefactorCompletionInInexistentModule(markerContents, imageModule, "Create " + markerContents +
" module", null,
Expand All @@ -401,23 +403,23 @@ private void addCreateModuleOption(PySelection ps, PyEdit edit, List<ICompletion
ps));
}

private void addCreateMethodOption(PySelection ps, PyEdit edit, List<ICompletionProposalHandle> props,
private void addCreateMethodOption(PySelection ps, IPyEdit edit, List<ICompletionProposalHandle> props,
String markerContents, List<String> parametersAfterCall) {
props.add(new TddRefactorCompletion(markerContents, imageMethod, "Create " + markerContents +
" method", null,
null, IPyCompletionProposal.PRIORITY_CREATE, edit, PyCreateClass.LOCATION_STRATEGY_BEFORE_CURRENT,
parametersAfterCall, new PyCreateMethodOrField(), ps));
}

private void addCreateClassOption(PySelection ps, PyEdit edit, List<ICompletionProposalHandle> props,
private void addCreateClassOption(PySelection ps, IPyEdit edit, List<ICompletionProposalHandle> props,
String markerContents, List<String> parametersAfterCall) {
props.add(new TddRefactorCompletion(markerContents, imageClass, "Create " + markerContents +
" class", null,
null, IPyCompletionProposal.PRIORITY_CREATE, edit, PyCreateClass.LOCATION_STRATEGY_BEFORE_CURRENT,
parametersAfterCall, new PyCreateClass(), ps));
}

private ArrayList<IDefinition> findDefinitions(IPythonNature nature, PyEdit edit, int start, IDocument doc) {
private ArrayList<IDefinition> findDefinitions(IPythonNature nature, IPyEdit edit, int start, IDocument doc) {
CompletionState completionState = new CompletionState();
ArrayList<IDefinition> selected = new ArrayList<IDefinition>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> parametersAfterCall, AbstractPyCreateAction pyCreateAction, PySelection ps) {

super(edit, replacementString, 0, 0, 0, image, displayString, contextInformation, additionalProposalInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public List<ICompletionProposalHandle> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<ICompletionProposalHandle> props)
throws BadLocationException, CoreException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<ICompletionProposalHandle> props)
throws BadLocationException, CoreException {
Integer id = (Integer) marker.markerAnnotation.getMarker().getAttribute(AnalysisRunner.PYDEV_ANALYSIS_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<ICompletionProposalHandle> props)
throws BadLocationException, CoreException {
IMarker marker = markerAnnotation.markerAnnotation.getMarker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ICompletionProposalHandle> props)
throws BadLocationException, CoreException {
IMarker m = marker.markerAnnotation.getMarker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ICompletionProposalHandle> props)
throws BadLocationException, CoreException {
IMarker m = marker.markerAnnotation.getMarker();
Expand Down

0 comments on commit a8706d5

Please sign in to comment.