From 0769038c82184ba92b4f0b9f04f2932af9837b6a Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Sat, 21 Sep 2024 13:16:25 -0300 Subject: [PATCH] wip2 --- .../org.python.pydev.ast/META-INF/MANIFEST.MF | 1 + .../ast/adapters/visitors/VisitorFactory.java | 27 ++++++++ .../selection/SelectionException.java | 2 +- .../selection/SelectionExtenderVisitor.java | 2 +- .../selection/SelectionValidationVisitor.java | 2 +- .../ast/visitors/VisitorFactory.java | 61 ------------------- .../ExtractMethodRefactoring.java | 10 +-- .../core/base/RefactoringInfo.java | 15 +++-- .../adapter/FunctionDefAdapterTestCase.java | 8 +-- .../tests/adapter/HierarchyTestCase.java | 6 +- .../tests/adapter/ModuleAdapterTestCase.java | 4 +- .../GeneratePropertiesTestCase.java | 8 +-- .../extractmethod/ExtractMethodTestCase.java | 3 +- .../tests/core/AbstractIOTestCase.java | 6 +- .../visitors/AttributeVisitorTestCase.java | 19 +++--- .../tests/visitors/ClassVisitorTestCase.java | 11 ++-- .../visitors/PropertyVisitorTestCase.java | 14 +++-- .../ScopeVarAssignVisitorTestCase.java | 11 ++-- .../visitors/ScopeVarVisitorTestCase.java | 14 +++-- 19 files changed, 101 insertions(+), 123 deletions(-) rename plugins/{org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast => org.python.pydev.ast/src/org/python/pydev/ast/adapters}/visitors/selection/SelectionException.java (96%) rename plugins/{org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast => org.python.pydev.ast/src/org/python/pydev/ast/adapters}/visitors/selection/SelectionExtenderVisitor.java (99%) rename plugins/{org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast => org.python.pydev.ast/src/org/python/pydev/ast/adapters}/visitors/selection/SelectionValidationVisitor.java (97%) delete mode 100644 plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/VisitorFactory.java diff --git a/plugins/org.python.pydev.ast/META-INF/MANIFEST.MF b/plugins/org.python.pydev.ast/META-INF/MANIFEST.MF index 1bd588939c..cc80eef98d 100644 --- a/plugins/org.python.pydev.ast/META-INF/MANIFEST.MF +++ b/plugins/org.python.pydev.ast/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Export-Package: org.python.pydev.ast, org.python.pydev.ast.adapters.context, org.python.pydev.ast.adapters.offsetstrategy, org.python.pydev.ast.adapters.visitors, + org.python.pydev.ast.adapters.visitors.selection, org.python.pydev.ast.analysis, org.python.pydev.ast.analysis.messages, org.python.pydev.ast.builder, diff --git a/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/VisitorFactory.java b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/VisitorFactory.java index 3ce715b190..c5a2779e34 100644 --- a/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/VisitorFactory.java +++ b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/VisitorFactory.java @@ -8,6 +8,9 @@ import org.python.pydev.ast.adapters.ModuleAdapter; import org.python.pydev.ast.adapters.PythonModuleManager; import org.python.pydev.ast.adapters.context.AbstractContextVisitor; +import org.python.pydev.ast.adapters.visitors.selection.SelectionException; +import org.python.pydev.ast.adapters.visitors.selection.SelectionExtenderVisitor; +import org.python.pydev.ast.adapters.visitors.selection.SelectionValidationVisitor; import org.python.pydev.ast.codecompletion.revisited.modules.SourceModule; import org.python.pydev.core.BaseModuleRequest; import org.python.pydev.core.IGrammarVersionProvider; @@ -109,4 +112,28 @@ public AdditionalGrammarVersionsToCheck getAdditionalGrammarVersions() return new ModuleAdapter(pythonModuleManager, file, doc, org.python.pydev.parser.PyParser.parseSimple(doc, versionProvider), nature); } + public static void validateSelection(ModuleAdapter scope) throws SelectionException { + SelectionValidationVisitor visitor = null; + try { + visitor = new SelectionValidationVisitor(); + scope.getASTNode().accept(visitor); + } catch (SelectionException e) { + throw e; + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public static ICoreTextSelection createSelectionExtension(AbstractScopeNode scope, + ICoreTextSelection selection) { + SelectionExtenderVisitor visitor = null; + try { + visitor = new SelectionExtenderVisitor(scope.getModule(), selection); + scope.getASTNode().accept(visitor); + } catch (Exception e) { + throw new RuntimeException(e); + } + return visitor.getSelection(); + } + } diff --git a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionException.java b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionException.java similarity index 96% rename from plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionException.java rename to plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionException.java index 90ece05e46..d49d12fbf8 100644 --- a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionException.java +++ b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionException.java @@ -22,7 +22,7 @@ * */ -package org.python.pydev.refactoring.ast.visitors.selection; +package org.python.pydev.ast.adapters.visitors.selection; import org.python.pydev.parser.jython.SimpleNode; diff --git a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionExtenderVisitor.java b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionExtenderVisitor.java similarity index 99% rename from plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionExtenderVisitor.java rename to plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionExtenderVisitor.java index 74b39b4b2e..e53eca3884 100644 --- a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionExtenderVisitor.java +++ b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionExtenderVisitor.java @@ -22,7 +22,7 @@ * */ -package org.python.pydev.refactoring.ast.visitors.selection; +package org.python.pydev.ast.adapters.visitors.selection; import java.util.List; diff --git a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionValidationVisitor.java b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionValidationVisitor.java similarity index 97% rename from plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionValidationVisitor.java rename to plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionValidationVisitor.java index 8d8ae60abb..0207ddd840 100644 --- a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/selection/SelectionValidationVisitor.java +++ b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/adapters/visitors/selection/SelectionValidationVisitor.java @@ -22,7 +22,7 @@ * */ -package org.python.pydev.refactoring.ast.visitors.selection; +package org.python.pydev.ast.adapters.visitors.selection; import org.python.pydev.ast.codecompletion.revisited.visitors.AbstractVisitor; import org.python.pydev.parser.jython.SimpleNode; diff --git a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/VisitorFactory.java b/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/VisitorFactory.java deleted file mode 100644 index 489c56e9fa..0000000000 --- a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/VisitorFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** -* Copyright (C) 2006-2013 IFS Institute for Software and others -* -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Eclipse Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/epl-v10.html -* -* Original authors: -* Dennis Hunziker -* Ueli Kistler -* Reto Schuettel -* Robin Stocker -* Contributors: -* Fabio Zadrozny - initial implementation -******************************************************************************/ -/* - * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler - * Copyright (C) 2007 Reto Schuettel, Robin Stocker - * - * IFS Institute for Software, HSR Rapperswil, Switzerland - * - */ - -package org.python.pydev.refactoring.ast.visitors; - -import org.python.pydev.ast.adapters.AbstractScopeNode; -import org.python.pydev.ast.adapters.ModuleAdapter; -import org.python.pydev.refactoring.ast.visitors.selection.SelectionException; -import org.python.pydev.refactoring.ast.visitors.selection.SelectionExtenderVisitor; -import org.python.pydev.refactoring.ast.visitors.selection.SelectionValidationVisitor; -import org.python.pydev.shared_core.string.ICoreTextSelection; - -public final class VisitorFactory { - private VisitorFactory() { - } - - public static ICoreTextSelection createSelectionExtension(AbstractScopeNode scope, - ICoreTextSelection selection) { - SelectionExtenderVisitor visitor = null; - try { - visitor = new SelectionExtenderVisitor(scope.getModule(), selection); - scope.getASTNode().accept(visitor); - } catch (Exception e) { - throw new RuntimeException(e); - } - return visitor.getSelection(); - } - - public static void validateSelection(ModuleAdapter scope) throws SelectionException { - SelectionValidationVisitor visitor = null; - try { - visitor = new SelectionValidationVisitor(); - scope.getASTNode().accept(visitor); - } catch (SelectionException e) { - throw e; - } catch (Throwable e) { - throw new RuntimeException(e); - } - } -} diff --git a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractmethod/ExtractMethodRefactoring.java b/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractmethod/ExtractMethodRefactoring.java index 52544802ff..495996e38a 100644 --- a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractmethod/ExtractMethodRefactoring.java +++ b/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractmethod/ExtractMethodRefactoring.java @@ -14,12 +14,12 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* +/* * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler * Copyright (C) 2007 Reto Schuettel, Robin Stocker * * IFS Institute for Software, HSR Rapperswil, Switzerland - * + * */ package org.python.pydev.refactoring.coderefactoring.extractmethod; @@ -32,9 +32,8 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.python.pydev.ast.adapters.IClassDefAdapter; import org.python.pydev.ast.adapters.ModuleAdapter; +import org.python.pydev.ast.adapters.visitors.selection.SelectionException; import org.python.pydev.core.log.Log; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; -import org.python.pydev.refactoring.ast.visitors.selection.SelectionException; import org.python.pydev.refactoring.core.base.AbstractPythonRefactoring; import org.python.pydev.refactoring.core.base.RefactoringInfo; import org.python.pydev.refactoring.core.base.RefactoringInfo.SelectionComputer; @@ -70,7 +69,8 @@ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws Core } try { - VisitorFactory.validateSelection(selectionComputer.selectionModuleAdapter); + org.python.pydev.ast.adapters.visitors.VisitorFactory + .validateSelection(selectionComputer.selectionModuleAdapter); } catch (SelectionException e) { status.addFatalError(e.getMessage()); return status; diff --git a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/base/RefactoringInfo.java b/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/base/RefactoringInfo.java index 90b604fd9a..f2bf4aa10b 100644 --- a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/base/RefactoringInfo.java +++ b/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/base/RefactoringInfo.java @@ -56,7 +56,6 @@ import org.python.pydev.parser.jython.ast.exprType; import org.python.pydev.parser.jython.ast.stmtType; import org.python.pydev.parser.jython.ast.factory.AdapterPrefs; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.shared_core.SharedCorePlugin; import org.python.pydev.shared_core.string.CoreTextSelection; import org.python.pydev.shared_core.string.ICoreTextSelection; @@ -133,7 +132,8 @@ private void initInfo(ICoreTextSelection selection) { } try { - this.moduleAdapter = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(moduleManager, realFile, doc, nature, + this.moduleAdapter = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter( + moduleManager, realFile, doc, nature, this.versionProvider); } catch (Throwable e) { throw new RuntimeException(e); @@ -314,7 +314,8 @@ private ModuleAdapter getParsedMultilineSelection(RefactoringInfo info, ICoreTex source = source.replaceAll("\r", ""); try { - ModuleAdapter node = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(source), null, + ModuleAdapter node = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, + null, new Document(source), null, info.getVersionProvider()); return node; } catch (TokenMgrError e) { @@ -335,8 +336,9 @@ public SelectionComputer getSelectionComputer(SelectionComputer.SelectionCompute private ICoreTextSelection getExtendedSelection() { if (getScopeAdapter() != null) { - return moduleAdapter.normalizeSelection(VisitorFactory.createSelectionExtension( - getScopeAdapter(), this.userSelection)); + return moduleAdapter + .normalizeSelection(org.python.pydev.ast.adapters.visitors.VisitorFactory.createSelectionExtension( + getScopeAdapter(), this.userSelection)); } return null; } @@ -351,7 +353,8 @@ private ModuleAdapter getParsedSelection(ICoreTextSelection selection) { if (selection != null && source.length() > 0) { try { - parsedAdapter = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(moduleManager, null, new Document(source), nature, + parsedAdapter = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(moduleManager, + null, new Document(source), nature, this.versionProvider); } catch (TokenMgrError e) { return null; diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/FunctionDefAdapterTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/FunctionDefAdapterTestCase.java index 846d1e295c..36f16616f6 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/FunctionDefAdapterTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/FunctionDefAdapterTestCase.java @@ -12,8 +12,8 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* - * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler +/* + * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler */ package org.python.pydev.refactoring.tests.adapter; @@ -24,7 +24,6 @@ import org.python.pydev.ast.adapters.FunctionDefAdapter; import org.python.pydev.ast.adapters.IClassDefAdapter; import org.python.pydev.ast.adapters.ModuleAdapter; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.tests.core.AbstractIOTestCase; public class FunctionDefAdapterTestCase extends AbstractIOTestCase { @@ -37,7 +36,8 @@ public FunctionDefAdapterTestCase(String name) { @Override public void runTest() throws Throwable { StringBuffer buffer = new StringBuffer(); - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(data.source), + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, + new Document(data.source), new PythonNatureStub(), createVersionProvider()); List classes = module.getClasses(); assertTrue(classes.size() > 0); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/HierarchyTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/HierarchyTestCase.java index 54871a10e0..261ebfb943 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/HierarchyTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/HierarchyTestCase.java @@ -37,7 +37,6 @@ import org.python.pydev.ast.codecompletion.shell.PythonShellTest; import org.python.pydev.core.ShellId; import org.python.pydev.core.TestDependent; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.shared_core.io.FileUtils; public class HierarchyTestCase extends CodeCompletionTestsBase { @@ -84,8 +83,9 @@ public void tearDown() throws Exception { public void testHierarchyWithBuiltins() throws Throwable { - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(new PythonModuleManager(nature), file, new Document( - FileUtils.getFileContents(file)), nature, nature); + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory + .createModuleAdapter(new PythonModuleManager(nature), file, new Document( + FileUtils.getFileContents(file)), nature, nature); List classes = module.getClasses(); assertEquals(1, classes.size()); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/ModuleAdapterTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/ModuleAdapterTestCase.java index 0249e530e8..a90ad2a14b 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/ModuleAdapterTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/adapter/ModuleAdapterTestCase.java @@ -24,7 +24,6 @@ import org.eclipse.jface.text.Document; import org.python.pydev.ast.adapters.FQIdentifier; import org.python.pydev.ast.adapters.ModuleAdapter; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.tests.core.AbstractIOTestCase; import com.thoughtworks.xstream.XStream; @@ -47,7 +46,8 @@ public void runTest() throws Throwable { }); xstream.alias("config", ModuleAdapterTestConfig.class); - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(data.source), + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, + new Document(data.source), new PythonNatureStub(), createVersionProvider()); if (data.config.length() > 0) { config = (ModuleAdapterTestConfig) xstream.fromXML(data.config); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/generateproperties/GeneratePropertiesTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/generateproperties/GeneratePropertiesTestCase.java index 796da910b1..d77f9a0171 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/generateproperties/GeneratePropertiesTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/generateproperties/GeneratePropertiesTestCase.java @@ -12,8 +12,8 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* - * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler +/* + * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler */ package org.python.pydev.refactoring.tests.codegenerator.generateproperties; @@ -30,7 +30,6 @@ import org.python.pydev.ast.adapters.IClassDefAdapter; import org.python.pydev.ast.adapters.ModuleAdapter; import org.python.pydev.core.MisconfigurationException; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.codegenerator.generateproperties.edit.DeleteMethodEdit; import org.python.pydev.refactoring.codegenerator.generateproperties.edit.GetterMethodEdit; import org.python.pydev.refactoring.codegenerator.generateproperties.edit.PropertyEdit; @@ -90,7 +89,8 @@ private IDocument applyGenerateProperties(MockupGeneratePropertiesRequestProcess private MockupGeneratePropertiesRequestProcessor setupRequestProcessor(MockupGeneratePropertiesConfig config) throws Throwable { - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(data.source), + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, + new Document(data.source), new PythonNatureStub(), createVersionProvider()); List classes = module.getClasses(); assertTrue(classes.size() > 0); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/coderefactoring/extractmethod/ExtractMethodTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/coderefactoring/extractmethod/ExtractMethodTestCase.java index dadf1dff1a..240d3fcf59 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/coderefactoring/extractmethod/ExtractMethodTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/coderefactoring/extractmethod/ExtractMethodTestCase.java @@ -14,7 +14,7 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* +/* * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler * Copyright (C) 2007 Reto Schuettel, Robin Stocker */ @@ -35,7 +35,6 @@ import org.python.pydev.core.MisconfigurationException; import org.python.pydev.parser.jython.ParseException; import org.python.pydev.parser.jython.ast.Module; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.coderefactoring.extractmethod.edit.ExtractCallEdit; import org.python.pydev.refactoring.coderefactoring.extractmethod.edit.ExtractMethodEdit; import org.python.pydev.refactoring.coderefactoring.extractmethod.edit.ParameterReturnDeduce; diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/core/AbstractIOTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/core/AbstractIOTestCase.java index 06ef8bfbbc..f95f38ec24 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/core/AbstractIOTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/core/AbstractIOTestCase.java @@ -33,7 +33,6 @@ import org.python.pydev.core.IGrammarVersionProvider; import org.python.pydev.core.IModulesManager; import org.python.pydev.core.MisconfigurationException; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.shared_core.io.FileUtils; import org.python.pydev.shared_core.string.StringUtils; @@ -64,8 +63,9 @@ protected ModuleAdapter createModuleAdapterFromDataSource(String version) throws CodeCompletionTestsBase.nature.setVersion(version, null); } - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(pythonModuleManager, data.file, new Document( - data.source), CodeCompletionTestsBase.nature, CodeCompletionTestsBase.nature); + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory + .createModuleAdapter(pythonModuleManager, data.file, new Document( + data.source), CodeCompletionTestsBase.nature, CodeCompletionTestsBase.nature); return module; } catch (Exception e) { throw new RuntimeException("Error handling: " + data.file); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/AttributeVisitorTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/AttributeVisitorTestCase.java index 20a5e22121..e232827610 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/AttributeVisitorTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/AttributeVisitorTestCase.java @@ -12,8 +12,8 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* - * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler +/* + * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler */ package org.python.pydev.refactoring.tests.visitors; @@ -27,7 +27,6 @@ import org.python.pydev.ast.adapters.context.ClassDefVisitor; import org.python.pydev.ast.adapters.context.GlobalAttributeVisitor; import org.python.pydev.ast.adapters.context.LocalAttributeVisitor; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.tests.adapter.PythonNatureStub; import org.python.pydev.refactoring.tests.core.AbstractIOTestCase; @@ -40,16 +39,20 @@ public AttributeVisitorTestCase(String name) { @Override public void runTest() throws Throwable { StringBuffer buffer = new StringBuffer(); - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(data.source), + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, + new Document(data.source), new PythonNatureStub(), createVersionProvider()); - GlobalAttributeVisitor globalVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(GlobalAttributeVisitor.class, - module.getASTNode(), module, module); - ClassDefVisitor classVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(ClassDefVisitor.class, module.getASTNode(), + GlobalAttributeVisitor globalVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory + .createContextVisitor(GlobalAttributeVisitor.class, + module.getASTNode(), module, module); + ClassDefVisitor classVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor( + ClassDefVisitor.class, module.getASTNode(), module, module); assertTrue(classVisitor.getAll().size() > 0); ClassDefAdapter classDefAdapter = (ClassDefAdapter) classVisitor.getAll().get(0); - LocalAttributeVisitor localVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(LocalAttributeVisitor.class, + LocalAttributeVisitor localVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor( + LocalAttributeVisitor.class, classDefAdapter.getASTNode(), module, classDefAdapter); printAttributes(buffer, globalVisitor); printAttributes(buffer, localVisitor); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ClassVisitorTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ClassVisitorTestCase.java index 6217365c64..7e89f715da 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ClassVisitorTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ClassVisitorTestCase.java @@ -12,8 +12,8 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* - * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler +/* + * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler */ package org.python.pydev.refactoring.tests.visitors; @@ -24,7 +24,6 @@ import org.python.pydev.ast.adapters.IClassDefAdapter; import org.python.pydev.ast.adapters.ModuleAdapter; import org.python.pydev.ast.adapters.context.ClassDefVisitor; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.tests.adapter.PythonNatureStub; import org.python.pydev.refactoring.tests.core.AbstractIOTestCase; @@ -40,9 +39,11 @@ public ClassVisitorTestCase(String name) { @Override public void runTest() throws Throwable { StringBuffer buffer = new StringBuffer(); - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(data.source), + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, + new Document(data.source), new PythonNatureStub(), createVersionProvider()); - ClassDefVisitor visitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(ClassDefVisitor.class, module.getASTNode(), + ClassDefVisitor visitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor( + ClassDefVisitor.class, module.getASTNode(), module, module); Iterator iter = visitor.iterator(); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/PropertyVisitorTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/PropertyVisitorTestCase.java index 070616be83..5770d4d57e 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/PropertyVisitorTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/PropertyVisitorTestCase.java @@ -12,8 +12,8 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* - * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler +/* + * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler */ package org.python.pydev.refactoring.tests.visitors; @@ -26,7 +26,6 @@ import org.python.pydev.ast.adapters.PropertyAdapter; import org.python.pydev.ast.adapters.context.ClassDefVisitor; import org.python.pydev.ast.adapters.context.PropertyVisitor; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.tests.adapter.PythonNatureStub; import org.python.pydev.refactoring.tests.core.AbstractIOTestCase; @@ -38,14 +37,17 @@ public PropertyVisitorTestCase(String name) { @Override public void runTest() throws Throwable { StringBuffer buffer = new StringBuffer(); - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(data.source), + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, + new Document(data.source), new PythonNatureStub(), createVersionProvider()); - ClassDefVisitor classVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(ClassDefVisitor.class, module.getASTNode(), + ClassDefVisitor classVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor( + ClassDefVisitor.class, module.getASTNode(), module, module); assertTrue(classVisitor.getAll().size() > 0); ClassDefAdapter classDefAdapter = (ClassDefAdapter) classVisitor.getAll().get(0); - PropertyVisitor propertyVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(PropertyVisitor.class, + PropertyVisitor propertyVisitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor( + PropertyVisitor.class, classDefAdapter.getASTNode(), module, classDefAdapter); printProperties(buffer, propertyVisitor); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ScopeVarAssignVisitorTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ScopeVarAssignVisitorTestCase.java index 88d0bd554b..22140ab5dc 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ScopeVarAssignVisitorTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ScopeVarAssignVisitorTestCase.java @@ -12,8 +12,8 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* - * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler +/* + * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler */ package org.python.pydev.refactoring.tests.visitors; @@ -24,7 +24,6 @@ import org.python.pydev.ast.adapters.ModuleAdapter; import org.python.pydev.ast.adapters.SimpleAdapter; import org.python.pydev.ast.adapters.context.ScopeAssignedVisitor; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.tests.adapter.PythonNatureStub; import org.python.pydev.refactoring.tests.core.AbstractIOTestCase; @@ -37,9 +36,11 @@ public ScopeVarAssignVisitorTestCase(String name) { @Override public void runTest() throws Throwable { StringBuffer buffer = new StringBuffer(); - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(data.source), + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, + new Document(data.source), new PythonNatureStub(), createVersionProvider()); - ScopeAssignedVisitor visitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(ScopeAssignedVisitor.class, + ScopeAssignedVisitor visitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor( + ScopeAssignedVisitor.class, module.getASTNode(), module, module); assertTrue(visitor.getAll().size() > 0); diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ScopeVarVisitorTestCase.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ScopeVarVisitorTestCase.java index f920e10292..37c6ec8f78 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ScopeVarVisitorTestCase.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/visitors/ScopeVarVisitorTestCase.java @@ -12,8 +12,8 @@ * Contributors: * Fabio Zadrozny - initial implementation ******************************************************************************/ -/* - * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler +/* + * Copyright (C) 2006, 2007 Dennis Hunziker, Ueli Kistler */ package org.python.pydev.refactoring.tests.visitors; @@ -27,7 +27,6 @@ import org.python.pydev.ast.adapters.ModuleAdapter; import org.python.pydev.ast.adapters.SimpleAdapter; import org.python.pydev.ast.adapters.context.ScopeVariablesVisitor; -import org.python.pydev.refactoring.ast.visitors.VisitorFactory; import org.python.pydev.refactoring.tests.adapter.PythonNatureStub; import org.python.pydev.refactoring.tests.core.AbstractIOTestCase; @@ -40,19 +39,22 @@ public ScopeVarVisitorTestCase(String name) { @Override public void runTest() throws Throwable { StringBuffer buffer = new StringBuffer(); - ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, new Document(data.source), + ModuleAdapter module = org.python.pydev.ast.adapters.visitors.VisitorFactory.createModuleAdapter(null, null, + new Document(data.source), new PythonNatureStub(), createVersionProvider()); for (FunctionDefAdapter func : module.getFunctions()) { - ScopeVariablesVisitor visitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(ScopeVariablesVisitor.class, + ScopeVariablesVisitor visitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor( + ScopeVariablesVisitor.class, func.getASTNode(), module, func); printAttributes(buffer, visitor, func.getName()); } for (IClassDefAdapter clazz : module.getClasses()) { ClassDefAdapter c = (ClassDefAdapter) clazz; - ScopeVariablesVisitor visitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor(ScopeVariablesVisitor.class, + ScopeVariablesVisitor visitor = org.python.pydev.ast.adapters.visitors.VisitorFactory.createContextVisitor( + ScopeVariablesVisitor.class, c.getASTNode(), module, c); printAttributes(buffer, visitor, clazz.getName());