diff --git a/platform/lang-impl/src/com/intellij/ide/CopyPasteUtil.java b/platform/lang-impl/src/com/intellij/ide/CopyPasteUtil.java index f8a28971261f..27a730f3459e 100644 --- a/platform/lang-impl/src/com/intellij/ide/CopyPasteUtil.java +++ b/platform/lang-impl/src/com/intellij/ide/CopyPasteUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.ide; @@ -8,6 +8,7 @@ import com.intellij.openapi.ide.CopyPasteManager; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; +import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; import java.util.function.Consumer; @@ -16,6 +17,10 @@ import static com.intellij.openapi.application.ApplicationManager.getApplication public final class CopyPasteUtil { private CopyPasteUtil() { } + public static void copyTextToClipboard(@NotNull String text) { + CopyPasteManager.getInstance().setContents(new StringSelection(text)); + } + public static PsiElement[] getElementsInTransferable(Transferable t) { final PsiElement[] elts = PsiCopyPasteManager.getElements(t); return elts != null ? elts : PsiElement.EMPTY_ARRAY;