// Path: editor/src/org/z64sim/editor/highlighter/z64Parser.java
// public static class z64ParserResult extends ParserResult {
// 
//     private final Assembler assembler;
//     private final AtomicBoolean valid = new AtomicBoolean(true);
//     private final Snapshot snapshot;
//     private List<ErrorDescription> errors;
// 
//     z64ParserResult(Snapshot snapshot, Assembler assembler) {
//         super(snapshot);
//         this.snapshot = snapshot;
//         this.assembler = assembler;
//     }
// 
//     public Assembler getAssembler() throws org.netbeans.modules.parsing.spi.ParseException {
//         if (!valid.get()) {
//             throw new org.netbeans.modules.parsing.spi.ParseException();
//         }
//         return assembler;
//     }
// 
//     @Override
//     protected void invalidate() {
//         valid.set(false);
//     }
// 
//     public boolean getResult() throws org.netbeans.modules.parsing.spi.ParseException {
//         if (!valid.get()) {
//             throw new org.netbeans.modules.parsing.spi.ParseException();
//         }
//         return true;
//     }
// 
//     public List<ErrorDescription> getErrors() {
//         return this.errors;
//     }
// 
//     @Override
//     public List<? extends Error> getDiagnostics() {
// 
//         try {
//             List<ParseException> syntaxErrors = this.assembler.getSyntaxErrors();
//             Document document = this.snapshot.getSource().getDocument(false);
//             this.errors = new ArrayList<ErrorDescription>();
//             for (ParseException syntaxError : syntaxErrors) {
//                 Token token = syntaxError.currentToken;
//                 int start = NbDocument.findLineOffset((StyledDocument) document, token.beginLine - 1) + token.beginColumn - 1;
//                 int end = NbDocument.findLineOffset((StyledDocument) document, token.endLine - 1) + token.endColumn;
//                 ErrorDescription errorDescription = ErrorDescriptionFactory.createErrorDescription(
//                         org.netbeans.spi.editor.hints.Severity.ERROR,
//                         syntaxError.getMessage(),
//                         document,
//                         document.createPosition(start),
//                         document.createPosition(end)
//                 );
//                 this.errors.add(errorDescription);
//             }
//         } catch (BadLocationException ex1) {
//             Exceptions.printStackTrace(ex1);
//         }
// 
//         return Collections.EMPTY_LIST;
//     }
// 
//     @Override
//     public Snapshot getSnapshot() {
//         return this.snapshot;
//     }
// 
// }


import java.util.Collection;
import java.util.Collections;
import java.util.logging.Logger;
import javax.swing.text.Document;
import org.netbeans.api.editor.mimelookup.MimeRegistration;
import org.netbeans.modules.parsing.api.Snapshot;
import org.netbeans.modules.parsing.spi.ParserResultTask;
import org.netbeans.modules.parsing.spi.SchedulerEvent;
import org.netbeans.modules.parsing.spi.TaskFactory;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
import org.netbeans.modules.parsing.spi.ParseException;
import org.netbeans.modules.parsing.spi.Scheduler;
import org.netbeans.modules.parsing.spi.SchedulerTask;
import org.netbeans.spi.editor.hints.HintsController;
import org.z64sim.editor.highlighter.z64Parser.z64ParserResult;
    }

    public void compile(z64ParserResult parseResult) {
        // TODO: this approach makes highlighting slow if project is more than
        // a handful of files. We need some caching, which will probably require
        // changes to be made to z64Parser.

        try {
            // Assemble the program
            parseResult.getAssembler().Program();
        } catch (org.z64sim.assembler.ParseException ex) {
            Exceptions.printStackTrace(ex);
        } catch (org.netbeans.modules.parsing.spi.ParseException ex) {
            Exceptions.printStackTrace(ex);
        }

        // Display the errors
        Document document = parseResult.getSnapshot().getSource().getDocument(false);
        // This call builds the error list. It's actually odd that I cannot return
        // the list error directly from here, but I think I'm missing something
        // at this point about the Netbeans Parsing API
        parseResult.getDiagnostics();
        HintsController.setErrors(document, "z64asm", parseResult.getErrors());
    }

    @Override
    public int getPriority() {
        return 100;
    }

