diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContext.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContext.java index 9ce91201c96e..78d99a84f6aa 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContext.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -16,6 +16,7 @@ package com.intellij.openapi.actionSystem; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -34,6 +35,7 @@ public interface DataContext { * * @param dataId the data identifier for which the value is requested. * @return the value, or null if no value is available in the current context for this identifier. + * @deprecated use {@link DataContext#getData(DataKey)} */ @Nullable Object getData(@NonNls String dataId); @@ -45,4 +47,16 @@ public interface DataContext { return null; } }; + + /** + * Returns the value corresponding to the specified data key. Some of the supported + * data identifiers are defined in the {@link com.intellij.openapi.actionSystem.PlatformDataKeys} class. + * + * @param key the data key for which the value is requested. + * @return the value, or null if no value is available in the current context for this identifier. + */ + @Nullable + default T getData(@NotNull DataKey key) { + return (T)getData(key.getName()); + } }