Skip to content

Commit

Permalink
Instanceof improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hurricup committed Oct 8, 2023
1 parent 75607ee commit b0b07e7
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,24 @@ public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull
return parent;
}

if (!(parent instanceof PsiPerlAssignExpr)) {
if (!(parent instanceof PsiPerlAssignExpr assignExpr)) {
return null;
}

if (PsiUtilCore.getElementType(((PsiPerlAssignExpr)parent).getRightOperatorElement(host)) != OPERATOR_ASSIGN) {
if (PsiUtilCore.getElementType(assignExpr.getRightOperatorElement(host)) != OPERATOR_ASSIGN) {
return null;
}

PsiElement variable = ((PsiPerlAssignExpr)parent).getLeftPartOfAssignment(host);
if (variable instanceof PerlVariableDeclarationExpr) {
List<PsiPerlVariableDeclarationElement> variables = ((PerlVariableDeclarationExpr)variable).getVariableDeclarationElementList();
PsiElement variable = assignExpr.getLeftPartOfAssignment(host);
if (variable instanceof PerlVariableDeclarationExpr variableDeclarationExpr) {
List<PsiPerlVariableDeclarationElement> variables = variableDeclarationExpr.getVariableDeclarationElementList();
if (variables.size() != 1) {
return null;
}
variable = variables.get(0);
}
else if (variable instanceof PsiPerlScalarVariable) {
PerlVariableDeclarationElement variableDeclarationElement = ((PsiPerlScalarVariable)variable).getLexicalDeclaration();
else if (variable instanceof PsiPerlScalarVariable scalarVariable) {
PerlVariableDeclarationElement variableDeclarationElement = scalarVariable.getLexicalDeclaration();
if (variableDeclarationElement == null) {
return null;
}
Expand Down

0 comments on commit b0b07e7

Please sign in to comment.