Skip to content

KtTypeCodeFragment

class KtTypeCodeFragment(
    project: Project, 
    name: String, 
    text: CharSequence, 
    context: PsiElement?
) : KtCodeFragment

A KtCodeFragment whose content is a type reference.

Use this when the snippet denotes a type rather than a value, for example when specifying a cast target in a refactoring. Its content element is a KtTypeReference, or null if the text could not be parsed as one.

Constructors

KtTypeCodeFragment

constructor(
    project: Project, 
    name: String, 
    text: CharSequence, 
    context: PsiElement?
)

Properties

allChildren

val PsiElement.allChildren: PsiChildRange

The range of all direct children of this element, or an empty range if it has none.

analysisContext

var KtFile.analysisContext: PsiElement?

The element whose context this file should be analyzed in, or null if the file has no analysis context. Set for files created by a contextual factory.

annotationEntries

annotations

open override val annotations: List<KtAnnotation>

children

open override val children: @NotNull Array<out PsiElement>

classes

open override val classes: Array<PsiClass>

containingDirectory

@get:Nullable
open override val containingDirectory: @Nullable PsiDirectory?

containingFile

@get:NotNull
open override val containingFile: @NotNull PsiFile

containingKtFile

open override val containingKtFile: KtFile

contentElementType

open var contentElementType: IElementType?

context

open override val context: PsiElement?

customStubBuilder

open val customStubBuilder: StubBuilder?

A stub builder to be used instead of the language-wide one from com.intellij.psi.stubs.LanguageStubDefinition.

danglingAnnotations

danglingModifierLists

declarations

open override val declarations: List<KtDeclaration>

doNotAnalyze

When non-null, marks this file as one that must not be analyzed; the string is a human-readable explanation. Set on throwaway files created by KtPsiFactory without a context.

elementTypeForStubBuilder

open val elementTypeForStubBuilder: @Nullable IStubFileElementType<*>?

endOffset

val PsiElement.endOffset: Int

The offset just past the end of this element's text range in the file.

exceptionHandler

open override var exceptionHandler: JavaCodeFragment.ExceptionHandler?

fileAnnotationList

The file-level annotation list holding the @file:... annotations, or null if the file has none.

fileDocument

@get:NotNull
override val fileDocument: @NotNull Document

fileElementType

@get:Nullable
open override val fileElementType: @Nullable IFileElementType?

fileType

open override val fileType: FileType

firstChild

open override val firstChild: PsiElement?

forcedResolveScope

open override val forcedResolveScope: GlobalSearchScope?

greenStub

val greenStub: @Nullable StubElement<*>?

greenStubTree

val greenStubTree: @Nullable StubTree?

importDirectives

The import directives of this file, in source order; empty if the file has no imports.

importList

open override val importList: KtImportList?

The primary import list of this file, or null if the file has no imports.

isCompiled

isContentsLoaded

isDirectory

open override val isDirectory: Boolean

isIndexingFileCopy

isPhysical

open override fun isPhysical(): Boolean
open override val isPhysical: Boolean

isTemplateDataFile

isUserDataEmpty

isValid

open override fun isValid(): Boolean

Always true: a code fragment is synthetic and always considered valid.

open override val isValid: Boolean

isWritable

open override val isWritable: Boolean

language

@get:NotNull
override val language: @NotNull Language

lastChild

open override val lastChild: PsiElement?

manager

override val manager: PsiManager?

modificationStamp

open override val modificationStamp: Long

name

@get:NotNull
open override var name: @NotNull String
open override val navigationElement: PsiElement?

nextLeafs

val PsiElement.nextLeafs: Sequence<PsiElement>

The following leaf elements as a lazy sequence, nearest first.

nextSibling

open override val nextSibling: PsiElement?

node

@get:NotNull
open override val node: @NotNull FileASTNode

nodeIfLoaded

@get:Nullable
open val nodeIfLoaded: @Nullable FileASTNode?

originalElement

open override val originalElement: PsiElement?

originalFile

@get:NotNull
open override var originalFile: @NotNull PsiFile

ownDeclarations

@get:NotNull
open val ownDeclarations: @NotNull Collection<out @NotNull PsiSymbolDeclaration>

