[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:
Sebastian Zarnekow 2012-03-06 10:57:21 +01:00
parent cec0e93b34
commit 0e0dab5370

View file

@ -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);
}