org.eclipse.jface.text.source.AnnotationModel Java Examples

The following examples show how to use org.eclipse.jface.text.source.AnnotationModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmbeddedEditorModelAccess.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void setModel(XtextDocument document, String prefix, String editablePart, String suffix) {
	if (this.insertLineBreaks) {
		String delimiter = document.getDefaultLineDelimiter();
		prefix = prefix + delimiter;
		suffix = delimiter + suffix;
	}
	String model = prefix + editablePart + suffix;
	document.set(model);
	XtextResource resource = createResource(model);
	document.setInput(resource);
	AnnotationModel annotationModel = new AnnotationModel();
	if (document instanceof ISynchronizable) {
		Object lock = ((ISynchronizable) document).getLockObject();
		if (lock == null) {
			lock = new Object();
			((ISynchronizable) document).setLockObject(lock);
		}
		((ISynchronizable) annotationModel).setLockObject(lock);
	}
	this.viewer.setDocument(document, annotationModel, prefix.length(), editablePart.length());
}
 
Example #2
Source File: ContributionAnnotationHistoryTest.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testAddEntryWithMultipleModels() {
  final AnnotationModel testModel2 = new AnnotationModel();

  Pair<IAnnotationModel, List<ContributionAnnotation>> annotationsToRemove =
      history.addNewEntry(createDummyAnnotation(testModel2));
  assertNull(annotationsToRemove);

  for (int i = 1; i < MAX_HISTORY_LENGTH; i++) {
    annotationsToRemove = history.addNewEntry(createDummyAnnotation(testModel));
    assertNull(annotationsToRemove);
  }

  annotationsToRemove = history.addNewEntry(createDummyAnnotation(testModel));
  assertSame(testModel2, annotationsToRemove.getLeft());

  annotationsToRemove = history.addNewEntry(createDummyAnnotation(testModel));
  assertSame(testModel, annotationsToRemove.getLeft());
}
 
Example #3
Source File: CompilationUnitDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void connect(Object element) throws CoreException {
	super.connect(element);
	if (getFileInfo(element) != null)
		return;

	CompilationUnitInfo info= fFakeCUMapForMissingInfo.get(element);
	if (info == null) {
		ICompilationUnit cu= createFakeCompiltationUnit(element, true);
		if (cu == null)
			return;
		info= new CompilationUnitInfo();
		info.fCopy= cu;
		info.fElement= element;
		info.fModel= new AnnotationModel();
		fFakeCUMapForMissingInfo.put(element, info);
	}
	info.fCount++;
}
 
Example #4
Source File: XtextDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
	if (element instanceof IFileEditorInput) {
		IFileEditorInput input = (IFileEditorInput) element;
		return new XtextResourceMarkerAnnotationModel(input.getFile(), issueResolutionProvider, issueUtil);
	} else if (element instanceof IURIEditorInput) {
		return new AnnotationModel();
	}
	return super.createAnnotationModel(element);
}
 
Example #5
Source File: StyledTextXtextAdapter.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected XtextSourceViewer createXtextSourceViewer() {
	final XtextSourceViewer result = new XtextSourceViewerEx(getStyledText(),
			getPreferenceStoreAccess().getPreferenceStore());
	result.configure(getXtextSourceViewerConfiguration());
	result.setDocument(getXtextDocument(), new AnnotationModel());
	return result;
}
 
Example #6
Source File: ContributionAnnotationManagerTest.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Before
public void setUp() {
  store = new PreferenceStore();
  store.setValue(EclipsePreferenceConstants.SHOW_CONTRIBUTION_ANNOTATIONS, true);
  createListenerMocks();

  manager = new ContributionAnnotationManager(sessionMock, store);
  model = new AnnotationModel();
}
 
Example #7
Source File: CommonAnnotationModelFactory.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public IAnnotationModel createAnnotationModel(IPath path)
{
	IResource file = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
	if (file instanceof IFile)
	{
		return new CommonAnnotationModel(file);
	}
	return new AnnotationModel();
}
 
Example #8
Source File: ScriptEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new line number ruler column that is appropriately initialized.
 * 
 * @return the created line number column
 */
