本文整理汇总了Java中org.eclipse.jface.text.source.IAnnotationModelExtension2类的典型用法代码示例。如果您正苦于以下问题:Java IAnnotationModelExtension2类的具体用法?Java IAnnotationModelExtension2怎么用?Java IAnnotationModelExtension2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAnnotationModelExtension2类属于org.eclipse.jface.text.source包,在下文中一共展示了IAnnotationModelExtension2类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: hasProblem
import org.eclipse.jface.text.source.IAnnotationModelExtension2; //导入依赖的package包/类
/***
* Returns true if it exists a marker annotation in the given offset and false
* otherwise.
*
* @param textViewer
* @param offset
* @return true if it exists a marker annotation in the given offset and false
* otherwise.
*/
private static boolean hasProblem(ITextViewer textViewer, int offset) {
if (!(textViewer instanceof ISourceViewer)) {
return false;
}
IAnnotationModel annotationModel = ((ISourceViewer) textViewer).getAnnotationModel();
Iterator<Annotation> iter = (annotationModel instanceof IAnnotationModelExtension2)
? ((IAnnotationModelExtension2) annotationModel).getAnnotationIterator(offset, 1, true, true)
: annotationModel.getAnnotationIterator();
while (iter.hasNext()) {
Annotation ann = iter.next();
if (ann instanceof MarkerAnnotation) {
return true;
}
}
return false;
}
开发者ID:angelozerr,项目名称:ec4e,代码行数:27,代码来源:EditorConfigTextHover.java
示例2: getAnnotation
import org.eclipse.jface.text.source.IAnnotationModelExtension2; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private Annotation getAnnotation(final int offset, final int length) {
final IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
if (model == null)
return null;
Iterator iterator;
if (model instanceof IAnnotationModelExtension2) {
iterator = ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true);
} else {
iterator = model.getAnnotationIterator();
}
while (iterator.hasNext()) {
final Annotation a = (Annotation) iterator.next();
final Position p = model.getPosition(a);
if (p != null && p.overlapsWith(offset, length))
return a;
}
return null;
}
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:XtextEditor.java
示例3: getAnnotation
import org.eclipse.jface.text.source.IAnnotationModelExtension2; //导入依赖的package包/类
/**
* Returns the annotation overlapping with the given range or <code>null</code>.
*
* @param offset the region offset
* @param length the region length
* @return the found annotation or <code>null</code>
* @since 3.0
*/
private Annotation getAnnotation(int offset, int length) {
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
if (model == null)
return null;
Iterator<Annotation> parent;
if (model instanceof IAnnotationModelExtension2)
parent= ((IAnnotationModelExtension2)model).getAnnotationIterator(offset, length, true, true);
else
parent= model.getAnnotationIterator();
Iterator<Annotation> e= new JavaAnnotationIterator(parent, false);
while (e.hasNext()) {
Annotation a= e.next();
Position p= model.getPosition(a);
if (p != null && p.overlapsWith(offset, length))
return a;
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:JavaEditor.java
示例4: getHoverInfo2
import org.eclipse.jface.text.source.IAnnotationModelExtension2; //导入依赖的package包/类
@Override
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
IPath path;
IAnnotationModel model;
if (textViewer instanceof ISourceViewer) {
path = null;
model = ((ISourceViewer) textViewer).getAnnotationModel();
} else {
// Get annotation model from file buffer manager
path = getEditorInputPath();
model = getAnnotationModel(path);
}
if (model == null)
return null;
try {
Iterator<Annotation> parent;
if (model instanceof IAnnotationModelExtension2)
parent = ((IAnnotationModelExtension2) model).getAnnotationIterator(hoverRegion.getOffset(),
hoverRegion.getLength() > 0 ? hoverRegion.getLength() : 1, true, true);
else
parent = model.getAnnotationIterator();
Iterator<Annotation> e = new TypeScriptAnnotationIterator(parent, fAllAnnotations);
int layer = -1;
Annotation annotation = null;
Position position = null;
while (e.hasNext()) {
Annotation a = e.next();
AnnotationPreference preference = getAnnotationPreference(a);
if (preference == null || !(preference.getTextPreferenceKey() != null
/*
* && fStore.getBoolean(preference.getTextPreferenceKey()) ||
* (preference.getHighlightPreferenceKey() != null &&
* fStore.getBoolean(preference.getHighlightPreferenceKey()))
*/))
continue;
Position p = model.getPosition(a);
int l = fAnnotationAccess.getLayer(a);
if (l > layer && p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
String msg = a.getText();
if (msg != null && msg.trim().length() > 0) {
layer = l;
annotation = a;
position = p;
}
}
}
if (layer > -1)
return createAnnotationInfo(annotation, position, textViewer);
} finally {
try {
if (path != null) {
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.disconnect(path, LocationKind.NORMALIZE, null);
}
} catch (CoreException ex) {
TypeScriptUIPlugin.log(ex.getStatus());
}
}
return null;
}
开发者ID:angelozerr,项目名称:typescript.java,代码行数:69,代码来源:AbstractAnnotationHover.java
示例5: getApplicableAnnotations
import org.eclipse.jface.text.source.IAnnotationModelExtension2; //导入依赖的package包/类
protected Set<Annotation> getApplicableAnnotations(final IXtextDocument document, final IAnnotationModel annotationModel,
final int offset) throws BadLocationException {
final int line = document.getLineOfOffset(offset);
final String delim = document.getLineDelimiter(line);
final int delimLength = delim != null ? delim.length() : 0;
final int lineLength = document.getLineLength(line) - delimLength;
final int lineOffset = document.getLineOffset(line);
Iterator<?> iterator;
if (annotationModel instanceof IAnnotationModelExtension2)
iterator = ((IAnnotationModelExtension2) annotationModel).getAnnotationIterator(lineOffset, lineLength, true,
true);
else
iterator = annotationModel.getAnnotationIterator();
Set<Annotation> possibleAnnotations = Sets.newHashSet();
Annotation actualAnnotation = null;
int nearestAnnotationOffset = Integer.MAX_VALUE;
Annotation firstAnnotation = null;
int offsetOfFirstAnnotation = Integer.MAX_VALUE;
while (iterator.hasNext()) {
Object key = iterator.next();
if (!(key instanceof Annotation))
continue;
Annotation annotationTemp = (Annotation) key;
if (!canFix(annotationTemp))
continue;
Position pos = annotationModel.getPosition(annotationTemp);
if (pos == null)
continue;
if (pos.overlapsWith(lineOffset, lineLength)) {
possibleAnnotations.add(annotationTemp);
if (pos.getOffset() < offsetOfFirstAnnotation) {
offsetOfFirstAnnotation = pos.getOffset();
firstAnnotation = annotationTemp;
}
int distanceToOffset = offset - pos.getOffset();
if (distanceToOffset >= 0 && distanceToOffset < nearestAnnotationOffset) {
actualAnnotation = annotationTemp;
nearestAnnotationOffset = distanceToOffset;
}
}
}
// choose the first annotation if there is no better selection available
if (actualAnnotation == null) {
actualAnnotation = firstAnnotation;
}
// Find Annotations with same offset an length
Set<Annotation> actualAnnotations = Sets.newHashSet();
for(Annotation possibleAnnotation : possibleAnnotations){
Position possibleAnnotationPosition = annotationModel.getPosition(possibleAnnotation);
Position actualAnnotationPosition = annotationModel.getPosition(actualAnnotation);
// position may be null due to concurrent operation on the annotation model
if(possibleAnnotationPosition != null && possibleAnnotationPosition.equals(actualAnnotationPosition)){
actualAnnotations.add(possibleAnnotation);
}
}
return actualAnnotations;
}
开发者ID:cplutte,项目名称:bts,代码行数:64,代码来源:XtextQuickAssistProcessor.java
示例6: getHoverInfo2
import org.eclipse.jface.text.source.IAnnotationModelExtension2; //导入依赖的package包/类
@Override
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
IPath path;
IAnnotationModel model;
if (textViewer instanceof ISourceViewer) {
path= null;
model= ((ISourceViewer)textViewer).getAnnotationModel();
} else {
// Get annotation model from file buffer manager
path= getEditorInputPath();
model= getAnnotationModel(path);
}
if (model == null)
return null;
try {
Iterator<Annotation> parent;
if (model instanceof IAnnotationModelExtension2)
parent= ((IAnnotationModelExtension2)model).getAnnotationIterator(hoverRegion.getOffset(), hoverRegion.getLength(), true, true);
else
parent= model.getAnnotationIterator();
Iterator<Annotation> e= new JavaAnnotationIterator(parent, fAllAnnotations);
int layer= -1;
Annotation annotation= null;
Position position= null;
while (e.hasNext()) {
Annotation a= e.next();
AnnotationPreference preference= getAnnotationPreference(a);
if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
continue;
Position p= model.getPosition(a);
int l= fAnnotationAccess.getLayer(a);
if (l > layer && p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
String msg= a.getText();
if (msg != null && msg.trim().length() > 0) {
layer= l;
annotation= a;
position= p;
}
}
}
if (layer > -1)
return createAnnotationInfo(annotation, position, textViewer);
} finally {
try {
if (path != null) {
ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
manager.disconnect(path, LocationKind.NORMALIZE, null);
}
} catch (CoreException ex) {
JavaPlugin.log(ex.getStatus());
}
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:63,代码来源:AbstractAnnotationHover.java
示例7: computeQuickAssistProposals
import org.eclipse.jface.text.source.IAnnotationModelExtension2; //导入依赖的package包/类
@Override
public ICompletionProposal[] computeQuickAssistProposals(
IQuickAssistInvocationContext invocationContext) {
ISourceViewer viewer = invocationContext.getSourceViewer();
int documentOffset = invocationContext.getOffset();
int length = viewer != null ? viewer.getSelectedRange().y : 0;
IAnnotationModel model = viewer.getAnnotationModel();
if (model == null)
return null;
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
if (model instanceof IAnnotationModelExtension2) {
Iterator iter = ((IAnnotationModelExtension2) model)
.getAnnotationIterator(documentOffset, length, true, true);
while (iter.hasNext()) {
Annotation anno = (Annotation) iter.next();
if (canFix(anno)) {
int offset = -1;
if (anno instanceof TemporaryAnnotation) {
offset = ((TemporaryAnnotation) anno).getPosition()
.getOffset();
} else if (anno instanceof MarkerAnnotation) {
offset = ((MarkerAnnotation) anno).getMarker()
.getAttribute(IMarker.CHAR_START, -1);
}
if (offset == -1)
continue;
// add "New file wizard" completion proposal
IDOMAttr attr = DOMHelper.getAttrByOffset(
viewer.getDocument(), offset);
if (attr != null) {
IFile file = EditorUtils.getFile(viewer.getDocument());
CreateFileCompletionProposal proposal = new CreateFileCompletionProposal(
file, attr);
if (!proposals.contains(proposal)) {
proposals.add(proposal);
}
}
}
}
}
if (proposals.isEmpty())
return null;
return proposals
.toArray(new ICompletionProposal[proposals.size()]);
}
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:53,代码来源:WebResourceQuickFixProcessor.java
示例8: getHoverInfo
import org.eclipse.jface.text.source.IAnnotationModelExtension2; //导入依赖的package包/类
@Override
public Object getHoverInfo(ISourceBuffer sourceBuffer, IRegion hoverRegion, ITextViewer textViewer) {
if (!(textViewer instanceof ISourceViewer)) {
return null;
}
ISourceViewer sourceViewer = (ISourceViewer) textViewer;
// IPath path = null;
IAnnotationModel model = sourceViewer.getAnnotationModel();
// if (editor.getSourceViewer_() instanceof ISourceViewer) {
// path= null;
// model= editor.getSourceViewer_().getAnnotationModel();
// } else {
// // Get annotation model from file buffer manager
// path= getEditorInputPath();
// model= getAnnotationModel(path);
// }
if (model == null)
return null;
// try {
Iterator<Annotation> parent;
if (model instanceof IAnnotationModelExtension2)
parent= ((IAnnotationModelExtension2)model).getAnnotationIterator(hoverRegion.getOffset(), hoverRegion.getLength(), true, true);
else
parent= model.getAnnotationIterator();
Iterator<Annotation> e= new JavaAnnotationIterator(parent, fAllAnnotations);
int layer= -1;
Annotation annotation= null;
Position position= null;
while (e.hasNext()) {
Annotation a= e.next();
AnnotationPreference preference= getAnnotationPreference(a);
if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
continue;
Position p= model.getPosition(a);
int l= fAnnotationAccess.getLayer(a);
if (l > layer && p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
String msg= a.getText();
if (msg != null && msg.trim().length() > 0) {
layer= l;
annotation= a;
position= p;
}
}
}
if (layer > -1)
return createAnnotationInfo(annotation, position, textViewer);
// } finally {
// try {
// if (path != null) {
// ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
// manager.disconnect(path, LocationKind.NORMALIZE, null);
// }
// } catch (CoreException ex) {
// LangUIPlugin.logStatus(ex);
// }
// }
return null;
}
开发者ID:GoClipse,项目名称:goclipse,代码行数:69,代码来源:AbstractAnnotationHover.java
注:本文中的org.eclipse.jface.text.source.IAnnotationModelExtension2类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论