// Path: editor/src/org/z64sim/editor/highlighter/z64Parser.java
// public static class z64ParserResult extends ParserResult {
// 
//     private final Assembler assembler;
//     private final AtomicBoolean valid = new AtomicBoolean(true);
//     private final Snapshot snapshot;
//     private List<ErrorDescription> errors;
// 
//     z64ParserResult(Snapshot snapshot, Assembler assembler) {
//         super(snapshot);
//         this.snapshot = snapshot;
//         this.assembler = assembler;
//     }
// 
//     public Assembler getAssembler() throws org.netbeans.modules.parsing.spi.ParseException {
//         if (!valid.get()) {
//             throw new org.netbeans.modules.parsing.spi.ParseException();
//         }
//         return assembler;
//     }
// 
//     @Override
//     protected void invalidate() {
//         valid.set(false);
//     }
// 
//     public boolean getResult() throws org.netbeans.modules.parsing.spi.ParseException {
//         if (!valid.get()) {
//             throw new org.netbeans.modules.parsing.spi.ParseException();
//         }
//         return true;
//     }
// 
//     public List<ErrorDescription> getErrors() {
//         return this.errors;
//     }
// 
//     @Override
//     public List<? extends Error> getDiagnostics() {
// 
//         try {
//             List<ParseException> syntaxErrors = this.assembler.getSyntaxErrors();
//             Document document = this.snapshot.getSource().getDocument(false);
//             this.errors = new ArrayList<ErrorDescription>();
//             for (ParseException syntaxError : syntaxErrors) {
//                 Token token = syntaxError.currentToken;
//                 int start = NbDocument.findLineOffset((StyledDocument) document, token.beginLine - 1) + token.beginColumn - 1;
//                 int end = NbDocument.findLineOffset((StyledDocument) document, token.endLine - 1) + token.endColumn;
//                 ErrorDescription errorDescription = ErrorDescriptionFactory.createErrorDescription(
//                         org.netbeans.spi.editor.hints.Severity.ERROR,
//                         syntaxError.getMessage(),
//                         document,
//                         document.createPosition(start),
//                         document.createPosition(end)
//                 );
//                 this.errors.add(errorDescription);
//             }
//         } catch (BadLocationException ex1) {
//             Exceptions.printStackTrace(ex1);
//         }
// 
//         return Collections.EMPTY_LIST;
//     }
// 
//     @Override
//     public Snapshot getSnapshot() {
//         return this.snapshot;
//     }
// 
// }


// Path: editor/src/org/z64sim/editor/highlighter/z64ParserHighlighter.java
import java.util.Collection;
import java.util.Collections;
import java.util.logging.Logger;
import javax.swing.text.Document;
import org.netbeans.api.editor.mimelookup.MimeRegistration;
import org.netbeans.modules.parsing.api.Snapshot;
import org.netbeans.modules.parsing.spi.ParserResultTask;
import org.netbeans.modules.parsing.spi.SchedulerEvent;
import org.netbeans.modules.parsing.spi.TaskFactory;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
import org.netbeans.modules.parsing.spi.ParseException;
import org.netbeans.modules.parsing.spi.Scheduler;
import org.netbeans.modules.parsing.spi.SchedulerTask;
import org.netbeans.spi.editor.hints.HintsController;
import org.z64sim.editor.highlighter.z64Parser.z64ParserResult;

    }

    public void compile(z64ParserResult parseResult) {
        // TODO: this approach makes highlighting slow if project is more than
        // a handful of files. We need some caching, which will probably require
        // changes to be made to z64Parser.

        try {
            // Assemble the program
            parseResult.getAssembler().Program();
        } catch (org.z64sim.assembler.ParseException ex) {
            Exceptions.printStackTrace(ex);
        } catch (org.netbeans.modules.parsing.spi.ParseException ex) {
            Exceptions.printStackTrace(ex);
        }

        // Display the errors
        Document document = parseResult.getSnapshot().getSource().getDocument(false);
        // This call builds the error list. It's actually odd that I cannot return
        // the list error directly from here, but I think I'm missing something
        // at this point about the Netbeans Parsing API
        parseResult.getDiagnostics();
        HintsController.setErrors(document, "z64asm", parseResult.getErrors());
    }

    @Override
    public int getPriority() {
        return 100;
    }

    @Override