private CompositeRuler createCompositeRuler( )
{
	CompositeRuler ruler = new CompositeRuler( );

	ruler.setModel( new AnnotationModel( ) );
	return ruler;
}
 
Example #9
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new line number ruler column that is appropriately initialized.
 * 
 * @return the created line number column
 */
private CompositeRuler createCompositeRuler( )
{
	CompositeRuler ruler = new CompositeRuler( );

	ruler.setModel( new AnnotationModel( ) );
	return ruler;
}
 
Example #10
Source File: ContributionAnnotationManagerTest.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testHistoryRemovalWithMultipleModels() {
  final AnnotationModel model2 = new AnnotationModel();
  final AnnotationModel model3 = new AnnotationModel();
  final int numberOfInsertions = 5;

  // Fill history
  for (int i = 0; i < numberOfInsertions; i++) {
    manager.insertAnnotation(model2, i, 1, ALICE_TEST_USER);
  }

  for (int i = 0; i < numberOfInsertions; i++) {
    manager.insertAnnotation(model3, i, 1, ALICE_TEST_USER);
  }

  int offset = 0;
  final int remainingInsertions = MAX_HISTORY_LENGTH - 2 * numberOfInsertions;
  for (int i = 0; i < remainingInsertions; i++, offset++) {
    manager.insertAnnotation(model, offset, 1, ALICE_TEST_USER);
  }

  assertEquals(remainingInsertions, getAnnotationCount(model));
  assertEquals(numberOfInsertions, getAnnotationCount(model2));
  assertEquals(numberOfInsertions, getAnnotationCount(model3));

  for (int i = 0; i < numberOfInsertions; i++, offset++) {
    manager.insertAnnotation(model, offset, 1, ALICE_TEST_USER);
  }

  assertEquals(remainingInsertions + numberOfInsertions, getAnnotationCount(model));
  assertEquals(
      "Insertions in another model should lead to removing all annotations in the model",
      0,
      getAnnotationCount(model2));
  assertEquals(numberOfInsertions, getAnnotationCount(model3));

  for (int i = 0; i < numberOfInsertions; i++, offset++) {
    manager.insertAnnotation(model, offset, 1, ALICE_TEST_USER);
  }

  assertEquals(remainingInsertions + 2 * numberOfInsertions, getAnnotationCount(model));
  assertEquals(0, getAnnotationCount(model2));
  assertEquals(
      "Insertions in another model should lead to removing all annotations in the model",
      0,
      getAnnotationCount(model3));
}
 
Example #11
Source File: AbstractSourceView.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected AnnotationModel createAnnotationModel() {
	return new AnnotationModel();
}
 
Example #12
Source File: ContributionAnnotationHistoryTest.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
private List<ContributionAnnotation> createDummyAnnotation(final AnnotationModel model) {
  final User dummyUser = new User(new JID("alice@test"), false, false, null);
  final ContributionAnnotation dummyAnnotation = new ContributionAnnotation(dummyUser, model);
  return Arrays.asList(dummyAnnotation);
}
 
Example #13
Source File: ContributionAnnotationHistoryTest.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void setUp() {
  history = new ContributionAnnotationHistory(MAX_HISTORY_LENGTH);
  testModel = new AnnotationModel();
}
 
Example #14
Source File: CompilationUnitDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public IAnnotationModel createAnnotationModel(IPath path) {
	IResource file= ResourcesPlugin.getWorkspace().getRoot().findMember(path);
	if (file instanceof IFile)
		return new CompilationUnitAnnotationModel(file);
	return new AnnotationModel();
}
 
Example #15
Source File: CommitCommentArea.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public CommentSpellingReconcileStrategy(AnnotationModel annotationModel) {
  this.fAnnotationModel = annotationModel;
  fSpellingContext = new SpellingContext();
  fSpellingContext.setContentType(Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT));
}
 
Example #16
Source File: CommitCommentArea.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public SourceViewerConfig(AnnotationModel annotationModel,
		Document document) {
	strategy = new CommentSpellingReconcileStrategy(annotationModel);
	strategy.setDocument(document);
}
 
Example #17
Source File: DerivedSourceView.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected AnnotationModel createAnnotationModel() {
	IFile file = getSelectedFile();
	return file != null ? new ResourceMarkerAnnotationModel(file) : super.createAnnotationModel();
}