This repository was archived by the owner on Dec 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ export class KotlinProfile implements LanguageProfile {
6969 )?
7070
7171 (class_declaration
72- (type_identifier) @interface -name
72+ (type_identifier) @class -name
7373 (class_body
7474 (property_declaration
7575 (binding_pattern_kind)?
Original file line number Diff line number Diff line change @@ -91,7 +91,6 @@ export class KotlinStructurerProvider extends BaseStructurerProvider {
9191 interfaceObj . methods = methods . slice ( ) ;
9292 codeFile . classes . push ( { ...interfaceObj } ) ;
9393
94- // 重置字段和方法
9594 methods . length = 0 ;
9695 fields . length = 0 ;
9796 }
Original file line number Diff line number Diff line change 1+ import { TestLanguageServiceProvider } from "src/test/TestLanguageService" ;
2+ import { KotlinStructurerProvider } from "../../../code-context/kotlin/KotlinStructurerProvider" ;
3+
4+ const Parser = require ( 'web-tree-sitter' ) ;
5+
6+ describe ( 'KotlinStructure' , ( ) => {
7+ it ( 'should convert a simple file to CodeFile' , async ( ) => {
8+ const kotlinHelloWorld = `package com.example
9+ interface Shape {
10+ val vertexCount: Int
11+ }
12+
13+ class Rectangle(override val vertexCount: Int = 4) : Shape // Always has 4 vertices
14+
15+ class Polygon : Shape {
16+ override var vertexCount: Int = 0 // Can be set to any number later
17+ }` ;
18+
19+ await Parser . init ( ) ;
20+ const parser = new Parser ( ) ;
21+ const languageService = new TestLanguageServiceProvider ( parser ) ;
22+
23+ const structurer = new KotlinStructurerProvider ( ) ;
24+ await structurer . init ( languageService ) ;
25+
26+ const codeFile = await structurer . parseFile ( kotlinHelloWorld , '' ) ;
27+ console . log ( codeFile ) ;
28+ } ) ;
29+ } ) ;
You can’t perform that action at this time.
0 commit comments