Skip to content

Commit 539ca7e

Browse files
committed
test(csharp): add CsharpFileContextBuilder and CsharpClassContextBuilderTest
This commit adds the CsharpFileContextBuilder class, which implements the FileContextBuilder interface and provides the getFileContext method for C# files. It also includes the CsharpClassContextBuilderTest class, which contains a test case for the getFileContext method.
1 parent 1e06da0 commit 539ca7e

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package cc.unitmesh.csharp.context
2+
3+
import cc.unitmesh.devti.context.FileContext
4+
import cc.unitmesh.devti.context.builder.FileContextBuilder
5+
import com.intellij.psi.PsiFile
6+
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.psi.CSharpFile
7+
8+
class CsharpFileContextBuilder: FileContextBuilder {
9+
override fun getFileContext(psiFile: PsiFile): FileContext? {
10+
if(psiFile !is CSharpFile) return null
11+
12+
13+
return null
14+
}
15+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package cc.unitmesh.csharp.context;
2+
3+
import com.intellij.psi.PsiFileFactory
4+
import com.intellij.testFramework.LightPlatform4TestCase
5+
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.CSharpFileType
6+
import org.junit.Test
7+
8+
class CsharpClassContextBuilderTest : LightPlatform4TestCase() {
9+
10+
@Test
11+
fun testShouldReturnNullWhenPsiElementIsNotCSharpBlock() {
12+
val code = """
13+
// Hello World! program
14+
namespace HelloWorld
15+
{
16+
class Hello {
17+
static void Main(string[] args)
18+
{
19+
System.Console.WriteLine("Hello World!");
20+
}
21+
}
22+
}
23+
""".trimIndent()
24+
25+
// val psiElement =
26+
// PsiFileFactory.getInstance(project)
27+
// .createFileFromText("HelloWorld.cs", CSharpFileType, code)
28+
29+
// val builder: ClassContextBuilder = CsharpClassContextBuilder()
30+
// builder.getClassContext(psiElement, false)
31+
}
32+
}

0 commit comments

Comments
 (0)