2009-03-23 27 views
0

私はエディタにコンテンツアシストを追加しようとしています。Eclipse RCP - コンテンツアシストのトラブル

public class TagCompletionProcessor implements IContentAssistProcessor { 
private ITypedRegion wordRegion; 
private String currentWord; 
private SmartTreeSet tags; 
public TagCompletionProcessor() { 
    tags = new SmartTreeSet(); 
    //filling tags skipped 
} 
@Override 
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, 
     int offset) { 
    System.out.println("compute"); 
    wordRegion = viewer.getDocument().getDocumentPartitioner().getPartition(offset); 
    try { 
     int offs = wordRegion.getOffset(); 
     int len = wordRegion.getLength(); 
     currentWord = viewer.getDocument().get(offs, len); 
     return tags.getProposals(currentWord.toLowerCase(), offs, len); 
    } catch (BadLocationException e) { 
     return null; 
    } 
} 
@Override 
public IContextInformation[] computeContextInformation(ITextViewer viewer, 
     int offset) { 
    return null; 
} 
@Override 
public char[] getCompletionProposalAutoActivationCharacters() { 
    return new char[] {'<'}; 
} 
@Override 
public char[] getContextInformationAutoActivationCharacters() { 
    return null; 
} 
@Override 
public IContextInformationValidator getContextInformationValidator() { 
    return null; 
} 
@Override 
public String getErrorMessage() { 
    return "No tags found"; 
} 

}

を...しかし、それは働いていない:私は完了プロセッサクラスを作った後、エディタの設定に

public IContentAssistant getContentAssistant(ISourceViewer sv) { 
    ContentAssistant ca = new ContentAssistant(); 
    IContentAssistProcessor pr = new TagCompletionProcessor(); 
    ca.setContentAssistProcessor(pr, XMLPartitionScanner.XML_TAG); 
    ca.setContentAssistProcessor(pr, IDocument.DEFAULT_CONTENT_TYPE); 
    return ca; 
} 

を追加しました。 Initは正常ですが、自動アクティベーションは機能しません。また、ctrl-spaceを押すと(Bindingsのextポイントにorg.eclipse.ui.edit.text.contentAssist.proposalsコマンドを追加しました)空のリストが表示されますカーソルの近くではなく、一定の場所で)。私は間違って何をしていますか?

答えて

0

申し訳ありませんが、途中でいくつかのヌル出力がありました。何が失敗=(

0

ドキュメントはあなたのアシスタントのパーティションを設定するために持っているよりも、IDocumentExtension3を実装している場合...

ca.setDocumentPartitioning(MyPartitionScanner.MyPartitioning); 

・ホープ、このヘルプ

関連する問題