PY-26963: Create language for Django 2.0 url syntax

This commit is contained in:
Ilya.Kazakevich
2017-12-18 23:23:20 +03:00
parent f1be2c6d33
commit c3d05a977a
3 changed files with 42 additions and 1 deletions
@@ -0,0 +1,7 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.extensions
import org.intellij.lang.regexp.psi.RegExpPattern
import java.util.regex.Pattern
fun RegExpPattern.asPattern() = Pattern.compile(text)!!
@@ -0,0 +1,34 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.extensions
import com.jetbrains.python.FunctionParameter
import com.jetbrains.python.psi.PyArgumentList
import com.jetbrains.python.psi.PyExpression
import com.jetbrains.python.psi.PyKeywordArgument
import com.jetbrains.python.psi.StringLiteralExpression
/**
* If literal is argument of some function call -- return callee
*/
fun StringLiteralExpression.getCalleeIfArgument(argumentPosition: Int, argumentName: String? = null): PyExpression? {
val parent = this.parent ?: return null
val argumentList = when (parent) {
is PyArgumentList -> parent
is PyKeywordArgument -> parent.parent as? PyArgumentList
else -> null
} ?: return null
if ((this == argumentList.arguments.getOrNull(argumentPosition))
||
(this == argumentName?.run { argumentList.getKeywordArgument(this@run)?.valueExpression })) {
return argumentList.callExpression?.callee
}
return null
}
/**
* @see getCalleeIfArgument
*/
fun StringLiteralExpression.getCalleeIfArgument(argument: FunctionParameter) = this.getCalleeIfArgument(argument.position, argument.name)
+1 -1
View File
@@ -38,7 +38,7 @@ import java.util.*;
/**
* @author traff
*
* All inhertors must be in {@link com.jetbrains.env.}.*
* All inhertors must be in {@link com.jetbrains.env}.*
*/
public abstract class PyEnvTestCase {
private static final Logger LOG = Logger.getInstance(PyEnvTestCase.class.getName());