Package com._1c.g5.v8.dt.ql
Class QlUtil
- java.lang.Object
-
- com._1c.g5.v8.dt.ql.QlUtil
-
public class QlUtil extends Object
Methods for this class is used in different area of ql and ql.dcs
-
-
Constructor Summary
Constructors Constructor Description QlUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static int
checkForNull(Object objF, Object objS)
static TypeDescription
cloneTypeDescription(TypeDescription source)
Create copy of type descriptionstatic int
compareValueDateLiteral(DateLiteralExpression dateFt, DateLiteralExpression dateSd)
compare two date literalsstatic Map<String,String>
createUserDataIntnl()
Gets user data intnl for indexing valuesstatic Map<String,String>
createUserDataRu()
Gets user data ru for indexing valuesstatic TypeDescription
expandTypeSet(TypeDescription initialType, org.eclipse.emf.ecore.EObject context)
static TypeDescriptionSource
expandTypeSet(TypeDescriptionSource initialType, org.eclipse.emf.ecore.EObject context)
static boolean
fieldFromCompoundType(CommonExpression expr, IExpressionTypeChecker qlChecker)
static DbViewElement
getDbView(org.eclipse.emf.ecore.EObject object, IDynamicDbViewFieldComputer dynamicDbViewComputer)
Try found refer toDbViewElement
inobject
static ACommonExpression
getExpressionOfNestedTable(CommonExpression expression, IDynamicDbViewFieldComputer dbViewComputer)
Gets expression corresponding to the field of nested tablestatic List<DbViewFieldDef>
getFieldsFromOriginalDbView(DbViewElement dbViewDef, IDynamicDbViewFieldComputer dynamicDbViewComputer)
Get fields fromdbViewDef
, whendbViewDef.getMdObject() != null
anddbViewDef.getMdObject()
was linked with another DbViewstatic List<String>
getProposalsNameFor(org.eclipse.xtext.scoping.IScope scope, boolean isTable)
Get string proposals from scope (only that instance ofTable
)static CommonExpression
getRefExpressionOfNestedTable(CommonExpression expression, IDynamicDbViewFieldComputer dbViewComputer)
Gets expression corresponding to reference field of nested tablestatic String
getTypeName(TypeDescription type, boolean isRussian)
return name of the type, language sensetivestatic String
getTypeName(TypeDescriptionSource type, boolean isRussian)
Return name of the type, language sensetivestatic boolean
isCompoundType(TypeDescription type, org.eclipse.emf.ecore.EObject context)
Compound type is the type which has 2 or more TypeItem.static boolean
isCompoundType(TypeDescriptionSource type, org.eclipse.emf.ecore.EObject context)
Compound type is the type which has 2 or more TypeItem.static boolean
isCurrentLangRussian(org.eclipse.emf.ecore.EObject eObject)
Deprecated.Use the variant with provided services due to performance reasonsstatic boolean
isCurrentLangRussian(org.eclipse.emf.ecore.EObject eObject, IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager)
Check current language of configuration forScriptVariant.RUSSIAN
static boolean
isCurrentLangRussian(org.eclipse.emf.ecore.resource.Resource resource)
Deprecated.Use the variant with provided services due to performance reasonsstatic boolean
isCurrentLangRussian(org.eclipse.emf.ecore.resource.Resource resource, IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager)
Check current language of configuration forScriptVariant.RUSSIAN
static boolean
isExternalDataSourceTable(AbstractQuerySchemaTable input)
Checks thatAbstractQuerySchemaTable
corresponding to the table ofExternalDataSource
objectDbViewElement
.static boolean
isExternalDataSourceTable(CommonExpression input)
static boolean
isExternaldataSourceTemporaryTable(AbstractQuerySchemaTable input)
Checks thatAbstractQuerySchemaTable
corresponding to the temporary table ofExternalDataSource
Checks for full naming without using alias from query - segments count inAbstractQuerySchemaTable
should equals 4, it should be start fromEXTERNAL_DATA_SOURCE
.static boolean
isFloatNumber(NumberLiteralExpression number)
static boolean
isNestedTable(DbViewElement dbView)
Checks thatdbView
is nested tablestatic boolean
isPartOfBracketCommonExpression(CommonExpression expression)
Checks thatexpression
corresponding to the {@link QlPackage#Literals#BRACKET_COMMON_EXPRESSION__COMMON_EXPRESSION} partstatic boolean
isPeriodKeyword(CommonExpression expr, QlTypeDescriptionContainer qlTypeDescr)
Checks thatCommonExpression
content corresponding to period keywordstatic boolean
isQSExprNestedTable(QuerySchemaExpression qsExpr, IDynamicDbViewFieldComputer dbViewComputer)
Checks that expression contains link to nested tablestatic boolean
isSpecialCompoundType(TypeDescription type, org.eclipse.emf.ecore.EObject context)
Compound type is the type which has 2 or more TypeItem which have different base types and not is ref types.static boolean
isSpecialCompoundType(TypeDescriptionSource type, org.eclipse.emf.ecore.EObject context)
Compound type is the type which has 2 or more TypeItem which have different base types and not is ref types.static boolean
isUnfixedType(TypeDescription type)
Checks qualifiers of string and binary type for 'fix'static boolean
isUnlimitedType(TypeDescription type)
Checks qualifiers of string and binary type for 'unlimited'static boolean
isUnlimitedType(TypeDescriptionSource type)
Checks qualifiers of string and binary type for 'unlimited'static boolean
isZeroNumber(NumberLiteralExpression number)
ChecksNumberLiteralExpression
for zerostatic int
numberOfFields(QuerySchemaExpression qsExpr, IDynamicDbViewFieldComputer dynamicDbViewComputer)
determine number of fields forqsExpr
-
-
-
Method Detail
-
isFloatNumber
public static boolean isFloatNumber(NumberLiteralExpression number)
- Parameters:
number
-- Returns:
- if number is float value then
true
, else returnfalse
-
cloneTypeDescription
public static TypeDescription cloneTypeDescription(TypeDescription source)
Create copy of type description- Parameters:
source
- sourceTypeDescription
, cannot benull
- Returns:
- created copy, cannot be
null
-
isZeroNumber
public static boolean isZeroNumber(NumberLiteralExpression number)
ChecksNumberLiteralExpression
for zero- Parameters:
number
-NumberLiteralExpression
checking number, cannot benull
- Returns:
- if integer and fractional part of number equal zero then
true
, else returnfalse
-
getTypeName
public static String getTypeName(TypeDescription type, boolean isRussian)
return name of the type, language sensetive- Parameters:
type
-isRussian
-- Returns:
- name of the type
-
getTypeName
public static String getTypeName(TypeDescriptionSource type, boolean isRussian)
Return name of the type, language sensetive- Parameters:
type
- theTypeDescriptionSource
, may benull
isRussian
- Request russion variant of the name if true- Returns:
- The type name. Never
null
-
isQSExprNestedTable
public static boolean isQSExprNestedTable(QuerySchemaExpression qsExpr, IDynamicDbViewFieldComputer dbViewComputer)
Checks that expression contains link to nested table- Parameters:
qsExpr
- checkingQuerySchemaExpression
, cannot benull
dbViewComputer
- actualIDynamicDbViewFieldComputer
, cannot benull
- Returns:
- if
qsExpr
corresponding to nested table expression in ql language thentrue
elsefalse
-
isNestedTable
public static boolean isNestedTable(DbViewElement dbView)
Checks thatdbView
is nested table- Parameters:
dbView
- checking dbView, can benull
- Returns:
- if
dbView
corresponding to nested table thentrue
elsefalse
-
numberOfFields
public static int numberOfFields(QuerySchemaExpression qsExpr, IDynamicDbViewFieldComputer dynamicDbViewComputer)
determine number of fields forqsExpr
- Parameters:
qsExpr
-dynamicDbViewComputer
- special computer ofDbViewElement
fromCommonExpression
orAbstractQuerySchemaTable
- Returns:
- number of fields
-
isUnfixedType
public static boolean isUnfixedType(TypeDescription type)
Checks qualifiers of string and binary type for 'fix'- Parameters:
type
- checking type, cannot benull
- Returns:
true
, if string 'not fix',false
otherwise
-
isUnlimitedType
public static boolean isUnlimitedType(TypeDescription type)
Checks qualifiers of string and binary type for 'unlimited'- Parameters:
type
- checking type, cannot benull
- Returns:
true
, if string 'unlimited'false
otherwise
-
isUnlimitedType
public static boolean isUnlimitedType(TypeDescriptionSource type)
Checks qualifiers of string and binary type for 'unlimited'- Parameters:
type
- checking type, cannot benull
- Returns:
true
, if string 'unlimited'false
otherwise
-
isCompoundType
public static boolean isCompoundType(TypeDescription type, org.eclipse.emf.ecore.EObject context)
Compound type is the type which has 2 or more TypeItem.- Parameters:
type
- cannot benull
- Returns:
- true, if it's compound
-
isCompoundType
public static boolean isCompoundType(TypeDescriptionSource type, org.eclipse.emf.ecore.EObject context)
Compound type is the type which has 2 or more TypeItem.- Parameters:
type
- cannot benull
- Returns:
- true, if it's compound
-
isSpecialCompoundType
public static boolean isSpecialCompoundType(TypeDescription type, org.eclipse.emf.ecore.EObject context)
Compound type is the type which has 2 or more TypeItem which have different base types and not is ref types. This method not expandTypeSet
fromTypeDescription
- Parameters:
type
- checkedTypeDescription
, cannot benull
context
- context object for expandTypeSet
inTypeDescription
, cannot benull
- Returns:
- true, if it's compound
-
isSpecialCompoundType
public static boolean isSpecialCompoundType(TypeDescriptionSource type, org.eclipse.emf.ecore.EObject context)
Compound type is the type which has 2 or more TypeItem which have different base types and not is ref types. This method not expandTypeSet
fromTypeDescription
- Parameters:
type
- checkedTypeDescription
, cannot benull
context
- context object for expandTypeSet
inTypeDescription
, cannot benull
- Returns:
- true, if it's compound
-
compareValueDateLiteral
public static int compareValueDateLiteral(DateLiteralExpression dateFt, DateLiteralExpression dateSd)
compare two date literals- Parameters:
dateFt
-dateSd
-- Returns:
- 0 - if dateFt == dateSd, 1 - if dateFt > dateSd, -1 - if dateFt < dateSd, 2 - if dateFt not comparable with dateSd
-
getDbView
public static DbViewElement getDbView(org.eclipse.emf.ecore.EObject object, IDynamicDbViewFieldComputer dynamicDbViewComputer)
Try found refer toDbViewElement
inobject
- Parameters:
object
-dynamicDbViewComputer
- special computer ofDbViewElement
fromCommonExpression
orAbstractQuerySchemaTable
- Returns:
- actual dbView for this
object
ornull
-
getFieldsFromOriginalDbView
public static List<DbViewFieldDef> getFieldsFromOriginalDbView(DbViewElement dbViewDef, IDynamicDbViewFieldComputer dynamicDbViewComputer)
Get fields fromdbViewDef
, whendbViewDef.getMdObject() != null
anddbViewDef.getMdObject()
was linked with another DbView- Parameters:
dbViewDef
-dynamicDbViewComputer
- special computer ofDbViewElement
fromCommonExpression
orAbstractQuerySchemaTable
- Returns:
- fields of original dbView for
dbViewDef
-
checkForNull
public static int checkForNull(Object objF, Object objS)
- Parameters:
objF
-objS
-- Returns:
- 0 - both != null; 1 - both == null; -1 - else
-
isCurrentLangRussian
@Deprecated public static boolean isCurrentLangRussian(org.eclipse.emf.ecore.EObject eObject)
Deprecated.Use the variant with provided services due to performance reasonsCheck current language of configuration forScriptVariant.RUSSIAN
- Parameters:
eObject
- actual object- Returns:
- true, if current language of configuration equal
ScriptVariant.RUSSIAN
- See Also:
ScriptVariant
-
isCurrentLangRussian
public static boolean isCurrentLangRussian(org.eclipse.emf.ecore.EObject eObject, IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager)
Check current language of configuration forScriptVariant.RUSSIAN
- Parameters:
eObject
- actual objectresourceLookup
-IResourceLookup
service reference. May not benull
v8ProjectManager
-IV8ProjectManager
service reference. May not benull
- Returns:
- true, if current language of configuration equal
ScriptVariant.RUSSIAN
- See Also:
ScriptVariant
-
isCurrentLangRussian
@Deprecated public static boolean isCurrentLangRussian(org.eclipse.emf.ecore.resource.Resource resource)
Deprecated.Use the variant with provided services due to performance reasonsCheck current language of configuration forScriptVariant.RUSSIAN
- Parameters:
resource
- actual resource- Returns:
- true, if current language of configuration equal
ScriptVariant.RUSSIAN
- See Also:
ScriptVariant
-
isCurrentLangRussian
public static boolean isCurrentLangRussian(org.eclipse.emf.ecore.resource.Resource resource, IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager)
Check current language of configuration forScriptVariant.RUSSIAN
- Parameters:
resource
- actual resourceresourceLookup
-IResourceLookup
service reference. May not benull
v8ProjectManager
-IV8ProjectManager
service reference. May not benull
- Returns:
- true, if current language of configuration equal
ScriptVariant.RUSSIAN
- See Also:
ScriptVariant
-
getProposalsNameFor
public static List<String> getProposalsNameFor(org.eclipse.xtext.scoping.IScope scope, boolean isTable)
Get string proposals from scope (only that instance ofTable
)- Parameters:
scope
-isTable
- define what kind of type proposals we look up - table or field- Returns:
- list of proposals
-
createUserDataRu
public static Map<String,String> createUserDataRu()
Gets user data ru for indexing values- Returns:
- user data ru for indexing values, never
null
-
createUserDataIntnl
public static Map<String,String> createUserDataIntnl()
Gets user data intnl for indexing values- Returns:
- user data intnl for indexing values, never
null
-
isPeriodKeyword
public static boolean isPeriodKeyword(CommonExpression expr, QlTypeDescriptionContainer qlTypeDescr)
Checks thatCommonExpression
content corresponding to period keyword- Parameters:
expr
- checkingCommonExpression
, cannot benull
qlTypeDescr
- actualQlTypeDescriptionContainer
cannot benull
- Returns:
true
ifCommonExpression
content corresponding to period keyword,false
otherwise
-
getExpressionOfNestedTable
public static ACommonExpression getExpressionOfNestedTable(CommonExpression expression, IDynamicDbViewFieldComputer dbViewComputer)
Gets expression corresponding to the field of nested table- Parameters:
expression
- checking expression, cannot benull
dbViewComputer
- actualIDynamicDbViewFieldComputer
, cannot benull
- Returns:
- expression corresponding to field of nested table or
null
if field wasn't found
-
getRefExpressionOfNestedTable
public static CommonExpression getRefExpressionOfNestedTable(CommonExpression expression, IDynamicDbViewFieldComputer dbViewComputer)
Gets expression corresponding to reference field of nested table- Parameters:
expression
- checking expression, cannot benull
dbViewComputer
- actualIDynamicDbViewFieldComputer
, cannot benull
- Returns:
- expression corresponding to reference field of nested table or
null
if reference field wasn't found
-
isPartOfBracketCommonExpression
public static boolean isPartOfBracketCommonExpression(CommonExpression expression)
Checks thatexpression
corresponding to the {@link QlPackage#Literals#BRACKET_COMMON_EXPRESSION__COMMON_EXPRESSION} part- Parameters:
expression
- checking expression, cannot benull
- Returns:
true
ifexpression
corresponding to the {@link QlPackage#Literals#BRACKET_COMMON_EXPRESSION__COMMON_EXPRESSION} part,false
otherwise
-
expandTypeSet
public static TypeDescription expandTypeSet(TypeDescription initialType, org.eclipse.emf.ecore.EObject context)
- Parameters:
initialType
- initialTypeDescription
checking for containing ofTypeSet
ofDefinedType
orChartOfCharacteristicTypes
, cannot benull
context
- actualEObject
for resolving, cannot benull
- Returns:
TypeDescription
with types fromTypeSet
ofDefinedType
orChartOfCharacteristicTypes
, nevernull
-
expandTypeSet
public static TypeDescriptionSource expandTypeSet(TypeDescriptionSource initialType, org.eclipse.emf.ecore.EObject context)
- Parameters:
initialType
- initialTypeDescription
checking for containing ofTypeSet
ofDefinedType
orChartOfCharacteristicTypes
, cannot benull
context
- actualEObject
for resolving, cannot benull
- Returns:
TypeDescription
with types fromTypeSet
ofDefinedType
orChartOfCharacteristicTypes
, nevernull
-
fieldFromCompoundType
public static boolean fieldFromCompoundType(CommonExpression expr, IExpressionTypeChecker qlChecker)
-
isExternalDataSourceTable
public static boolean isExternalDataSourceTable(CommonExpression input)
Checks thatCommonExpression
corresponding to the field ofExternalDataSource
objectDbViewElement
. Checks for full naming without using alias from query - segments count inCommonExpression
should be more than 4, it should be start fromEXTERNAL_DATA_SOURCE
. SeeMdUtil.getFullyQualifiedName(com._1c.g5.v8.dt.metadata.mdclass.MdObject)
forExternalDataSource
and its objects- Parameters:
input
- checkingCommonExpression
, cannot benull
- Returns:
true
ifCommonExpression
is table ofExternalDataSource
objects,false
otherwise
-
isExternalDataSourceTable
public static boolean isExternalDataSourceTable(AbstractQuerySchemaTable input)
Checks thatAbstractQuerySchemaTable
corresponding to the table ofExternalDataSource
objectDbViewElement
. Checks for full naming without using alias from query - segments count inAbstractQuerySchemaTable
should be more than 4, it should be start fromEXTERNAL_DATA_SOURCE
. SeeMdUtil.getFullyQualifiedName(com._1c.g5.v8.dt.metadata.mdclass.MdObject)
forExternalDataSource
and its objects- Parameters:
input
- checkingAbstractQuerySchemaTable
, cannot benull
- Returns:
true
ifAbstractQuerySchemaTable
is table ofExternalDataSource
objects,false
otherwise
-
isExternaldataSourceTemporaryTable
public static boolean isExternaldataSourceTemporaryTable(AbstractQuerySchemaTable input)
Checks thatAbstractQuerySchemaTable
corresponding to the temporary table ofExternalDataSource
Checks for full naming without using alias from query - segments count inAbstractQuerySchemaTable
should equals 4, it should be start fromEXTERNAL_DATA_SOURCE
.- Parameters:
input
- checkingAbstractQuerySchemaTable
, cannot benull
- Returns:
true
ifAbstractQuerySchemaTable
is temporary table ofExternalDataSource
objects,false
otherwise
-
-