<commit_before>package org.strategoxt.imp.runtime.parser.ast;

import static org.eclipse.core.resources.IMarker.CHAR_END;
import static org.eclipse.core.resources.IMarker.CHAR_START;
import static org.eclipse.core.resources.IMarker.LINE_NUMBER;
import static org.eclipse.core.resources.IMarker.MESSAGE;
import static org.eclipse.core.resources.IMarker.PRIORITY;
import static org.eclipse.core.resources.IMarker.SEVERITY;
import static org.eclipse.core.resources.IMarker.SEVERITY_ERROR;
import static org.eclipse.core.resources.IMarker.TRANSIENT;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.spoofax.jsglr.client.imploder.IToken;
import org.spoofax.jsglr.client.imploder.ITokenizer;
import org.strategoxt.imp.runtime.Environment;

/**
 * Marker configuration attributes containment and comparison.
 * 
 * @author <NAME> <lennart add lclnet.nl>
 */
public class MarkerSignature {

	private static final String[] ATTRIBUTES = { LINE_NUMBER, CHAR_START, CHAR_END, MESSAGE, SEVERITY, PRIORITY, TRANSIENT };
	
	private IResource resource;

	private Object[] values;
	
	private final int line;
	
	private final int severity;
	
	private final String message;
	
	private final String comparisonMessage;
	
	public MarkerSignature(IResource resource, IToken left, IToken right, String message,
			int severity, int priority, boolean isTransient) {
		if (message == null) message = "Problem";
		this.resource = resource;
		this.line = left.getLine();
		this.message = message;
		this.severity = severity;
		this.comparisonMessage = removeSyntaxErrorDetails(message);
		this.values = new Object[] { line, left.getStartOffset(), right.getEndOffset() + 1, message, severity, priority, isTransient };
	}
	
	public MarkerSignature(IMarker marker) {
		this.line = marker.getAttribute(LINE_NUMBER, 0);
		this.message = marker.getAttribute(MESSAGE, "Problem");
		this.comparisonMessage = removeSyntaxErrorDetails(message);
		this.severity = marker.getAttribute(SEVERITY, SEVERITY_ERROR);
		this.values = null;
	}
	
	public final String[] getAttributes() {
		return ATTRIBUTES;
	}

	public final Object[] getValues() {
		return values;
	}
	
	public final IResource getResource() {
		return resource;
	}
	<commit_msg>Placing a maximum length restriction on the marker message<commit_after>package org.strategoxt.imp.runtime.parser.ast;

import static org.eclipse.core.resources.IMarker.CHAR_END;
import static org.eclipse.core.resources.IMarker.CHAR_START;
import static org.eclipse.core.resources.IMarker.LINE_NUMBER;
import static org.eclipse.core.resources.IMarker.MESSAGE;
import static org.eclipse.core.resources.IMarker.PRIORITY;
import static org.eclipse.core.resources.IMarker.SEVERITY;
import static org.eclipse.core.resources.IMarker.SEVERITY_ERROR;
import static org.eclipse.core.resources.IMarker.TRANSIENT;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.spoofax.jsglr.client.imploder.IToken;
import org.spoofax.jsglr.client.imploder.ITokenizer;
import org.strategoxt.imp.runtime.Environment;

/**
 * Marker configuration attributes containment and comparison.
 * 
 * @author <NAME> <lennart add lclnet.nl>
 */
public class MarkerSignature {

	private static final int MAX_MESSAGE_LEN = 1000;

	private static final String[] ATTRIBUTES = { LINE_NUMBER, CHAR_START, CHAR_END, MESSAGE, SEVERITY, PRIORITY, TRANSIENT };
	
	private IResource resource;

	private Object[] values;
	
	private final int line;
	
	private final int severity;
	
	private final String message;
	
	private final String comparisonMessage;
	
	public MarkerSignature(IResource resource, IToken left, IToken right, String message,
			int severity, int priority, boolean isTransient) {
		assert message != null;
		this.resource = resource;
		this.line = left.getLine();
		this.message = message.substring(0, Math.min(message.length(), MAX_MESSAGE_LEN));
		this.severity = severity;
		this.comparisonMessage = removeSyntaxErrorDetails(message);
		this.values = new Object[] { line, left.getStartOffset(), right.getEndOffset() + 1, message, severity, priority, isTransient };
	}
	
	public MarkerSignature(IMarker marker) {
		this.line = marker.getAttribute(LINE_NUMBER, 0);
		this.message = marker.getAttribute(MESSAGE, "Problem");
		this.comparisonMessage = removeSyntaxErrorDetails(message);
		this.severity = marker.getAttribute(SEVERITY, SEVERITY_ERROR);
		this.values = null;
	}
	
	public final String[] getAttributes() {
		return ATTRIBUTES;
	}

	public final Object[] getValues() {
		return values;
	}
	
	public final IResource getResource() {
		return resource;
	}
	
{'fraction_non_alphanumeric': 0.10190274841437633, 'fraction_numerical': 0.0019027484143763213, 'mean_word_length': 5.257936507936508, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3320827', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1396, 'n_words': 336}