ownReferences

@get:NotNull
open val ownReferences: @NotNull Collection<out @NotNull PsiSymbolReference>

packageDirective

The package directive of this file, or null if the file has no explicit package statement (root package).

packageFqName

var packageFqName: FqName

The fully qualified name of the file's package, or FqName.ROOT for the default (root) package.

packageName

open override var packageName: String

parent

open override val parent: PsiDirectory?

parents

val PsiElement.parents: Sequence<PsiElement>

The ancestors of this element, from its immediate parent up to and including the containing file.

parentsWithSelf

val PsiElement.parentsWithSelf: Sequence<PsiElement>

This element and its ancestors, from the element itself up to and including the containing file.

parserDefinition

@get:NotNull
open val parserDefinition: @NotNull ParserDefinition

presentation

open override val presentation: ItemPresentation?

prevLeafs

val PsiElement.prevLeafs: Sequence<PsiElement>

The preceding leaf elements as a lazy sequence, nearest first.

prevSibling

open override val prevSibling: PsiElement?

project

@get:NotNull
override val project: @NotNull Project

psiOrParent

open override val psiOrParent: KtElement

psiRoots

open override val psiRoots: @NotNull Array<out PsiFile?>

pureEndOffset

The end offset of this element's source.

pureStartOffset

The start offset of this element's source, excluding any leading comments.

reference

open override val reference: PsiReference?

references

open override val references: @NotNull Array<out PsiReference?>

resolveScope

open override val resolveScope: @NotNull GlobalSearchScope

script

The script declaration if this file is a Kotlin script, or null for a regular Kotlin file.

startOffset

val PsiElement.startOffset: Int

The offset of the start of this element's text range in the file.

startOffsetInParent

open override val startOffsetInParent: Int

startOffsetSkippingComments

The start offset of this element, skipping leading comments and the whitespace that follows them.

stub

open override val stub: KotlinFileStub?

stubbedSpine

@get:NotNull
open val stubbedSpine: @NotNull StubbedSpine

stubDescriptor

@get:Nullable
open val stubDescriptor: @Nullable LanguageStubDescriptor?

stubTree

@get:Nullable
open val stubTree: @Nullable StubTree?

stubTreeOrFileElement

@get:NotNull
open val stubTreeOrFileElement: @NotNull Pair<@Nullable StubTree?, @Nullable FileElement?>

superType

open override var superType: PsiType?

text

open override val text: String?

textLength

open override val textLength: Int

textOffset

open override val textOffset: Int

textRange

open override val textRange: TextRange?

textRangeInParent

@get:Contract(pure = true)
@get:NotNull
open val textRangeInParent: @NotNull TextRange

textRangeWithoutComments

val PsiElement.textRangeWithoutComments: TextRange

The text range of this element excluding any leading comments.

thisType

open override var thisType: PsiType?

treeElement

@get:Nullable
open val treeElement: @Nullable FileElement?

userDataString

@get:TestOnly
open val userDataString: String?

userMap

@get:NotNull
open var userMap: @NotNull KeyFMap

useScope

@get:NotNull
open override val useScope: @NotNull SearchScope

viewProvider

override val viewProvider: SingleRootFileViewProvider

virtualFile

open override val virtualFile: VirtualFile?

virtualFilePath

The path of the backing virtual file. The value is cached after the first access.

visibilityChecker

open override var visibilityChecker: JavaCodeFragment.VisibilityChecker

Functions

accept

open override fun accept(visitor: PsiElementVisitor)
open override fun <R, D> accept(visitor: KtVisitor<R, D>, data: D): R

Dispatches this element to the corresponding visit* method of the given visitor and returns its result.

acceptChildren

open fun acceptChildren(@NotNull visitor: @NotNull PsiElementVisitor)
open override fun <D> acceptChildren(visitor: KtVisitor<Void, D>, data: D)

Passes each direct child of this element to the given visitor.

add

open fun add(@NotNull element: @NotNull PsiElement): PsiElement?

addAfter

open fun addAfter(@NotNull element: @NotNull PsiElement, anchor: PsiElement?): PsiElement?

addBefore

open fun addBefore(@NotNull element: @NotNull PsiElement, anchor: PsiElement?): PsiElement?

