Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Sep 28, 2024
1 parent 69339b0 commit f9e4020
Show file tree
Hide file tree
Showing 35 changed files with 218 additions and 140 deletions.
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 @@ -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
Expand Up @@ -14,9 +14,9 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
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.core.IAnalysisPreferences;
import org.python.pydev.core.IIndentPrefs;
import org.python.pydev.core.docutils.PySelection;
import org.python.pydev.core.docutils.TabNannyDocIterator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import java.util.HashMap;
import java.util.Map;

import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.ast.codecompletion.revisited.modules.SourceToken;
import org.python.pydev.ast.codecompletion.revisited.visitors.AbstractVisitor;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IModule;
import org.python.pydev.core.IPythonNature;
import org.python.pydev.parser.jython.SimpleNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import org.eclipse.core.resources.IMarker;
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.CompositeMessage;
import org.python.pydev.ast.analysis.messages.IMessage;
import org.python.pydev.ast.analysis.messages.Message;
import org.python.pydev.ast.codecompletion.revisited.modules.SourceToken;
import org.python.pydev.ast.codecompletion.revisited.visitors.AbstractVisitor;
import org.python.pydev.ast.codecompletion.revisited.visitors.AbstractVisitor.ImportPartSourceToken;
import org.python.pydev.core.CheckAnalysisErrors;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IToken;
import org.python.pydev.core.docutils.ParsingUtils;
import org.python.pydev.core.docutils.PySelection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import java.util.HashMap;
import java.util.Map;

import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.ast.codecompletion.revisited.modules.SourceToken;
import org.python.pydev.ast.codecompletion.revisited.visitors.AbstractVisitor;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.ICompletionCache;
import org.python.pydev.core.IModule;
import org.python.pydev.parser.jython.ast.Assign;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.Document;
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.SourceToken;
import org.python.pydev.ast.codecompletion.revisited.visitors.AbstractVisitor;
import org.python.pydev.ast.codecompletion.revisited.visitors.Definition;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IDefinition;
import org.python.pydev.core.IModule;
import org.python.pydev.core.IPythonNature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
import java.util.HashSet;
import java.util.List;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.ast.codecompletion.revisited.CompletionCache;
import org.python.pydev.ast.codecompletion.revisited.CompletionState;
import org.python.pydev.ast.codecompletion.revisited.CompletionStateFactory;
Expand All @@ -25,9 +23,12 @@
import org.python.pydev.ast.codecompletion.revisited.visitors.Definition;
import org.python.pydev.ast.refactoring.PyRefactoringFindDefinition;
import org.python.pydev.ast.refactoring.RefactoringRequest;
import org.python.pydev.core.IAnalysisMarkersParticipant;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.ICodeCompletionASTManager;
import org.python.pydev.core.ICompletionState;
import org.python.pydev.core.IDefinition;
import org.python.pydev.core.IMarkerInfoForAnalysis;
import org.python.pydev.core.IModule;
import org.python.pydev.core.IPyEdit;
import org.python.pydev.core.IPythonNature;
Expand All @@ -38,7 +39,6 @@
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.codefolding.MarkerAnnotationAndPosition;
import org.python.pydev.parser.jython.SimpleNode;
import org.python.pydev.parser.jython.ast.ClassDef;
import org.python.pydev.parser.visitors.NodeUtils;
Expand All @@ -54,8 +54,6 @@
import org.python.pydev.shared_core.structure.Tuple;
import org.python.pydev.shared_ui.SharedUiPlugin;

import com.python.pydev.analysis.additionalinfo.builders.AnalysisRunner;
import com.python.pydev.analysis.ctrl_1.IAnalysisMarkersParticipant;
import com.python.pydev.analysis.refactoring.tdd.NullPyCreateAction;
import com.python.pydev.analysis.refactoring.tdd.PyCreateClass;
import com.python.pydev.analysis.refactoring.tdd.PyCreateMethodOrField;
Expand All @@ -79,7 +77,7 @@ public TddQuickFixParticipant() {
}

