Class XtextFile

  • All Implemented Interfaces:
    IXtextFile, org.eclipse.core.runtime.IAdaptable, org.eclipse.handly.model.IElement, org.eclipse.handly.model.impl.IElementImpl, org.eclipse.handly.model.impl.IElementImplExtension, org.eclipse.handly.model.impl.ISourceElementImpl, org.eclipse.handly.model.impl.ISourceFileImpl, org.eclipse.handly.model.impl.ISourceFileImplExtension, org.eclipse.handly.model.impl.support.IElementImplSupport, org.eclipse.handly.model.impl.support.IModelManager.Provider, org.eclipse.handly.model.impl.support.ISourceElementImplSupport, org.eclipse.handly.model.impl.support.ISourceFileImplSupport, org.eclipse.handly.model.ISourceElement, org.eclipse.handly.model.ISourceFile, org.eclipse.xtext.util.concurrent.IReadAccess<org.eclipse.xtext.resource.XtextResource>, org.eclipse.xtext.util.concurrent.IWriteAccess<org.eclipse.xtext.resource.XtextResource>

    public abstract class XtextFile
    extends org.eclipse.handly.model.impl.support.WorkspaceSourceFile
    implements IXtextFile
    Represents an Xtext-based source file.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.eclipse.handly.model.impl.IElementImplExtension

        org.eclipse.handly.model.impl.IElementImplExtension.CloseHint
      • Nested classes/interfaces inherited from interface org.eclipse.xtext.util.concurrent.IReadAccess

        org.eclipse.xtext.util.concurrent.IReadAccess.Priority<State extends Object>
      • Nested classes/interfaces inherited from interface org.eclipse.handly.model.impl.support.ISourceFileImplSupport

        org.eclipse.handly.model.impl.support.ISourceFileImplSupport.NotifyingReconcileOperation, org.eclipse.handly.model.impl.support.ISourceFileImplSupport.ReconcileOperation
    • Field Summary

      • Fields inherited from interface org.eclipse.handly.model.impl.IElementImplExtension

        CLOSE_HINT, FORCE_OPEN
      • Fields inherited from interface org.eclipse.handly.model.impl.support.IElementImplSupport

        NEW_ELEMENTS, NO_BODY
      • Fields inherited from interface org.eclipse.handly.model.impl.ISourceFileImplExtension

        WORKING_COPY_BUFFER, WORKING_COPY_CALLBACK, WORKING_COPY_CONTEXT
      • Fields inherited from interface org.eclipse.handly.model.impl.support.ISourceFileImplSupport

        SOURCE_AST, SOURCE_CONTENTS, SOURCE_SNAPSHOT
    • Constructor Summary

      Constructors 
      Constructor Description
      XtextFile​(org.eclipse.handly.model.impl.support.Element parent, org.eclipse.core.resources.IFile file)
      Constructs a handle for an Xtext-based source file with the given parent element and the given underlying workspace file.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void buildSourceStructure_​(org.eclipse.handly.context.IContext context, org.eclipse.core.runtime.IProgressMonitor monitor)  
      protected abstract void buildStructure​(org.eclipse.handly.context.IContext context, org.eclipse.xtext.resource.XtextResource resource)
      Creates and initializes bodies for the given XtextResource's contents.
      protected org.eclipse.xtext.resource.IResourceServiceProvider getResourceServiceProvider()
      Returns the IResourceSetProvider corresponding to this file.
      protected org.eclipse.emf.common.util.URI getResourceUri()
      Returns the EMF resource URI for this file.
      protected <T> T internalModify​(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,​org.eclipse.xtext.resource.XtextResource> work)
      The actual implementation of modify(IUnitOfWork)
      protected <T> T internalReadOnly​(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,​org.eclipse.xtext.resource.XtextResource> work)
      The actual implementation of readOnly(IUnitOfWork)
      <T> T modify​(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,​org.eclipse.xtext.resource.XtextResource> work)  
      protected org.eclipse.xtext.resource.XtextResource parse​(String contents, String encoding)
      Returns a new XtextResource loaded from the given contents.
      <T> T readOnly​(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,​org.eclipse.xtext.resource.XtextResource> work)  
      • Methods inherited from class org.eclipse.handly.model.impl.support.WorkspaceSourceFile

        getFile_, getFileObject_, getResource_
      • Methods inherited from class org.eclipse.handly.model.impl.support.Element

        equals, getName_, getParent_, hashCode, toString
      • Methods inherited from class org.eclipse.core.runtime.PlatformObject

        getAdapter
      • Methods inherited from interface org.eclipse.handly.model.IElement

        equals, hashCode
      • Methods inherited from interface org.eclipse.handly.model.impl.IElementImpl

        equalsAndSameParentChain_, getChildrenOfType_, getHandleMemento_, getLocationUri_, getName_, getParent_, getRoot_, toDisplayString_
      • Methods inherited from interface org.eclipse.handly.model.impl.IElementImplExtension

        close_, getBody_, getBody_, getChildren_
      • Methods inherited from interface org.eclipse.handly.model.impl.support.IElementImplSupport

        canEqual_, exists_, findBody_, getChildrenFromBody_, getElementManager_, getModel_, isOpenable_, newDoesNotExistException_, open_, peekAtBody_, remove_, removing_, toString_, toStringAncestors_, toStringBody_, toStringChildren_
      • Methods inherited from interface org.eclipse.handly.model.impl.support.IModelManager.Provider

        getModelManager_
      • Methods inherited from interface org.eclipse.xtext.util.concurrent.IReadAccess

        tryReadOnly, tryReadOnly, tryReadOnly
      • Methods inherited from interface org.eclipse.handly.model.impl.support.ISourceElementImplSupport

        getSourceElementAt_, getSourceElementAt_, getSourceElementInfo_
      • Methods inherited from interface org.eclipse.handly.model.impl.ISourceFileImpl

        getFileStore_
      • Methods inherited from interface org.eclipse.handly.model.impl.support.ISourceFileImplSupport

        acquireExistingWorkingCopy_, becomeWorkingCopy_, buildStructure_, close_, defaultEquals_, defaultHashCode_, fileExists_, getBuffer_, getFileBuffer_, getFileSnapshotProvider_, getReconcileOperation_, getWorkingCopyContext_, isWorkingCopy_, needsReconciling_, newWorkingCopyContext_, openParent_, reconcile_, releaseWorkingCopy_, toStringName_, validateExistence_, workingCopyModeChanged_
      • Methods inherited from interface org.eclipse.xtext.util.concurrent.IWriteAccess

        tryModify, tryModify, tryModify
    • Constructor Detail

      • XtextFile

        public XtextFile​(org.eclipse.handly.model.impl.support.Element parent,
                         org.eclipse.core.resources.IFile file)
        Constructs a handle for an Xtext-based source file with the given parent element and the given underlying workspace file.
        Parameters:
        parent - the parent of the element (not null)
        file - the workspace file underlying the element (not null)
    • Method Detail

      • readOnly

        public <T> T readOnly​(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,​org.eclipse.xtext.resource.XtextResource> work)
        Specified by:
        readOnly in interface org.eclipse.xtext.util.concurrent.IReadAccess<org.eclipse.xtext.resource.XtextResource>
      • modify

        public <T> T modify​(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,​org.eclipse.xtext.resource.XtextResource> work)
        Specified by:
        modify in interface org.eclipse.xtext.util.concurrent.IWriteAccess<org.eclipse.xtext.resource.XtextResource>
      • buildSourceStructure_

        public void buildSourceStructure_​(org.eclipse.handly.context.IContext context,
                                          org.eclipse.core.runtime.IProgressMonitor monitor)
                                   throws org.eclipse.core.runtime.CoreException
        Specified by:
        buildSourceStructure_ in interface org.eclipse.handly.model.impl.support.ISourceFileImplSupport
        Throws:
        org.eclipse.core.runtime.CoreException
      • buildStructure

        protected abstract void buildStructure​(org.eclipse.handly.context.IContext context,
                                               org.eclipse.xtext.resource.XtextResource resource)
        Creates and initializes bodies for the given XtextResource's contents.

        The resource is safe to read in the dynamic context of the method call, but must not be modified. Implementations must not keep references to any part of the given resource (including the node model) outside the dynamic scope of the invocation of this method.

        Parameters:
        context - the operation context (never null)
        resource - an XtextResource corresponding to this file (never null)
      • internalReadOnly

        protected <T> T internalReadOnly​(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,​org.eclipse.xtext.resource.XtextResource> work)
                                  throws Exception
        The actual implementation of readOnly(IUnitOfWork)
        Parameters:
        work -
        Returns:
        Throws:
        Exception
      • internalModify

        protected <T> T internalModify​(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,​org.eclipse.xtext.resource.XtextResource> work)
                                throws Exception
        The actual implementation of modify(IUnitOfWork)
        Parameters:
        work -
        Returns:
        Throws:
        Exception
      • parse

        protected org.eclipse.xtext.resource.XtextResource parse​(String contents,
                                                                 String encoding)
                                                          throws IOException
        Returns a new XtextResource loaded from the given contents. The resource is created in a new ResourceSet obtained from the IResourceSetProvider corresponding to this file. The resource's encoding is set to the given value. This is a handle-only method.
        Parameters:
        contents - the contents to parse (not null)
        encoding - the encoding to be set for the created XtextResource (not null)
        Returns:
        the new XtextResource loaded from the given contents (never null)
        Throws:
        IOException - if resource loading failed
      • getResourceServiceProvider

        protected org.eclipse.xtext.resource.IResourceServiceProvider getResourceServiceProvider()
        Returns the IResourceSetProvider corresponding to this file. This is a handle-only method.
        Returns:
        the IResourceSetProvider for this file (never null)
      • getResourceUri

        protected org.eclipse.emf.common.util.URI getResourceUri()
        Returns the EMF resource URI for this file. This is a handle-only method.
        Returns:
        the resource URI for this file (never null)