mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,27 +10,21 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.ui.cxx;
|
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.PreferenceConstants;
|
||||||
import org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler;
|
import org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler;
|
||||||
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
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.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
|
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.IProject;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Alena
|
* @author Alena
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CodanCReconciler implements ICReconcilingListener {
|
public class CodanCReconciler implements ICReconcilingListener {
|
||||||
private CxxCodanReconciler reconsiler = new CxxCodanReconciler();
|
private CxxCodanReconciler reconsiler = new CxxCodanReconciler();
|
||||||
|
@ -59,9 +53,7 @@ public class CodanCReconciler implements ICReconcilingListener {
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled()
|
||||||
* org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled
|
|
||||||
* ()
|
|
||||||
*/
|
*/
|
||||||
public void aboutToBeReconciled() {
|
public void aboutToBeReconciled() {
|
||||||
// nothing
|
// nothing
|
||||||
|
@ -70,27 +62,23 @@ public class CodanCReconciler implements ICReconcilingListener {
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(
|
||||||
* org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(org
|
* org.eclipse.cdt.core.dom.ast.IASTTranslationUnit, boolean,
|
||||||
* .eclipse.cdt.core.dom.ast.IASTTranslationUnit, boolean,
|
|
||||||
* org.eclipse.core.runtime.IProgressMonitor)
|
* org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
|
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
|
||||||
if (ast == null)
|
if (ast == null)
|
||||||
return;
|
return;
|
||||||
String filePath = ast.getFilePath();
|
ITranslationUnit tu = ast.getOriginatingTranslationUnit();
|
||||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
if (tu == null)
|
||||||
IWorkspaceRoot root = workspace.getRoot();
|
return;
|
||||||
IFile[] resources;
|
IResource resource = tu.getResource();
|
||||||
URI uri = new File(filePath).toURI();
|
if (resource == null)
|
||||||
resources = root.findFilesForLocationURI(uri);
|
return;
|
||||||
if (resources != null && resources.length > 0) {
|
|
||||||
IFile resource = resources[0];
|
|
||||||
IProject project = resource.getProject();
|
IProject project = resource.getProject();
|
||||||
IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(project);
|
IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(project);
|
||||||
if (store.getBoolean(PreferenceConstants.P_RUN_IN_EDITOR)) {
|
if (store.getBoolean(PreferenceConstants.P_RUN_IN_EDITOR)) {
|
||||||
reconsiler.reconciledAst(ast, resource, progressMonitor);
|
reconsiler.reconciledAst(ast, resource, progressMonitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue