Skip to content

Commit

Permalink
Check if type container is null
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwan87 committed Oct 17, 2024
1 parent e7e271d commit 53e8097
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class OdinTypeResolver extends OdinVisitor {
OdinDeclaredIdentifier declaredIdentifier,
OdinDeclaration declaration,
OdinType type) {
if(type == null)
return TsOdinBuiltInTypes.UNKNOWN;

OdinTypeResolver typeResolver = new OdinTypeResolver(level, symbolTable, declaration, declaredIdentifier);
type.accept(typeResolver);
return Objects.requireNonNullElse(typeResolver.type, TsOdinBuiltInTypes.UNKNOWN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ importPath ::= DQ_STRING_LITERAL {
getReference
getReferences
getImportInfo
shouldAskParentForReferences
] implements=["com.intellij.psi.HintedReferenceHost"]}

fileScopeStatement ::= foreignImportDeclarationStatement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public class OdinPsiUtil {
OdinTypes.OROR,
OdinTypes.ANDAND);

public static boolean shouldAskParentForReferences(OdinImportPath ignored,
@NotNull PsiReferenceService.Hints ignored2) {
return true;
}

public static PsiReference getReference(OdinIdentifier self) {
return new OdinReference(self);
}
Expand Down Expand Up @@ -192,7 +197,12 @@ public static OdinType getTypeDefinition(OdinVariableDeclarationStatement statem
}

public static OdinType getTypeDefinition(OdinParameterDeclarator statement) {
return statement.getTypeDefinitionContainer().getType();
OdinTypeDefinitionContainer typeDefinitionContainer = statement.getTypeDefinitionContainer();
if(typeDefinitionContainer != null) {
return typeDefinitionContainer.getType();
}

return null;
}

public static OdinType getTypeDefinition(OdinVariableInitializationStatement statement) {
Expand Down

0 comments on commit 53e8097

Please sign in to comment.