diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a5a664d..44c8db4d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: steps: - name: Checkout the requested branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Fetch all tags and branches run: git fetch --prune --unshallow diff --git a/src/dotnet/cake-rider/CakeFrostingProjectsHost.cs b/src/dotnet/cake-rider/CakeFrostingProjectsHost.cs index 5899941d..b33bb1d4 100644 --- a/src/dotnet/cake-rider/CakeFrostingProjectsHost.cs +++ b/src/dotnet/cake-rider/CakeFrostingProjectsHost.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; @@ -70,10 +71,9 @@ public CakeFrostingProjectsHost( public void Refresh(IProjectMark projectMark) { + _logger.Trace($"Handle change for project: {projectMark.Location}"); using (_solution.Locks.UsingReadLock()) { - _logger.Trace("Handle change for project: {0}", projectMark.Location); - // Do not dispose IProject! #pragma warning disable IDISP001 var projectByMark = _solution.GetProjectByMark(projectMark); @@ -124,23 +124,25 @@ public void ProcessTasks(ICSharpFile file, IDocument document) foreach (var classDeclaration in classDeclarations) { var declaredElement = classDeclaration.DeclaredElement; - if (declaredElement != null) + if (declaredElement == null) { - if (!declaredElement.IsCakeFrostingTask()) - { - continue; - } + continue; + } - var name = declaredElement.GetCakeFrostingTaskName(); + if (!declaredElement.IsCakeFrostingTask()) + { + continue; + } - if (!cakeFrostingProject.Tasks.Contains(name)) - { - toAdd.Add(name); - } + var name = declaredElement.GetCakeFrostingTaskName(); - currentFileTasks.Add(name); - newTasks.Add(name); + if (!cakeFrostingProject.Tasks.Contains(name)) + { + toAdd.Add(name); } + + currentFileTasks.Add(name); + newTasks.Add(name); } foreach (var currentFileTask in currentFileTasks) @@ -174,6 +176,7 @@ private void ProjectRemoved(IProjectMark projectMark) { if (_cakeFrostingProjects.TryGetValue(projectMark, out var cakeFrostingProject) && _isSolutionLoaded) { + _logger.Trace($"removing project {projectMark.Name} from loaded tasks"); _model.Projects.Remove(cakeFrostingProject); _cakeFrostingProjects.Remove(projectMark); _cakeFrostingTasks.Remove(projectMark); @@ -191,6 +194,7 @@ private void ProjectAdded(IProject project) return; } + _logger.Trace($"Project {projectMark.Name} was added."); var cakeFrostingProject = new CakeFrostingProject(); cakeFrostingProject.Name.Set(project.Name); cakeFrostingProject.ProjectFilePath.Set( @@ -198,38 +202,58 @@ private void ProjectAdded(IProject project) _model.Projects.Add(cakeFrostingProject); _cakeFrostingProjects.Add(projectMark, cakeFrostingProject); _cakeFrostingTasks.Add(projectMark, new Dictionary>()); + LoadTasksForProject(projectMark, cakeFrostingProject); } - private void LoadAllTasks() + private void LoadTasksForProject(IProjectMark projectMark, CakeFrostingProject cakeFrostingProject) { - foreach ((IProjectMark projectMark, CakeFrostingProject cakeFrostingProject) in _cakeFrostingProjects) + _logger.Trace($"loading all tasks of project:{cakeFrostingProject.Name}"); + foreach (var psiModule in _solution.GetProjectByMark(projectMark)!.GetPsiModules()) { - var fileTaskMap = _cakeFrostingTasks[projectMark]; - - foreach (var psiModule in _solution.GetProjectByMark(projectMark)!.GetPsiModules()) + _logger.Trace($"walking psiModule:{psiModule.Name}"); + using (CompilationContextCookie.OverrideOrCreate(psiModule.GetContextFromModule())) { - using (CompilationContextCookie.OverrideOrCreate(psiModule.GetContextFromModule())) + foreach (var sourceFile in psiModule.SourceFiles) { - foreach (var sourceFile in psiModule.SourceFiles) + _logger.Trace($"walking file:{sourceFile.Name}"); + foreach (var klass in _symbolCache.GetTypesAndNamespacesInFile(sourceFile).OfType()) { - var tasks = fileTaskMap[sourceFile] = new HashSet(); + _logger.Trace($"walking class:{klass.ShortName}"); + Interruption.Current.CheckAndThrow(); + + if (!klass.IsCakeFrostingTask()) + { + _logger.Trace($"{klass.ShortName} is not a Cake.Frosting task"); + continue; + } - foreach (var klass in _symbolCache.GetTypesAndNamespacesInFile(sourceFile).OfType()) + var name = klass.GetCakeFrostingTaskName(); + if (cakeFrostingProject.Tasks.Any(x => + x.Equals(name, StringComparison.OrdinalIgnoreCase))) { - Interruption.Current.CheckAndThrow(); - - if (klass.IsCakeFrostingTask()) - { - var name = klass.GetCakeFrostingTaskName(); - cakeFrostingProject.Tasks.Add(name); - tasks.Add(name); - } + // if the task was already registered, it's either an error, + // or the task was defined twice in partials (in Cake Frosting) + // either way, we can ignore it. + _logger.Trace($"Task '{name}' already added. skipping it here."); + continue; } + + _logger.Trace($"Adding Task '{name}'."); + cakeFrostingProject.Tasks.Add(name); } } } } } + + private void LoadAllTasks() + { + _logger.Trace("Intially loading all Cake.Frosting tasks"); + foreach ((IProjectMark projectMark, CakeFrostingProject cakeFrostingProject) in _cakeFrostingProjects) + { + LoadTasksForProject(projectMark, cakeFrostingProject); + } + } } public interface IDetectFrostingModules diff --git a/src/rider/build.gradle.kts b/src/rider/build.gradle.kts index ef202f65..2cf2259a 100644 --- a/src/rider/build.gradle.kts +++ b/src/rider/build.gradle.kts @@ -18,9 +18,9 @@ plugins { // detekt linter - read more: https://detekt.github.io/detekt/gradle.html id("io.gitlab.arturbosch.detekt") version "1.23.1" // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle - id("org.jlleitschuh.gradle.ktlint") version "11.5.1" + id("org.jlleitschuh.gradle.ktlint") version "11.6.0" // grammarkit to generate parser & lexer (i.e. the bnf and the flex file...) - id("org.jetbrains.grammarkit") version "2022.3.1" + id("org.jetbrains.grammarkit") version "2022.3.2" } val jvmVersion = "17" diff --git a/src/rider/gradle.properties b/src/rider/gradle.properties index 068e65a0..71bf45d5 100644 --- a/src/rider/gradle.properties +++ b/src/rider/gradle.properties @@ -5,7 +5,7 @@ pluginGroup = net.cakebuild pluginName = cake-rider pluginVersion = 0.1.0-alpha.1 pluginSinceBuild = 232 -pluginUntilBuild = 232.* +pluginUntilBuild = 233.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. # or https://data.services.jetbrains.com/products?fields=name,releases.downloads,releases.version,releases.build,releases.type&code=RD diff --git a/src/rider/settings.gradle.kts b/src/rider/settings.gradle.kts index 5cfd3cc4..cb48ef33 100644 --- a/src/rider/settings.gradle.kts +++ b/src/rider/settings.gradle.kts @@ -18,7 +18,7 @@ pluginManagement { } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" } rootProject.name = "cake-rider" diff --git a/src/rider/src/main/kotlin/net/cakebuild/toolwindow/CakeTasksWindow.kt b/src/rider/src/main/kotlin/net/cakebuild/toolwindow/CakeTasksWindow.kt index 159b0662..589d44b4 100644 --- a/src/rider/src/main/kotlin/net/cakebuild/toolwindow/CakeTasksWindow.kt +++ b/src/rider/src/main/kotlin/net/cakebuild/toolwindow/CakeTasksWindow.kt @@ -175,9 +175,17 @@ class CakeTasksWindow(private val project: Project) : SimpleToolWindowPanel(true val cakeProject = CakeScriptProject(project) for (cakeFile in cakeProject.getCakeFiles()) { val fileNode = DefaultMutableTreeNode(cakeFile) + val children = mutableListOf() rootNode.add(fileNode) for (task in cakeFile.getTasks()) { + if (children.contains(task.name)) { + // this is an error and won't compile. + // we simply skip it. + continue + } + + children.add(task.name) val taskNode = DefaultMutableTreeNode(task) fileNode.add(taskNode) }