Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Sep 29, 2024
1 parent 4cfd990 commit ee91c07
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 {

/**
Expand Down Expand Up @@ -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;
}
Expand All @@ -123,7 +121,8 @@ static void addCreateMethodOption(PySelection ps, IPyEdit edit, List<ICompletion
String displayString = StringUtils.format("Create %s %s at %s",
markerContents,
pyCreateMethod.getCreationStr(), classNameInLine);
TddRefactorCompletion tddRefactorCompletion = new TddRefactorCompletion(markerContents,
ICompletionProposalHandle tddRefactorCompletion = CompletionProposalFactory.get().createTddRefactorCompletion(
markerContents,
imageCache.get(UIConstants.CREATE_METHOD_ICON), displayString, null, null,
IPyCompletionProposal.PRIORITY_CREATE,
edit, PyCreateClass.LOCATION_STRATEGY_BEFORE_CURRENT, parametersAfterCall, pyCreateMethod, ps);
Expand Down Expand Up @@ -183,11 +182,12 @@ public static boolean checkCreationBasedOnFoundPointers(IPyEdit edit, PySelectio
"Create %s %s at %s (%s)", methodToCreate,
pyCreateMethod.getCreationStr(), className, definition.module.getName());

TddRefactorCompletionInModule completion = new TddRefactorCompletionInModule(methodToCreate,
imageCache.get(UIConstants.CREATE_METHOD_ICON), displayString,
null, displayString, IPyCompletionProposal.PRIORITY_CREATE, edit,
definition.module.getFile(), parametersAfterCall, pyCreateMethod, newSelection,
AbstractPyCreateAction.LOCATION_STRATEGY_END);
ICompletionProposalHandle completion = CompletionProposalFactory.get()
.createTddRefactorCompletionInModule(methodToCreate,
imageCache.get(UIConstants.CREATE_METHOD_ICON), displayString,
null, displayString, IPyCompletionProposal.PRIORITY_CREATE, edit,
definition.module.getFile(), parametersAfterCall, pyCreateMethod, newSelection,
AbstractPyCreateAction.LOCATION_STRATEGY_END);
ret.add(completion);
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/com.python.pydev.refactoring/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<ctrl_1_participant class="com.python.pydev.refactoring.tdd.TddCodeGenerationQuickFixFromMarkersParticipant"/>
</extension>
<extension point="org.python.pydev.pydev_ctrl_1">
<ctrl_1_participant class="com.python.pydev.refactoring.tdd.TddCodeGenerationQuickFixWithoutMarkersParticipant"/>
<ctrl_1_participant class="com.python.pydev.analysis.refactoring.tdd.TddCodeGenerationQuickFixWithoutMarkersParticipant"/>
</extension>


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

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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.python.pydev.analysis.additionalinfo.builders.AnalysisRunner;
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;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.python.pydev.core.proposals;

import java.io.File;
import java.util.List;

import org.eclipse.jface.text.IRegion;
Expand Down Expand Up @@ -135,4 +136,15 @@ ICompletionProposalHandle createMoveImportsToLocalCompletionProposal(

ShellId getCythonShellId();

ICompletionProposalHandle createTddRefactorCompletion(String markerContents, IImageHandle iImageHandle,
String displayString, Object object, Object object2, int priorityCreate, IPyEdit edit,
int locationStrategyBeforeCurrent, List<String> parametersAfterCall,
/*PyCreateMethodOrField*/ Object pyCreateMethod,
PySelection ps);

ICompletionProposalHandle createTddRefactorCompletionInModule(String string, IImageHandle iImageHandle,
String displayString, Object object, String displayString2, int priorityCreate, IPyEdit edit, File file,
List<String> parametersAfterCall, /*PyCreateMethodOrField*/ Object pyCreateMethod, PySelection callPs,
int locationStrategyFirstMethod);

}

0 comments on commit ee91c07

Please sign in to comment.