IDEA-CR-3824 "maybe make it an error in test mode"

This commit is contained in:
Vladimir Krivosheev
2015-07-21 15:23:17 +02:00
parent 927237687d
commit efc328d9cf
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.components;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -46,8 +47,15 @@ public class ServiceManager {
if (instance == null) {
instance = componentManager.getComponent(serviceClass);
if (instance != null) {
LOG.warn(serviceClass.getName() + " requested as a service, but it is a component - convert it to a service or change call to " +
(componentManager == ApplicationManager.getApplication() ? "ApplicationManager.getApplication().getComponent()" : "project.getComponent()"));
Application app = ApplicationManager.getApplication();
String message = serviceClass.getName() + " requested as a service, but it is a component - convert it to a service or change call to " +
(componentManager == app ? "ApplicationManager.getApplication().getComponent()" : "project.getComponent()");
if (app.isUnitTestMode()) {
LOG.error(message);
}
else {
LOG.warn(message);
}
}
}
return instance;