Skip to content

Commit

Permalink
Fix project order in treeview (#742)
Browse files Browse the repository at this point in the history
* Fix project order

* Add tests for project order
  • Loading branch information
badsyntax authored Oct 7, 2020
1 parent 45f6179 commit 80a758d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions extension/src/tasks/taskUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function createVSCodeTaskFromGradleTask(
);
}

function getVSCodeTasksFromGradleProject(
export function getVSCodeTasksFromGradleProject(
taskTerminalsStore: TaskTerminalsStore,
rootProject: RootProject,
gradleProject: GradleProject,
Expand All @@ -249,7 +249,7 @@ function getVSCodeTasksFromGradleProject(
let projects: Array<GradleProject> = [gradleProject];
const vsCodeTasks: vscode.Task[] = [];
while (projects.length) {
const project = projects.pop();
const project = projects.shift();
const gradleTasks: GradleTask[] | void = project!.getTasksList();
for (const gradleTask of gradleTasks) {
vsCodeTasks.push(
Expand Down
35 changes: 34 additions & 1 deletion extension/src/test/unit/taskUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import * as vscode from 'vscode';
import { GradleBuild, GradleProject, GradleTask } from '../../proto/gradle_pb';
import { RootProject } from '../../rootProject/RootProject';
import { TaskTerminalsStore } from '../../stores';
import { loadTasksForProjectRoots } from '../../tasks/taskUtil';
import {
getVSCodeTasksFromGradleProject,
loadTasksForProjectRoots,
} from '../../tasks/taskUtil';
import { buildMockClient, getSuiteName } from '../testUtil';

const mockWorkspaceFolder: vscode.WorkspaceFolder = {
Expand Down Expand Up @@ -131,4 +134,34 @@ describe(getSuiteName('taskUtil'), () => {
);
assert.strictEqual(tasks.length, 255101);
});

it('should not change the order of tasks when building vscode tasks from gradle tasks', () => {
const subProject1 = new GradleProject();
const task1 = new GradleTask();
task1.setBuildfile('A');
subProject1.setTasksList([task1]);

const subProject2 = new GradleProject();
const task2 = new GradleTask();
task2.setBuildfile('B');
subProject2.setTasksList([task2]);

const subProject3 = new GradleProject();
const task3 = new GradleTask();
task3.setBuildfile('C');
subProject3.setTasksList([task3]);

const gradleProject = new GradleProject();
gradleProject.setProjectsList([subProject1, subProject2, subProject3]);
const tasks = getVSCodeTasksFromGradleProject(
mockTaskTerminalsStore,
mockRootProject,
gradleProject,
mockClient
);

assert.strictEqual(tasks[0].definition.buildFile, 'A');
assert.strictEqual(tasks[1].definition.buildFile, 'B');
assert.strictEqual(tasks[2].definition.buildFile, 'C');
});
});

0 comments on commit 80a758d

Please sign in to comment.