下面列出了怎么用org.eclipse.jface.text.reconciler.IReconciler的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getReconciler(org.eclipse.jface.text.source.ISourceViewer)
*/
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
return null;
if (!TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.ECLIPSE_BUILDIN_SPELLCHECKER))
return null;
//Set TeXlipse spelling Engine as default
PreferenceStore store = new PreferenceStore();
store.setValue(SpellingService.PREFERENCE_SPELLING_ENGINE,
"org.eclipse.texlipse.LaTeXSpellEngine");
store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED,
true);
SpellingService spellingService = new SpellingService(store);
if (spellingService.getActiveSpellingEngineDescriptor(store) == null)
return null;
IReconcilingStrategy strategy= new TeXSpellingReconcileStrategy(sourceViewer, spellingService);
MonoReconciler reconciler= new MonoReconciler(strategy, true);
reconciler.setDelay(500);
reconciler.setProgressMonitor(new NullProgressMonitor());
return reconciler;
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
if (!EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
return null;
IReconcilingStrategy strategy= new SpellingReconcileStrategy(sourceViewer, EditorsUI.getSpellingService()) {
@Override
protected IContentType getContentType() {
return PROPERTIES_CONTENT_TYPE;
}
};
MonoReconciler reconciler= new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
if (!EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
return null;
IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, EditorsUI.getSpellingService()) {
@Override
protected IContentType getContentType() {
return EditorConfigTextTools.EDITORCONFIG_CONTENT_TYPE;
}
};
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setDelay(500);
return reconciler;
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
return null;
}
SpellingService spellingService = EditorsUI.getSpellingService();
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
return null;
}
//Overridden (just) to return a PyReconciler!
IReconcilingStrategy strategy = new PyReconciler(sourceViewer, spellingService);
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setIsIncrementalReconciler(false);
reconciler.setProgressMonitor(new NullProgressMonitor());
reconciler.setDelay(500);
return reconciler;
}
protected ICompletionProposal[] computeQuickAssistProposals(int offset) {
XtextSourceViewer sourceViewer = getSourceViewer();
XtextReconciler reconciler = (XtextReconciler) sourceViewer.getAdapter(IReconciler.class);
IReconcilingStrategyExtension reconcilingStrategyExtension = (IReconcilingStrategyExtension) reconciler.getReconcilingStrategy("");
reconcilingStrategyExtension.initialReconcile();
QuickAssistAssistant quickAssistAssistant = (QuickAssistAssistant) sourceViewer.getQuickAssistAssistant();
IQuickAssistProcessor quickAssistProcessor = quickAssistAssistant.getQuickAssistProcessor();
ICompletionProposal[] quickAssistProposals = quickAssistProcessor
.computeQuickAssistProposals(new TextInvocationContext(sourceViewer, offset, -1));
return quickAssistProposals;
}
/**
* @since 2.7
*/
@Override
public void forceReconcile() {
IReconciler reconciler = Adapters.adapt(getInternalSourceViewer(), IReconciler.class);
if (reconciler instanceof XtextReconciler)
((XtextReconciler)reconciler).forceReconcile();
}
/**
* Supported adapter types are {@link IReconciler} and {@link IXtextDocument}.
*
* @since 2.3
*/
@Override
public <T> T getAdapter(Class<T> adapter) {
if (IReconciler.class.isAssignableFrom(adapter) && adapter.isInstance(fReconciler)) {
return adapter.cast(fReconciler);
}
if (IXtextDocument.class.equals(adapter)) {
return adapter.cast(getXtextDocument());
}
return Platform.getAdapterManager().getAdapter(this, adapter);
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
IReconciler reconciler = reconcilerProvider.get();
if (reconciler instanceof XtextReconciler && editor instanceof XtextEditor)
((XtextReconciler) reconciler).setEditor((XtextEditor) editor);
return reconciler;
}
/**
* {@inheritDoc}
*/
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
final ITextEditor editor = getEditor();
if (editor != null) {
ModulaCompositeReconcilingStrategy strategy = new ModulaCompositeReconcilingStrategy(sourceViewer, textEditor);
ModulaReconciler reconciler = new ModulaReconciler(textEditor, strategy);
reconciler.setIsAllowedToModifyDocument(false);
reconciler.setDelay(500);
// return super.getReconciler(sourceViewer);
return reconciler;
}
return null;
}
/**
*
*/
@Override
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
final TLAReconcilingStrategy strategy = new TLAReconcilingStrategy();
strategy.setEditor(editor);
if (sourceViewer instanceof ProjectionViewer) {
strategy.setProjectionViewer((ProjectionViewer)sourceViewer);
}
return new MonoReconciler(strategy, false);
}
private void internalDoSetInput(IEditorInput input) throws CoreException {
ISourceViewer sourceViewer = getSourceViewer();
TypeScriptSourceViewer TypeScriptSourceViewer = null;
if (sourceViewer instanceof TypeScriptSourceViewer)
TypeScriptSourceViewer = (TypeScriptSourceViewer) sourceViewer;
IPreferenceStore store = getPreferenceStore();
// if (TypeScriptSourceViewer != null && isFoldingEnabled() &&(store ==
// null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
// TypeScriptSourceViewer.prepareDelayedProjection();
super.doSetInput(input);
if (TypeScriptSourceViewer != null && TypeScriptSourceViewer.getReconciler() == null) {
IReconciler reconciler = getSourceViewerConfiguration().getReconciler(TypeScriptSourceViewer);
if (reconciler != null) {
reconciler.install(TypeScriptSourceViewer);
TypeScriptSourceViewer.setReconciler(reconciler);
}
}
// if (fEncodingSupport != null)
// fEncodingSupport.reset();
// setOutlinePageInput(fOutlinePage, input);
//
// if (isShowingOverrideIndicators())
// installOverrideIndicator(false);
}
public static void setAsReconciler(
StructuredTextViewerConfiguration configuration) throws Exception {
try {
IReconciler reconciler = createReconciler();
// Reflectively set the spelling service to our own
Field reconcilerField = StructuredTextViewerConfiguration.class.getDeclaredField("fReconciler");
reconcilerField.setAccessible(true);
reconcilerField.set(configuration, reconciler);
} catch (Throwable t) {
throw new Exception(t);
}
}
/**
* Creates and initializes the UI Binder-specific reconciler.
*/
private static IReconciler createReconciler() {
// Initialization mirrors StructuredTextViewerConfiguration.getReconciler.
// Difference: We do not have an ISourceViewer, but the
// ISourceViewer.getConfiguredDocumentPartitioning for structured text
// always returns the DEFAULT_STRUCTURED_PARTITIONING (the method is final
// and it is just a simple return of this value.)
UiBinderStructuredRegionProcessor reconciler = new UiBinderStructuredRegionProcessor();
reconciler.setDocumentPartitioning(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING);
return reconciler;
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
JavaReconciler reconciler = (JavaReconciler) super.getReconciler(sourceViewer);
if (reconciler != null) {
try {
JavaCompositeReconcilingStrategy strategy = (JavaCompositeReconcilingStrategy) reconciler.getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
IReconcilingStrategy[] strategies = strategy.getReconcilingStrategies();
IReconcilingStrategy[] newStrategies = new IReconcilingStrategy[strategies.length];
for (int i = 0; i < strategies.length; i++) {
if (strategies[i] instanceof JavaSpellingReconcileStrategy) {
// Replace the default Java reconcile strategy with our own, which
// will suppress spell checking within JSNI blocks
newStrategies[i] = new GWTJavaSpellingReconcileStrategy(
sourceViewer, getEditor());
} else {
newStrategies[i] = strategies[i];
}
}
strategy.setReconcilingStrategies(newStrategies);
} catch (Exception e) {
// We're being defensive to ensure that we always return a reconciler
GWTPluginLog.logError(e);
}
return reconciler;
}
return null;
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
JsonReconcilingStrategy strategy = new JsonReconcilingStrategy();
strategy.setEditor(editor);
MonoReconciler reconciler = new MonoReconciler(strategy, false);
return reconciler;
}
public IReconciler getReconciler(ISourceViewer sourceViewer) {
MonoReconciler reconciler = new MonoReconciler(strategy, false);
reconciler.setIsIncrementalReconciler(false);
reconciler.setProgressMonitor(new NullProgressMonitor());
reconciler.setDelay(200);
return reconciler;
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer)
{
if (fTextEditor != null && fTextEditor.isEditable())
{
IReconcilingStrategy reconcilingStrategy = new CommonReconcilingStrategy(fTextEditor);
if (EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
{
SpellingService spellingService = EditorsUI.getSpellingService();
Collection<String> spellingContentTypes = getSpellingContentTypes(sourceViewer);
if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) != null
&& !spellingContentTypes.isEmpty())
{
reconcilingStrategy = new CompositeReconcilingStrategy(reconcilingStrategy,
new MultiRegionSpellingReconcileStrategy(sourceViewer, spellingService,
getConfiguredDocumentPartitioning(sourceViewer), spellingContentTypes));
}
}
CommonReconciler reconciler = new CommonReconciler(reconcilingStrategy);
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
reconciler.setIsIncrementalReconciler(false);
reconciler.setIsAllowedToModifyDocument(false);
reconciler.setProgressMonitor(new NullProgressMonitor());
reconciler.setDelay(500);
return fReconciler = reconciler;
}
return null;
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
final ITextEditor editor= getEditor();
if (editor != null && editor.isEditable()) {
JavaCompositeReconcilingStrategy strategy= new JavaCompositeReconcilingStrategy(sourceViewer, editor, getConfiguredDocumentPartitioning(sourceViewer));
JavaReconciler reconciler= new JavaReconciler(editor, strategy, false);
reconciler.setIsAllowedToModifyDocument(false);
reconciler.setDelay(500);
return reconciler;
}
return null;
}
private void internalDoSetInput(IEditorInput input) throws CoreException {
ISourceViewer sourceViewer= getSourceViewer();
JavaSourceViewer javaSourceViewer= null;
if (sourceViewer instanceof JavaSourceViewer)
javaSourceViewer= (JavaSourceViewer)sourceViewer;
IPreferenceStore store= getPreferenceStore();
if (javaSourceViewer != null && isFoldingEnabled() &&(store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
javaSourceViewer.prepareDelayedProjection();
super.doSetInput(input);
if (javaSourceViewer != null && javaSourceViewer.getReconciler() == null) {
IReconciler reconciler= getSourceViewerConfiguration().getReconciler(javaSourceViewer);
if (reconciler != null) {
reconciler.install(javaSourceViewer);
javaSourceViewer.setReconciler(reconciler);
}
}
if (fEncodingSupport != null)
fEncodingSupport.reset();
setOutlinePageInput(fOutlinePage, input);
if (isShowingOverrideIndicators())
installOverrideIndicator(false);
}
public IReconciler getReconciler( ISourceViewer sourceViewer )
{
// Creates an instance of MonoReconciler with the specified strategy,
// and is not incremental.
return new MonoReconciler( new ScriptReconcilingStrategy( sourceViewer ),
false );
}
public Class<? extends IReconciler> bindIReconciler() {
return XtextReconciler.class;
}
@Override
public Class<? extends IReconciler> bindIReconciler() {
return GamlReconciler.class;
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
return null; // not used, disable the textual spellchecker too
}
public Class<? extends IReconciler> bindIReconciler() {
return NoSpellingReconciler.class;
}
/**
* Sets the given reconciler.
*
* @param reconciler
* the reconciler
*
*/
void setReconciler(IReconciler reconciler) {
fReconciler = reconciler;
}
/**
* Returns the reconciler.
*
* @return the reconciler or <code>null</code> if not set
*
*/
IReconciler getReconciler() {
return fReconciler;
}
/**
* Sets the given reconciler.
*
* @param reconciler the reconciler
* @since 3.0
*/
void setReconciler(IReconciler reconciler) {
fReconciler= reconciler;
}
/**
* Returns the reconciler.
*
* @return the reconciler or <code>null</code> if not set
* @since 3.0
*/
IReconciler getReconciler() {
return fReconciler;
}