addImportsFromString

open override fun addImportsFromString(imports: String?)

addRange

open fun addRange(first: PsiElement?, last: PsiElement?): PsiElement?

addRangeAfter

open fun addRangeAfter(
    first: PsiElement?, 
    last: PsiElement?, 
    anchor: PsiElement?
): PsiElement?

addRangeBefore

open fun addRangeBefore(
    @NotNull first: @NotNull PsiElement, 
    @NotNull last: @NotNull PsiElement, 
    anchor: PsiElement?
): PsiElement?

anyDescendantOfType

inline fun <reified T : PsiElement> PsiElement.anyDescendantOfType(noinline predicate: (T) -> Boolean = { true }): Boolean

Returns true if this element or any descendant of type T satisfies predicate.

inline fun <reified T : PsiElement> PsiElement.anyDescendantOfType(crossinline canGoInside: (PsiElement) -> Boolean, noinline predicate: (T) -> Boolean = { true }): Boolean

Returns true if this element or any descendant of type T satisfies predicate. canGoInside controls traversal into children but does not prevent the current element from being tested.

before

fun PsiElement.before(element: PsiElement): Boolean

Returns true if this element ends at or before element starts (that is, it precedes element in the file).

beforeAstChange

blockExpressionsOrSingle

Returns the statements of this element if it is a block, otherwise a single-element sequence of this element.

calcStubTree

open fun calcStubTree(): @NotNull StubTree

calcTreeElement

fun calcTreeElement(): @NotNull FileElement

canNavigate

open fun canNavigate(): Boolean

canNavigateToSource

checkAdd

fun checkAdd(@NotNull element: @NotNull PsiElement)

checkDecompiledText

fun PsiElement.checkDecompiledText()

Throws if this element belongs to a compiled file that is backed by a stub. Loading decompiled text is slow and should be avoided; stubs should be used instead. Called by the descendant-traversal helpers as a guard.

checkDelete

open fun checkDelete()

checkSetName

open fun checkSetName(name: String?)

clearCaches

open override fun clearCaches()

collectDescendantsOfType

inline fun <reified T : PsiElement> PsiElement.collectDescendantsOfType(noinline predicate: (T) -> Boolean = { true }): List<T>

Collects this element and all descendants of type T satisfying predicate into a list in post-order.

inline fun <reified T : PsiElement> PsiElement.collectDescendantsOfType(crossinline canGoInside: (PsiElement) -> Boolean, noinline predicate: (T) -> Boolean = { true }): List<T>

Collects this element and all descendants of type T satisfying predicate into a list in post-order. canGoInside controls traversal into children but does not prevent the current element from being collected.

collectDescendantsOfTypeTo

inline fun <reified T : PsiElement, C : MutableCollection<T>> PsiElement.collectDescendantsOfTypeTo(
    to: C, 
    crossinline canGoInside: (PsiElement) -> Boolean, 
    noinline predicate: (T) -> Boolean = { true }
): C

Adds this element and all descendants of type T satisfying predicate to to in post-order. canGoInside controls traversal into children but does not prevent the current element from being added.

containingClass

Returns the nearest enclosing KtClass, or null if there is none.

copy

fun copy(): PsiElement?

copyCopyableDataTo

open fun copyCopyableDataTo(clone: @NotNull UserDataHolderBase)

copyUserDataTo

open fun copyUserDataTo(other: @NotNull UserDataHolderBase)

createContentLeafElement

open fun createContentLeafElement(leafText: CharSequence?): TreeElement?

delete

open fun delete()

deleteChildRange

open fun deleteChildRange(first: PsiElement?, last: PsiElement?)

derefStub

fun derefStub(): @Nullable StubTree?

elementsInRange

fun PsiFile.elementsInRange(range: TextRange): List<PsiElement>

Returns the top-level elements that together cover the given range within this file.

findAliasByFqName

fun findAliasByFqName(fqName: FqName): KtImportAlias?

Returns the KtImportAlias under which the declaration with the given fqName is imported, or null if that declaration is not imported with an alias in this file.

findChildByClass

open fun <T> findChildByClass(aClass: Class<T?>?): @Nullable T?

findChildrenByClass

