From b6be0da06edaa889b366d3d23042a0066e7a9ad3 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Wed, 2 Oct 2024 07:18:37 -0300 Subject: [PATCH] Move code related to TDD actions to core plugins. --- .../TddQuickFixFromMarkersParticipant.java | 58 ++++++++++++------- .../refactoring/tdd/PyCreateClass.java | 4 +- ...tionQuickFixWithoutMarkersParticipant.java | 32 +++++----- .../com.python.pydev.refactoring/plugin.xml | 2 +- ...erationQuickFixFromMarkersParticipant.java | 1 + ...CodeGenerationQuickFixParticipantTest.java | 3 + ...ionQuickFixParticipantWithMarkersTest.java | 4 ++ .../proposals/ICompletionProposalFactory.java | 22 +++++++ .../string/TextSelectionUtils.java | 8 ++- plugins/org.python.pydev/META-INF/MANIFEST.MF | 1 + .../AbstractTddRefactorCompletion.java | 2 +- .../completions}/TddRefactorCompletion.java | 4 +- ...dRefactorCompletionInInexistentModule.java | 2 +- .../TddRefactorCompletionInModule.java | 2 +- .../DefaultCompletionProposalFactory.java | 44 ++++++++++++++ 15 files changed, 143 insertions(+), 46 deletions(-) rename plugins/{com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd => com.python.pydev.analysis/src/com/python/pydev/analysis/marker_quick_fixes}/TddQuickFixFromMarkersParticipant.java (91%) rename plugins/{com.python.pydev.refactoring/src/com/python/pydev => com.python.pydev.analysis/src/com/python/pydev/analysis}/refactoring/tdd/TddCodeGenerationQuickFixWithoutMarkersParticipant.java (94%) rename plugins/{com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd => org.python.pydev/src/com/python/pydev/refactoring/tdd/completions}/AbstractTddRefactorCompletion.java (98%) rename plugins/{com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd => org.python.pydev/src/com/python/pydev/refactoring/tdd/completions}/TddRefactorCompletion.java (96%) rename plugins/{com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd => org.python.pydev/src/com/python/pydev/refactoring/tdd/completions}/TddRefactorCompletionInInexistentModule.java (99%) rename plugins/{com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd => org.python.pydev/src/com/python/pydev/refactoring/tdd/completions}/TddRefactorCompletionInModule.java (98%) diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddQuickFixFromMarkersParticipant.java b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/marker_quick_fixes/TddQuickFixFromMarkersParticipant.java similarity index 91% rename from plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddQuickFixFromMarkersParticipant.java rename to plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/marker_quick_fixes/TddQuickFixFromMarkersParticipant.java index 873ea3cf98..8ccb58b2ef 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddQuickFixFromMarkersParticipant.java +++ b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/marker_quick_fixes/TddQuickFixFromMarkersParticipant.java @@ -4,7 +4,7 @@ * Please see the license.txt included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ -package com.python.pydev.refactoring.tdd; +package com.python.pydev.analysis.marker_quick_fixes; import java.io.File; import java.util.ArrayList; @@ -38,10 +38,12 @@ import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.log.Log; import org.python.pydev.core.preferences.FileTypesPreferences; +import org.python.pydev.core.proposals.CompletionProposalFactory; import org.python.pydev.core.structure.CompletionRecursionException; 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.SharedCorePlugin; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; import org.python.pydev.shared_core.code_completion.IPyCompletionProposal; import org.python.pydev.shared_core.image.IImageCache; @@ -52,7 +54,6 @@ import org.python.pydev.shared_core.string.FullRepIterable; import org.python.pydev.shared_core.string.StringUtils; import org.python.pydev.shared_core.structure.Tuple; -import org.python.pydev.shared_ui.SharedUiPlugin; import com.python.pydev.analysis.refactoring.tdd.AbstractPyCreateAction; import com.python.pydev.analysis.refactoring.tdd.NullPyCreateAction; @@ -69,7 +70,7 @@ public class TddQuickFixFromMarkersParticipant implements IAnalysisMarkersPartic /*default*/IImageHandle imageModule; public TddQuickFixFromMarkersParticipant() { - IImageCache imageCache = SharedUiPlugin.getImageCache(); + IImageCache imageCache = SharedCorePlugin.getImageCache(); if (imageCache != null) { //making tests imageClass = imageCache.get(UIConstants.CREATE_CLASS_ICON); imageMethod = imageCache.get(UIConstants.CREATE_METHOD_ICON); @@ -343,9 +344,12 @@ protected File getFileStructure(File file, String withoutLastPart) { 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 + - " classmethod at " + className + - " in " + file.getName(), null, + + props.add(CompletionProposalFactory.get().createTddRefactorCompletionInModule(markerContents, imageMethod, + "Create " + markerContents + + " classmethod at " + className + + " in " + file.getName(), + null, "Create " + markerContents + " classmethod at class: " + className + " in " + file, @@ -355,8 +359,10 @@ private void addCreateClassmethodOption(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, + props.add(CompletionProposalFactory.get().createTddRefactorCompletionInModule(markerContents, imageMethod, + "Create " + markerContents + + " method at " + file.getName(), + null, "Create " + markerContents + " method at " + file, IPyCompletionProposal.PRIORITY_CREATE, edit, file, parametersAfterCall, new PyCreateMethodOrField(), @@ -365,8 +371,10 @@ IPyCompletionProposal.PRIORITY_CREATE, edit, file, parametersAfterCall, new PyCr 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, + props.add(CompletionProposalFactory.get().createTddRefactorCompletionInModule(markerContents, imageClass, + "Create " + markerContents + + " class at " + file.getName(), + null, "Create " + markerContents + " class at " + file, IPyCompletionProposal.PRIORITY_CREATE, edit, file, parametersAfterCall, new PyCreateClass(), ps, @@ -375,8 +383,10 @@ IPyCompletionProposal.PRIORITY_CREATE, edit, file, parametersAfterCall, new PyCr 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, + props.add(CompletionProposalFactory.get().createTddRefactorCompletionInInexistentModule(markerContents, + imageClass, "Create " + markerContents + + " class at new module " + moduleName, + null, "Create " + markerContents + " class at new module " + file, @@ -386,8 +396,10 @@ private void addCreateClassInNewModuleOption(PySelection ps, IPyEdit edit, List< 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, + props.add(CompletionProposalFactory.get().createTddRefactorCompletionInInexistentModule(markerContents, + imageMethod, "Create " + markerContents + + " method at new module " + moduleName, + null, "Create " + markerContents + " method at new module " + file, @@ -397,8 +409,10 @@ private void addCreateMethodInNewModuleOption(PySelection ps, IPyEdit edit, List private void addCreateModuleOption(PySelection ps, IPyEdit edit, List props, String markerContents, File file) { - props.add(new TddRefactorCompletionInInexistentModule(markerContents, imageModule, "Create " + markerContents + - " module", null, + props.add(CompletionProposalFactory.get().createTddRefactorCompletionInInexistentModule(markerContents, + imageModule, "Create " + markerContents + + " module", + null, "Create " + markerContents + " module (" + file + ")", @@ -408,16 +422,20 @@ private void addCreateModuleOption(PySelection ps, IPyEdit edit, List props, String markerContents, List parametersAfterCall) { - props.add(new TddRefactorCompletion(markerContents, imageMethod, "Create " + markerContents + - " method", null, + props.add(CompletionProposalFactory.get().createTddRefactorCompletion(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, IPyEdit edit, List props, String markerContents, List parametersAfterCall) { - props.add(new TddRefactorCompletion(markerContents, imageClass, "Create " + markerContents + - " class", null, + props.add(CompletionProposalFactory.get().createTddRefactorCompletion(markerContents, imageClass, + "Create " + markerContents + + " class", + null, null, IPyCompletionProposal.PRIORITY_CREATE, edit, PyCreateClass.LOCATION_STRATEGY_BEFORE_CURRENT, parametersAfterCall, new PyCreateClass(), ps)); } diff --git a/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/tdd/PyCreateClass.java b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/tdd/PyCreateClass.java index 8c9ce5b8ed..c73e11beb6 100644 --- a/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/tdd/PyCreateClass.java +++ b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/tdd/PyCreateClass.java @@ -21,14 +21,14 @@ public class PyCreateClass extends AbstractPyCreateClassOrMethodOrField { private final static String baseClassStr = "" + - "class %s(${object}):\n" + + "class %s:\n" + " ${pass}${cursor}\n" + "\n" + "\n" + ""; private final static String baseClassWithInitStr = "" + - "class %s(${object}):\n" + + "class %s:\n" + " \n" + " def __init__(self, %s):\n" + diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixWithoutMarkersParticipant.java b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/tdd/TddCodeGenerationQuickFixWithoutMarkersParticipant.java similarity index 94% rename from plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixWithoutMarkersParticipant.java rename to plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/tdd/TddCodeGenerationQuickFixWithoutMarkersParticipant.java index 0ee4eb05b0..32f8d4b7bc 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixWithoutMarkersParticipant.java +++ b/plugins/com.python.pydev.analysis/src/com/python/pydev/analysis/refactoring/tdd/TddCodeGenerationQuickFixWithoutMarkersParticipant.java @@ -1,4 +1,4 @@ -package com.python.pydev.refactoring.tdd; +package com.python.pydev.analysis.refactoring.tdd; import java.io.File; import java.util.ArrayList; @@ -29,6 +29,7 @@ import org.python.pydev.core.docutils.PySelection.LineStartingScope; import org.python.pydev.core.docutils.PySelection.TddPossibleMatches; import org.python.pydev.core.log.Log; +import org.python.pydev.core.proposals.CompletionProposalFactory; import org.python.pydev.core.structure.CompletionRecursionException; import org.python.pydev.parser.jython.ast.ClassDef; import org.python.pydev.parser.jython.ast.FunctionDef; @@ -46,10 +47,6 @@ import org.python.pydev.shared_core.string.FullRepIterable; import org.python.pydev.shared_core.string.StringUtils; -import com.python.pydev.analysis.refactoring.tdd.AbstractPyCreateAction; -import com.python.pydev.analysis.refactoring.tdd.PyCreateClass; -import com.python.pydev.analysis.refactoring.tdd.PyCreateMethodOrField; - public class TddCodeGenerationQuickFixWithoutMarkersParticipant implements IAssistProps { /** @@ -104,11 +101,12 @@ static boolean checkInitCreation(IPyEdit edit, PySelection callPs, ItemPointer[] String displayString = StringUtils.format( "Create %s __init__ (%s)", className, definition.module.getName()); - TddRefactorCompletionInModule completion = new TddRefactorCompletionInModule("__init__", - imageCache.get(UIConstants.CREATE_METHOD_ICON), displayString, null, displayString, - IPyCompletionProposal.PRIORITY_CREATE, edit, definition.module.getFile(), - parametersAfterCall, pyCreateMethod, callPs, - AbstractPyCreateAction.LOCATION_STRATEGY_FIRST_METHOD); + ICompletionProposalHandle completion = CompletionProposalFactory.get() + .createTddRefactorCompletionInModule("__init__", + imageCache.get(UIConstants.CREATE_METHOD_ICON), displayString, null, displayString, + IPyCompletionProposal.PRIORITY_CREATE, edit, definition.module.getFile(), + parametersAfterCall, pyCreateMethod, callPs, + AbstractPyCreateAction.LOCATION_STRATEGY_FIRST_METHOD); ret.add(completion); return true; } @@ -123,7 +121,8 @@ static void addCreateMethodOption(PySelection ps, IPyEdit edit, List - + diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixFromMarkersParticipant.java b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixFromMarkersParticipant.java index 8f1c880662..f0b04c53cc 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixFromMarkersParticipant.java +++ b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixFromMarkersParticipant.java @@ -2,6 +2,7 @@ import com.python.pydev.analysis.additionalinfo.builders.AnalysisRunner; import com.python.pydev.analysis.ctrl_1.AbstractAnalysisMarkersParticipants; +import com.python.pydev.analysis.marker_quick_fixes.TddQuickFixFromMarkersParticipant; public class TddCodeGenerationQuickFixFromMarkersParticipant extends AbstractAnalysisMarkersParticipants { diff --git a/plugins/com.python.pydev.refactoring/tests/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixParticipantTest.java b/plugins/com.python.pydev.refactoring/tests/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixParticipantTest.java index d35120dc4e..351fe632e8 100644 --- a/plugins/com.python.pydev.refactoring/tests/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixParticipantTest.java +++ b/plugins/com.python.pydev.refactoring/tests/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixParticipantTest.java @@ -28,7 +28,10 @@ import com.python.pydev.analysis.refactoring.refactorer.Refactorer; import com.python.pydev.analysis.refactoring.tdd.AbstractPyCreateClassOrMethodOrField; +import com.python.pydev.analysis.refactoring.tdd.TddCodeGenerationQuickFixWithoutMarkersParticipant; import com.python.pydev.analysis.refactoring.tdd.TemplateInfo; +import com.python.pydev.refactoring.tdd.completions.TddRefactorCompletion; +import com.python.pydev.refactoring.tdd.completions.TddRefactorCompletionInModule; /** * @author Fabio diff --git a/plugins/com.python.pydev.refactoring/tests/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixParticipantWithMarkersTest.java b/plugins/com.python.pydev.refactoring/tests/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixParticipantWithMarkersTest.java index a1816a8acc..3381bc8782 100644 --- a/plugins/com.python.pydev.refactoring/tests/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixParticipantWithMarkersTest.java +++ b/plugins/com.python.pydev.refactoring/tests/com/python/pydev/refactoring/tdd/TddCodeGenerationQuickFixParticipantWithMarkersTest.java @@ -38,9 +38,13 @@ import com.python.pydev.analysis.AnalysisPreferences; import com.python.pydev.analysis.AnalysisTestsBase; import com.python.pydev.analysis.additionalinfo.builders.AnalysisRunner; +import com.python.pydev.analysis.marker_quick_fixes.TddQuickFixFromMarkersParticipant; import com.python.pydev.analysis.refactoring.quick_fixes.DummyMarkerInfoForAnalysis; import com.python.pydev.analysis.refactoring.refactorer.Refactorer; +import com.python.pydev.analysis.refactoring.tdd.TddCodeGenerationQuickFixWithoutMarkersParticipant; import com.python.pydev.analysis.refactoring.tdd.TemplateInfo; +import com.python.pydev.refactoring.tdd.completions.TddRefactorCompletion; +import com.python.pydev.refactoring.tdd.completions.TddRefactorCompletionInModule; /** * @author Fabio diff --git a/plugins/org.python.pydev.core/src/org/python/pydev/core/proposals/ICompletionProposalFactory.java b/plugins/org.python.pydev.core/src/org/python/pydev/core/proposals/ICompletionProposalFactory.java index 26e887550d..2fd21858ab 100644 --- a/plugins/org.python.pydev.core/src/org/python/pydev/core/proposals/ICompletionProposalFactory.java +++ b/plugins/org.python.pydev.core/src/org/python/pydev/core/proposals/ICompletionProposalFactory.java @@ -1,5 +1,6 @@ package org.python.pydev.core.proposals; +import java.io.File; import java.util.List; import org.eclipse.jface.text.IRegion; @@ -135,4 +136,25 @@ ICompletionProposalHandle createMoveImportsToLocalCompletionProposal( ShellId getCythonShellId(); + ICompletionProposalHandle createTddRefactorCompletion(String replacementString, IImageHandle image, + String displayString, + /*IContextInformation*/Object contextInformation, String additionalProposalInfo, int priority, IPyEdit edit, + int locationStrategy, List parametersAfterCall, /*PyCreateMethodOrField*/Object pyCreateAction, + PySelection ps); + + ICompletionProposalHandle createTddRefactorCompletionInModule(String replacementString, IImageHandle image, + String displayString, + /*IContextInformation*/ Object contextInformation, String additionalProposalInfo, int priority, + IPyEdit edit, + File module, List parametersAfterCall, /*AbstractPyCreateAction*/ Object pyCreateAction, + PySelection ps, + int locationStrategy); + + ICompletionProposalHandle createTddRefactorCompletionInInexistentModule(String replacementString, + IImageHandle image, String displayString, + /*IContextInformation*/ Object contextInformation, String additionalProposalInfo, int priority, + IPyEdit edit, + File module, List parametersAfterCall, /*AbstractPyCreateAction*/ Object pyCreateAction, + PySelection ps); + } \ No newline at end of file diff --git a/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/string/TextSelectionUtils.java b/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/string/TextSelectionUtils.java index c111a46a21..99ccf8cb28 100644 --- a/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/string/TextSelectionUtils.java +++ b/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/string/TextSelectionUtils.java @@ -760,7 +760,11 @@ public static int getFirstCharRelativePosition(IDocument doc, int cursorOffset) */ public static int getFirstCharPosition(IDocument doc, int cursorOffset) throws BadLocationException { IRegion region; - region = doc.getLineInformationOfOffset(cursorOffset); + try { + region = doc.getLineInformationOfOffset(cursorOffset); + } catch (BadLocationException e) { + throw new BadLocationException("Error: bad offset: " + cursorOffset + " doc len: " + doc.getLength()); + } int offset = region.getOffset(); return offset + getFirstCharRelativePosition(doc, cursorOffset); } @@ -1219,7 +1223,7 @@ public String getContentsFromLineRange(int startLine, int endLine) { */ public static boolean stillInTok(String string, int j) { char c = string.charAt(j); - + return c != '\n' && c != '\r' && c != ' ' && c != '.' && c != '(' && c != ')' && c != ',' && c != ']' && c != '[' && c != '#' && c != '\'' && c != '"'; } diff --git a/plugins/org.python.pydev/META-INF/MANIFEST.MF b/plugins/org.python.pydev/META-INF/MANIFEST.MF index f705285159..8123e810aa 100644 --- a/plugins/org.python.pydev/META-INF/MANIFEST.MF +++ b/plugins/org.python.pydev/META-INF/MANIFEST.MF @@ -50,6 +50,7 @@ Export-Package: com.python.pydev.actions, com.python.pydev.analysis.ctrl_1, com.python.pydev.analysis.indexview, com.python.pydev.analysis.ui, + com.python.pydev.refactoring.tdd.completions, com.python.pydev.ui.hierarchy, org.python.copiedfromeclipsesrc, org.python.pydev.ast.codecompletion, diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/AbstractTddRefactorCompletion.java b/plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/AbstractTddRefactorCompletion.java similarity index 98% rename from plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/AbstractTddRefactorCompletion.java rename to plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/AbstractTddRefactorCompletion.java index 6b15436f5e..8f35b9c1ea 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/AbstractTddRefactorCompletion.java +++ b/plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/AbstractTddRefactorCompletion.java @@ -4,7 +4,7 @@ * Please see the license.txt included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ -package com.python.pydev.refactoring.tdd; +package com.python.pydev.refactoring.tdd.completions; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; import org.eclipse.jface.text.contentassist.IContextInformation; diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletion.java b/plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletion.java similarity index 96% rename from plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletion.java rename to plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletion.java index a8f0607c3b..096d88862a 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletion.java +++ b/plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletion.java @@ -4,7 +4,7 @@ * Please see the license.txt included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ -package com.python.pydev.refactoring.tdd; +package com.python.pydev.refactoring.tdd.completions; import java.util.List; @@ -39,7 +39,7 @@ public final class TddRefactorCompletion extends AbstractTddRefactorCompletion { private PySelection ps; private TemplateInfo templateInfo; - TddRefactorCompletion(String replacementString, IImageHandle image, String displayString, + public TddRefactorCompletion(String replacementString, IImageHandle image, String displayString, IContextInformation contextInformation, String additionalProposalInfo, int priority, IPyEdit edit, int locationStrategy, List parametersAfterCall, AbstractPyCreateAction pyCreateAction, PySelection ps) { diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInInexistentModule.java b/plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletionInInexistentModule.java similarity index 99% rename from plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInInexistentModule.java rename to plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletionInInexistentModule.java index 067b49eaa3..0bdcc4d0d2 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInInexistentModule.java +++ b/plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletionInInexistentModule.java @@ -4,7 +4,7 @@ * Please see the license.txt included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ -package com.python.pydev.refactoring.tdd; +package com.python.pydev.refactoring.tdd.completions; import java.io.ByteArrayInputStream; import java.io.File; diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInModule.java b/plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletionInModule.java similarity index 98% rename from plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInModule.java rename to plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletionInModule.java index 734987c0d8..593bfa45f8 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/TddRefactorCompletionInModule.java +++ b/plugins/org.python.pydev/src/com/python/pydev/refactoring/tdd/completions/TddRefactorCompletionInModule.java @@ -4,7 +4,7 @@ * Please see the license.txt included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ -package com.python.pydev.refactoring.tdd; +package com.python.pydev.refactoring.tdd.completions; import java.io.File; import java.util.List; diff --git a/plugins/org.python.pydev/src/org/python/pydev/editor/codecompletion/proposals/DefaultCompletionProposalFactory.java b/plugins/org.python.pydev/src/org/python/pydev/editor/codecompletion/proposals/DefaultCompletionProposalFactory.java index fcb299c90b..8e8333479f 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/editor/codecompletion/proposals/DefaultCompletionProposalFactory.java +++ b/plugins/org.python.pydev/src/org/python/pydev/editor/codecompletion/proposals/DefaultCompletionProposalFactory.java @@ -1,5 +1,6 @@ package org.python.pydev.editor.codecompletion.proposals; +import java.io.File; import java.util.List; import org.eclipse.jface.text.IRegion; @@ -35,6 +36,11 @@ import org.python.pydev.shared_core.string.FastStringBuffer; import org.python.pydev.shared_ui.ImageCache; +import com.python.pydev.analysis.refactoring.tdd.AbstractPyCreateAction; +import com.python.pydev.refactoring.tdd.completions.TddRefactorCompletion; +import com.python.pydev.refactoring.tdd.completions.TddRefactorCompletionInInexistentModule; +import com.python.pydev.refactoring.tdd.completions.TddRefactorCompletionInModule; + public class DefaultCompletionProposalFactory implements ICompletionProposalFactory { @Override @@ -273,4 +279,42 @@ public ICompletionProposalHandle createMoveImportsToLocalCompletionProposal(Obje importHandleInfo, iImageHandle, displayString); } + @Override + public ICompletionProposalHandle createTddRefactorCompletion(String replacementString, IImageHandle image, + String displayString, + /*IContextInformation*/ Object contextInformation, String additionalProposalInfo, int priority, + IPyEdit edit, + int locationStrategy, List parametersAfterCall, /*AbstractPyCreateAction*/ Object pyCreateAction, + PySelection ps) { + return new TddRefactorCompletion(replacementString, image, displayString, + (IContextInformation) contextInformation, additionalProposalInfo, + priority, edit, locationStrategy, parametersAfterCall, (AbstractPyCreateAction) pyCreateAction, ps); + } + + @Override + public ICompletionProposalHandle createTddRefactorCompletionInModule(String replacementString, IImageHandle image, + String displayString, + /*IContextInformation*/ Object contextInformation, String additionalProposalInfo, int priority, + IPyEdit edit, + File module, List parametersAfterCall, /*AbstractPyCreateAction*/ Object pyCreateAction, + PySelection ps, + int locationStrategy) { + return new TddRefactorCompletionInModule(replacementString, image, displayString, + (IContextInformation) contextInformation, + additionalProposalInfo, priority, edit, module, parametersAfterCall, + (AbstractPyCreateAction) pyCreateAction, ps, + locationStrategy); + } + + @Override + public ICompletionProposalHandle createTddRefactorCompletionInInexistentModule(String replacementString, + IImageHandle image, String displayString, Object contextInformation, String additionalProposalInfo, + int priority, IPyEdit edit, File module, List parametersAfterCall, Object pyCreateAction, + PySelection ps) { + return new TddRefactorCompletionInInexistentModule(replacementString, image, displayString, + (IContextInformation) contextInformation, + additionalProposalInfo, priority, edit, module, parametersAfterCall, + (AbstractPyCreateAction) pyCreateAction, ps); + } + }