Search in sources :

Example 11 with DocumentTokenSource

use of org.eclipse.xtext.ui.editor.model.DocumentTokenSource in project xtext-eclipse by eclipse.

the class ValidationJobSchedulerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    referenceDescriptions = Lists.newArrayList();
    dirtyStateManager = new DirtyStateManager();
    testMe = new ValidationJobScheduler();
    testMe.setDirtyStateManager(dirtyStateManager);
    testMe.setDescriptionUtils(new DescriptionUtils());
    testMe.setResourceDescriptions(this);
    testMe.setResourceDescriptionManager(new DefaultResourceDescriptionManager());
    DocumentTokenSource nullSource = new DocumentTokenSource() {

        @Override
        protected IRegion computeDamageRegion(DocumentEvent e) {
            return new Region(0, 0);
        }
    };
    document = new XtextDocument(nullSource, null, outdatedStateManager, operationCanceledManager) {

        @Override
        public URI getResourceURI() {
            return documentURI;
        }

        @Override
        public void checkAndUpdateAnnotations() {
            validationScheduled = true;
        }
    };
    documentResource = new TestableDocumentResource();
    targetResource = new AbstractResourceDescription() {

        @Override
        public URI getURI() {
            return targetURI;
        }

        @Override
        public Iterable<IReferenceDescription> getReferenceDescriptions() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Iterable<QualifiedName> getImportedNames() {
            throw new UnsupportedOperationException();
        }

        @Override
        protected List<IEObjectDescription> computeExportedObjects() {
            if (documentResource.importedName == null)
                throw new UnsupportedOperationException();
            return Collections.emptyList();
        }
    };
}
Also used : DescriptionUtils(org.eclipse.xtext.resource.DescriptionUtils) AbstractResourceDescription(org.eclipse.xtext.resource.impl.AbstractResourceDescription) ValidationJobScheduler(org.eclipse.xtext.ui.editor.ValidationJobScheduler) DefaultResourceDescriptionManager(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) DocumentEvent(org.eclipse.jface.text.DocumentEvent) URI(org.eclipse.emf.common.util.URI) DirtyStateManager(org.eclipse.xtext.ui.editor.DirtyStateManager) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) List(java.util.List)

Aggregations

DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)11 Lexer (org.eclipse.xtext.parser.antlr.Lexer)8 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)8 DocumentEvent (org.eclipse.jface.text.DocumentEvent)3 InternalXtextLexer (org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer)3 OutdatedStateManager (org.eclipse.xtext.resource.OutdatedStateManager)3 OperationCanceledManager (org.eclipse.xtext.service.OperationCanceledManager)3 AntlrTokenDefProvider (org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider)2 XtextAntlrTokenFileProvider (org.eclipse.xtext.parser.antlr.XtextAntlrTokenFileProvider)2 DocumentPartitioner (org.eclipse.xtext.ui.editor.model.DocumentPartitioner)2 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)2 PartitionTokenScanner (org.eclipse.xtext.ui.editor.model.PartitionTokenScanner)2 TerminalsTokenTypeToPartitionMapper (org.eclipse.xtext.ui.editor.model.TerminalsTokenTypeToPartitionMapper)2 List (java.util.List)1 URI (org.eclipse.emf.common.util.URI)1 Document (org.eclipse.jface.text.Document)1 IDocumentListener (org.eclipse.jface.text.IDocumentListener)1 IRegion (org.eclipse.jface.text.IRegion)1 Region (org.eclipse.jface.text.Region)1 TextAttribute (org.eclipse.jface.text.TextAttribute)1