in src/org/jetbrains/r/codeInsight/table/RTableManipulationAnalyzerManager.kt [29:64]
fun processColumnsOfTables(context: PsiElement,
tables: List<RExpression>,
processor: Processor<TableColumnInfo>,
tableContextInfo: TableManipulationContextInfo<T>? = null): Boolean {
if (tables.isEmpty()) {
return true
}
val runtimeInfo = tables.first().containingFile.originalFile.runtimeInfo ?: return true
val tableAnalyser = getTableManipulationAnalyzer()
val collectProcessor = RTableColumnCollectProcessor()
var allTableColumnsMustBeQuoted = false
val tableInfos = tables.map { tableAnalyser.getTableColumns(it, runtimeInfo) }
if (tableContextInfo != null) {
val tableCallInfo = tableContextInfo.callInfo
val isCorrectTableType = tableInfos.all { it.type == tableAnalyser.tableColumnType }
val isQuotesNeeded = !isCorrectTableType && tableAnalyser.isSubscription(tableCallInfo.function)
|| tableCallInfo.function.isQuotesNeeded(tableCallInfo.argumentInfo, tableContextInfo.currentTableArgument)
if (!isQuotesNeeded && context.parent is RStringLiteralExpression) return true
allTableColumnsMustBeQuoted = isQuotesNeeded && context.parent !is RStringLiteralExpression
}
tableInfos.map { it.columns }.flatten().forEach(Consumer { t ->
t.quoteNeeded = allTableColumnsMustBeQuoted || columnMustBeQuoted(t.name)
collectProcessor.process(t)
})
tables.forEach(Consumer { table -> tableAnalyser.processStaticTableColumns(table, collectProcessor)})
for (column in collectProcessor.results) {
if (!processor.process(column)) {
return false
}
}
return true
}