@@ -44,25 +44,25 @@ class ImplementAbstractMembersQuickFix : QuickFix {
4444
4545 // If the client side and the server side diagnostics contain a valid diagnostic for this range.
4646 if (diagnostic != null && anyDiagnosticMatch(kotlinDiagnostics, startCursor, endCursor)) {
47- // Get the class with the missing functions
47+ // Get the class with the missing members
4848 val kotlinClass = file.parseAtPoint(startCursor)
4949 if (kotlinClass is KtClass ) {
5050 // Get the functions that need to be implemented
51- val functionsToImplement = getAbstractFunctionStubs (file, kotlinClass)
51+ val membersToImplement = getAbstractMembersStubs (file, kotlinClass)
5252
5353 val uri = file.parse.toPath().toUri().toString()
54- // Get the padding to be introduced before the function declarations
54+ // Get the padding to be introduced before the member declarations
5555 val padding = getDeclarationPadding(file, kotlinClass)
5656
5757 // Get the location where the new code will be placed
58- val newFunctionStartPosition = getNewFunctionStartPosition (file, kotlinClass)
59- val bodyAppendBeginning = listOf (TextEdit (Range (newFunctionStartPosition, newFunctionStartPosition ), " {" )).takeIf { kotlinClass.hasNoBody() } ? : emptyList()
60- val bodyAppendEnd = listOf (TextEdit (Range (newFunctionStartPosition, newFunctionStartPosition ), System .lineSeparator() + " }" )).takeIf { kotlinClass.hasNoBody() } ? : emptyList()
58+ val newMembersStartPosition = getNewMembersStartPosition (file, kotlinClass)
59+ val bodyAppendBeginning = listOf (TextEdit (Range (newMembersStartPosition, newMembersStartPosition ), " {" )).takeIf { kotlinClass.hasNoBody() } ? : emptyList()
60+ val bodyAppendEnd = listOf (TextEdit (Range (newMembersStartPosition, newMembersStartPosition ), System .lineSeparator() + " }" )).takeIf { kotlinClass.hasNoBody() } ? : emptyList()
6161
62- val textEdits = bodyAppendBeginning + functionsToImplement .map {
63- // We leave two new lines before the function is inserted
62+ val textEdits = bodyAppendBeginning + membersToImplement .map {
63+ // We leave two new lines before the member is inserted
6464 val newText = System .lineSeparator() + System .lineSeparator() + padding + it
65- TextEdit (Range (newFunctionStartPosition, newFunctionStartPosition ), newText)
65+ TextEdit (Range (newMembersStartPosition, newMembersStartPosition ), newText)
6666 } + bodyAppendEnd
6767
6868 val codeAction = CodeAction ()
@@ -83,7 +83,7 @@ fun findDiagnosticMatch(diagnostics: List<Diagnostic>, range: Range) =
8383private fun anyDiagnosticMatch (diagnostics : Diagnostics , startCursor : Int , endCursor : Int ) =
8484 diagnostics.any { diagnosticMatch(it, startCursor, endCursor, hashSetOf(" ABSTRACT_MEMBER_NOT_IMPLEMENTED" , " ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED" )) }
8585
86- private fun getAbstractFunctionStubs (file : CompiledFile , kotlinClass : KtClass ) =
86+ private fun getAbstractMembersStubs (file : CompiledFile , kotlinClass : KtClass ) =
8787 // For each of the super types used by this class
8888 kotlinClass.superTypeListEntries.mapNotNull {
8989 // Find the definition of this super type
@@ -214,12 +214,12 @@ private fun getDeclarationPadding(file: CompiledFile, kotlinClass: KtClass): Str
214214 return " " .repeat(paddingSize)
215215}
216216
217- private fun getNewFunctionStartPosition (file : CompiledFile , kotlinClass : KtClass ): Position ? =
218- // If the class is not empty, the new function will be put right after the last declaration
217+ private fun getNewMembersStartPosition (file : CompiledFile , kotlinClass : KtClass ): Position ? =
218+ // If the class is not empty, the new member will be put right after the last declaration
219219 if (kotlinClass.declarations.isNotEmpty()) {
220220 val lastFunctionEndOffset = kotlinClass.declarations.last().endOffset
221221 position(file.content, lastFunctionEndOffset)
222- } else { // Otherwise, the function is put at the beginning of the class
222+ } else { // Otherwise, the member is put at the beginning of the class
223223 val body = kotlinClass.body
224224 if (body != null ) {
225225 position(file.content, body.startOffset + 1 )
0 commit comments