Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-03-25 17:49:27 -0400
committerSergey Prigogin2011-03-25 17:49:27 -0400
commit60b01f39f336317e35e3df71837acde8388bfb07 (patch)
tree2df4aa23b9f868b2409c5a71e695c51ea2e7e26e /codan/org.eclipse.cdt.codan.ui.cxx
parent67cc996e494e5c82536287680c6811d1aa3db33c (diff)
downloadorg.eclipse.cdt-60b01f39f336317e35e3df71837acde8388bfb07.tar.gz
org.eclipse.cdt-60b01f39f336317e35e3df71837acde8388bfb07.tar.xz
org.eclipse.cdt-60b01f39f336317e35e3df71837acde8388bfb07.zip
Bug 338349 - CodanCReconciler does not find resources consistenly.
Diffstat (limited to 'codan/org.eclipse.cdt.codan.ui.cxx')
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java48
1 files changed, 18 insertions, 30 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java
index 3c44ab1981..687898f9c6 100644
--- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java
@@ -1,36 +1,30 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Alena Laskavaia
+ * Copyright (c) 2009, 2011 Alena Laskavaia
* 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:
- * Alena Laskavaia - initial API and implementation
+ * Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.cxx;
-import java.io.File;
-import java.net.URI;
-
import org.eclipse.cdt.codan.core.PreferenceConstants;
import org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler;
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.texteditor.ITextEditor;
/**
* @author Alena
- *
*/
public class CodanCReconciler implements ICReconcilingListener {
private CxxCodanReconciler reconsiler = new CxxCodanReconciler();
@@ -59,9 +53,7 @@ public class CodanCReconciler implements ICReconcilingListener {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled
- * ()
+ * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled()
*/
public void aboutToBeReconciled() {
// nothing
@@ -70,27 +62,23 @@ public class CodanCReconciler implements ICReconcilingListener {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(org
- * .eclipse.cdt.core.dom.ast.IASTTranslationUnit, boolean,
- * org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(
+ * org.eclipse.cdt.core.dom.ast.IASTTranslationUnit, boolean,
+ * org.eclipse.core.runtime.IProgressMonitor)
*/
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
if (ast == null)
return;
- String filePath = ast.getFilePath();
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceRoot root = workspace.getRoot();
- IFile[] resources;
- URI uri = new File(filePath).toURI();
- resources = root.findFilesForLocationURI(uri);
- if (resources != null && resources.length > 0) {
- IFile resource = resources[0];
- IProject project = resource.getProject();
- IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(project);
- if (store.getBoolean(PreferenceConstants.P_RUN_IN_EDITOR)) {
- reconsiler.reconciledAst(ast, resource, progressMonitor);
- }
+ ITranslationUnit tu = ast.getOriginatingTranslationUnit();
+ if (tu == null)
+ return;
+ IResource resource = tu.getResource();
+ if (resource == null)
+ return;
+ IProject project = resource.getProject();
+ IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(project);
+ if (store.getBoolean(PreferenceConstants.P_RUN_IN_EDITOR)) {
+ reconsiler.reconciledAst(ast, resource, progressMonitor);
}
}
}

Back to the top