open fun <T> findChildrenByClass(aClass: Class<T?>?): @NotNull Array<out T?>

findDescendantOfType

inline fun <reified T : PsiElement> PsiElement.findDescendantOfType(noinline predicate: (T) -> Boolean = { true }): T?

Returns the first element of type T in a pre-order traversal of this element and its descendants that satisfies predicate, or null if there is none.

inline fun <reified T : PsiElement> PsiElement.findDescendantOfType(crossinline canGoInside: (PsiElement) -> Boolean, noinline predicate: (T) -> Boolean = { true }): T?

Returns the first element of type T in a pre-order traversal of this element and its descendants that satisfies predicate, or null. canGoInside controls traversal into children but does not prevent the current element from being tested.

findElementAt

open fun findElementAt(offset: Int): PsiElement?

findImportByAlias

Returns the import directive that introduces the given alias name, or null if this file has no such alias.

findReferenceAt

open fun findReferenceAt(offset: Int): PsiReference?

forceResolveScope

open override fun forceResolveScope(scope: GlobalSearchScope?)

forEachDescendantOfType

inline fun <reified T : PsiElement> PsiElement.forEachDescendantOfType(noinline action: (T) -> Unit)

Applies action to this element and every descendant of type T, in post-order (children before parents).

inline fun <reified T : PsiElement> PsiElement.forEachDescendantOfType(crossinline canGoInside: (PsiElement) -> Boolean, noinline action: (T) -> Unit)

Applies action to this element and every descendant of type T, in post-order. canGoInside controls whether each visited element's children are traversed; the element itself is still passed to action when it is a T, even if canGoInside returns false for it.

forEachDescendantOfTypeInPreorder

inline fun <reified T : PsiElement> PsiElement.forEachDescendantOfTypeInPreorder(noinline action: (T) -> Unit)

Applies action to this element and every descendant of type T, in pre-order (parents before children).

inline fun <reified T : PsiElement> PsiElement.forEachDescendantOfTypeInPreorder(crossinline canGoInside: (PsiElement) -> Boolean, noinline action: (T) -> Unit)

Applies action to this element and every descendant of type T, in pre-order. canGoInside controls whether each visited element's children are traversed; the element itself is still passed to action when it is a T, even if canGoInside returns false for it.

getAnnotationEntries

Retrieves the list of KtAnnotationEntry associated with this element.

getAnnotations

open override fun getAnnotations(): List<KtAnnotation>

Retrieves the list of KtAnnotation associated with this element.

getAssignmentLhsIfUnwrappable

fun PsiElement.getAssignmentLhsIfUnwrappable(): PsiElement?

Returns the operand this operation applies to, but only when that operand is wrapped in parentheses, a label, or annotations; returns null otherwise.

getChildOfType

inline fun <reified T : PsiElement> PsiElement.getChildOfType(): T?

Returns the first direct child of type T, or null if there is none.

getChildren

open fun getChildren(): @NotNull Array<out PsiElement>

getChildrenOfType

inline fun <reified T : PsiElement> PsiElement.getChildrenOfType(): Array<T>

Returns the direct children of type T, or an empty array if there are none.

getClasses

open override fun getClasses(): Array<PsiClass>

Returns the Java light classes that this file contributes, such as the file facade class and any top-level class declarations, or an empty array if none are available.

getContainingDirectory

@Nullable
open fun getContainingDirectory(): @Nullable PsiDirectory?

getContainingFile

@NotNull
open fun getContainingFile(): @NotNull PsiFile

getContainingKtFile

open override fun getContainingKtFile(): KtFile

Returns the KtFile this element belongs to.

getContentElement

open override fun getContentElement(): @Nullable KtTypeReference?

Returns the meaningful content of this fragment (for example, the parsed expression, block, or type reference), or null if it could not be parsed.

getContext

open override fun getContext(): PsiElement?

getContextContainingFile

Returns the KtFile that ultimately contains this fragment's context (see getOriginalContext), or null if the context is invalid or not a Kotlin element.

getCopyableUserData

@Nullable
@Contract(pure = true)
open fun <T> getCopyableUserData(@NotNull p0: @NotNull Key<T?>): @Nullable T?

