本文整理匯總了Java中org.eclipse.jface.text.source.Annotation類的典型用法代碼示例。如果您正苦於以下問題:Java Annotation類的具體用法?Java Annotation怎麽用?Java Annotation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Annotation類屬於org.eclipse.jface.text.source包,在下文中一共展示了Annotation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculatePositions
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private void calculatePositions() {
if (hasSnippetsModifications()) {
final Map<ProjectionAnnotation, Position> annotations = getAllSnippetsAnnotations();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (!annotations.isEmpty() && getProjectionAnnotationModel() == null) {
enableProjection();
}
if (getProjectionAnnotationModel() != null) {
Annotation[] oldAnno = oldAnnotations.keySet().toArray(new Annotation[0]);
getProjectionAnnotationModel().modifyAnnotations(oldAnno, annotations, null);
oldAnnotations.clear();
oldAnnotations.putAll(annotations);
if (annotations.isEmpty()) {
disableProjection();
}
}
}
});
}
}
示例2: removeOldAnnotation
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private void removeOldAnnotation(final int offset) {
this.annotationModel.connect(this.document);
final Iterator<Annotation> iter = this.annotationModel.getAnnotationIterator();
Annotation beRemoved = null;
while (iter.hasNext()) {
beRemoved = iter.next();
if (!beRemoved.getType().equals(this.MME_REASON_ANNOT_TYPE)) {
continue;
}
final Position position = this.annotationModel.getPosition(beRemoved);
if (position.getOffset() + position.getLength() == offset || position.includes(offset)) {
this.annotationModel.removeAnnotation(beRemoved);
}
}
this.annotationModel.disconnect(this.document);
}
示例3: addNewAnnotation
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
/**
* We add new error annotation related to error which alloy parser is giving us.
*
* @param e the exception which is parse operation occurred
*/
private void addNewAnnotation(final Err e) {
final int line = e.pos.y;
int offset = 0;
final int length = e.pos.x2 - e.pos.x + 1;
final String message = e.getLocalizedMessage();
try {
offset = this.document.getLineOffset(line - 1) + e.pos.x - 1;
} catch (final BadLocationException e1) {
e1.printStackTrace();
}
final Annotation annotation = new Annotation(this.MME_PARSE_ANNOT_TYPE, true, message);
this.annotationModel.connect(this.document);
this.annotationModel.addAnnotation(annotation, new Position(offset, length));
this.annotationModel.disconnect(this.document);
}
示例4: hasProblem
import org.eclipse.jface.text.source.Annotation; //導入依賴的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;
}
示例5: updateFolding
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private void updateFolding(EditorConfig editorConfig) {
if (projectionAnnotationModel == null) {
return;
}
List<Section> sections = editorConfig.getSections();
CommentBlocks commentBlocks = editorConfig.getAdapter(CommentBlocks.class);
List<CommentBlock> comments = commentBlocks != null ? commentBlocks.getCommentBlocks()
: Collections.emptyList();
Map<Annotation, Position> newAnnotations = new HashMap<>();
// Collection section and comment spans;
List<Span> spans = /*Stream.concat(sections.stream(), comments.stream())*/
sections.stream()
.map(a -> a.getAdapter(Span.class))
.sorted((s1, s2) -> s1.getStart().getLine() - s2.getStart().getLine()).collect(Collectors.toList());
Annotation[] annotations = new Annotation[spans.size()];
for (int i = 0; i < spans.size(); i++) {
Span span = spans.get(i);
int startOffset = span.getStart().getOffset();
int endOffset = span.getEnd().getOffset();
ProjectionAnnotation annotation = new ProjectionAnnotation();
newAnnotations.put(annotation, new Position(startOffset, endOffset - startOffset));
annotations[i] = annotation;
}
projectionAnnotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null);
oldAnnotations = annotations;
}
示例6: getHoverInfo
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
@Override
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
IAnnotationModel model = sourceViewer.getAnnotationModel();
Iterator iterator = model.getAnnotationIterator();
while (iterator.hasNext()) {
Annotation annotation = (Annotation) iterator.next();
Position position = model.getPosition(annotation);
try {
int lineOfAnnotation = sourceViewer.getDocument().
getLineOfOffset(position.getOffset());
if (lineNumber == lineOfAnnotation) {
return annotation.getText();
}
} catch (BadLocationException e) {
// TODO: handle exception
}
}
return null;
}
示例7: updateCodefolding
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
/**
* <p>
* Checks whether the given positions are in the
* <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
* to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
* count less than 2.
* </p>
*
* @param positions a list of available foldable positions
*/
public void updateCodefolding(List<Position> positions) {
IDocument document = sourceViewer.getDocument();
if (document == null) {
return;
}
oldAnnotations.clear();
Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
while (annotationIterator.hasNext()) {
oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
}
// Add new Position with a unique line offset
for (Position position : positions) {
if (!isInAdditions(position)) {
addPosition(position);
}
}
projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
additions.clear();
}
示例8: getQuickFixes
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> foundFixes = new ArrayList<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例9: getQuickFixes
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例10: getQuickFixes
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> foundFixes = new ArrayList<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例11: getQuickFixes
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> foundFixes = new ArrayList<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例12: getQuickFixes
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例13: getQuickFixes
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private List<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例14: getQuickFixes
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private List<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> foundFixes = new ArrayList<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例15: addProposals
import org.eclipse.jface.text.source.Annotation; //導入依賴的package包/類
private void addProposals(final SubMenuManager quickFixMenu) {
IAnnotationModel sourceModel = sourceViewer.getAnnotationModel();
Iterator annotationIterator = sourceModel.getAnnotationIterator();
while (annotationIterator.hasNext()) {
Annotation annotation = (Annotation) annotationIterator.next();
boolean isDeleted = annotation.isMarkedDeleted();
boolean isIncluded = includes(sourceModel.getPosition(annotation),
getTextWidget().getCaretOffset());
boolean isFixable = sourceViewer.getQuickAssistAssistant().canFix(
annotation);
if (!isDeleted && isIncluded && isFixable) {
IQuickAssistProcessor processor = sourceViewer
.getQuickAssistAssistant()
.getQuickAssistProcessor();
IQuickAssistInvocationContext context = sourceViewer
.getQuickAssistInvocationContext();
ICompletionProposal[] proposals = processor
.computeQuickAssistProposals(context);
for (ICompletionProposal proposal : proposals)
quickFixMenu.add(createQuickFixAction(proposal));
}
}
}