Skip to content

Commit

Permalink
Fixed NPE when variable has no references.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylussaud committed Feb 29, 2024
1 parent 0db035a commit a0d9430
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2023 Obeo.
* Copyright (c) 2017, 2024 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -136,7 +136,7 @@ public List<VarRef> getResolvedVarRef(Declaration declaration) {
final Optional<List<VarRef>> res = aqlValidationResults.values().stream().map(vr -> vr
.getResolvedVarRef(declaration)).filter(db -> db != null).findFirst();

return res.orElse(null);
return res.orElse(Collections.emptyList());
}

/**
Expand All @@ -154,7 +154,7 @@ public void putBindingResolvedVarRef(Variable variable, VarRef varRef) {

@Override
public List<VarRef> getResolvedVarRef(Variable variable) {
return variableResolvedVarRef.get(variable);
return variableResolvedVarRef.getOrDefault(variable, Collections.emptyList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2023 Obeo.
* Copyright (c) 2017, 2024 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -81,8 +81,7 @@ public interface IAcceleoValidationResult {
*
* @param declaration
* the {@link Declaration}
* @return the {@link List} of resolved {@link VarRef} for the given {@link Declaration} if any,
* <code>null</code> otherwise
* @return the {@link List} of resolved {@link VarRef} for the given {@link Declaration}
*/
List<VarRef> getResolvedVarRef(Declaration declaration);

Expand All @@ -91,8 +90,7 @@ public interface IAcceleoValidationResult {
*
* @param variable
* the {@link Variable}
* @return the {@link List} of resolved {@link VarRef} for the given {@link Variable} if any,
* <code>null</code> otherwise
* @return the {@link List} of resolved {@link VarRef} for the given {@link Variable}
*/
List<VarRef> getResolvedVarRef(Variable variable);

Expand Down

0 comments on commit a0d9430

Please sign in to comment.