本文整理汇总了Java中org.eclipse.jface.text.source.ISourceViewer.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java ISourceViewer.getDocument方法的具体用法?Java ISourceViewer.getDocument怎么用?Java ISourceViewer.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.source.ISourceViewer
的用法示例。
在下文中一共展示了ISourceViewer.getDocument方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHoverInfo
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public String getHoverInfo( ISourceViewer sourceViewer, int lineNumber){
IDocument document = sourceViewer.getDocument();
try {
IRegion info = document.getLineInformation(lineNumber);
return document.get(info.getOffset(), info.getLength());
} catch (BadLocationException x) {
}
return null;
}
示例2: getHoverInfo
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
/**
* Find a problem marker from the given line and return its error message.
*
* @param sourceViewer the source viewer
* @param lineNumber line number in the file, starting from zero
* @return the message of the marker of null, if no marker at the specified line
*/
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
IDocument document= sourceViewer.getDocument();
IAnnotationModel model= sourceViewer.getAnnotationModel();
if (model == null)
return null;
List<String> lineMarkers = null;
Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
Annotation o= e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a= (MarkerAnnotation) o;
if (isRulerLine(model.getPosition(a), document, lineNumber)) {
if (lineMarkers == null)
lineMarkers = new LinkedList<String>();
lineMarkers.add(a.getMarker().getAttribute(IMarker.MESSAGE, null));
}
}
}
if (lineMarkers != null)
return getMessage(lineMarkers);
return null;
}
示例3: getHoverInfo
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber)
{
IDocument document = sourceViewer.getDocument();
/*
try
{
IRegion info = document.getLineInformation(lineNumber);
return "This is an annotation for: " + document.get(info.getOffset(), info.getLength());
} catch (BadLocationException x)
{
}
*/
return null;
}
示例4: getReconciler
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
return null;
}
SpellingService spellingService = EditorsUI.getSpellingService();
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
return null;
}
IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
@Override
protected ISpellingProblemCollector createSpellingProblemCollector() {
final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
return new ISpellingProblemCollector() {
public void accept(SpellingProblem problem) {
int offset = problem.getOffset();
int length = problem.getLength();
if (sourceViewer == null) {
return;
}
IDocument document = sourceViewer.getDocument();
if (document == null) {
return;
}
String text;
try {
text = document.get(offset, length);
} catch (BadLocationException e) {
return;
}
if (new de.darwinspl.preferences.resource.dwprofile.ui.DwprofileIgnoredWordsFilter().ignoreWord(text)) {
return;
}
collector.accept(problem);
}
public void beginCollecting() {
collector.beginCollecting();
}
public void endCollecting() {
collector.endCollecting();
}
};
}
};
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
示例5: getReconciler
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
return null;
}
SpellingService spellingService = EditorsUI.getSpellingService();
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
return null;
}
IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
@Override
protected ISpellingProblemCollector createSpellingProblemCollector() {
final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
return new ISpellingProblemCollector() {
public void accept(SpellingProblem problem) {
int offset = problem.getOffset();
int length = problem.getLength();
if (sourceViewer == null) {
return;
}
IDocument document = sourceViewer.getDocument();
if (document == null) {
return;
}
String text;
try {
text = document.get(offset, length);
} catch (BadLocationException e) {
return;
}
if (new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionIgnoredWordsFilter().ignoreWord(text)) {
return;
}
collector.accept(problem);
}
public void beginCollecting() {
collector.beginCollecting();
}
public void endCollecting() {
collector.endCollecting();
}
};
}
};
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
示例6: getReconciler
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
return null;
}
SpellingService spellingService = EditorsUI.getSpellingService();
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
return null;
}
IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
@Override
protected ISpellingProblemCollector createSpellingProblemCollector() {
final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
return new ISpellingProblemCollector() {
public void accept(SpellingProblem problem) {
int offset = problem.getOffset();
int length = problem.getLength();
if (sourceViewer == null) {
return;
}
IDocument document = sourceViewer.getDocument();
if (document == null) {
return;
}
String text;
try {
text = document.get(offset, length);
} catch (BadLocationException e) {
return;
}
if (new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaIgnoredWordsFilter().ignoreWord(text)) {
return;
}
collector.accept(problem);
}
public void beginCollecting() {
collector.beginCollecting();
}
public void endCollecting() {
collector.endCollecting();
}
};
}
};
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
示例7: getReconciler
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
return null;
}
SpellingService spellingService = EditorsUI.getSpellingService();
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
return null;
}
IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
@Override
protected ISpellingProblemCollector createSpellingProblemCollector() {
final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
return new ISpellingProblemCollector() {
public void accept(SpellingProblem problem) {
int offset = problem.getOffset();
int length = problem.getLength();
if (sourceViewer == null) {
return;
}
IDocument document = sourceViewer.getDocument();
if (document == null) {
return;
}
String text;
try {
text = document.get(offset, length);
} catch (BadLocationException e) {
return;
}
if (new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueIgnoredWordsFilter().ignoreWord(text)) {
return;
}
collector.accept(problem);
}
public void beginCollecting() {
collector.beginCollecting();
}
public void endCollecting() {
collector.endCollecting();
}
};
}
};
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
示例8: getReconciler
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
return null;
}
SpellingService spellingService = EditorsUI.getSpellingService();
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
return null;
}
IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
@Override
protected ISpellingProblemCollector createSpellingProblemCollector() {
final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
return new ISpellingProblemCollector() {
public void accept(SpellingProblem problem) {
int offset = problem.getOffset();
int length = problem.getLength();
if (sourceViewer == null) {
return;
}
IDocument document = sourceViewer.getDocument();
if (document == null) {
return;
}
String text;
try {
text = document.get(offset, length);
} catch (BadLocationException e) {
return;
}
if (new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingIgnoredWordsFilter().ignoreWord(text)) {
return;
}
collector.accept(problem);
}
public void beginCollecting() {
collector.beginCollecting();
}
public void endCollecting() {
collector.endCollecting();
}
};
}
};
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
示例9: getReconciler
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
return null;
}
SpellingService spellingService = EditorsUI.getSpellingService();
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
return null;
}
IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
@Override
protected ISpellingProblemCollector createSpellingProblemCollector() {
final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
return new ISpellingProblemCollector() {
public void accept(SpellingProblem problem) {
int offset = problem.getOffset();
int length = problem.getLength();
if (sourceViewer == null) {
return;
}
IDocument document = sourceViewer.getDocument();
if (document == null) {
return;
}
String text;
try {
text = document.get(offset, length);
} catch (BadLocationException e) {
return;
}
if (new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsIgnoredWordsFilter().ignoreWord(text)) {
return;
}
collector.accept(problem);
}
public void beginCollecting() {
collector.beginCollecting();
}
public void endCollecting() {
collector.endCollecting();
}
};
}
};
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
示例10: getReconciler
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
return null;
}
SpellingService spellingService = EditorsUI.getSpellingService();
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
return null;
}
IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
@Override
protected ISpellingProblemCollector createSpellingProblemCollector() {
final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
return new ISpellingProblemCollector() {
public void accept(SpellingProblem problem) {
int offset = problem.getOffset();
int length = problem.getLength();
if (sourceViewer == null) {
return;
}
IDocument document = sourceViewer.getDocument();
if (document == null) {
return;
}
String text;
try {
text = document.get(offset, length);
} catch (BadLocationException e) {
return;
}
if (new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestIgnoredWordsFilter().ignoreWord(text)) {
return;
}
collector.accept(problem);
}
public void beginCollecting() {
collector.beginCollecting();
}
public void endCollecting() {
collector.endCollecting();
}
};
}
};
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
示例11: run
import org.eclipse.jface.text.source.ISourceViewer; //导入方法依赖的package包/类
public void run(IAction action) {
if (targetEditor == null) return;
ISourceViewer sourceViewer= targetEditor.getViewer();
IDocument document= sourceViewer.getDocument();
if (document == null)
return;
ITextSelection selection = (ITextSelection) targetEditor.getSelectionProvider().getSelection();
SubStatusLineManager slm =
(SubStatusLineManager) targetEditor.getEditorSite().getActionBars().getStatusLineManager();
int selectionLength= Math.abs(selection.getLength());
if (selectionLength > 1) {
slm.setErrorMessage(TexlipsePlugin.getResourceString("gotoMatchingBracketNotSelected"));
slm.setVisible(true);
sourceViewer.getTextWidget().getDisplay().beep();
return;
}
int sourceCaretOffset= selection.getOffset() + selection.getLength();
TexPairMatcher fBracketMatcher = new TexPairMatcher("{}[]()");
IRegion region= fBracketMatcher.match(document, sourceCaretOffset);
if (region == null) {
slm.setErrorMessage(TexlipsePlugin.getResourceString("gotoMatchingBracketNotFound"));
slm.setVisible(true);
sourceViewer.getTextWidget().getDisplay().beep();
return;
}
int offset= region.getOffset();
int length= region.getLength();
if (length < 1) return;
int anchor = fBracketMatcher.getAnchor();
int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length;
if (selection.getLength() < 0)
targetOffset -= selection.getLength();
sourceViewer.setSelectedRange(targetOffset, selection.getLength());
sourceViewer.revealRange(targetOffset, selection.getLength());
}