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

📄 functionargadapter.java

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

import java.util.ArrayList;
import java.util.List;

import org.python.pydev.parser.jython.ast.argumentsType;
import org.python.pydev.parser.jython.ast.exprType;
import org.python.pydev.refactoring.ast.rewriter.RewriterVisitor;

public class FunctionArgAdapter extends AbstractNodeAdapter<argumentsType> {

	public FunctionArgAdapter(ModuleAdapter module, FunctionDefAdapter parent, argumentsType node, String endLineDelim) {
		super(module, parent, node, endLineDelim);
	}

	public boolean hasKwArg() {
		return getASTNode().kwarg != null;
	}

	public boolean hasVarArg() {
		return (getASTNode().vararg != null);
	}

	public boolean hasArg() {
		return (getASTNode().args != null) && (getASTNode().args.length > 0);
	}

	public List<String> getArgOnly() {
		List<String> args = new ArrayList<String>();
		for (exprType arg : getASTNode().args) {
			args.add(nodeHelper.getName(arg));
		}
		return args;
	}

	public List<String> getSelfFilteredArgNames() {
		List<String> args = new ArrayList<String>();
		for (exprType arg : getSelfFilteredArgs()) {
			args.add(nodeHelper.getName(arg));
		}
		return args;
	}

	public List<exprType> getSelfFilteredArgs() {
		List<exprType> args = new ArrayList<exprType>();
		if (getASTNode().args == null)
			return args;

		for (exprType arg : getASTNode().args) {
			String argument = nodeHelper.getName(arg);
			if (!nodeHelper.isSelf(argument))
				args.add(arg);
		}
		return args;
	}

	public boolean isEmptyArgument() {
		return (!hasArg()) && (!(hasVarArg())) && (!(hasKwArg()));
	}

	public boolean hasOnlySelf() {
		return getSelfFilteredArgs().size() == 0 && (!(hasVarArg())) && (!(hasKwArg()));
	}

	public String getSignature() {
		return RewriterVisitor.createSourceFromAST(this.getASTNode(), true, getModule().getEndLineDelimiter());
	}
}

⌨️ 快捷键说明

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