Skip to content

Commit

Permalink
Merge pull request #373 from nils-a/release/7.1.0
Browse files Browse the repository at this point in the history
Release/7.1.0
  • Loading branch information
nils-a authored Sep 27, 2023
2 parents ec03d7b + ede1e30 commit e99de00
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
86 changes: 55 additions & 31 deletions src/dotnet/cake-rider/CakeFrostingProjectsHost.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -191,45 +194,66 @@ 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(
project.ProjectFileLocation.NormalizeSeparators(FileSystemPathEx.SeparatorStyle.Unix));
_model.Projects.Add(cakeFrostingProject);
_cakeFrostingProjects.Add(projectMark, cakeFrostingProject);
_cakeFrostingTasks.Add(projectMark, new Dictionary<IPsiSourceFile, HashSet<string>>());
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<IClass>())
{
var tasks = fileTaskMap[sourceFile] = new HashSet<string>();
_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<IClass>())
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
Expand Down
4 changes: 2 additions & 2 deletions src/rider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/rider/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/rider/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>()
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)
}
Expand Down

0 comments on commit e99de00

Please sign in to comment.