Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Sequence Editors Time library #1324

Closed
wants to merge 17 commits into from
Closed
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"stylelint-order": "^6.0.4",
"svelte-check": "^3.4.4",
"tslib": "^2.6.0",
"typescript": "5.4.3",
"typescript": "5.0.4",
"unique-names-generator": "^4.7.1",
"vite": "5.1.6",
"vitest": "^1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/components/sequencing/form/SelectedCommand.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
}
}

function hasAncestorWithId(element: Element | null, id: string) {
function hasAncestorWithId(element: Element | null, id: string): boolean {
if (element === null) {
return false;
} else if (element.id === id) {
Expand Down
8 changes: 8 additions & 0 deletions src/enums/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ export enum TIME_MS {
MONTH = 2629800000,
YEAR = 31557600000,
}

export enum TimeTypes {
ABSOLUTE = 'absolute',
EPOCH = 'epoch',
EPOCH_SIMPLE = 'epoch_simple',
RELATIVE = 'relative',
RELATIVE_SIMPLE = 'relative_simple',
}
9 changes: 8 additions & 1 deletion src/utilities/codemirror/codemirror-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function isQuoted(s: string) {
}

export function unquoteUnescape(s: string) {
if (isQuoted(s) && s.length > 1) {
if (isQuoted(s)) {
return s.slice(1, -1).replaceAll('\\"', '"');
}
return s;
Expand All @@ -126,6 +126,13 @@ export function quoteEscape(s: string) {
return `"${s.replaceAll('"', '\\"')}"`;
}

export function removeQuotes(text: string | number | boolean): string | number | boolean {
if (typeof text === 'string') {
return text.replace(/\\"|"(?!\\")/g, '"').trim();
}
return text;
}

export function removeEscapedQuotes(text: string | number | boolean): string | number | boolean {
if (typeof text === 'string') {
return text.replace(/\\"|"(?!\\")/g, '"').trim();
Expand Down
9 changes: 7 additions & 2 deletions src/utilities/monacoHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const sequenceProvideCodeActions = (
.map(unbalancedTime => {
const match = unbalancedTime.message.match(/Suggestion:\s*(.*)/);
if (match) {
const extractSuggestedTime = match[1].replace(/\s+/g, '');
const extractSuggestedTime = match[1].replace(/\s+/, '').replace(/\[|\]/g, '');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be combined to match[1].replace(/\s+|[\[|\]]/g, '')?

return generateQuickFixAction('Convert Unbalanced Time', extractSuggestedTime, unbalancedTime, model);
}
return undefined; // Return undefined when the match fails
Expand Down Expand Up @@ -42,7 +42,12 @@ function generateQuickFixAction(
{
resource: model.uri,
textEdit: {
range: diagnostics,
range: {
endColumn: diagnostics.endColumn - 1,
endLineNumber: diagnostics.endLineNumber,
startColumn: diagnostics.startColumn + 2,
startLineNumber: diagnostics.startLineNumber,
},
text: replaceText,
},
versionId: model.getVersionId(),
Expand Down
13 changes: 11 additions & 2 deletions src/utilities/new-sequence-editor/sequence-completion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Completion, CompletionContext, CompletionResult } from '@codemirror/autocomplete';
import { syntaxTree } from '@codemirror/language';
import type { ChannelDictionary, CommandDictionary, ParameterDictionary } from '@nasa-jpl/aerie-ampcs';
import { getDoyTime } from '../time';
import { fswCommandArgDefault } from './command-dictionary';
import { getCustomArgDef } from './extension-points';

Expand Down Expand Up @@ -103,9 +104,17 @@ export function sequenceCompletion(
);

if (!cursor.isTimeTagBefore) {
//get the first of the year date
const date = new Date();
date.setMonth(0);
date.setDate(1);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
timeTagCompletions.push(
{
apply: 'A0000-000T00:00:00 ',
apply: `A${getDoyTime(date)} `,
info: 'Execute command at an absolute time',
label: `A (absolute)`,
section: 'Time Tags',
Expand All @@ -119,7 +128,7 @@ export function sequenceCompletion(
type: 'keyword',
},
{
apply: 'E+00:00:00 ',
apply: 'E+1 ',
info: 'Execute command at an offset from an epoch',
label: 'E (epoch)',
section: 'Time Tags',
Expand Down
249 changes: 0 additions & 249 deletions src/utilities/new-sequence-editor/time-utils.ts

This file was deleted.

Loading
Loading