getDeclarations

open override fun getDeclarations(): List<KtDeclaration>

Returns the declarations directly contained in this element, in their source order. Returns an empty list if there are none.

getElementTextWithContext

fun PsiElement.getElementTextWithContext(): String

Returns this element's text with surrounding source context, for use in diagnostics and log messages.

getExceptionHandler

open override fun getExceptionHandler(): JavaCodeFragment.ExceptionHandler?

getExplicitReceiverOfDotQualified

fun PsiElement.getExplicitReceiverOfDotQualified(): PsiElement?

Returns the source of the explicit receiver if this element is a dot-qualified expression, or null otherwise.

getFileDocument

@NotNull
fun getFileDocument(): @NotNull Document

getFileElementType

@Nullable
open fun getFileElementType(): @Nullable IFileElementType?

getFileOrScriptDeclarations

Returns the top-level declarations of this file, taking them from the script if the file is a script.

getFileType

open override fun getFileType(): FileType

getFirstChild

open fun getFirstChild(): PsiElement?

getForcedResolveScope

open override fun getForcedResolveScope(): GlobalSearchScope?

getIcon

@Nullable
open fun getIcon(flags: Int): @Nullable Icon?

getLanguage

@NotNull
fun getLanguage(): @NotNull Language

getLastChild

open fun getLastChild(): PsiElement?

getLastParentOfTypeInRow

inline fun <reified T : PsiElement> PsiElement.getLastParentOfTypeInRow(): T?

Returns the outermost element in an uninterrupted chain of ancestors of type T, or null if the parent is not a T.

getLastParentOfTypeInRowWithSelf

inline fun <reified T : PsiElement> PsiElement.getLastParentOfTypeInRowWithSelf(): T?

Like getLastParentOfTypeInRow, but the chain may start at this element itself.

getManager

fun getManager(): PsiManager?

getModificationStamp

getModificationStamp

Returns the modification stamp of the nearest enclosing element that tracks one (a file, a stub-based declaration, or a supertype list). The stamp changes whenever that element's subtree is modified, so it can be used to invalidate caches keyed on this element.

getName

@NotNull
open fun getName(): @NotNull String

getNameForGivenImportAlias

fun getNameForGivenImportAlias(name: Name): Name?

Returns the original short name that the given alias name refers to, or null if name is not an alias declared in this file.

getNavigationElement

open fun getNavigationElement(): PsiElement?

getNextSibling

open fun getNextSibling(): PsiElement?

getNextSiblingIgnoringWhitespace

fun PsiElement.getNextSiblingIgnoringWhitespace(withItself: Boolean = false): PsiElement?

Returns the next sibling that is not whitespace, or null. Considers this element if withItself.

getNextSiblingIgnoringWhitespaceAndComments

fun PsiElement.getNextSiblingIgnoringWhitespaceAndComments(withItself: Boolean = false): PsiElement?

Returns the next sibling that is neither whitespace nor a comment, or null. Considers this element if withItself.

getNode

@NotNull
open fun getNode(): @NotNull FileASTNode

getNonStrictParentOfType

inline fun <reified T : PsiElement> PsiElement.getNonStrictParentOfType(): T?

Returns the nearest ancestor of type T including this element, or null if there is none.

fun <T : PsiElement> PsiElement.getNonStrictParentOfType(parentClass: Class<T>): T?

Returns the nearest ancestor of type T (including this element), or null if there is none.

getOriginalContext

Returns the original context element, unwrapping nested code fragments so that the result is a real source element rather than another fragment's context, or null if there is no Kotlin context.

getOriginalElement

open fun getOriginalElement(): PsiElement?

getOriginalFile

@NotNull
open fun getOriginalFile(): @NotNull PsiFile

getOutermostParentContainedIn

tailrec fun PsiElement.getOutermostParentContainedIn(container: PsiElement): PsiElement?

Returns the outermost element on the path from this element that is still strictly contained in container, or null.

getParent

open fun getParent(): PsiDirectory?

getParentOfType

inline fun <reified T : PsiElement> PsiElement.getParentOfType(strict: Boolean): T?

Returns the nearest ancestor of type T, or null. When strict is false, this element itself is also considered.

inline fun <reified T : PsiElement> PsiElement.getParentOfType(strict: Boolean, vararg stopAt: Class<out PsiElement>): T?

Returns the nearest ancestor of type T, stopping the search once an ancestor of any type in stopAt is reached, or null. When strict is false, this element itself is also considered.

getParentOfTypeAndBranch

inline fun <reified T : PsiElement> PsiElement.getParentOfTypeAndBranch(strict: Boolean = false, noinline branch: T.() -> PsiElement?): T?

Checks the nearest element of type T and returns it if this element lies within the subtree selected by branch. If that candidate's branch does not contain this element, returns null without checking higher ancestors. When strict is false, this element itself is also considered as the candidate.

getParentOfTypeAndBranches

inline fun <reified T : PsiElement> PsiElement.getParentOfTypeAndBranches(strict: Boolean = false, noinline branches: T.() -> Iterable<PsiElement?>): T?

Checks the nearest element of type T and returns it if this element lies within any subtree selected by branches. If none of that candidate's branches contain this element, returns null without checking higher ancestors. When strict is false, this element itself is also considered as the candidate.

getParentOfTypes

fun <T : PsiElement> PsiElement.getParentOfTypes(strict: Boolean = false, vararg parentClasses: Class<out T>): T?

Returns the nearest ancestor that is an instance of one of parentClasses, or null if there is none. When strict is false, this element itself is also considered.

getParentOfTypes2

inline fun <reified T : PsiElement, reified V : PsiElement> PsiElement.getParentOfTypes2(): PsiElement?

Returns the nearest strict ancestor that is a T or V, or null if there is none.

getParentOfTypes3

inline fun <reified T : PsiElement, reified V : PsiElement, reified U : PsiElement> PsiElement.getParentOfTypes3(): PsiElement?

Returns the nearest strict ancestor that is a T, V, or U, or null if there is none.

getParentOfTypesAndPredicate

fun <T : PsiElement> PsiElement.getParentOfTypesAndPredicate(
    strict: Boolean = false, 
    vararg parentClasses: Class<out T>, 
    predicate: (T) -> Boolean
): T?

Returns the nearest ancestor that is an instance of one of parentClasses and satisfies predicate, or null. When parentClasses is empty, any type matches. When strict is false, this element itself is also considered.

getPresentation

open fun getPresentation(): ItemPresentation?

getPrevSibling

open fun getPrevSibling(): PsiElement?

getPrevSiblingIgnoringWhitespace

fun PsiElement.getPrevSiblingIgnoringWhitespace(withItself: Boolean = false): PsiElement?

Returns the previous sibling that is not whitespace, or null. Considers this element if withItself.

getPrevSiblingIgnoringWhitespaceAndComments

fun PsiElement.getPrevSiblingIgnoringWhitespaceAndComments(withItself: Boolean = false): PsiElement?

Returns the previous sibling that is neither whitespace nor a comment, or null. Considers this element if withItself.

getProject

@NotNull
fun getProject(): @NotNull Project

getPsiOrParent

open override fun getPsiOrParent(): KtElement

Returns this or parent source element (for synthetic element declarations). Use it only for the purposes of source attribution.

getPsiRoots

open fun getPsiRoots(): @NotNull Array<out PsiFile?>

getQualifiedElementSelector

Returns the rightmost selector of this qualified element, or null if there is no such selector.

getQualifiedExpressionForSelector

Returns the qualified expression in which this element is the selector, or null if it is not a selector.

getReference

open fun getReference(): PsiReference?

getReferences

open fun getReferences(): @NotNull Array<out PsiReference?>

getResolveScope

open override fun getResolveScope(): @NotNull GlobalSearchScope

getStartOffsetIn

fun PsiElement.getStartOffsetIn(ancestor: PsiElement): Int

Returns the offset of this element relative to the start of ancestor (which must be an ancestor of this element).

getStartOffsetInParent

getStrictParentOfType

inline fun <reified T : PsiElement> PsiElement.getStrictParentOfType(): T?

Returns the nearest strict ancestor of type T, or null if there is none.

getStub

open override fun getStub(): KotlinFileStub?

getSuperType

open override fun getSuperType(): PsiType?

getText

