私はEclipse用の独自のPowerShellエディタープラグインを作成しています。現在、エディターには優れたコード強調表示があります。しかし、優れたアウトラインビューとフォーマットを作成できるようにするには、優れたドキュメントパーティションが必要です。そこで、現在2つのルールだけでパーティションスキャナー(RuleBasedPartitionScannerを拡張)を作成しました。
IToken psComment = new Token(PS_COMMENT);
IToken psFunction = new Token(PS_FUNCTION);
IPredicateRule[] rules = new IPredicateRule[2];
rules[0] = new EndOfLineRule("#", psComment);
rules[1] = new SingleLineRule("function", "{", psFunction);
setPredicateRules(rules);
FastPartitionerを使用して、必要なすべてのコンテンツタイプ(IDocument.DEFAULT_CONTENT_TYPE、PowershellPartitionScanner.PS_FUNCTION、PowershellPartitionScanner.PS_COMMENT)を使用してドキュメントで作成しました。
強調表示のために、スキャナーを作成しました(RuleBasedScannerを拡張します)。
構成クラスで、getPresentrationReconcilerをオーバーライドしました。
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(
new PowershellScanner());
reconciler.setDamager(dr, PowershellPartitionScanner.PS_FUNCTION);
reconciler.setRepairer(dr, PowershellPartitionScanner.PS_FUNCTION);
dr = new DefaultDamagerRepairer(new PowershellScanner());
reconciler.setDamager(dr, PowershellPartitionScanner.PS_COMMENT);
reconciler.setRepairer(dr, PowershellPartitionScanner.PS_COMMENT);
dr = new DefaultDamagerRepairer(new PowershellScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
return reconciler;
私は上書きしました:
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
PowershellPartitionScanner.PS_COMMENT,
PowershellPartitionScanner.PS_FUNCTION };
}
現在、ドキュメントは適切にパーティション化されています。ただし、コードの強調表示はありません。すべてが黒です。
ドキュメントを分割していない場合、強調表示は機能します。
私は何かが足りないのですか?
ありがとう