mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-26963: Create language for Django 2.0 url syntax
This commit is contained in:
@@ -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
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user