⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propertyvisitortestcase.java

📁 Python Development Environment (Python IDE plugin for Eclipse). Features editor, code completion, re
💻 JAVA
字号:
package org.python.pydev.refactoring.tests.visitors;

import java.util.Iterator;

import org.eclipse.jface.text.Document;
import org.python.pydev.refactoring.ast.adapters.ClassDefAdapter;
import org.python.pydev.refactoring.ast.adapters.ModuleAdapter;
import org.python.pydev.refactoring.ast.adapters.PropertyAdapter;
import org.python.pydev.refactoring.ast.visitors.VisitorFactory;
import org.python.pydev.refactoring.ast.visitors.context.ClassDefVisitor;
import org.python.pydev.refactoring.ast.visitors.context.PropertyVisitor;
import org.python.pydev.refactoring.tests.adapter.PythonNatureStub;
import org.python.pydev.refactoring.tests.core.AbstractIOTestCase;

public class PropertyVisitorTestCase extends AbstractIOTestCase {
	public PropertyVisitorTestCase(String name) {
		super(name);
	}

	@Override
	public void runTest() throws Throwable {
		StringBuffer buffer = new StringBuffer();
		ModuleAdapter module = VisitorFactory.createModuleAdapter(null, null, new Document(getSource()), new PythonNatureStub());
		ClassDefVisitor classVisitor = VisitorFactory.createContextVisitor(ClassDefVisitor.class, module.getASTNode(), module, module);

		assertTrue(classVisitor.getAll().size() > 0);
		ClassDefAdapter classDefAdapter = (ClassDefAdapter) classVisitor.getAll().get(0);
        PropertyVisitor propertyVisitor = VisitorFactory.createContextVisitor(PropertyVisitor.class, classDefAdapter
				.getASTNode(), module, classDefAdapter);

		printProperties(buffer, propertyVisitor);

		assertEquals(getExpected(), getGenerated());
	}

	private void printProperties(StringBuffer buffer, PropertyVisitor propertyVisitor) {
		Iterator<PropertyAdapter> iter = propertyVisitor.iterator();
		buffer.append("# " + propertyVisitor.getAll().size() + "\n");
		while (iter.hasNext()) {
			PropertyAdapter propertyAdapter = iter.next();
			buffer.append("# " + propertyAdapter.getParentName() + " " + propertyAdapter.getName() + " " + propertyAdapter.isComplete()
					+ " " + propertyAdapter.hasGetter() + " " + propertyAdapter.hasSetter() + " " + propertyAdapter.hasDelete() + " "
					+ propertyAdapter.hasDocString() + "\n");
		}
		this.setTestGenerated(buffer.toString().trim());
	}

	@Override
	public String getExpected() {
		return getResult();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -