mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
[validation][bug 400989] Get issue location from parent node
DiagnosticConverterImpl#getLocationData() can only retrieve the location data (line number, offset, and length) if there is any node in the parse tree directly corresponding to the semantic object. This commit changes this by retrieving the location data for the container object in that case. Additionally there is a last fallback which will return location data (0, 0, 0) to make sure that there will always be an annotation displayed in the editor. Change-Id: Ied45b9dcaa402e32de94da496601116b6c4c3293
This commit is contained in:
parent
df18d11326
commit
3e52d685c4
1 changed files with 12 additions and 1 deletions
|
@ -11,6 +11,7 @@ import static com.google.common.collect.Lists.*;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.EStructuralFeature;
|
||||
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
|
||||
|
@ -216,8 +217,18 @@ public class DiagnosticConverterImpl implements IDiagnosticConverter {
|
|||
parserNode = nodes.get(index);
|
||||
}
|
||||
return getLocationForNode(parserNode);
|
||||
} else if (obj.eContainer() != null) {
|
||||
EObject container = obj.eContainer();
|
||||
EStructuralFeature containingFeature = obj.eContainingFeature();
|
||||
return getLocationData(container, containingFeature,
|
||||
containingFeature.isMany() ? ((EList<?>) container.eGet(containingFeature)).indexOf(obj)
|
||||
: ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
|
||||
}
|
||||
return null;
|
||||
IssueLocation result = new IssueLocation();
|
||||
result.lineNumber = 0;
|
||||
result.offset = 0;
|
||||
result.length = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
protected IssueLocation getLocationForNode(INode node) {
|
||||
|
|
Loading…
Reference in a new issue