mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 338349 - CodanCReconciler does not find resources consistenly.
This commit is contained in:
parent
67cc996e49
commit
60b01f39f3
1 changed files with 18 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
|
@ -10,27 +10,21 @@
|
|||
*******************************************************************************/
|
||||
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,22 +62,19 @@ public class CodanCReconciler implements ICReconcilingListener {
|
|||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(org
|
||||
* .eclipse.cdt.core.dom.ast.IASTTranslationUnit, boolean,
|
||||
* @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];
|
||||
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)) {
|
||||
|
@ -93,4 +82,3 @@ public class CodanCReconciler implements ICReconcilingListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue