Skip to content

Commit

Permalink
Move code related to TDD actions to core plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Sep 29, 2024
1 parent 9b27249 commit 4cfd990
Show file tree
Hide file tree
Showing 72 changed files with 2,090 additions and 1,259 deletions.
2 changes: 2 additions & 0 deletions plugins/com.python.pydev.analysis/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ Export-Package: com.python.pydev.analysis,
com.python.pydev.analysis.additionalinfo.dependencies,
com.python.pydev.analysis.external,
com.python.pydev.analysis.flake8,
com.python.pydev.analysis.marker_quick_fixes,
com.python.pydev.analysis.mypy,
com.python.pydev.analysis.pep8,
com.python.pydev.analysis.pylint,
com.python.pydev.analysis.refactoring.changes,
com.python.pydev.analysis.refactoring.quick_fixes,
com.python.pydev.analysis.refactoring.refactorer,
com.python.pydev.analysis.refactoring.tdd,
com.python.pydev.analysis.refactoring.wizards,
com.python.pydev.analysis.refactoring.wizards.rename,
com.python.pydev.analysis.refactoring.wizards.rename.visitors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.HashMap;
import java.util.Map;

import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.core.IAnalysisPreferences;

public abstract class AbstractAnalysisPreferences implements IAnalysisPreferences {

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

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.preferences.PydevPrefs;
import org.python.pydev.shared_core.SharedCorePlugin;
import org.python.pydev.shared_core.preferences.IScopedPreferences;
Expand Down Expand Up @@ -119,7 +119,7 @@ private Map<Integer, Integer> getSeverityTypeMap() {
/**
* return the severity based on the user-set values
*
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#getSeverityForType(int)
* @see org.python.pydev.core.IAnalysisPreferences#getSeverityForType(int)
*/
@Override
public int getSeverityForType(int type) {
Expand All @@ -134,7 +134,7 @@ public int getSeverityForType(int type) {
/**
* yeah, we always do code analysis...
*
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#makeCodeAnalysis()
* @see org.python.pydev.core.IAnalysisPreferences#makeCodeAnalysis()
*/
@Override
public boolean makeCodeAnalysis() {
Expand All @@ -147,7 +147,7 @@ public boolean makeCodeAnalysis() {
}

/**
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#getNamesIgnoredByUnusedVariable()
* @see org.python.pydev.core.IAnalysisPreferences#getNamesIgnoredByUnusedVariable()
*/
@Override
public Set<String> getNamesIgnoredByUnusedVariable() {
Expand Down Expand Up @@ -177,7 +177,7 @@ private Set<String> getSetOfNames(String preferencesName) {
}

/**
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#getModuleNamePatternsToBeIgnored()
* @see org.python.pydev.core.IAnalysisPreferences#getModuleNamePatternsToBeIgnored()
*/
@Override
public Set<String> getModuleNamePatternsToBeIgnored() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.text.IDocument;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.ast.analysis.messages.IMessage;
import org.python.pydev.ast.analysis.messages.Message;
import org.python.pydev.ast.codecompletion.revisited.modules.SourceModule;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IIndentPrefs;
import org.python.pydev.core.IPythonNature;
import org.python.pydev.core.log.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.text.IDocument;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.ast.analysis.messages.IMessage;
import org.python.pydev.ast.builder.PyDevBuilderVisitor;
import org.python.pydev.ast.codecompletion.revisited.modules.SourceModule;
import org.python.pydev.core.CheckAnalysisErrors;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IModule;
import org.python.pydev.core.IPythonNature;
import org.python.pydev.core.MisconfigurationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ public List<MarkerInfo> setMarkers(IResource resource, IDocument document, IMess
return null;
}

public ArrayList<MarkerInfo> generateMarkers(IDocument document, IMessage[] messages, IProgressMonitor monitor) {
public static ArrayList<MarkerInfo> generateMarkers(IDocument document, IMessage[] messages,
IProgressMonitor monitor) {
ArrayList<MarkerInfo> lst = new ArrayList<MarkerInfo>();
//add the markers... the id is put as additional info for it
for (IMessage m : messages) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.analysis.ctrl_1;
package com.python.pydev.analysis.marker_quick_fixes;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -16,12 +16,12 @@
import org.python.pydev.core.IPythonNature;
import org.python.pydev.core.docutils.PySelection;
import org.python.pydev.core.proposals.CompletionProposalFactory;
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;
import org.python.pydev.shared_core.image.IImageHandle;
import org.python.pydev.shared_core.image.UIConstants;
import org.python.pydev.shared_ui.SharedUiPlugin;

import com.python.pydev.analysis.additionalinfo.builders.AnalysisRunner;

Expand All @@ -30,7 +30,7 @@ public class DontAnalyzeFileMarkerParticipant implements IAssistProps {
private IImageHandle annotationImage;

public DontAnalyzeFileMarkerParticipant() {
IImageCache analysisImageCache = SharedUiPlugin.getImageCache();
IImageCache analysisImageCache = SharedCorePlugin.getImageCache();
annotationImage = analysisImageCache.get(UIConstants.ASSIST_ANNOTATION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,28 @@
*
* @author Fabio Zadrozny
*/
package com.python.pydev.analysis.ctrl_1;
package com.python.pydev.analysis.marker_quick_fixes;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.core.CheckAnalysisErrors;
import org.python.pydev.core.IAnalysisMarkersParticipant;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IMarkerInfoForAnalysis;
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.codefolding.MarkerAnnotationAndPosition;
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;
import org.python.pydev.shared_core.image.UIConstants;
import org.python.pydev.shared_ui.SharedUiPlugin;

import com.python.pydev.analysis.additionalinfo.builders.AnalysisRunner;

public class IgnoreErrorParticipant implements IAnalysisMarkersParticipant {

Expand All @@ -43,19 +42,23 @@ public IgnoreErrorParticipant() {
this(null);
}

private IgnoreErrorParticipant(FormatStd format) {
this.format = format;
}

/**
* Only for tests.
*/
/*default*/ IgnoreErrorParticipant(FormatStd format) {
this.format = format;
public static IgnoreErrorParticipant createForTests(FormatStd format) {
return new IgnoreErrorParticipant(format);
}

@Override
public void addProps(MarkerAnnotationAndPosition marker, IAnalysisPreferences analysisPreferences,
public void addProps(IMarkerInfoForAnalysis markerInfo, IAnalysisPreferences analysisPreferences,
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);
Integer id = markerInfo.getPyDevAnalisysType();
if (handled.contains(id)) {
return;
}
Expand All @@ -65,7 +68,7 @@ public void addProps(MarkerAnnotationAndPosition marker, IAnalysisPreferences an
return;
}

IImageCache imageCache = SharedUiPlugin.getImageCache();
IImageCache imageCache = SharedCorePlugin.getImageCache();
ICompletionProposalHandle proposal = CompletionProposalFactory.get().createIgnoreCompletionProposalInSameLine(
messageToIgnore, ps.getEndLineOffset(), 0, offset,
imageCache != null ? imageCache.get(UIConstants.ASSIST_ANNOTATION) : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@
/*
* Created on 24/09/2005
*/
package com.python.pydev.analysis.ctrl_1;
package com.python.pydev.analysis.marker_quick_fixes;

import java.util.List;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.core.IAnalysisMarkersParticipant;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.ICodeCompletionASTManager;
import org.python.pydev.core.IMarkerInfoForAnalysis;
import org.python.pydev.core.IPyEdit;
import org.python.pydev.core.IPythonNature;
import org.python.pydev.core.docutils.PySelection;
import org.python.pydev.editor.codefolding.MarkerAnnotationAndPosition;
import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle;

import com.python.pydev.analysis.additionalinfo.builders.AnalysisRunner;
import com.python.pydev.analysis.refactoring.quick_fixes.UndefinedVariableQuickFixCreator;

/**
Expand All @@ -46,12 +45,11 @@ public UndefinedVariableFixParticipant(boolean forceReparseOnApply) {
}

@Override
public void addProps(MarkerAnnotationAndPosition markerAnnotation, IAnalysisPreferences analysisPreferences,
public void addProps(IMarkerInfoForAnalysis markerInfoForAnalysis, IAnalysisPreferences analysisPreferences,
String line, PySelection ps, int offset, IPythonNature initialNature, IPyEdit edit,
List<ICompletionProposalHandle> props)
throws BadLocationException, CoreException {
IMarker marker = markerAnnotation.markerAnnotation.getMarker();
Integer id = (Integer) marker.getAttribute(AnalysisRunner.PYDEV_ANALYSIS_TYPE);
Integer id = markerInfoForAnalysis.getPyDevAnalisysType();
if (id != IAnalysisPreferences.TYPE_UNDEFINED_VARIABLE) {
return;
}
Expand All @@ -63,11 +61,11 @@ public void addProps(MarkerAnnotationAndPosition markerAnnotation, IAnalysisPref
return;
}

if (markerAnnotation.position == null) {
if (!markerInfoForAnalysis.hasPosition()) {
return;
}
int start = markerAnnotation.position.offset;
int end = start + markerAnnotation.position.length;
int start = markerInfoForAnalysis.getOffset();
int end = start + markerInfoForAnalysis.getLength();
UndefinedVariableQuickFixCreator.createImportQuickProposalsFromMarkerSelectedText(edit, ps, offset,
initialNature, props, astManager, start, end, forceReparseOnApply);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.ast.analysis.messages.IMessage;
import org.python.pydev.ast.analysis.messages.Message;
import org.python.pydev.ast.codecompletion.revisited.modules.SourceModule;
import org.python.pydev.core.CheckAnalysisErrors;
import org.python.pydev.core.CorePlugin;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.docutils.PySelection;
import org.python.pydev.core.log.Log;
import org.python.pydev.core.pep8.Pep8Runner;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.python.pydev.analysis.refactoring.quick_fixes;

import org.python.pydev.core.IMarkerInfoForAnalysis;

public class DummyMarkerInfoForAnalysis implements IMarkerInfoForAnalysis {

public Object message;
public Object flake8MessageId;
public int length;
public int offset;
public Integer pyDevAnalysisType;
public Object pyLintMessageId;

public DummyMarkerInfoForAnalysis(int pyDevAnalysisType, int offset, int length) {
this.pyDevAnalysisType = pyDevAnalysisType;
this.offset = offset;
this.length = length;
}

@Override
public Object getPyLintMessageIdAttribute() {
return pyLintMessageId;
}

@Override
public Integer getPyDevAnalisysType() {
return pyDevAnalysisType;
}

@Override
public boolean hasPosition() {
return true;
}

@Override
public int getOffset() {
return offset;
}

@Override
public int getLength() {
return length;
}

@Override
public void delete() {

}

@Override
public Object getFlake8MessageId() {
return flake8MessageId;
}

@Override
public Object getMessage() {
return message;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
* 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.refactoring.tdd;

import java.util.List;

import org.eclipse.jface.action.IAction;
import org.python.pydev.ast.refactoring.RefactoringInfo;
import org.python.pydev.core.IPyEdit;
import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle;

public abstract class AbstractPyCreateAction {

Expand All @@ -21,11 +19,11 @@ public abstract class AbstractPyCreateAction {

protected IPyEdit targetEditor;

public void setActiveEditor(IAction action, IPyEdit edit) {
public void setActiveEditor(IPyEdit edit) {
this.targetEditor = edit;
}

public abstract ICompletionProposalHandle createProposal(RefactoringInfo refactoringInfo, String actTok,
public abstract TemplateInfo createProposal(RefactoringInfo refactoringInfo, String actTok,
int locationStrategy, List<String> parametersAfterCall);

}
Loading

0 comments on commit 4cfd990

Please sign in to comment.