Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class JumpToDeclarationFromSqlAction : AnAction() {
*/
private fun isNotBindVariable(it: PsiElement) =
(
it.parent.elementType is IFileElementType &&
it.parent?.elementType is IFileElementType &&
it.elementType != SqlTypes.EL_IDENTIFIER &&
it !is SqlElPrimaryExpr &&
!it.isNotWhiteSpace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class PsiDaoMethod(
val rootDir = psiProject.getContentRoot(daoFile) ?: return@runReadAction
val sqlFile = File(sqlFilePath)
val sqlFileName = sqlFile.name
val parentDir = "${RESOURCES_PATH}/${sqlFile.parent.replace("\\", "/")}"
val parentDir = "${RESOURCES_PATH}/${sqlFile.parent?.replace("\\", "/")}"
val parenDirPathSpirit = parentDir.split("/").toTypedArray()

WriteCommandAction.runWriteCommandAction(psiProject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ object PsiPatternUtil {
(element.elementType == SqlTypes.EL_IDENTIFIER && element.prevLeaf()?.text == it) ||
(
element.elementType == TokenType.BAD_CHARACTER &&
element.parent.prevLeafs
.firstOrNull { p -> p.text == it || p.elementType == SqlTypes.BLOCK_COMMENT_START }
element.parent
?.prevLeafs
?.firstOrNull { p -> p.text == it || p.elementType == SqlTypes.BLOCK_COMMENT_START }
?.text == it
)
}
Expand All @@ -75,7 +76,11 @@ object PsiPatternUtil {
override fun accepts(
element: PsiElement,
context: ProcessingContext?,
): Boolean = element.containingFile.originalFile.virtualFile.extension == extension
): Boolean =
element.containingFile
?.originalFile
?.virtualFile
?.extension == extension
},
)

Expand All @@ -88,7 +93,7 @@ object PsiPatternUtil {
element: PsiElement,
symbol: String,
): String {
val text = originalFile.containingFile.text
val text = originalFile.containingFile?.text ?: " "
val offset = element.textOffset
val builder = StringBuilder()
for (i in offset - 1 downTo 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class SqlParameterCompletionProvider : CompletionProvider<CompletionParameters>(
setFieldsAndMethodsCompletionResultSet(matchFields, matchMethod, result)
return
}
if (top.parent !is PsiFile && top.parent.parent !is PsiDirectory) {
if (top.parent !is PsiFile && top.parent?.parent !is PsiDirectory) {
val staticDirective = top.findNodeParent(SqlTypes.EL_STATIC_FIELD_ACCESS_EXPR)
staticDirective?.let {
topElementType = getElementTypeByStaticFieldAccess(top, it, topText) ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,16 +580,16 @@ open class SqlBlock(
}

if (child2 is SqlElBlockCommentBlock) {
when (child1) {
return when (child1) {
is SqlElBlockCommentBlock -> {
return SqlCustomSpacingBuilder().getSpacing(child2)
SqlCustomSpacingBuilder().getSpacing(child2)
}

is SqlWhitespaceBlock -> {
return SqlCustomSpacingBuilder().getSpacing(child2)
SqlCustomSpacingBuilder().getSpacing(child2)
}

else -> return SqlCustomSpacingBuilder.normalSpacing
else -> SqlCustomSpacingBuilder.normalSpacing
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SqlLineMakerProvider : RelatedItemLineMarkerProvider() {
if (!isSupportFileType(file) || isInjectionSqlFile(file)) return
// Display only on the first line
if (e.originalElement?.parent?.originalElement !is PsiFile ||
e.textRange.startOffset != file.textRange.startOffset
e.textRange?.startOffset != file.textRange?.startOffset
) {
return
}
Expand All @@ -66,7 +66,7 @@ class SqlLineMakerProvider : RelatedItemLineMarkerProvider() {
identifier.textRange,
getIcon(daoFile.toPsiFile(project)),
getToolTipTitle(daoFile.toPsiFile(project)),
getHandler(daoFile, identifier, file.virtualFile.nameWithoutExtension),
getHandler(daoFile, identifier, file.virtualFile?.nameWithoutExtension ?: ""),
GutterIconRenderer.Alignment.RIGHT,
) {
ArrayList<GotoRelatedItem>()
Expand Down
Loading