Examples of IStructuredDocument


Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

   * parser is to handle tag libraries, it must have a TaglibSupport object
   * with a valid URIResolver and this IStructuredDocument attached to it
   * before the contents are set on the IStructuredDocument.
   */
  protected IEncodedDocument newEncodedDocument() {
    IStructuredDocument structuredDocument = StructuredDocumentFactory.getNewStructuredDocumentInstance(getParser());
    ((BasicStructuredDocument) structuredDocument).setReParser(new JSPReParser());
    // structuredDocument.setDocumentPartitioner(new
    // JSPJavaDocumentPartioner());
    // even though this is an "empty model" ... we want it to have at
    // least
    // the
    // default embeddeded content type handler
    EmbeddedTypeHandler embeddedType = getJSPDefaultEmbeddedType();
    embeddedType.initializeParser(structuredDocument.getParser());
    return structuredDocument;
  }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

    IMessage mes = new LocalizedMessage(severity, message.getMessage(), this.file);
    mes.setOffset(message.getOffset());
    mes.setLength(message.getLength());
    if (this.model != null) {
      IStructuredDocument flatModel = this.model.getStructuredDocument();
      if (flatModel != null) {
        int line = flatModel.getLineOfOffset(message.getOffset());
        mes.setLineNo(line + 1);
      }
    }

    return mes;
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

  private void loadTagFile(CMElementDeclarationImpl ed, IFile tagFile, boolean allowIncludes, InputStream inputStream) {
    try {
      ed.setPath(tagFile.getFullPath().toString());
      ed.setTagSource(TLDElementDeclaration.SOURCE_TAG_FILE);
      ed.setLocationString(tagFile.getFullPath().toString());
      IStructuredDocument document = null;
      if(inputStream != null) {
        document = (IStructuredDocument)new ModelHandlerForJSP().getDocumentLoader().createNewStructuredDocument(tagFile.getName(), inputStream);
      }
      else if(tagFile.isAccessible()) {
        document = (IStructuredDocument) new ModelHandlerForJSP().getDocumentLoader().createNewStructuredDocument(tagFile);
      }
      if (document == null)
        return;
      IStructuredDocumentRegion documentRegion = document.getFirstStructuredDocumentRegion();
      while (documentRegion != null) {
        if (documentRegion.getType().equals(DOMJSPRegionContexts.JSP_DIRECTIVE_NAME)) {
          if (documentRegion.getNumberOfRegions() > 2) {
            ITextRegionList regions = documentRegion.getRegions();
            String directiveName = documentRegion.getText(regions.get(1));
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

    IDocument jspDoc = ((JSPTranslationExtension) translation).getJspDocument();
    if (!(jspDoc instanceof IStructuredDocument))
      return;

    IStructuredDocument sDoc = (IStructuredDocument) jspDoc;
    IStructuredDocumentRegion[] regions = sDoc.getStructuredDocumentRegions(0, m.getOffset() + m.getLength());
    // iterate backwards until you hit the include directive
    for (int i = regions.length - 1; i >= 0; i--) {
      IStructuredDocumentRegion region = regions[i];
      if (region.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
        if (getDirectiveName(region).equals("include")) { //$NON-NLS-1$
          ITextRegion fileValueRegion = getAttributeValueRegion(region, "file"); //$NON-NLS-1$
          if (fileValueRegion != null) {
            m.setOffset(region.getStartOffset(fileValueRegion));
            m.setLength(fileValueRegion.getTextLength());
          }
          else {
            m.setOffset(region.getStartOffset());
            m.setLength(region.getTextLength());
          }
          /**
           * Bug 219761 - Syntax error reported at wrong location
           * (don't forget to adjust the line number, too)
           */
          m.setLineNo(sDoc.getLineOfOffset(m.getOffset()) + 1);
          break;
        }
      }
    }
  }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

    if (node == null)
      return node;
    IDOMModel model = ((IDOMNode) node).getModel();
    if (model == null)
      return node;
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    if (structuredDocument == null)
      return node;
    if ( !getCleanupPreferences().getFormatSource())
      return node;
   
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

  static protected StructuredDocumentEvent replaceSource(IDOMModel model, Object requester, int offset, int length, String source) {

    StructuredDocumentEvent result = null;
    if (model == null)
      return result;
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    if (structuredDocument == null)
      return result;
    if (source == null)
      source = new String();
    if (structuredDocument.containsReadOnly(offset, length))
      return result;
    if (requester == null) {
      requester = structuredDocument;
    }
    return structuredDocument.replaceText(requester, offset, length, source);
  }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

    ICompletionProposal[] jspResults = EMPTY_PROPOSAL_SET;
    ICompletionProposal[] embeddedResults = EMPTY_PROPOSAL_SET;

    // check the actual partition type
    String partitionType = getPartitionType(viewer, documentPosition);
    IStructuredDocument structuredDocument = (IStructuredDocument) viewer.getDocument();

    IStructuredDocumentRegion fn = structuredDocument.getRegionAtCharacterOffset(documentPosition);

    // ////////////////////////////////////////////////////////////////////////////
    // ANOTHER WORKAROUND UNTIL PARTITIONING TAKES CARE OF THIS
    // check for xml-jsp tags...
    if (partitionType == IJSPPartitions.JSP_DIRECTIVE && fn != null) {
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

  }

  public void forceParse() {
    String contents = fTextToParse;

    IStructuredDocument document = (IStructuredDocument) new JSPDocumentLoader().createNewStructuredDocument();
    if(contents != null && document != null) {   
      // from outer class
      List blockMarkers = this.fTranslator.getBlockMarkers();
      // this adds the current markers from the outer class list
      // to this parser so parsing works correctly
      for (int i = 0; i < blockMarkers.size(); i++) {
        addBlockMarker((BlockMarker) blockMarkers.get(i));
      }
      reset(contents);
 
      document.set(contents);
      IStructuredDocumentRegion cursor = document.getFirstStructuredDocumentRegion();
      while(cursor != null) {
        nodeParsed(cursor);
        cursor = cursor.getNext();
      }
    }
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

   *
   * @param filename @return
   */
  public boolean parse(String filePathString) {
    boolean parsed = false;
    IStructuredDocument document = null;
    String contents = null;

    IPath filePath = new Path(filePathString);
    IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
    if (f == null || !f.isAccessible()) {
      f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(filePath);
    }
    if (f != null && f.isAccessible()) {
      /*
       * using a real document allows us to pull out text in the
       * translator for dealing with TEI variables
       */
      try {
        IModelHandler handler = ModelHandlerRegistry.getInstance().getHandlerFor(f, false);
        if (handler == null)
          handler = ModelHandlerRegistry.getInstance().getHandlerForContentTypeId(ContentTypeIdForJSP.ContentTypeID_JSPFRAGMENT);
        document = (IStructuredDocument) handler.getDocumentLoader().createNewStructuredDocument();
        contents = FileContentCache.getInstance().getContents(f.getFullPath());
      }
      catch (CoreException e) {
        Logger.logException(e);
      }
    }
    if (contents != null && document != null) {
      // from outer class
      List blockMarkers = this.fTranslator.getBlockMarkers();
      // this adds the current markers from the outer class list
      // to this parser so parsing works correctly
      for (int i = 0; i < blockMarkers.size(); i++) {
        addBlockMarker((BlockMarker) blockMarkers.get(i));
      }
      reset(contents);
      // forces parse
      document.set(contents);
      IStructuredDocumentRegion cursor = document.getFirstStructuredDocumentRegion();
      while (cursor != null) {
        nodeParsed(cursor);
        cursor = cursor.getNext();
      }
      parsed = true;
View Full Code Here

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

   */
  private boolean containsReadOnly(IDocument document, int startOffset, int endOffset) {

    int start = startOffset;
    int end = endOffset;
    IStructuredDocument structuredDocument = null;
    if (document instanceof IStructuredDocument) {
      structuredDocument = (IStructuredDocument) document;
    }
    else {
      if (document instanceof ProjectionDocument) {
        IDocument doc = ((ProjectionDocument) document).getMasterDocument();
        if (doc instanceof IStructuredDocument) {
          structuredDocument = (IStructuredDocument) doc;
          int adjust = ((ProjectionDocument) document).getProjectionMapping().getCoverage().getOffset();
          start = adjust + start;
          end = adjust + end;
        }
      }
    }
    if (structuredDocument == null) {
      return false;
    }
    else {
      int length = end - start;
      return structuredDocument.containsReadOnly(start, length);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.