open fun getText(): String?

getTextLength

open fun getTextLength(): Int

getTextOffset

open fun getTextOffset(): Int

getTextRange

open fun getTextRange(): TextRange?

getTextWithLocation

fun PsiElement.getTextWithLocation(): String

Returns this element's text together with its source location, for use in diagnostics and log messages.

getThisType

open override fun getThisType(): PsiType?

getTopmostParentOfType

inline fun <reified T : PsiElement> PsiElement.getTopmostParentOfType(): T?

Returns the outermost ancestor of type T including this element, or null if there is none.

getUserData

open fun <T> getUserData(@NotNull key: @NotNull Key<T?>): T?

getUseScope

@NotNull
open fun getUseScope(): @NotNull SearchScope

getViewProvider

override fun getViewProvider(): SingleRootFileViewProvider

getVirtualFile

open fun getVirtualFile(): VirtualFile?

getVisibilityChecker

open override fun getVisibilityChecker(): JavaCodeFragment.VisibilityChecker

hasImportAlias

Returns true if any import in this file introduces an alias (import foo.Bar as Baz).

hasTopLevelCallables

Returns true if this file declares top-level callables (functions or properties), a type alias, or a script, that is, if it contributes a file facade class. Expected (expect) declarations are not counted.

importClass

open override fun importClass(aClass: PsiClass): Boolean

Accepts a class import request from the platform. Kotlin code fragments manage imports themselves, so this always returns true without modifying the fragment.

importsAsImportList

Builds a KtImportList from the imports registered on this fragment, or null if the fragment has no imports or no context.

importsToString

open override fun importsToString(): String

isAncestor

fun PsiElement?.isAncestor(element: PsiElement, strict: Boolean = false): Boolean

Returns true if this element is an ancestor of element. When strict is false, an element is its own ancestor.

isContextualDeclaration

Returns true if this callable, class, or object declares at least one legacy context receiver. Named context parameters are ignored.

isCopyableDataEqual

open fun isCopyableDataEqual(other: @NotNull UserDataHolderBase): Boolean

isDirectory

open fun isDirectory(): Boolean

isEquivalentTo

open fun isEquivalentTo(another: PsiElement?): Boolean

isExtensionDeclaration

fun PsiElement.isExtensionDeclaration(): Boolean

Returns true if this element is an extension function or property (that is, it declares a receiver).

isFirstStatement

Returns true if this element is the first statement of its enclosing block.

isFunctionalExpression

fun PsiElement.isFunctionalExpression(): Boolean

Returns true if this element is an anonymous function, such as the fun expression in val predicate = fun(x: Int): Boolean = x > 0.

isInsideOf

fun PsiElement.isInsideOf(elements: Iterable<PsiElement>): Boolean

Returns true if this element lies within, or is equal to, any of the given elements.

isScript

fun isScript(): Boolean

Returns true if this file is a Kotlin script.

isTopLevelKtOrJavaMember

fun PsiElement.isTopLevelKtOrJavaMember(): Boolean

Returns true if this element is a top-level member of a Kotlin file or a top-level Java class.

isWritable

open fun isWritable(): Boolean

markInvalidated

open fun navigate(requestFocus: Boolean)
open fun navigationRequest(): @Nullable NavigationRequest?

nextLeaf

fun PsiElement.nextLeaf(skipEmptyElements: Boolean = false): PsiElement?

Returns the next leaf element in the tree, or null if there is none. Empty leaves are skipped if skipEmptyElements.

fun PsiElement.nextLeaf(filter: (PsiElement) -> Boolean): PsiElement?

Returns the nearest following leaf that satisfies filter, or null if there is none.

nonStaticOuterClasses

Returns the enclosing classes that this element can access an outer instance of, from innermost to outermost.

onContentReload

open fun onContentReload()

parameterIndex

fun PsiElement.parameterIndex(): Int

Returns the index of this parameter within its own parameter list (Kotlin or Java), or -1 if it is not a parameter.

prevLeaf

fun PsiElement.prevLeaf(skipEmptyElements: Boolean = false): PsiElement?

Returns the previous leaf element in the tree, or null if there is none. Empty leaves are skipped if skipEmptyElements.

fun PsiElement.prevLeaf(filter: (PsiElement) -> Boolean): PsiElement?

Returns the nearest preceding leaf that satisfies filter, or null if there is none.

processChildren

open fun processChildren(@NotNull processor: @NotNull PsiElementProcessor<in PsiFileSystemItem?>): Boolean

processDeclarations

open fun processDeclarations(
    @NotNull processor: @NotNull PsiScopeProcessor, 
    @NotNull state: @NotNull ResolveState, 
    lastParent: PsiElement?, 
    @NotNull place: @NotNull PsiElement
): Boolean

putCopyableUserData

open fun <T> putCopyableUserData(@NotNull key: @NotNull Key<T?>, value: T?)

putInfo

open fun putInfo(info: @NotNull MutableMap<in String?, in String?>)

putUserData

open fun <T> putUserData(@NotNull key: @NotNull Key<T?>, @Nullable value: @Nullable T?)

putUserDataIfAbsent

open fun <T> putUserDataIfAbsent(key: @NotNull Key<T?>, value: @NotNull T & Any): @NotNull T & Any

rawDelete

open override fun rawDelete()

Deletes this PSI element using the raw platform implementation, bypassing Kotlin PSI-specific delete overrides.

replace

open fun <T> replace(
    key: @NotNull Key<T?>, 
    oldValue: @Nullable T?, 
    newValue: @Nullable T?
): Boolean
open fun replace(@NotNull newElement: @NotNull PsiElement): PsiElement?

setExceptionHandler

open override fun setExceptionHandler(checker: JavaCodeFragment.ExceptionHandler?)

setName

open override fun setName(name: String): PsiElement

Renames this file.

setPackageName

open override fun setPackageName(packageName: String)

setSuperType

open override fun setSuperType(superType: PsiType?)

setThisType

open override fun setThisType(psiType: PsiType?)

setTreeElementPointer

open fun setTreeElementPointer(element: @Nullable FileElement?)

setVisibilityChecker

open override fun setVisibilityChecker(checker: JavaCodeFragment.VisibilityChecker?)

shouldChangeModificationCount

fun shouldChangeModificationCount(place: PsiElement): Boolean

Always returns false: for Kotlin files the modification count is tracked entirely by the code-block modification listener, so changes within this file never bump the out-of-code-block modification count.

siblings

fun PsiElement.siblings(forward: Boolean = true, withItself: Boolean = true): Sequence<PsiElement>

Returns the siblings of this element as a lazy sequence, going forward (or backward) and optionally including the element itself (withItself).

startsWithComment

fun PsiElement.startsWithComment(): Boolean

Returns true if this element's first child is a comment.

subtreeChanged

open fun subtreeChanged()

textContains

open fun textContains(c: Char): Boolean

textMatches

open fun textMatches(@NotNull element: @NotNull PsiElement): Boolean
open fun textMatches(@NotNull text: @NotNull CharSequence): Boolean

textToCharArray

open fun textToCharArray(): @NotNull CharArray

toString

open override fun toString(): String

unwrapParenthesesLabelsAndAnnotations

fun PsiElement?.unwrapParenthesesLabelsAndAnnotations(): PsiElement?

Recursively unwraps this element while it is a parenthesized, labeled, or annotated expression, returning the innermost base element. A non-wrapper element is returned unchanged.

unwrapParenthesesLabelsAndAnnotationsDeeply

fun PsiElement.unwrapParenthesesLabelsAndAnnotationsDeeply(): PsiElement

Walks up through immediately enclosing parentheses, labels, and annotations, returning the first parent outside that wrapper chain.

withGreenStubOrAst

fun <T> withGreenStubOrAst(stubProcessor: Function<PsiFileStub<*>?, T?>?, astProcessor: Function<FileElement?, T?>?): T?
fun <T, S : PsiFileStub<*>?> withGreenStubOrAst(
    stubClass: Class<S?>?, 
    stubProcessor: Function<S?, T?>?, 
    astProcessor: Function<FileElement?, T?>?
): T?

withGreenStubTreeOrAst

fun <T> withGreenStubTreeOrAst(stubProcessor: Function<StubTree?, T?>?, astProcessor: Function<FileElement?, T?>?): T?