Skip to content

Commit

Permalink
Merge pull request #11 from ironsheep/develop
Browse files Browse the repository at this point in the history
add global labels to outline   (from Develop)
  • Loading branch information
ironsheep authored Dec 26, 2022
2 parents 54bfaa1 + 921c800 commit 97fb82b
Show file tree
Hide file tree
Showing 7 changed files with 1,398 additions and 42 deletions.
6 changes: 6 additions & 0 deletions spin2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Possible next additions:
- Add new-file templates as Snippets
- Add additional Snippets as the community identifies them

## [1.8.1] 2022-12-26

Minor Outline/Navigation update for P2

- Add global Pasm labels to outline


## [1.8.0] 2022-12-23

Expand Down
2 changes: 1 addition & 1 deletion spin2/TEST/spin2/test-file-003.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ DAT { instructions by group }
X_4ADC8_0P_4DAC8_WFLONG
X_4P_1DAC4_WFBYTE
X_4P_2DAC2_WFBYTE
X_4P_4DAC1_WF_BYTE
X_4P_4DAC1_WFBYTE
X_8P_1DAC8_WFBYTE
X_8P_2DAC4_WFBYTE
X_8P_4DAC2_WFBYTE
Expand Down
2 changes: 1 addition & 1 deletion spin2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Spin2",
"description": "Spin2/Pasm2 Syntax/Semantic Highlighting w/Code Outline and Custom tabbing support",
"icon": "images/Propeller.ico",
"version": "1.8.0",
"version": "1.8.1",
"publisher": "IronSheepProductionsLLC",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion spin2/src/spin1.semanticAndOutline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3725,7 +3725,7 @@ export class Spin1DocumentSemanticTokensProvider implements vscode.DocumentSeman
"x_4adc8_0p_4dac8_wflong",
"x_4p_1dac4_wfbyte",
"x_4p_2dac2_wfbyte",
"x_4p_4dac1_wf_byte",
"x_4p_4dac1_wfbyte",
"x_8p_1dac8_wfbyte",
"x_8p_2dac4_wfbyte",
"x_8p_4dac2_wfbyte",
Expand Down
121 changes: 121 additions & 0 deletions spin2/src/spin2.semantic.findings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
"use strict";
// src/spin2.semantic.findings.ts

import * as vscode from "vscode";

// ============================================================================
// this file contains both an outline provider
// and our semantic highlighting provider
//
class RememberedToken {
_type: string;
_modifiers: string[] = [];
constructor(type: string, modifiers: string[] | undefined) {
this._type = type;
if (modifiers != undefined) {
this._modifiers = modifiers;
}
}
get type() {
return this._type;
}
get modifiers() {
return this._modifiers;
}
}

// ----------------------------------------------------------------------------
// Shared Data Storage for what our current document contains
//
export class DocumentFindings {
private tokenSet = new Map<string, RememberedToken>();
private outputChannel: vscode.OutputChannel | undefined = undefined;
private bLogEnabled: boolean = false;
private bDataLoaded: boolean = false;

public constructor(isLogging: boolean, logHandle: vscode.OutputChannel | undefined) {
this.bLogEnabled = isLogging;
this.outputChannel = logHandle;
this.logTokenMessage("* gTOK ready");
}

private logTokenMessage(message: string): void {
if (this.bLogEnabled && this.outputChannel != undefined) {
// Write to output window.
this.outputChannel.appendLine(message);
}
}

*[Symbol.iterator]() {
yield* this.tokenSet;
}

public entries() {
return Array.from(this.tokenSet.entries());
}

public clear(): void {
this.tokenSet.clear();
this.logTokenMessage("* gTOK clear() now " + this.length() + " tokens");
}
public isReady(): boolean {
return this.bDataLoaded;
}

public setLoaded(bState: boolean): void {
this.bDataLoaded = bState;
}

public length(): number {
return this.tokenSet.size;
}

public rememberdTokenString(tokenName: string, aToken: RememberedToken | undefined): string {
let desiredInterp: string = " -- token=[len:" + tokenName.length + " [" + tokenName + "](undefined)";
if (aToken != undefined) {
desiredInterp = " -- token=[len:" + tokenName.length + " [" + tokenName + "](" + aToken.type + "[" + aToken.modifiers + "])]";
}
return desiredInterp;
}

public isToken(tokenName: string): boolean {
let foundStatus: boolean = false;
if (tokenName.length > 0) {
foundStatus = this.tokenSet.has(tokenName.toLowerCase());
if (foundStatus) {
this.logTokenMessage("* gTOK [" + tokenName + "] found: " + foundStatus);
}
}
return foundStatus;
}

public setToken(tokenName: string, token: RememberedToken): void {
if (tokenName.length > 0 && !this.isToken(tokenName)) {
this.tokenSet.set(tokenName.toLowerCase(), token);
const currCt: number = this.length();
this.logTokenMessage("* gTOK #" + currCt + ": " + this.rememberdTokenString(tokenName, token));
}
}

public getToken(tokenName: string): RememberedToken | undefined {
var desiredToken: RememberedToken | undefined = this.tokenSet.get(tokenName.toLowerCase());
if (desiredToken != undefined) {
// let's never return a declaration modifier! (somehow "declaration" creeps in to our list!??)
let modifiersNoDecl: string[] = this._modifiersWithout(desiredToken.modifiers, "declaration");
desiredToken = new RememberedToken(desiredToken.type, modifiersNoDecl);
}
return desiredToken;
}

private _modifiersWithout(initialModifiers: string[], unwantedModifier: string): string[] {
// remove modification attribute
var updatedModifiers: string[] = [];
for (var idx = 0; idx < initialModifiers.length; idx++) {
var possModifier: string = initialModifiers[idx];
if (possModifier !== unwantedModifier) {
updatedModifiers.push(possModifier);
}
}
return updatedModifiers;
}
}
Loading

0 comments on commit 97fb82b

Please sign in to comment.