blob: 8ed94c1d0514eb32bc534be650f796d1d03b1355 (
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
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
|
/*******************************************************************************
* Copyright (c) 2009, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.ptp.internal.rdt.core.model;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.core.model.CElementDeltaBuilder;
import org.eclipse.cdt.internal.core.model.ReconcileWorkingCopyOperation;
import org.eclipse.cdt.internal.core.model.WorkingCopy;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ptp.rdt.core.resources.RemoteNature;
/**
* Reconcile a working copy and signal the changes through a delta.
* @author vkong
*
*/
public class RemoteReconcileWorkingCopyOperation extends ReconcileWorkingCopyOperation {
boolean forceProblemDetection;
boolean fComputeAST;
public RemoteModelWorkingCopy fRmWorkingCopy;
public RemoteReconcileWorkingCopyOperation(ICElement workingCopy,
boolean computeAST, boolean forceProblemDetection) {
super(workingCopy, computeAST, forceProblemDetection);
fComputeAST= computeAST;
this.forceProblemDetection = forceProblemDetection;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.model.ReconcileWorkingCopyOperation#executeOperation()
*/
@Override
protected void executeOperation() throws CModelException {
//if this was executed by a local project by mistake
if (!RemoteNature.hasRemoteNature(getWorkingCopy().getCProject().getProject())) {
super.executeOperation();
return;
}
if (fMonitor != null){
if (fMonitor.isCanceled())
throw new OperationCanceledException();
fMonitor.beginTask("element.reconciling", 10); //$NON-NLS-1$
}
WorkingCopy workingCopy = getWorkingCopy();
boolean wasConsistent = workingCopy.isConsistent();
CElementDeltaBuilder deltaBuilder = null;
try {
if (!wasConsistent || forceProblemDetection || fComputeAST) {
// create the delta builder (this remembers the current content of the tu)
deltaBuilder = new CElementDeltaBuilder(workingCopy);
// update the element infos with the content of the working copy
// it parses and produces an AST and create the model using the AST
RemoteModelWorkingCopy rmWorkingCopy = null;
if(workingCopy.getFile() == null)
rmWorkingCopy = new RemoteModelWorkingCopy(workingCopy, false);
else
rmWorkingCopy = new RemoteModelWorkingCopy(workingCopy);
rmWorkingCopy.makeConsistent(fMonitor,false);
fRmWorkingCopy = rmWorkingCopy;
if (deltaBuilder != null) {
deltaBuilder.buildDeltas();
// register the deltas
if (deltaBuilder.getDelta() != null) {
if (!wasConsistent || forceProblemDetection || deltaBuilder.getDelta().getAffectedChildren().length > 0) {
addReconcileDelta(workingCopy, deltaBuilder.getDelta());
}
}
}
}
if (fMonitor != null) fMonitor.worked(2);
} finally {
if (fMonitor != null) fMonitor.done();
}
}
}
|