エディタ作成までの最短道のり(パーティション編)

TextEditorを継承しクラスを作成

コンストラクタでsetSourceViewerConfigurationにSourceViewerConfigurationを継承したクラスを設定

SourceViewerConfigurationを継承しクラスを作成

以下をオーバーライド
  • getConfiguredContentTypes(ISourceViewer)

damagerとrepairerを使用するcontentTypeをすべて返す

  • getPresentationReconciler(ISourceViewer)
    • PresentationReconcilerのインスタンスにdamagerとrepairerをcontentType分だけ設定する
    • damager/repairerの生成にはDefaultDamagerRepairer(ITokenScanner)のインスタンスで十分

PresentationReconciler#setDamager(damager,contentType)--damagerの設定
PresentationReconciler#setRepairer(repairer,contentType)--repairerの設定

    • TokenScannerに属性を設定する

RuleBasedScanner#setDefaultReturnToken(new Token(new TextAttribute(Color)))

RuleBasedScannerを継承してScannerの作成

コンストラクタの作成
  • ITokenの生成

new Token(new TextAttribute(Color))

  • IRule[]の生成

SingleLineRule
EndOfLineRule
WordPatternRule
MultiLineRule
WhitespaceRule

  • ルールの設定

#setRules(IRule[])

TextEditorを継承しクラスを作成

コンストラクタでsetDocumentProviderにFileDocumentProviderを継承したクラスを設定

FileDocumentProviderを継承しクラスを作成

createDocument(Object)をオーバーライド
  • 親のcreateDocumentを呼びIDocumentを取得
  • IDocumentPartitionerの生成

new FastPartitioner(IPartitionTokenScanner, String[])

  • IDocumentPartitioner#connect(IDocument)で関連付ける
  • IDocument#setDocumentPartitioner(IDocumentPartitioner)で関連付ける

RuleBasedPartitionScannerを継承してIPartitionTokenScannerの実装

コンストラクタの作成
  • ITokenの生成

new Token(String);

  • IPredicateRule[]の生成

SingleLineRule
EndOfLineRule
WordPatternRule
MultiLineRule
WhitespaceRule

  • ルールの設定

#setPredicateRules(IPredicateRule[])

TODO

サンプルソースを追加