use of com.perl5.lang.perl.psi.PsiPerlConditionalBlock in project Perl5-IDEA by Camelcade.
the class PerlBraceMatcher method getCodeConstructStart.
@Override
public int getCodeConstructStart(PsiFile file, int openingBraceOffset) {
PsiElement element = file.findElementAt(openingBraceOffset);
if (element == null || element instanceof PsiFile) {
return openingBraceOffset;
}
PsiElement codeBlock = element.getParent();
if (codeBlock != null && codeBlock instanceof PsiPerlBlock) {
PsiElement blockContainer = codeBlock.getParent();
if (blockContainer != null) {
if (blockContainer instanceof PerlSubDefinitionElement || blockContainer instanceof PsiPerlForCompound) {
return blockContainer.getTextOffset();
} else if (blockContainer instanceof PsiPerlConditionalBlock || blockContainer instanceof PsiPerlIfCompoundImpl) {
PsiElement keyword = blockContainer.getPrevSibling();
while (keyword != null && (keyword instanceof PsiWhiteSpace || keyword instanceof PsiComment)) {
keyword = keyword.getPrevSibling();
}
if (keyword != null) {
return keyword.getTextOffset();
}
}
}
}
return openingBraceOffset;
}
Aggregations