Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 804d4f238969d5059747fdf80076d59d79b9d8f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package org.eclipse.cdt.internal.ui;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
 
import java.io.IOException;

import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;

import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.CoreException;

import org.eclipse.cdt.internal.core.model.TranslationUnit;

public class CFileElementWorkingCopy extends TranslationUnit {
	
	private IDocumentProvider fProvider;
	//private IFileEditorInput input;
	private IEditorInput input;
	
	/**
	 * Creates a working copy of this element
	 */
	public CFileElementWorkingCopy(IFileEditorInput fileInput, IDocumentProvider provider) throws CoreException {
		super(null, fileInput.getFile());
		input= fileInput;
		fProvider= provider;
	}

	/**
	 * Creates a working copy of this element
	 */
	public CFileElementWorkingCopy(IStorageEditorInput StoreInput, IDocumentProvider provider) throws CoreException {
		super(null, new Path(StoreInput.getName()));
		input = StoreInput;
		fProvider = provider;
		IStorage storage = StoreInput.getStorage();
		super.setLocation(storage.getFullPath());
	}

	/**
	 * @see CFileElement#update
	 */
	public void update() throws CoreException {
		IDocument doc= fProvider.getDocument(input);
		if (doc != null) {
			DocumentInputStream dis= new DocumentInputStream(doc);
			try {
				parse(dis);
			} finally {
				try { dis.close(); } catch (IOException e) {}
			}
		}
	}
}

Back to the top