<commit_before>/*  
    <NAME>

    Functions to highlight user specified fields on a HL7 message.
*/

// load modules
const vscode = require('vscode');
const common = require('./common.js');

// the list of fields to highlight
var fieldSelectionList = [];

// return codes for ExtractAllFields()
const HighlightFieldReturnCode = {
	ERROR_NO_LOCATION_PROVIDED: 0,
	SUCCESS_NO_FIELD_FOUND: 1,
	SUCCESS_FIELD_FOUND: 2
}; 

//----------------------------------------------------
// Highlight the HL7 field(s) identified by the user
// @param {string} itemLocation - a string identifying the field location (e.g. PID-3)
// @param {object} hl7Schema - An object containing the HL7 schema
// @param {string} backgroundColor - The RGBA colour value identifying the background colour e.g. "rgba(0,255,0,0.3)". If this is not supplied, a default colour will be used.
//
// @returns {int} - returns the number of decorations applied
function ShowHighlights(itemLocation, hl7Schema, backgroundColor) {
	// the default background colour for highlighted items (if not otherwise specified)
	const defaultBackgroundColour = 'rgba(0,255,0,0.3)';

	// load the message delimiters from the current file
	var delimiters = common.ParseDelimiters();
	// regex to match a segment name and field index 
	var itemLocationRegex = new RegExp("^[A-Z]{2}([A-Z]|[0-9])[-]([0-9]{1,3})$", 'i');
	// associative array indexed by segment name, with the field index as a value. 
	var locationHashtable = {};
	var highlightBackgroundColour = defaultBackgroundColour;
	var activeEditor = vscode.window.activeTextEditor;

	// dispose of decorations for previously highlighted fields. 
	if (fieldSelectionList.length > 0) {
		currentDecoration.dispose();
		fieldSelectionList = [];
	}

	// return if no location provided by the user, or no active editor
	if ((!itemLocation) || (!activeEditor)) {
		return HighlightFieldReturnCode.ERROR_NO_FIELD_PROVIDED;
	}

	// if a background colour was provided use it, otherwise the default background setting defined in defaultBackgroundColour will apply
	if (backgroundColor) {
		highlightBackgroundColour = backgroundColor
	}
<commit_msg>fixed return code if no location provided<commit_after>/*  
    <NAME>

    Functions to highlight user specified fields on a HL7 message.
*/

// load modules
const vscode = require('vscode');
const common = require('./common.js');

// the list of fields to highlight
var fieldSelectionList = [];

// return codes for ExtractAllFields()
const HighlightFieldReturnCode = {
	ERROR_NO_LOCATION_PROVIDED: 0,
	SUCCESS_NO_FIELD_FOUND: 1,
	SUCCESS_FIELD_FOUND: 2
}; 

//----------------------------------------------------
// Highlight the HL7 field(s) identified by the user
// @param {string} itemLocation - a string identifying the field location (e.g. PID-3)
// @param {object} hl7Schema - An object containing the HL7 schema
// @param {string} backgroundColor - The RGBA colour value identifying the background colour e.g. "rgba(0,255,0,0.3)". If this is not supplied, a default colour will be used.
//
// @returns {int} - returns the number of decorations applied
function ShowHighlights(itemLocation, hl7Schema, backgroundColor) {
	// the default background colour for highlighted items (if not otherwise specified)
	const defaultBackgroundColour = 'rgba(0,255,0,0.3)';

	// load the message delimiters from the current file
	var delimiters = common.ParseDelimiters();
	// regex to match a segment name and field index 
	var itemLocationRegex = new RegExp("^[A-Z]{2}([A-Z]|[0-9])[-]([0-9]{1,3})$", 'i');
	// associative array indexed by segment name, with the field index as a value. 
	var locationHashtable = {};
	var highlightBackgroundColour = defaultBackgroundColour;
	var activeEditor = vscode.window.activeTextEditor;

	// dispose of decorations for previously highlighted fields. 
	if (fieldSelectionList.length > 0) {
		currentDecoration.dispose();
		fieldSelectionList = [];
	}

	// return if no location provided by the user, or no active editor
	if ((!itemLocation) || (!activeEditor)) {
		return HighlightFieldReturnCode.ERROR_NO_LOCATION_PROVIDED;
	}

	// if a background colour was provided use it, otherwise the default background setting defined in defaultBackgroundColour will apply
	if (backgroundColor) {
		highlightBackgroundColour = backgroundColor
	}

{'fraction_non_alphanumeric': 0.1242178447276941, 'fraction_numerical': 0.01436848203939745, 'mean_word_length': 3.9325714285714284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4853685', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1209, 'n_words': 436}