@Override
public void addProps(MarkerAnnotationAndPosition markerAnnotation, IAnalysisPreferences analysisPreferences,
public void addProps(IMarkerInfoForAnalysis markerInfo, IAnalysisPreferences analysisPreferences,
String line, PySelection ps, int offset, IPythonNature nature, IPyEdit edit,
List<ICompletionProposalHandle> props)
throws BadLocationException, CoreException {
Expand All @@ -92,13 +90,13 @@ public void addProps(MarkerAnnotationAndPosition markerAnnotation, IAnalysisPref
return;
}

if (markerAnnotation.position == null) {
if (!markerInfo.hasPosition()) {
return;
}
IMarker marker = markerAnnotation.markerAnnotation.getMarker();
Integer id = (Integer) marker.getAttribute(AnalysisRunner.PYDEV_ANALYSIS_TYPE);
int start = markerAnnotation.position.offset;
int end = start + markerAnnotation.position.length;
Integer id = markerInfo.getPyDevAnalisysType();
int start = markerInfo.getOffset();
int end = start + markerInfo.getLength();

ps.setSelection(start, end);
String markerContents;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.ast.codecompletion.revisited.modules.SourceToken;
import org.python.pydev.ast.codecompletion.revisited.visitors.AbstractVisitor;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IToken;
import org.python.pydev.parser.jython.SimpleNode;
import org.python.pydev.parser.jython.ast.Import;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Iterator;
import java.util.List;

import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IToken;
import org.python.pydev.shared_core.string.FastStringBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ public interface IMessage {
int getSeverity();

/**
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_DUPLICATED_SIGNATURE
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_NO_SELF
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_REIMPORT
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_UNDEFINED_VARIABLE
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_UNRESOLVED_IMPORT
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_UNUSED_IMPORT
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_UNUSED_VARIABLE
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_UNUSED_PARAMETER
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_UNUSED_WILD_IMPORT
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_USED_WILD_IMPORT
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_NO_EFFECT_STMT
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_INDENTATION_PROBLEM
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_PEP8
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_ARGUMENTS_MISATCH
* @see org.python.pydev.ast.analysis.IAnalysisPreferences#TYPE_INVALID_ENCODING
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_DUPLICATED_SIGNATURE
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_NO_SELF
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_REIMPORT
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_UNDEFINED_VARIABLE
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_UNRESOLVED_IMPORT
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_UNUSED_IMPORT
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_UNUSED_VARIABLE
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_UNUSED_PARAMETER
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_UNUSED_WILD_IMPORT
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_USED_WILD_IMPORT
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_NO_EFFECT_STMT
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_INDENTATION_PROBLEM
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_PEP8
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_ARGUMENTS_MISATCH
* @see org.python.pydev.core.IAnalysisPreferences#TYPE_INVALID_ENCODING
*
* @return this message type
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package org.python.pydev.ast.analysis.messages;

import org.eclipse.core.runtime.Assert;
import org.python.pydev.ast.analysis.IAnalysisPreferences;
import org.python.pydev.core.IAnalysisPreferences;
import org.python.pydev.core.IToken;

public class Message extends AbstractMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
/*
* Created on 24/09/2005
*/
package com.python.pydev.analysis.ctrl_1;
package org.python.pydev.core;

import java.util.List;

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.codefolding.MarkerAnnotationAndPosition;
import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle;

public interface IAnalysisMarkersParticipant {
Expand All @@ -38,7 +34,7 @@ public interface IAnalysisMarkersParticipant {
* @throws BadLocationException
* @throws CoreException
*/
public abstract void addProps(MarkerAnnotationAndPosition marker, IAnalysisPreferences analysisPreferences,
public abstract void addProps(IMarkerInfoForAnalysis markerInfo, IAnalysisPreferences analysisPreferences,
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 @@ -7,7 +7,7 @@
/*
* Created on 24/07/2005
*/
package org.python.pydev.ast.analysis;
package org.python.pydev.core;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.python.pydev.core;

public interface IMarkerInfoForAnalysis {

Object getPyLintMessageIdAttribute();

Integer getPyDevAnalisysType();

boolean hasPosition();

int getOffset();

int getLength();

void delete();

Object getFlake8MessageId();

Object getMessage();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import java.util.List;

import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.templates.Template;
import org.eclipse.jface.text.templates.TemplateContext;
import org.python.pydev.core.ICompletionRequest;
import org.python.pydev.core.IMarkerInfoForAnalysis;
import org.python.pydev.core.IPyEdit;
import org.python.pydev.core.IToken;
import org.python.pydev.core.ShellId;
Expand Down Expand Up @@ -34,13 +34,13 @@ ICompletionProposalHandle createIgnorePyLintCompletionProposalInSameLine(
String replacementString, int replacementOffset, int replacementLength, int cursorPosition,
IImageHandle image, String displayString, Object contextInformation,
String additionalProposalInfo, int priority, IPyEdit edit, String line, PySelection ps, FormatStd format,
IMarker marker);
IMarkerInfoForAnalysis marker);

ICompletionProposalHandle createIgnoreFlake8CompletionProposalInSameLine(
String replacementString, int replacementOffset, int replacementLength, int cursorPosition,
IImageHandle image, String displayString, Object contextInformation,
String additionalProposalInfo, int priority, IPyEdit edit, String line, PySelection ps, FormatStd format,
IMarker marker);
IMarkerInfoForAnalysis marker);

ICompletionProposalHandle createPyTemplateProposal(Template template, TemplateContext context,
IRegion region, IImageHandle image, int relevance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import java.util.List;

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.IAssistProps;
import org.python.pydev.core.IPyEdit;
import org.python.pydev.core.IPythonNature;
Expand Down Expand Up @@ -67,7 +68,8 @@ 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, edit, props);
participant.addProps(marker.asMarkerInfoForAnalysis(), analysisPreferences, currLine, ps,
offset, nature, edit, props);
} catch (Exception e) {
Log.log("Error when getting proposals.", e);
}
Expand Down
Loading

0 comments on commit f9e4020

Please sign in to comment.