예제 #1
0
	def remove_call(self):
		args_body = self.args_body
		args_container = one(args_body.xpath('./CheetahVarNameChunks/CallArgString'))
		args = self.args

		if not args: # no arguments.
			assert args_container.totext().strip('(\n\t )') == '', args_container.totext()
			self.remove_self()
			return

		if len(args) == 1 and (
				args[0].tag == 'CheetahVar'
				or (
					args[0].tag == 'Py'
					and len(args[0].text) >= 2
					and args[0].text[0] == args[0].text[-1]
					and args[0].text[0] in '"'"'"
				)
		):
			#just one cheetah var / Python string
			arg = args[0]
			self.replace_self(arg)
			# replace the right paren with whatever followed the `self` token
			assert arg.tail.strip() == ')', repr(arg.tostring())
			arg.tail = self.tail
		elif (
				# Python tokens without spaces
				all(arg.tag == 'Py' for arg in args) and
				all(arg.tail == '' for arg in args[:-1]) and
				args[-1].tail.strip() == ')'
		):
			#just one Python variable.
			#replace the call with just the arg (keep the $)
			namechunks = one(args_body.xpath('./CheetahVarNameChunks'))
			namechunks.clear()
			namechunks.extend(args)
			args[-1].tail = ''
		else:
			#there's something more complicated here.
			#just remove the method name (keep the $())
			self.name.remove_self()
예제 #2
0
파일: node.py 프로젝트: jtwang/RefactorLib
	def remove_call(self):
		args_body = self.args_body
		args_container = one(args_body.xpath('./CheetahVarNameChunks/CallArgString'))
		args = self.args

		if not args: # no arguments.
			assert args_container.totext().strip('(\n\t )') == '', args_container.totext()
			self.remove_self()
			return

		if len(args) == 1 and (
				args[0].tag == 'CheetahVar'
				or (
					args[0].tag == 'Py'
					and len(args[0].text) >= 2
					and args[0].text[0] == args[0].text[-1]
					and args[0].text[0] in '"'"'"
				)
		):
			#just one cheetah var / Python string
			arg = args[0]
			self.replace_self(arg)
			# replace the right paren with whatever followed the `self` token
			assert arg.tail.strip() == ')', repr(arg.tostring())
			arg.tail = self.tail
		elif (
				# Python tokens without spaces
				all(arg.tag == 'Py' for arg in args) and
				all(arg.tail == '' for arg in args[:-1]) and
				args[-1].tail.strip() == ')'
		):
			#just one Python variable.
			#replace the call with just the arg (keep the $)
			namechunks = one(args_body.xpath('./CheetahVarNameChunks'))
			namechunks.clear()
			namechunks.extend(args)
			args[-1].tail = ''
		else:
			#there's something more complicated here.
			#just remove the method name (keep the $())
			self.name.remove_self()
예제 #3
0
 def args_container(self):
     return one(self.xpath('BracedExpression'))
예제 #4
0
 def name(self):
     return one(self.xpath('./Identifier'))
예제 #5
0
파일: node.py 프로젝트: jtwang/RefactorLib
	def args_body(self):
		return one(self.xpath('./CheetahVarBody'))
예제 #6
0
파일: node.py 프로젝트: jtwang/RefactorLib
	def args_container(self):
		return one(self.args_body.xpath('./CheetahVarNameChunks/CallArgString'))
예제 #7
0
파일: node.py 프로젝트: jtwang/RefactorLib
	def name(self):
		return one(self.args_body.xpath('./CheetahVarNameChunks/DottedName[1]'))
예제 #8
0
 def args_container(self):
     return one(self.xpath('BracedExpression'))
예제 #9
0
 def name(self):
     return one(self.xpath('./Identifier'))
예제 #10
0
	def args_body(self):
		return one(self.xpath('./CheetahVarBody'))
예제 #11
0
	def args_container(self):
		return one(self.args_body.xpath('./CheetahVarNameChunks/CallArgString'))
예제 #12
0
	def name(self):
		return one(self.args_body.xpath('./CheetahVarNameChunks/DottedName[1]'))