From f227331cae4c903d2d7360b1f515e619e6346db8 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 2 Feb 2011 15:50:35 +0100 Subject: [PATCH] EA-23902 (diagnostics) --- .../psi/stubs/SerializationManagerImpl.java | 11 ++++---- .../intellij/psi/stubs/StubSerializer.java | 7 +++-- .../source/tree/LazyParseableElement.java | 5 ++-- .../intellij/openapi/diagnostic/LogUtil.java | 26 +++++++++++++++++++ 4 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 platform/util/src/com/intellij/openapi/diagnostic/LogUtil.java diff --git a/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java b/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java index e90ab4138623..eb627af84818 100644 --- a/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java +++ b/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java @@ -13,14 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.psi.stubs; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.ApplicationComponent; +import com.intellij.openapi.diagnostic.LogUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.io.FileUtil; @@ -40,6 +37,9 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; +/* + * @author max + */ public class SerializationManagerImpl extends SerializationManager implements ApplicationComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.stubs.SerializationManagerImpl"); @@ -213,7 +213,7 @@ public class SerializationManagerImpl extends SerializationManager implements Ap private int getClassId(final StubSerializer serializer) { final Integer idValue = mySerializerToId.get(serializer); - assert idValue != null: "No ID found for serializer " + serializer; + assert idValue != null: "No ID found for serializer " + LogUtil.objectAndClass(serializer); return idValue.intValue(); } @@ -238,4 +238,3 @@ public class SerializationManagerImpl extends SerializationManager implements Ap } } } - diff --git a/platform/lang-api/src/com/intellij/psi/stubs/StubSerializer.java b/platform/lang-api/src/com/intellij/psi/stubs/StubSerializer.java index a254367c4ff1..d39204ee5010 100644 --- a/platform/lang-api/src/com/intellij/psi/stubs/StubSerializer.java +++ b/platform/lang-api/src/com/intellij/psi/stubs/StubSerializer.java @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.psi.stubs; import org.jetbrains.annotations.NonNls; import java.io.IOException; +/* + * @author max + */ public interface StubSerializer { @NonNls String getExternalId(); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java index 6eefc3ef646b..d1838797b7fc 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java @@ -22,6 +22,7 @@ package com.intellij.psi.impl.source.tree; import com.intellij.lang.ASTNode; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.ApplicationManagerEx; +import com.intellij.openapi.diagnostic.LogUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.ILazyParseableElementType; @@ -174,9 +175,9 @@ public class LazyParseableElement extends CompositeElement { if (parsedNode == null && myText.length() > 0) { if (ApplicationManagerEx.getApplicationEx().isInternal() && !ApplicationManager.getApplication().isUnitTestMode()) { - LOG.error("No parse for a non-empty string: " + myText + "; type=" + type + " (" + type.getClass().getName() + ")"); + LOG.error("No parse for a non-empty string: " + myText + "; type=" + LogUtil.objectAndClass(type)); } else { - LOG.error("No parse for a non-empty string: type=" + type + " (" + type.getClass().getName() + ")"); + LOG.error("No parse for a non-empty string: type=" + LogUtil.objectAndClass(type)); } } diff --git a/platform/util/src/com/intellij/openapi/diagnostic/LogUtil.java b/platform/util/src/com/intellij/openapi/diagnostic/LogUtil.java new file mode 100644 index 000000000000..adbc69fcff19 --- /dev/null +++ b/platform/util/src/com/intellij/openapi/diagnostic/LogUtil.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.diagnostic; + +import org.jetbrains.annotations.Nullable; + +public class LogUtil { + private LogUtil() { } + + public static String objectAndClass(@Nullable final Object o) { + return o != null ? o + " (" + o.getClass().getName() + ")" : "null"; + } +}