generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cpp): add CppWriteTestService and CppContextPrettify modifications
- Add CppWriteTestService class for running CMakeTestRunConfiguration - Modify CppContextPrettify to import additional classes and symbols - Update CLionWorkspaceContextProvider to remove unused import - Update cc.unitmesh.cpp.xml to add CppWriteTestService as testContextProvider
- Loading branch information
Showing
4 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
cpp/src/main/kotlin/cc/unitmesh/cpp/provider/testing/CppWriteTestService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cc.unitmesh.cpp.provider.testing | ||
|
||
import cc.unitmesh.cpp.util.CppContextPrettify | ||
import cc.unitmesh.devti.context.ClassContext | ||
import cc.unitmesh.devti.provider.WriteTestService | ||
import cc.unitmesh.devti.provider.context.TestFileContext | ||
import com.intellij.execution.configurations.RunProfile | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiFile | ||
import com.jetbrains.cidr.cpp.execution.testing.CMakeTestRunConfiguration | ||
import com.jetbrains.cidr.lang.psi.OCFunctionDeclaration | ||
|
||
class CppWriteTestService : WriteTestService() { | ||
override fun runConfigurationClass(project: Project): Class<out RunProfile> = CMakeTestRunConfiguration::class.java | ||
|
||
override fun isApplicable(element: PsiElement): Boolean { | ||
return true | ||
} | ||
|
||
override fun findOrCreateTestFile(sourceFile: PsiFile, project: Project, element: PsiElement): TestFileContext? { | ||
val currentClass = when (element) { | ||
is OCFunctionDeclaration -> { | ||
CppContextPrettify.printParentStructure(element) | ||
} | ||
|
||
else -> null | ||
} | ||
val relatedClasses = lookupRelevantClass(project, element) | ||
|
||
return TestFileContext( | ||
true, | ||
sourceFile.virtualFile, | ||
relatedClasses, | ||
"", | ||
sourceFile.language, | ||
currentClass, | ||
emptyList() | ||
) | ||
} | ||
|
||
override fun lookupRelevantClass(project: Project, element: PsiElement): List<ClassContext> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters