blob: ba40d4562a34c0d84a24f89c86aa95f474788340 [file]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
{
classHeader="apache2.txt"
psiImplUtilClass="com.intellij.lang.ognl.psi.impl.OgnlPsiUtil"
parserClass="com.intellij.lang.ognl.parser.OgnlParser"
implements="com.intellij.lang.ognl.psi.OgnlPsiCompositeElement"
extends="com.intellij.lang.ognl.psi.impl.OgnlPsiCompositeElementBase"
psiClassPrefix="Ognl"
psiImplClassSuffix="Impl"
psiPackage="com.intellij.lang.ognl.psi"
psiImplPackage="com.intellij.lang.ognl.psi.impl"
elementTypeHolderClass="com.intellij.lang.ognl.OgnlTypes"
elementTypePrefix=""
elementTypeClass="com.intellij.lang.ognl.psi.OgnlTokenType"
tokenTypeClass="com.intellij.lang.ognl.psi.OgnlTokenType"
extends(".*(Expression|Literal)")="expression"
tokens = [
EXPRESSION_START="%{"
EXPRESSION_END="}"
DOT="."
COMMA=","
COLON=":"
LPARENTH="("
RPARENTH=")"
LBRACKET="["
RBRACKET="]"
LBRACE="{"
RBRACE="}"
AT="@"
QUESTION="?"
DOLLAR="$"
HASH="#"
PLUS="+"
MINUS="-"
MULTIPLY="*"
DIVISION="/"
MODULO="%"
NEGATE="!"
NOT_EQUAL="!="
EQUAL="=="
EQ="="
LESS="<"
LESS_EQUAL="<="
GREATER=">"
GREATER_EQUAL=">="
EQ_KEYWORD="eq"
NEQ_KEYWORD="neq"
LT_KEYWORD="lt"
LT_EQ_KEYWORD="lte"
GT_KEYWORD="gt"
GT_EQ_KEYWORD="gte"
AND_AND="&&"
OR_OR="||"
AND_KEYWORD="and"
OR_KEYWORD="or"
NOT_KEYWORD="not"
OR="|"
XOR="^"
AND="&"
NOT="~"
BAND_KEYWORD="band"
BOR_KEYWORD="bor"
XOR_KEYWORD="xor"
NEW_KEYWORD="new"
TRUE_KEYWORD="true"
FALSE_KEYWORD="false"
NULL_KEYWORD="null"
INSTANCEOF_KEYWORD="instanceof"
NOT_IN_KEYWORD="not in"
IN_KEYWORD="in"
SHIFT_LEFT="<<"
SHIFT_RIGHT=">>"
SHIFT_RIGHT_LOGICAL=">>>"
SHIFT_LEFT_KEYWORD="shl"
SHIFT_RIGHT_KEYWORD="shr"
SHIFT_RIGHT_LOGICAL_KEYWORD="ushr"
]
}
root ::= EXPRESSION_START rootElement EXPRESSION_END { pin=1 }
private rootRecover ::= !(EXPRESSION_END)
private rootElement ::= expression {recoverWhile="rootRecover"}
expression ::= unaryExpression |
lambdaExpression |
mapExpression |
sequenceExpression |
parenthesizedExpression |
variableAssignmentExpression |
conditionalExpression |
binaryExpression |
newArrayExpression |
newExpression |
methodCallExpression |
indexedExpression |
referenceExpression |
variableExpression |
literalExpression
{
methods=[
getType
]
}
private numberLiteralExpression ::= INTEGER_LITERAL | BIG_INTEGER_LITERAL | DOUBLE_LITERAL | BIG_DECIMAL_LITERAL
private booleanLiteralExpression ::= "true" | "false"
private textLiteralExpression ::= STRING_LITERAL | CHARACTER_LITERAL // TODO detect missing closing quote/tick
literalExpression ::= numberLiteralExpression |
textLiteralExpression |
booleanLiteralExpression |
"null" {
methods=[
getConstantValue
]
}
projectionExpression ::= '{' expression '}'
{
methods=[
projectionExpression="expression"
]
}
selectionExpression ::= '{' ('?' | '^' | '$') expression '}'
{
methods=[
selectorExpression="expression"
]
}
referenceExpression ::= (variableExpression | ('@')? IDENTIFIER)
('.' IDENTIFIER)* ('@' IDENTIFIER)?
('.' selectionExpression)?
('.' projectionExpression )?
{
mixin="com.intellij.lang.ognl.psi.impl.OgnlReferenceExpressionBase"
}
variableExpression ::= '#' IDENTIFIER {
mixin="com.intellij.lang.ognl.psi.impl.OgnlVariableExpressionBase"
}
variableAssignmentExpression ::= '#' IDENTIFIER '=' expression {
methods=[
getVariableName
assignment="expression"
]
pin=3
}
parameterList ::= expression? (',' expression)* {
methods=[
parametersList="expression"
getParameterCount
]
}
methodCallExpression ::= referenceExpression '(' parameterList ')' {
methods=[
method="expression"
]
pin(".*")="'\('"
}
private expressionSequenceRequired ::= expression (',' expression)+ { pin(".*")=1 }
sequenceExpression ::= '{' expressionSequenceRequired '}' {
methods=[
elementsList="expression"
]
pin=1
}
mapEntryElement ::= expression ':' expression {
methods=[
expression=""
keyExpression="expression[0]"
valueExpression="expression[1]"
]
name="map entry"
pin=1
}
private mapExpressionSequence ::= [] mapEntryElement (',' mapEntryElement)* {pin(".*")=1}
private mapTypeExpression ::= '#@' fqnTypeExpression '@{' {
pin=1
}
mapExpression ::= ('#{' | mapTypeExpression) mapExpressionSequence '}' {
methods=[
mapType="fqnTypeExpression"
]
pin=1
}
lambdaExpression ::= ':' '[' expression "]" {
pin=1
}
indexedExpression ::= (referenceExpression | variableExpression) '[' expression ']'
('.' IDENTIFIER)*
('.' selectionExpression | projectionExpression)? {
methods=[
expression=""
referenceQualifier="expression[0]"
indexExpression="expression[1]"
]
pin=2
}
parenthesizedExpression ::= '(' expression ')' { pin=1 }
// binary ----------------------------------------------------------------
private plusMinusOperations ::= '+' | '-'
private divideMultiplyOperations ::= '*' | '/' | '%'
private booleanOperations ::= "&&" | "||" |
"and" | "or" |
"not"
private bitwiseBooleanOperations ::= "|" | "^" | "&" | "band" | "bor" | "xor"
private equalityOperations ::= "==" | "!=" |
"eq" | "neq"
private relationalOperations ::= '<' | "<=" | '>' | ">=" |
"lt" | "lte" | "gt" | "gte"
private shiftOperations ::= "<<" | ">>" | ">>>" |
"shl" | "shr" | "ushr"
private instanceOfOperation ::= "instanceof"
private setOperations ::= "not in" | "in"
private binaryOperations ::=
plusMinusOperations |
divideMultiplyOperations |
bitwiseBooleanOperations |
instanceOfOperation |
shiftOperations |
booleanOperations |
equalityOperations |
relationalOperations |
setOperations
{ name="operator" }
binaryExpression ::= expression binaryOperations expression {
methods=[
expression=""
left="expression[0]"
right="expression[1]"
getOperator
]
}
private bitwiseOperations ::= '!' | "~"
private unaryOperator ::= bitwiseOperations |
'+' | '-' | "not"
unaryExpression ::= unaryOperator expression {
methods=[
getUnaryOperator
]
}
private conditionalExpressionTail ::= ':' expression {pin=1}
conditionalExpression ::= expression '?' expression conditionalExpressionTail {
methods=[
expression=""
condition="expression[0]"
then="expression[1]"
else="expression[2]"
]
}
private constructorExpression ::= '(' parameterList ')' {pin=1}
newExpression ::= "new" fqnTypeExpression constructorExpression {
methods=[
objectType="fqnTypeExpression"
]
pin=1
}
private arrayConstructorExpression ::= '[' expression? ']' sequenceExpression? {pin=1}
newArrayExpression ::= "new" fqnTypeExpression arrayConstructorExpression {
methods=[
expression=""
objectType="expression[0]"
constructorExpression="expression[1]"
]
}
// common
fqnTypeExpression ::= IDENTIFIER ('.' IDENTIFIER)* {
pin(".*")=1
mixin="com.intellij.lang.ognl.psi.impl.OgnlFqnTypeExpressionBase"
}