mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
[formatting] Prevent NPE when formatting objects that reside in dummy resources without URI (backwards compatibility)
[debugAntlr] Set the URI for the formatting resource see https://bugs.eclipse.org/bugs/show_bug.cgi?id=347782
This commit is contained in:
parent
cec0e93b34
commit
0e0dab5370
1 changed files with 2 additions and 1 deletions
|
@ -69,8 +69,9 @@ public abstract class AbstractDeclarativeFormatter extends BaseFormatter {
|
|||
*/
|
||||
@Override
|
||||
public ITokenStream createFormatterStream(EObject context, String indent, ITokenStream out, boolean preserveWhitespaces) {
|
||||
if(context != null)
|
||||
if(context != null && context.eResource() != null && context.eResource().getURI() != null) {
|
||||
contextResourceURI = EcoreUtil2.getNormalizedResourceURI(context);
|
||||
}
|
||||
return new FormattingConfigBasedStream(out, indent, getConfig(), createMatcher(), hiddenTokenHelper,
|
||||
preserveWhitespaces);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue