1

IFile または IPath から IDocument を取得することは可能ですか? 私はこれを試しました:

IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(hFilePath);
TextFileDocumentProvider provider = new TextFileDocumentProvider();
IDocument doc = provider.getDocument(file);

しかし、getDocument は null を返すようです。

ありがとう

4

3 に答える 3

0

次のようなことができます。

IFile file = (IFile) resource;
IPath filePath = file.getLocation();
filePath = FileBuffers.normalizeLocation(filePath);
IDocument document = FileBuffers.getTextFileBufferManager().getTextFileBuffer(filePath , LocationKind.NORMALIZE).getDocument();
于 2021-06-23T18:56:18.253 に答える