<commit_before>//
// ImpToOrcMessageAdapter.java -- Java class ImpToOrcMessageAdapter.java
// Project OrcEclipse
//
// $Id$
//
// Created by jthywiss on Aug 15, 2009.
//
// Copyright (c) 2009 The University of Texas at Austin. All rights reserved.
//
// Use and redistribution of this file is governed by the license terms in
// the LICENSE file found in the project's top-level directory and also found at
// URL: http://orc.csres.utexas.edu/license.shtml .
//

package edu.utexas.cs.orc.orceclipse;

import java.io.File;

import orc.error.SourceLocation;
import orc.error.compiletime.CompileMessageRecorder;

import org.eclipse.core.resources.IMarker;
import org.eclipse.imp.builder.MarkerCreatorWithBatching;
import org.eclipse.imp.builder.ProblemLimit.LimitExceededException;
import org.eclipse.imp.parser.IMessageHandler;

/**
 * Wraps IMP's IMessageHandler interface in Orc's CompileMessageRecorder
 * interface.
 * 
 * @author jthywiss
 */
public class ImpToOrcMessageAdapter implements CompileMessageRecorder {

	private final IMessageHandler impMessageHandler;

	private Severity maxSeverity = Severity.UNKNOWN;

	/**
	 * Constructs an object of class ImpToOrcMessageAdapter.
	 * 
	 * @param impMessageHandler MessageHandler to be wrapped
	 */
	public ImpToOrcMessageAdapter(final IMessageHandler impMessageHandler) {
		super();
		this.impMessageHandler = impMessageHandler;
	}

	/* (non-Javadoc)
	 * @see orc.error.compiletime.CompileMessageRecorder#beginProcessing(java.io.File)
	 */
	public void beginProcessing(final File file) {
		if (impMessageHandler == null) {
			return;
		}
		impMessageHandler.clearMessages();
		maxSeverity = Severity.UNKNOWN;
	}

	/*
	 * (non-Javadoc)
	 * @see orc.error.CompileMessageRecorder#recordMessage(orc.error.CompileMessageRecorder.Severity, int, java.lang.String, orc.error.SourceLocation, java.lang.Object, java.lang.Throwable)
	 */
	public void recordMessage(final Severity severity, final int code, final String message, SourceLocation location, final Object astNode, final Throwable exception) {
		if (impMessageHandler == null) {
			return;
		}
<commit_msg>Be more defensive re null ptrs<commit_after>//
// ImpToOrcMessageAdapter.java -- Java class ImpToOrcMessageAdapter.java
// Project OrcEclipse
//
// $Id$
//
// Created by jthywiss on Aug 15, 2009.
//
// Copyright (c) 2009 The University of Texas at Austin. All rights reserved.
//
// Use and redistribution of this file is governed by the license terms in
// the LICENSE file found in the project's top-level directory and also found at
// URL: http://orc.csres.utexas.edu/license.shtml .
//

package edu.utexas.cs.orc.orceclipse;

import java.io.File;

import orc.error.SourceLocation;
import orc.error.compiletime.CompileMessageRecorder;

import org.eclipse.core.resources.IMarker;
import org.eclipse.imp.builder.MarkerCreatorWithBatching;
import org.eclipse.imp.builder.ProblemLimit.LimitExceededException;
import org.eclipse.imp.parser.IMessageHandler;

/**
 * Wraps IMP's IMessageHandler interface in Orc's CompileMessageRecorder
 * interface.
 * 
 * @author jthywiss
 */
public class ImpToOrcMessageAdapter implements CompileMessageRecorder {

	private final IMessageHandler impMessageHandler;

	private Severity maxSeverity = Severity.UNKNOWN;

	/**
	 * Constructs an object of class ImpToOrcMessageAdapter.
	 * 
	 * @param impMessageHandler MessageHandler to be wrapped
	 */
	public ImpToOrcMessageAdapter(final IMessageHandler impMessageHandler) {
		super();
		if (impMessageHandler == null) {
			throw new NullPointerException("Cannot instantiate ImpToOrcMessageAdapter with a null impMessageHandler");
		}
		this.impMessageHandler = impMessageHandler;
	}

	/* (non-Javadoc)
	 * @see orc.error.compiletime.CompileMessageRecorder#beginProcessing(java.io.File)
	 */
	public void beginProcessing(final File file) {
		impMessageHandler.clearMessages();
		maxSeverity = Severity.UNKNOWN;
	}

	/*
	 * (non-Javadoc)
	 * @see orc.error.CompileMessageRecorder#recordMessage(orc.error.CompileMessageRecorder.Severity, int, java.lang.String, orc.error.SourceLocation, java.lang.Object, java.lang.Throwable)
	 */
	public void recordMessage(final Severity severity, final int code, final String message, SourceLocation location, final Object astNode, final Throwable exception) {
{'fraction_non_alphanumeric': 0.09731621936989499, 'fraction_numerical': 0.004667444574095682, 'mean_word_length': 4.646903820816864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '680232', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1267, 'n_words': 327}