• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IDocumentExtension4类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jface.text.IDocumentExtension4的典型用法代码示例。如果您正苦于以下问题:Java IDocumentExtension4类的具体用法?Java IDocumentExtension4怎么用?Java IDocumentExtension4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDocumentExtension4类属于org.eclipse.jface.text包,在下文中一共展示了IDocumentExtension4类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: applyAllInSameDocument

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
/**
 * Applies all given changes to the given document. This method assumes that 'changes' contains only changes
 * intended for the given document; the actual URI stored in the changes is ignored.
 */
public void applyAllInSameDocument(Collection<? extends IAtomicChange> changes, IDocument document)
		throws BadLocationException {
	DocumentRewriteSession rewriteSession = null;
	try {
		// prepare
		if (document instanceof IDocumentExtension4) {
			rewriteSession = ((IDocumentExtension4) document).startRewriteSession(
					DocumentRewriteSessionType.UNRESTRICTED);
		}
		// perform replacements
		for (IAtomicChange currRepl : changes) {
			currRepl.apply(document);
		}
	} finally {
		// cleanup
		if (rewriteSession != null)
			((IDocumentExtension4) document).stopRewriteSession(rewriteSession);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:ChangeManager.java


示例2: ImportRewriter

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private ImportRewriter(IDocument document, Resource resource) {
	if (document instanceof IDocumentExtension4) {
		lineDelimiter = ((IDocumentExtension4) document).getDefaultLineDelimiter();
	} else {
		lineDelimiter = Strings.newLine();
	}
	this.script = (Script) resource.getContents().get(0);
	this.existingImports = Lists.newArrayList();
	for (ScriptElement element : script.getScriptElements()) {
		if (element instanceof ImportDeclaration)
			existingImports.add((ImportDeclaration) element);
	}
	this.requestedImports = Sets.newLinkedHashSet();
	this.lazySpacer = new Lazy<>(() -> spacerPreference.getSpacingPreference(resource));

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:17,代码来源:ImportRewriter.java


示例3: updateModel

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public void updateModel(String prefix, String editablePart, String suffix) {
	IDocument document = this.viewer.getDocument();
	if (this.insertLineBreaks) {
		String delimiter = document.getLegalLineDelimiters()[0];
		if (document instanceof IDocumentExtension4) {
			delimiter = ((IDocumentExtension4) document).getDefaultLineDelimiter();
		}
		prefix = prefix + delimiter;
		suffix = delimiter + suffix;
	}
	String model = prefix + editablePart + suffix;
	this.viewer.setRedraw(false);
	this.viewer.getUndoManager().disconnect();
	document.set(model);
	this.viewer.setVisibleRegion(prefix.length(), editablePart.length());
	this.viewer.getUndoManager().connect(this.viewer);
	this.viewer.setRedraw(true);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:EmbeddedEditorModelAccess.java


示例4: updatePrefix

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public void updatePrefix(String prefix) {
	try {
		IDocument document = this.viewer.getDocument();
		IRegion visibleRegion = this.viewer.getVisibleRegion();
		String editablePart = document.get(visibleRegion.getOffset(), visibleRegion.getLength());
		int suffixOffset = visibleRegion.getOffset() + visibleRegion.getLength();
		String suffix = "";
		if (document.getLength() - suffixOffset > 0) {
			suffix = document.get(suffixOffset, document.getLength() - suffixOffset);
			if (this.insertLineBreaks) {
				String delimiter = document.getLegalLineDelimiters()[0];
				if (document instanceof IDocumentExtension4) {
					delimiter = ((IDocumentExtension4) document).getDefaultLineDelimiter();
				}
				suffix = suffix.substring(delimiter.length());
			}
		}
		updateModel(prefix, editablePart, suffix);
	} catch (BadLocationException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:23,代码来源:EmbeddedEditorModelAccess.java


示例5: create

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public static BufferValidationState create(IFile file) {
  ITextFileBuffer buffer = getBuffer(file);
  if (buffer == null) {
    return new ModificationStampValidationState(file);
  } else {
    IDocument document = buffer.getDocument();
    if (document instanceof IDocumentExtension4) {
      return new ModificationStampValidationState(file);
    } else {
      if (buffer.isDirty()) {
        return new NoStampValidationState(file);
      } else {
        return new ModificationStampValidationState(file);
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:BufferValidationState.java


示例6: isValid

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public RefactoringStatus isValid(boolean needsSaving, boolean resilientForDerived)
    throws CoreException {
  RefactoringStatus result = super.isValid(needsSaving, resilientForDerived);
  if (result.hasFatalError()) return result;
  ModificationStamp currentStamp = getModificationStamp();
  // we don't need to check the kind here since the document stamp
  // and file stamp are in sync for documents implementing
  // IDocumentExtension4. If both are file stamps the file must
  // not be dirty
  if (fModificationStamp.getValue() != currentStamp.getValue()
      // we know here that the stamp value are equal. However, if
      // the stamp is a null stamp then the king must be equal as well.
      || (fModificationStamp.isFileStamp()
          && fModificationStamp.getValue() == IResource.NULL_STAMP
          && !currentStamp.isFileStamp())
      || (fModificationStamp.isDocumentStamp()
          && fModificationStamp.getValue() == IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP
          && !currentStamp.isDocumentStamp())
      || (fModificationStamp.isFileStamp() && currentStamp.isFileStamp() && isDirty(fFile))) {
    result.addFatalError(
        Messages.format(
            RefactoringCoreMessages.TextChanges_error_content_changed,
            BasicElementLabels.getPathLabel(fFile.getFullPath(), false)));
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:BufferValidationState.java


示例7: checkModificationStamp

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public void checkModificationStamp(RefactoringStatus status, long stampToMatch) {
  if (fKind == DOCUMENT) {
    if (stampToMatch != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP
        && fModificationStamp != stampToMatch) {
      status.addFatalError(
          Messages.format(
              RefactoringCoreMessages.ResourceChange_error_has_been_modified,
              BasicElementLabels.getPathLabel(fResource.getFullPath(), false)));
    }
  } else {
    if (stampToMatch != IResource.NULL_STAMP && fModificationStamp != stampToMatch) {
      status.addFatalError(
          Messages.format(
              RefactoringCoreMessages.ResourceChange_error_has_been_modified,
              BasicElementLabels.getPathLabel(fResource.getFullPath(), false)));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:ResourceChange.java


示例8: initializeFile

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private void initializeFile(IFile file) {
  fTextFileBuffer = getBuffer(file);
  if (fTextFileBuffer == null) {
    initializeResource(file);
  } else {
    IDocument document = fTextFileBuffer.getDocument();
    fDirty = fTextFileBuffer.isDirty();
    fReadOnly = Resources.isReadOnly(file);
    if (document instanceof IDocumentExtension4) {
      fKind = DOCUMENT;
      fModificationStamp = ((IDocumentExtension4) document).getModificationStamp();
    } else {
      fKind = RESOURCE;
      fModificationStamp = file.getModificationStamp();
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ResourceChange.java


示例9: performEdits

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
/**
 * Executes the text edits on the given document. Subclasses that override this method should call
 * <code>super.performEdits(document)</code>.
 *
 * @param document the document
 * @return an object representing the undo of the executed edits
 * @exception MalformedTreeException is thrown if the edit tree isn't in a valid state. This
 *     exception is thrown before any edit is executed. So the document is still in its original
 *     state.
 * @exception BadLocationException is thrown if one of the edits in the tree can't be executed.
 *     The state of the document is undefined if this exception is thrown.
 * @since 3.5
 */
protected UndoEdit performEdits(IDocument document)
    throws BadLocationException, MalformedTreeException {
  DocumentRewriteSession session = null;
  try {
    if (document instanceof IDocumentExtension4) {
      session =
          ((IDocumentExtension4) document)
              .startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
    }

    LinkedModeModel.closeAllModels(document);
    TextEditProcessor processor = createTextEditProcessor(document, TextEdit.CREATE_UNDO, false);
    return processor.performEdits();

  } finally {
    if (session != null) {
      ((IDocumentExtension4) document).stopRewriteSession(session);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:TextChange.java


示例10: performEdit

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private void performEdit(IDocument document, long oldFileValue, LinkedList<UndoEdit> editCollector, long[] oldDocValue, boolean[] setContentStampSuccess) throws MalformedTreeException, BadLocationException, CoreException {
	if (document instanceof IDocumentExtension4) {
		oldDocValue[0]= ((IDocumentExtension4)document).getModificationStamp();
	} else {
		oldDocValue[0]= oldFileValue;
	}

	// perform the changes
	for (int index= 0; index < fUndos.length; index++) {
		UndoEdit edit= fUndos[index];
		UndoEdit redo= edit.apply(document, TextEdit.CREATE_UNDO);
		editCollector.addFirst(redo);
	}

	if (document instanceof IDocumentExtension4 && fDocumentStamp != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP) {
		try {
			((IDocumentExtension4)document).replace(0, 0, "", fDocumentStamp); //$NON-NLS-1$
			setContentStampSuccess[0]= true;
		} catch (BadLocationException e) {
			throw wrapBadLocationException(e);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:CleanUpPostSaveListener.java


示例11: getDocumentStamp

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private long getDocumentStamp(IFile file, IProgressMonitor monitor) throws CoreException {
 final ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
 final IPath path= file.getFullPath();

 monitor.beginTask("", 2); //$NON-NLS-1$

 ITextFileBuffer buffer= null;
 try {
 	manager.connect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
  buffer= manager.getTextFileBuffer(path, LocationKind.IFILE);
	    IDocument document= buffer.getDocument();

	    if (document instanceof IDocumentExtension4) {
			return ((IDocumentExtension4)document).getModificationStamp();
		} else {
			return file.getModificationStamp();
		}
 } finally {
 	if (buffer != null)
 		manager.disconnect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
 	monitor.done();
 }
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:CleanUpPostSaveListener.java


示例12: removeOccurrenceAnnotations

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
void removeOccurrenceAnnotations() {
	fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
	fMarkOccurrenceTargetRegion= null;

	IDocumentProvider documentProvider= getDocumentProvider();
	if (documentProvider == null)
		return;

	IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
	if (annotationModel == null || fOccurrenceAnnotations == null)
		return;

	synchronized (getLockObject(annotationModel)) {
		if (annotationModel instanceof IAnnotationModelExtension) {
			((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
		} else {
			for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++)
				annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
		}
		fOccurrenceAnnotations= null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavaEditor.java


示例13: DocCopy

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public DocCopy(IDocument document) {
    this.contents = document.get();
    this.document = document;
    categoryToPos = new HashMap<>();
    String[] positionCategories = document.getPositionCategories();
    for (String string : positionCategories) {
        try {
            categoryToPos.put(string, document.getPositions(string));
        } catch (BadPositionCategoryException e) {
            Log.log(e);
        }
    }

    IDocumentExtension4 doc4 = (IDocumentExtension4) document;
    modificationStamp = doc4.getModificationStamp();
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:17,代码来源:DocCopy.java


示例14: initializeFile

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private void initializeFile(IFile file) {
    fTextFileBuffer = getBuffer(file);
    if (fTextFileBuffer == null) {
        initializeResource(file);
    } else {
        IDocument document = fTextFileBuffer.getDocument();
        fDirty = fTextFileBuffer.isDirty();
        fReadOnly = isReadOnly(file);
        if (document instanceof IDocumentExtension4) {
            fKind = DOCUMENT;
            fModificationStamp = ((IDocumentExtension4) document).getModificationStamp();
        } else {
            fKind = RESOURCE;
            fModificationStamp = file.getModificationStamp();
        }
    }

}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:19,代码来源:PyChange.java


示例15: getModificationStamp

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public long getModificationStamp(IResource resource) {
    if (!(resource instanceof IFile)) {
        return resource.getModificationStamp();
    }
    IFile file = (IFile) resource;
    ITextFileBuffer buffer = getBuffer(file);
    if (buffer == null) {
        return file.getModificationStamp();
    } else {
        IDocument document = buffer.getDocument();
        if (document instanceof IDocumentExtension4) {
            return ((IDocumentExtension4) document).getModificationStamp();
        } else {
            return file.getModificationStamp();
        }
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:18,代码来源:PyChange.java


示例16: findAndDeleteUnusedImports

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private void findAndDeleteUnusedImports(PySelection ps, PyEdit edit, IDocumentExtension4 doc, IFile f)
        throws Exception {
    Iterator<MarkerAnnotationAndPosition> it;
    if (edit != null) {
        it = edit.getPySourceViewer().getMarkerIterator();
    } else {

        IMarker markers[] = f.findMarkers(IMiscConstants.PYDEV_ANALYSIS_PROBLEM_MARKER, true, IResource.DEPTH_ZERO);
        MarkerAnnotationAndPosition maap[] = new MarkerAnnotationAndPosition[markers.length];
        int ix = 0;
        for (IMarker m : markers) {
            int start = (Integer) m.getAttribute(IMarker.CHAR_START);
            int end = (Integer) m.getAttribute(IMarker.CHAR_END);
            maap[ix++] =
                    new MarkerAnnotationAndPosition(new MarkerAnnotation(m), new Position(start, end - start));
        }
        it = Arrays.asList(maap).iterator();
    }
    ArrayList<MarkerAnnotationAndPosition> unusedImportsMarkers = getUnusedImports(it);
    sortInReverseDocumentOrder(unusedImportsMarkers);
    deleteImports(doc, ps, unusedImportsMarkers);

}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:24,代码来源:OrganizeImportsFixesUnused.java


示例17: run

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
@Override
protected boolean run(IMarker marker, AbstractTextEditor editor, IDocument doc) {
	String delimiter = ((IDocumentExtension4) doc).getDefaultLineDelimiter();
	int offset = marker.getAttribute(IMarker.CHAR_END, -1);
	StyledText text = (StyledText) editor.getAdapter(Control.class);
	text.getDisplay().syncExec(() -> {
		MarkerUtils.applyEdits(doc, new ReplaceEdit(offset, 0, delimiter));
	});
	return true;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:11,代码来源:InsertFinalNewLineMarkerResolution.java


示例18: UnchangedElementListener

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public UnchangedElementListener(ElementInfo element) {
	this.element = element;
	if (element.fDocument instanceof IDocumentExtension4) {
		modificationStamp = ((IDocumentExtension4) element.fDocument).getModificationStamp();
	} else {
		modificationStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
	}

}
 
开发者ID:cplutte,项目名称:bts,代码行数:10,代码来源:XtextDocumentProvider.java


示例19: assertModelInSyncWithDocument

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public void assertModelInSyncWithDocument(IDocument document, XtextResource resource, final ReconcilerReplaceRegion region) {
	if (document instanceof IDocumentExtension4 && resource != null) {
		long beforeGet = ((IDocumentExtension4) document).getModificationStamp();
		final String documentContent = document.get();
		long afterGet = ((IDocumentExtension4) document).getModificationStamp();
		if (beforeGet == afterGet && beforeGet == resource.getModificationStamp()) {
			IParseResult parseResult = resource.getParseResult();
			if (parseResult != null) {
				ICompositeNode rootNode = parseResult.getRootNode();
				final String resourceContent = rootNode.getText();
				if (!resourceContent.equals(documentContent)) {
					new DisplayRunnable() {
						@Override
						protected void run() throws Exception {
							LOG.error("XtextDocument and XtextResource have run out of sync:\n" 
											+ DiffUtil.diff(documentContent, resourceContent));
							LOG.error("Events: \n\t" + Joiner.on("\n\t").join(region.getDocumentEvents()));
							LOG.error("ReplaceRegion: \n\t'" + region + "'" );
							MessageDialog.openError(
									Display.getCurrent().getActiveShell(),
									"XtextReconcilerDebugger",
									"XtextDocument and XtextResource have run out of sync."
											+ "\n\nSee log for details.");
						}
						
					}.syncExec();
				} else {
					System.out.println("Model and document are in sync");
				}
			}
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:34,代码来源:XtextReconcilerDebugger.java


示例20: performEdits

import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
protected UndoEdit performEdits(IDocument document) throws BadLocationException, MalformedTreeException {
	DocumentRewriteSession session= null;
	try {
		if (document instanceof IDocumentExtension4) {
			session= ((IDocumentExtension4)document).startRewriteSession(
				DocumentRewriteSessionType.UNRESTRICTED);
		}
		return undoEdit.apply(document);
	} finally {
		if (session != null) {
			((IDocumentExtension4)document).stopRewriteSession(session);
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:EditorDocumentUndoChange.java



注:本文中的org.eclipse.jface.text.IDocumentExtension4类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ShadowWebView类代码示例发布时间:2022-05-21
下一篇:
Java User类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap