/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Source Code Map.
 *
 * The Initial Developer of the Original Code is
 * Alexander J. Vincent <ajvincent@gmail.com>.
 * Portions created by the Initial Developer are Copyright (C) 2006
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"
#include "nsISupportsPrimitives.idl"
#include "nsIScriptError.idl"

/* This interface is intended to let you add fragments of source code in
 * a single language from a composite-language document.  For instance,
 * JavaScript inside XHTML.  The scripts may come from different locations
 * within the original file.
 *
 * To use this interface, you would call startFragment when you have a function
 * ready to add to the map.  For each section of that function, you would call
 * addSource() with the section you're adding, and the line number and column
 * number the section starts at.  When you're done with that function, you call
 * endFragment().
 *
 * addSource() can be called several times after a startFragment() call and
 * before a endFragment() call.  This allows for the possibility that your
 * function may be split across multiple text and character data DOM nodes.
 *
 * When you're ready to test the source code you've added, you call
 * getFirstSyntaxError().  If it returns null, there are no syntax errors
 * reported in the source map (congratulations).  On the other hand, if you
 * get a nsIScriptError object back, the line number and column number will
 * correspond to your original source code's line number and column number
 * where the syntax error occurred.
 *
 * The source map is reusable.  Simply call clear() to clear any old source
 * code in the map.
 */

[scriptable, uuid(65be2e9a-d44e-4b4e-b8ea-b672e9ff7f17)]
interface xeISourceMap : nsISupports {
  /**
   * Clear the source map.
   */
  void clear();

  /**
   * Start recording a section of source code.
   */
  void startFragment(in nsISupportsString uri);

  /**
   * Add a section of source code.
   *
   * @param source       The source code to add.
   * @param lineNumber   The original line number of the source code.
   * @param columnNumber The original column number of the source code.
   */
  void addSource(in nsISupportsString source,
                 in PRUint32 lineNumber,
                 in PRUint32 columnNumber);

  /**
   * End recording a section of source code.
   */
  void endFragment();

  /**
   * Get the first syntax error for the original source code.
   *
   * @return nsIScriptError with line and column numbers for original code.
   */
  nsIScriptError getFirstSyntaxError();
};
