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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*******************************************************************************
* Copyright (c) 2007, 2012 Wind River Systems, Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor.asm;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.reconciler.DirtyRegion;
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
/**
* Reconciling strategy for assembly translation units.
*
* @since 5.0
*/
public class AsmReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
private ITextEditor fEditor;
public AsmReconcilingStrategy(ITextEditor editor) {
fEditor= editor;
}
private IProgressMonitor fProgressMonitor;
/*
* @see IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
*/
@Override
public void reconcile(IRegion partition) {
reconcile(false);
}
/*
* @see IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
*/
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
// unused - non-incremental reconciler
}
/*
* @see IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
*/
@Override
public void setDocument(IDocument document) {
// no-op
}
/*
* @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
*/
@Override
public void setProgressMonitor(IProgressMonitor monitor) {
fProgressMonitor= monitor;
}
/*
* @see IReconcilingStrategyExtension#initialReconcile()
*/
@Override
public void initialReconcile() {
reconcile(true);
}
private void reconcile(final boolean initialReconcile) {
IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager();
IWorkingCopy workingCopy= fManager.getWorkingCopy(fEditor.getEditorInput());
if (workingCopy == null) {
return;
}
try {
// reconcile
synchronized (workingCopy) {
workingCopy.reconcile(false, true, fProgressMonitor);
}
} catch (OperationCanceledException oce) {
// document was modified while parsing
} catch (CModelException e) {
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e); //$NON-NLS-1$
CUIPlugin.log(status);
}
}
}
|