mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
[xtext][locationInFileProvider] Minor refactored the implementation to avoid the EcoreSwitch for debugability reasons
This commit is contained in:
parent
fdb6859021
commit
cc25489506
1 changed files with 11 additions and 16 deletions
|
@ -16,7 +16,6 @@ import org.eclipse.emf.ecore.EClass;
|
|||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.EReference;
|
||||
import org.eclipse.emf.ecore.EStructuralFeature;
|
||||
import org.eclipse.emf.ecore.util.EcoreSwitch;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
@ -113,22 +112,18 @@ public class DefaultLocationInFileProvider implements ILocationInFileProvider, I
|
|||
|
||||
private ITextRegion getTextRegion(final EObject owner, EStructuralFeature feature, final int indexInList,
|
||||
final boolean isSignificant) {
|
||||
return new EcoreSwitch<ITextRegion>() {
|
||||
@Override
|
||||
public ITextRegion caseEAttribute(EAttribute feature) {
|
||||
return getLocationOfAttribute(owner, feature, indexInList, isSignificant);
|
||||
if (feature instanceof EAttribute) {
|
||||
return getLocationOfAttribute(owner, (EAttribute)feature, indexInList, isSignificant);
|
||||
} else if (feature instanceof EReference) {
|
||||
EReference reference = (EReference) feature;
|
||||
if (reference.isContainment() || reference.isContainer()) {
|
||||
return getLocationOfContainmentReference(owner, reference, indexInList, isSignificant);
|
||||
} else {
|
||||
return getLocationOfCrossReference(owner, reference, indexInList, isSignificant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextRegion caseEReference(EReference feature) {
|
||||
if (feature.isContainment() || feature.isContainer()) {
|
||||
return getLocationOfContainmentReference(owner, feature, indexInList, isSignificant);
|
||||
} else {
|
||||
return getLocationOfCrossReference(owner, feature, indexInList, isSignificant);
|
||||
}
|
||||
}
|
||||
|
||||
}.doSwitch(feature);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private ITextRegion doGetTextRegion(final EObject owner, EStructuralFeature feature, final int indexInList,
|
||||
|
|
Loading…
Reference in a new issue