mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
SCD profiles: integration with CPathEntry framework.
New PerFileDiscoveredPathContainer. Updating CPathEntries on profile change.
This commit is contained in:
parent
877ceeab4e
commit
0944b253a3
31 changed files with 1260 additions and 493 deletions
|
@ -129,7 +129,9 @@
|
||||||
id="GCCStandardMakePerProjectProfile"
|
id="GCCStandardMakePerProjectProfile"
|
||||||
name="%extensionGCCPerProjectProfile.name"
|
name="%extensionGCCPerProjectProfile.name"
|
||||||
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
||||||
<scannerInfoCollector class="org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector"/>
|
<scannerInfoCollector
|
||||||
|
class="org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector"
|
||||||
|
scope="project"/>
|
||||||
<buildOutputProvider>
|
<buildOutputProvider>
|
||||||
<open/>
|
<open/>
|
||||||
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerInfoConsoleParser"/>
|
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerInfoConsoleParser"/>
|
||||||
|
@ -146,7 +148,9 @@
|
||||||
id="GCCStandardMakePerFileProfile"
|
id="GCCStandardMakePerFileProfile"
|
||||||
name="%extensionGCCPerFileProfile.name"
|
name="%extensionGCCPerFileProfile.name"
|
||||||
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
||||||
<scannerInfoCollector class="org.eclipse.cdt.make.internal.core.scannerconfig2.PerFileSICollector"/>
|
<scannerInfoCollector
|
||||||
|
class="org.eclipse.cdt.make.internal.core.scannerconfig2.PerFileSICollector"
|
||||||
|
scope="file"/>
|
||||||
<buildOutputProvider>
|
<buildOutputProvider>
|
||||||
<open/>
|
<open/>
|
||||||
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileBOPConsoleParser"/>
|
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileBOPConsoleParser"/>
|
||||||
|
|
|
@ -65,6 +65,21 @@
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="scope" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
<simpleType>
|
||||||
|
<restriction base="string">
|
||||||
|
<enumeration value="project">
|
||||||
|
</enumeration>
|
||||||
|
<enumeration value="file">
|
||||||
|
</enumeration>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,11 @@ package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
public interface IDiscoveredPathManager {
|
public interface IDiscoveredPathManager {
|
||||||
|
|
||||||
|
@ -21,25 +23,75 @@ public interface IDiscoveredPathManager {
|
||||||
|
|
||||||
IProject getProject();
|
IProject getProject();
|
||||||
|
|
||||||
IPath[] getIncludePaths();
|
/**
|
||||||
|
* Get include paths for the whole project
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPath[] getIncludePaths();
|
||||||
|
/**
|
||||||
|
* Get defined symbols for the whole project
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Map getSymbols();
|
Map getSymbols();
|
||||||
|
|
||||||
void setIncludeMap(LinkedHashMap map);
|
/**
|
||||||
|
* Get include paths for the specific path (file)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPath[] getIncludePaths(IPath path);
|
||||||
|
/**
|
||||||
|
* Get defined symbols for the specific path (file)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map getSymbols(IPath path);
|
||||||
|
|
||||||
|
IDiscoveredScannerInfoSerializable getSerializable();
|
||||||
|
ScannerConfigScope getScope();
|
||||||
|
|
||||||
|
void setIncludeMap(LinkedHashMap map);
|
||||||
void setSymbolMap(LinkedHashMap map);
|
void setSymbolMap(LinkedHashMap map);
|
||||||
|
|
||||||
LinkedHashMap getIncludeMap();
|
LinkedHashMap getIncludeMap();
|
||||||
LinkedHashMap getSymbolMap();
|
LinkedHashMap getSymbolMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IDiscoveredInfoListener {
|
interface IDiscoveredScannerInfoSerializable {
|
||||||
|
/**
|
||||||
|
* Serialize discovered scanner info to an XML element
|
||||||
|
*
|
||||||
|
* @param root
|
||||||
|
*/
|
||||||
|
public void serialize(Element root);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserialize discovered scanner info from an XML element
|
||||||
|
*
|
||||||
|
* @param root
|
||||||
|
*/
|
||||||
|
public void deserialize(Element root);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an id of the collector
|
||||||
|
*/
|
||||||
|
public String getCollectorId();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IDiscoveredInfoListener {
|
||||||
|
|
||||||
void infoChanged(IDiscoveredPathInfo info);
|
void infoChanged(IDiscoveredPathInfo info);
|
||||||
void infoRemoved(IProject project);
|
void infoRemoved(IDiscoveredPathInfo info);
|
||||||
}
|
}
|
||||||
|
|
||||||
IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException;
|
IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException;
|
||||||
void removeDiscoveredInfo(IProject project);
|
void removeDiscoveredInfo(IProject project);
|
||||||
void updateDiscoveredInfo(IDiscoveredPathInfo info) throws CoreException;
|
void updateDiscoveredInfo(IDiscoveredPathInfo info) throws CoreException;
|
||||||
|
/**
|
||||||
|
* @param project
|
||||||
|
* @param profileScope
|
||||||
|
* @throws CModelException
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
void changeDiscoveredContainer(IProject project, ScannerConfigScope profileScope);
|
||||||
|
|
||||||
void addDiscoveredInfoListener(IDiscoveredInfoListener listener);
|
void addDiscoveredInfoListener(IDiscoveredInfoListener listener);
|
||||||
void removeDiscoveredInfoListener(IDiscoveredInfoListener listener);
|
void removeDiscoveredInfoListener(IDiscoveredInfoListener listener);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.core.scannerconfig;
|
package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -31,6 +32,15 @@ public interface IScannerInfoCollector2 extends IScannerInfoCollector {
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException;
|
public void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and return new IDiscoveredPathInfo that can hopefully serialize
|
||||||
|
* discovered scanner config to a file
|
||||||
|
*
|
||||||
|
* @return pathInfo
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public IDiscoveredPathInfo createPathInfoObject();
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Answers a map of collected defines that the the compiler uses by default.
|
// * Answers a map of collected defines that the the compiler uses by default.
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Profile scope enum
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public class ScannerConfigScope {
|
||||||
|
public static final ScannerConfigScope PROJECT_SCOPE = new ScannerConfigScope("project"); //$NON-NLS-1$
|
||||||
|
public static final ScannerConfigScope FILE_SCOPE = new ScannerConfigScope("file"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String scope;
|
||||||
|
private ScannerConfigScope(String scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public boolean equals(Object arg0) {
|
||||||
|
if (arg0 == null) return false;
|
||||||
|
if (arg0 == this) return true;
|
||||||
|
if (arg0 instanceof ScannerConfigScope) return scope.equals(((ScannerConfigScope)arg0).scope);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#hashCode()
|
||||||
|
*/
|
||||||
|
public int hashCode() {
|
||||||
|
return scope.hashCode();
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,4 +49,5 @@ ConsoleParser.Ambiguous_Filepath_Error_Message=CDT Path Discovery is unable to r
|
||||||
ConsoleParser.Working_Directory_Error_Message=CDT Path Discovery is unable to determine working directory of the build command
|
ConsoleParser.Working_Directory_Error_Message=CDT Path Discovery is unable to determine working directory of the build command
|
||||||
ConsoleParser.Nonexistent_Include_Path_Error_Message=CDT Path Discovery has discovered and will ignore a non-existent include path:
|
ConsoleParser.Nonexistent_Include_Path_Error_Message=CDT Path Discovery has discovered and will ignore a non-existent include path:
|
||||||
|
|
||||||
DiscoveredContainer.description=Discovered Paths
|
DiscoveredContainer.description=Discovered Paths
|
||||||
|
DiscoveredContainer.ScopeErrorMessage=Invalid scanner configuration discovery profile scope
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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 - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
|
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
public abstract class AbstractDiscoveredPathContainer implements IPathEntryContainer {
|
||||||
|
public static final IPath CONTAINER_ID = new Path("org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
protected final IProject fProject;
|
||||||
|
|
||||||
|
public AbstractDiscoveredPathContainer(IProject project) {
|
||||||
|
fProject = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPathEntry[] getPathEntries() {
|
||||||
|
IPathEntry[] fPathEntries;
|
||||||
|
try {
|
||||||
|
fPathEntries = getPathEntries(getPathEntryMap(), fProject);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
return new IPathEntry[0];
|
||||||
|
}
|
||||||
|
return fPathEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected Map getPathEntryMap();
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return MakeMessages.getString("DiscoveredContainer.description"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPath getPath() {
|
||||||
|
return CONTAINER_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IPathEntry[] getPathEntries(Map pathEntryMap, IProject project) throws CoreException {
|
||||||
|
IPathEntry[] entries = (IPathEntry[])pathEntryMap.get(project);
|
||||||
|
if (entries == null) {
|
||||||
|
entries = computeNewPathEntries(project);
|
||||||
|
pathEntryMap.put(project, entries);
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IPathEntry[] computeNewPathEntries(IProject project) throws CoreException {
|
||||||
|
IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
||||||
|
IPath[] includes = info.getIncludePaths();
|
||||||
|
Map syms = info.getSymbols();
|
||||||
|
List entries = new ArrayList(includes.length + syms.size());
|
||||||
|
for (int i = 0; i < includes.length; i++) {
|
||||||
|
entries.add(CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, includes[i])); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
Iterator iter = syms.entrySet().iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Entry entry = (Entry)iter.next();
|
||||||
|
entries.add(CoreModel.newMacroEntry(Path.EMPTY, (String)entry.getKey(), (String)entry.getValue())); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,92 +8,53 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
|
||||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredInfoListener;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredInfoListener;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
public class DiscoveredPathContainer implements IPathEntryContainer {
|
public class DiscoveredPathContainer extends AbstractDiscoveredPathContainer {
|
||||||
|
|
||||||
public static IPath CONTAINER_ID = new Path("org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
private final IProject fProject;
|
|
||||||
static Map fgPathEntries;
|
static Map fgPathEntries;
|
||||||
|
|
||||||
public DiscoveredPathContainer(IProject project) {
|
public DiscoveredPathContainer(IProject project) {
|
||||||
fProject = project;
|
super(project);
|
||||||
}
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
public static IPathEntry[] getPathEntries(IProject project) throws CoreException {
|
private static void initialize() {
|
||||||
if (fgPathEntries == null) {
|
if (fgPathEntries == null) {
|
||||||
fgPathEntries = new HashMap(10);
|
fgPathEntries = new HashMap(10);
|
||||||
IDiscoveredInfoListener listener = new IDiscoveredInfoListener() {
|
|
||||||
|
|
||||||
public void infoRemoved(IProject project) {
|
IDiscoveredInfoListener listener = new IDiscoveredInfoListener() {
|
||||||
fgPathEntries.remove(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void infoChanged(IDiscoveredPathInfo info) {
|
public void infoRemoved(IDiscoveredPathInfo info) {
|
||||||
fgPathEntries.remove(info.getProject());
|
if (info != null &&
|
||||||
}
|
ScannerConfigScope.PROJECT_SCOPE.equals(info.getScope())) {
|
||||||
};
|
fgPathEntries.remove(info.getProject());
|
||||||
MakeCorePlugin.getDefault().getDiscoveryManager().addDiscoveredInfoListener(listener);
|
}
|
||||||
}
|
}
|
||||||
IPathEntry[] entries = (IPathEntry[])fgPathEntries.get(project);
|
|
||||||
if (entries == null) {
|
|
||||||
entries = computeNewPathEntries(project);
|
|
||||||
fgPathEntries.put(project, entries);
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IPathEntry[] computeNewPathEntries(IProject project) throws CoreException {
|
public void infoChanged(IDiscoveredPathInfo info) {
|
||||||
IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
if (info != null &&
|
||||||
IPath[] includes = info.getIncludePaths();
|
ScannerConfigScope.PROJECT_SCOPE.equals(info.getScope())) {
|
||||||
Map syms = info.getSymbols();
|
fgPathEntries.remove(info.getProject());
|
||||||
List entries = new ArrayList(includes.length + syms.size());
|
}
|
||||||
for (int i = 0; i < includes.length; i++) {
|
}
|
||||||
entries.add(CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, includes[i])); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
Iterator iter = syms.entrySet().iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Entry entry = (Entry)iter.next();
|
|
||||||
entries.add(CoreModel.newMacroEntry(Path.EMPTY, (String)entry.getKey(), (String)entry.getValue())); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IPathEntry[] getPathEntries() {
|
};
|
||||||
IPathEntry[] fPathEntries;
|
MakeCorePlugin.getDefault().getDiscoveryManager().addDiscoveredInfoListener(listener);
|
||||||
try {
|
}
|
||||||
fPathEntries = getPathEntries(fProject);
|
}
|
||||||
} catch (CoreException e) {
|
|
||||||
MakeCorePlugin.log(e);
|
|
||||||
return new IPathEntry[0];
|
|
||||||
}
|
|
||||||
return fPathEntries;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
/* (non-Javadoc)
|
||||||
return MakeMessages.getString("DiscoveredContainer.description"); //$NON-NLS-1$
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig.AbstractDiscoveredPathContainer#getPathEntryMap()
|
||||||
}
|
*/
|
||||||
|
protected Map getPathEntryMap() {
|
||||||
public IPath getPath() {
|
return fgPathEntries;
|
||||||
return CONTAINER_ID;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,9 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -196,5 +197,39 @@ public class DiscoveredPathInfo implements IDiscoveredPathInfo, IDiscoveredScann
|
||||||
public String getCollectorId() {
|
public String getCollectorId() {
|
||||||
return PerProjectSICollector.COLLECTOR_ID;
|
return PerProjectSICollector.COLLECTOR_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath)
|
||||||
|
*/
|
||||||
|
public IPath[] getIncludePaths(IPath path) {
|
||||||
|
if (project.getFile(path) != null) {
|
||||||
|
return getIncludePaths();
|
||||||
|
}
|
||||||
|
return new IPath[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath)
|
||||||
|
*/
|
||||||
|
public Map getSymbols(IPath path) {
|
||||||
|
if (project.getFile(path) != null) {
|
||||||
|
return getSymbols();
|
||||||
|
}
|
||||||
|
return new HashMap(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable()
|
||||||
|
*/
|
||||||
|
public IDiscoveredScannerInfoSerializable getSerializable() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getScope()
|
||||||
|
*/
|
||||||
|
public ScannerConfigScope getScope() {
|
||||||
|
return ScannerConfigScope.PROJECT_SCOPE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,35 @@ package org.eclipse.cdt.make.internal.core.scannerconfig;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
|
import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
|
||||||
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
|
|
||||||
public class DiscoveredPathInitializer extends PathEntryContainerInitializer {
|
public class DiscoveredPathInitializer extends PathEntryContainerInitializer {
|
||||||
|
|
||||||
public void initialize(IPath containerPath, ICProject project) throws CoreException {
|
public void initialize(IPath containerPath, ICProject cProject) throws CoreException {
|
||||||
CoreModel.setPathEntryContainer(new ICProject[]{project}, new DiscoveredPathContainer(project.getProject()), null);
|
IProject project = cProject.getProject();
|
||||||
|
IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
|
||||||
|
ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
|
||||||
|
getSCProfileConfiguration(buildInfo.getSelectedProfileId()).getProfileScope();
|
||||||
|
if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
|
||||||
|
CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new DiscoveredPathContainer(project), null);
|
||||||
|
}
|
||||||
|
else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
|
||||||
|
CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new PerFileDiscoveredPathContainer(project), null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), 1,
|
||||||
|
MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,18 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable;
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||||
|
@ -33,6 +39,7 @@ import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
|
|
||||||
public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceChangeListener {
|
public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceChangeListener {
|
||||||
|
|
||||||
private Map fDiscoveredMap = new HashMap();
|
private Map fDiscoveredMap = new HashMap();
|
||||||
|
@ -62,7 +69,7 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
||||||
|
|
||||||
switch (event.getType()) {
|
switch (event.getType()) {
|
||||||
case IResourceChangeEvent.POST_CHANGE :
|
case IResourceChangeEvent.POST_CHANGE :
|
||||||
ScannerConfigUtil.updateScannerConfigStore(event.getDelta());
|
DiscoveredScannerInfoStore.getInstance().updateScannerConfigStore(event.getDelta());
|
||||||
break;
|
break;
|
||||||
case IResourceChangeEvent.PRE_DELETE :
|
case IResourceChangeEvent.PRE_DELETE :
|
||||||
case IResourceChangeEvent.PRE_CLOSE :
|
case IResourceChangeEvent.PRE_CLOSE :
|
||||||
|
@ -75,7 +82,7 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException {
|
public IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException {
|
||||||
DiscoveredPathInfo info = (DiscoveredPathInfo)fDiscoveredMap.get(project);
|
IDiscoveredPathInfo info = (IDiscoveredPathInfo)fDiscoveredMap.get(project);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
info = loadPathInfo(project);
|
info = loadPathInfo(project);
|
||||||
fDiscoveredMap.put(project, info);
|
fDiscoveredMap.put(project, info);
|
||||||
|
@ -83,15 +90,27 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscoveredPathInfo loadPathInfo(IProject project) throws CoreException {
|
private IDiscoveredPathInfo loadPathInfo(IProject project) throws CoreException {
|
||||||
DiscoveredPathInfo info = new DiscoveredPathInfo(project);
|
IDiscoveredPathInfo pathInfo = null;
|
||||||
DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, info);
|
|
||||||
return info;
|
IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
|
||||||
|
String profileId = buildInfo.getSelectedProfileId();
|
||||||
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
|
getSCProfileInstance(project, profileId);
|
||||||
|
IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
|
||||||
|
|
||||||
|
if (collector instanceof IScannerInfoCollector2) {
|
||||||
|
IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
|
||||||
|
pathInfo = collector2.createPathInfoObject();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pathInfo = new DiscoveredPathInfo(project);
|
||||||
|
}
|
||||||
|
return pathInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDiscoveredInfo(IProject project) {
|
public void removeDiscoveredInfo(IProject project) {
|
||||||
ScannerConfigUtil.getDiscoveredScannerConfigStore(project, true);
|
IDiscoveredPathInfo info = (IDiscoveredPathInfo)fDiscoveredMap.remove(project);
|
||||||
DiscoveredPathInfo info = (DiscoveredPathInfo)fDiscoveredMap.remove(project);
|
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
fireUpdate(INFO_REMOVED, info);
|
fireUpdate(INFO_REMOVED, info);
|
||||||
}
|
}
|
||||||
|
@ -99,15 +118,22 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
||||||
|
|
||||||
public void updateDiscoveredInfo(IDiscoveredPathInfo info) throws CoreException {
|
public void updateDiscoveredInfo(IDiscoveredPathInfo info) throws CoreException {
|
||||||
if (fDiscoveredMap.get(info.getProject()) != null) {
|
if (fDiscoveredMap.get(info.getProject()) != null) {
|
||||||
if (info instanceof IDiscoveredScannerInfoSerializable) {
|
IDiscoveredScannerInfoSerializable serializable = info.getSerializable();
|
||||||
IDiscoveredScannerInfoSerializable serializable = (IDiscoveredScannerInfoSerializable) info;
|
if (serializable != null) {
|
||||||
DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(info.getProject(), serializable);
|
IProject project = info.getProject();
|
||||||
|
DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, serializable);
|
||||||
fireUpdate(INFO_CHANGED, info);
|
fireUpdate(INFO_CHANGED, info);
|
||||||
ICProject cProject = CoreModel.getDefault().create(info.getProject());
|
|
||||||
if (cProject != null) {
|
// ICProject cProject = CoreModel.getDefault().create(info.getProject());
|
||||||
CoreModel.setPathEntryContainer(new ICProject[]{cProject},
|
// if (cProject != null) {
|
||||||
new DiscoveredPathContainer(info.getProject()), null);
|
// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
|
||||||
}
|
// new DiscoveredPathContainer(info.getProject()), null);
|
||||||
|
// }
|
||||||
|
IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
|
||||||
|
String profileId = buildInfo.getSelectedProfileId();
|
||||||
|
ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
|
||||||
|
getSCProfileConfiguration(profileId).getProfileScope();
|
||||||
|
changeDiscoveredContainer(project, profileScope);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
|
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
|
||||||
|
@ -116,6 +142,40 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#changeDiscoveredContainer(org.eclipse.core.resources.IProject, java.lang.String)
|
||||||
|
*/
|
||||||
|
public void changeDiscoveredContainer(IProject project, ScannerConfigScope profileScope) {
|
||||||
|
// order here is of essence
|
||||||
|
// 1. clear DiscoveredPathManager's path info cache
|
||||||
|
IDiscoveredPathInfo oldInfo = (IDiscoveredPathInfo) fDiscoveredMap.remove(project);
|
||||||
|
|
||||||
|
// 2. switch the containers
|
||||||
|
ICProject cProject = CoreModel.getDefault().create(project);
|
||||||
|
try {
|
||||||
|
if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
|
||||||
|
CoreModel.setPathEntryContainer(new ICProject[]{cProject},
|
||||||
|
new DiscoveredPathContainer(project), null);
|
||||||
|
}
|
||||||
|
else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
|
||||||
|
CoreModel.setPathEntryContainer(new ICProject[]{cProject},
|
||||||
|
new PerFileDiscoveredPathContainer(project), null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MakeCorePlugin.log(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), 1,
|
||||||
|
MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (CModelException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. clear the container's path entry cache
|
||||||
|
if (oldInfo != null) {
|
||||||
|
fireUpdate(INFO_REMOVED, oldInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void fireUpdate(final int type, final IDiscoveredPathInfo info) {
|
private void fireUpdate(final int type, final IDiscoveredPathInfo info) {
|
||||||
Object[] list = listeners.toArray();
|
Object[] list = listeners.toArray();
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
|
@ -135,7 +195,7 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
||||||
listener.infoChanged(info);
|
listener.infoChanged(info);
|
||||||
break;
|
break;
|
||||||
case INFO_REMOVED :
|
case INFO_REMOVED :
|
||||||
listener.infoRemoved(info.getProject());
|
listener.infoRemoved(info);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,5 +212,4 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -28,12 +29,17 @@ import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
|
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -48,28 +54,8 @@ import org.xml.sax.SAXException;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public class DiscoveredScannerInfoStore {
|
public class DiscoveredScannerInfoStore {
|
||||||
public interface IDiscoveredScannerInfoSerializable {
|
private static final QualifiedName dscFileNameProperty = new
|
||||||
/**
|
QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "discoveredScannerConfigFileName"); //$NON-NLS-1$
|
||||||
* Serialize discovered scanner info to an XML element
|
|
||||||
*
|
|
||||||
* @param root
|
|
||||||
*/
|
|
||||||
public void serialize(Element root);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize discovered scanner info from an XML element
|
|
||||||
*
|
|
||||||
* @param root
|
|
||||||
*/
|
|
||||||
public void deserialize(Element root);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return an id of the collector
|
|
||||||
*/
|
|
||||||
public String getCollectorId();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static final String CDESCRIPTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".discoveredScannerInfo"; //$NON-NLS-1$
|
private static final String CDESCRIPTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".discoveredScannerInfo"; //$NON-NLS-1$
|
||||||
public static final String SCD_STORE_VERSION = "scdStore"; //$NON-NLS-1$
|
public static final String SCD_STORE_VERSION = "scdStore"; //$NON-NLS-1$
|
||||||
public static final String SI_ELEM = "scannerInfo"; //$NON-NLS-1$
|
public static final String SI_ELEM = "scannerInfo"; //$NON-NLS-1$
|
||||||
|
@ -124,7 +110,7 @@ public class DiscoveredScannerInfoStore {
|
||||||
if (document == null) {
|
if (document == null) {
|
||||||
try {
|
try {
|
||||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
IPath path = ScannerConfigUtil.getDiscoveredScannerConfigStore(project, false);
|
IPath path = getDiscoveredScannerConfigStore(project);
|
||||||
if (path.toFile().exists()) {
|
if (path.toFile().exists()) {
|
||||||
// read form file
|
// read form file
|
||||||
FileInputStream file = new FileInputStream(path.toFile());
|
FileInputStream file = new FileInputStream(path.toFile());
|
||||||
|
@ -241,7 +227,7 @@ public class DiscoveredScannerInfoStore {
|
||||||
|
|
||||||
// Save the document
|
// Save the document
|
||||||
try {
|
try {
|
||||||
IPath path = ScannerConfigUtil.getDiscoveredScannerConfigStore(project, false);
|
IPath path = getDiscoveredScannerConfigStore(project);
|
||||||
FileOutputStream file = new FileOutputStream(path.toFile());
|
FileOutputStream file = new FileOutputStream(path.toFile());
|
||||||
file.write(stream.toByteArray());
|
file.write(stream.toByteArray());
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -263,4 +249,105 @@ public class DiscoveredScannerInfoStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IPath getDiscoveredScannerConfigStore(IProject project) {
|
||||||
|
String fileName = project.getName() + ".sc"; //$NON-NLS-1$
|
||||||
|
String storedFileName = null;
|
||||||
|
try {
|
||||||
|
storedFileName = project.getPersistentProperty(dscFileNameProperty);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e.getStatus());
|
||||||
|
}
|
||||||
|
if (storedFileName != null && !storedFileName.equals(fileName)) {
|
||||||
|
// try to move 2.x file name format to 3.x file name format
|
||||||
|
movePluginStateFile(storedFileName, fileName);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
project.setPersistentProperty(dscFileNameProperty, fileName);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
return MakeCorePlugin.getWorkingDirectory().append(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param delta
|
||||||
|
*/
|
||||||
|
public void updateScannerConfigStore(IResourceDelta delta) {
|
||||||
|
try {
|
||||||
|
delta.accept(new IResourceDeltaVisitor() {
|
||||||
|
|
||||||
|
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||||
|
IResource resource = delta.getResource();
|
||||||
|
if (resource instanceof IProject) {
|
||||||
|
IProject project = (IProject) resource;
|
||||||
|
int kind = delta.getKind();
|
||||||
|
switch (kind) {
|
||||||
|
case IResourceDelta.REMOVED:
|
||||||
|
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||||
|
// project renamed
|
||||||
|
IPath newPath = delta.getMovedToPath();
|
||||||
|
IProject newProject = delta.getResource().getWorkspace().
|
||||||
|
getRoot().getProject(newPath.toString());
|
||||||
|
scProjectRenamed(project, newProject);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// project deleted
|
||||||
|
scProjectDeleted(project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scProjectDeleted(IProject project) {
|
||||||
|
String scFileName = project.getName() + ".sc"; //$NON-NLS-1$
|
||||||
|
deletePluginStateFile(scFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param scFileName
|
||||||
|
*/
|
||||||
|
private void deletePluginStateFile(String scFileName) {
|
||||||
|
IPath path = MakeCorePlugin.getWorkingDirectory().append(scFileName);
|
||||||
|
File file = path.toFile();
|
||||||
|
if (file.exists()) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scProjectRenamed(IProject project, IProject newProject) {
|
||||||
|
String scOldFileName = project.getName() + ".sc"; //$NON-NLS-1$
|
||||||
|
String scNewFileName = newProject.getName() + ".sc"; //$NON-NLS-1$
|
||||||
|
movePluginStateFile(scOldFileName, scNewFileName);
|
||||||
|
try {
|
||||||
|
newProject.setPersistentProperty(dscFileNameProperty, scNewFileName);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param oldFileName
|
||||||
|
* @param newFileName
|
||||||
|
*/
|
||||||
|
private void movePluginStateFile(String oldFileName, String newFileName) {
|
||||||
|
IPath oldPath = MakeCorePlugin.getWorkingDirectory().append(oldFileName);
|
||||||
|
IPath newPath = MakeCorePlugin.getWorkingDirectory().append(newFileName);
|
||||||
|
File oldFile = oldPath.toFile();
|
||||||
|
File newFile = newPath.toFile();
|
||||||
|
if (oldFile.exists()) {
|
||||||
|
oldFile.renameTo(newFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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 - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||||
|
import org.eclipse.cdt.core.model.IMacroEntry;
|
||||||
|
import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredInfoListener;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
public class PerFileDiscoveredPathContainer extends AbstractDiscoveredPathContainer
|
||||||
|
implements IPathEntryContainerExtension {
|
||||||
|
private static final IIncludeEntry[] NO_INCLUDENTRIES = new IIncludeEntry[0];
|
||||||
|
private static final IMacroEntry[] NO_SYMBOLENTRIES = new IMacroEntry[0];
|
||||||
|
|
||||||
|
static Map fgPathEntries;
|
||||||
|
|
||||||
|
public PerFileDiscoveredPathContainer(IProject project) {
|
||||||
|
super(project);
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initialize() {
|
||||||
|
if (fgPathEntries == null) {
|
||||||
|
fgPathEntries = new HashMap(10);
|
||||||
|
|
||||||
|
IDiscoveredInfoListener listener = new IDiscoveredInfoListener() {
|
||||||
|
|
||||||
|
public void infoRemoved(IDiscoveredPathInfo info) {
|
||||||
|
if (info != null &&
|
||||||
|
ScannerConfigScope.FILE_SCOPE.equals(info.getScope())) {
|
||||||
|
fgPathEntries.remove(info.getProject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void infoChanged(IDiscoveredPathInfo info) {
|
||||||
|
if (info != null &&
|
||||||
|
ScannerConfigScope.FILE_SCOPE.equals(info.getScope())) {
|
||||||
|
fgPathEntries.remove(info.getProject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
MakeCorePlugin.getDefault().getDiscoveryManager().addDiscoveredInfoListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IPathEntryContainerExtension#getIncludeEntries(org.eclipse.core.runtime.IPath)
|
||||||
|
*/
|
||||||
|
public IIncludeEntry[] getIncludeEntries(IPath path) {
|
||||||
|
IDiscoveredPathInfo info;
|
||||||
|
try {
|
||||||
|
info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
|
||||||
|
IPath[] includes = info.getIncludePaths(path);
|
||||||
|
List entries = new ArrayList(includes.length);
|
||||||
|
for (int i = 0; i < includes.length; i++) {
|
||||||
|
entries.add(CoreModel.newIncludeEntry(path, Path.EMPTY, includes[i])); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
return (IIncludeEntry[])entries.toArray(new IIncludeEntry[entries.size()]);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
return NO_INCLUDENTRIES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.IPathEntryContainerExtension#getMacroEntries(org.eclipse.core.runtime.IPath)
|
||||||
|
*/
|
||||||
|
public IMacroEntry[] getMacroEntries(IPath path) {
|
||||||
|
IDiscoveredPathInfo info;
|
||||||
|
try {
|
||||||
|
info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
|
||||||
|
Map syms = info.getSymbols(path);
|
||||||
|
List entries = new ArrayList(syms.size());
|
||||||
|
for (Iterator iter = syms.entrySet().iterator(); iter.hasNext(); ) {
|
||||||
|
Entry entry = (Entry)iter.next();
|
||||||
|
entries.add(CoreModel.newMacroEntry(path, (String)entry.getKey(), (String)entry.getValue())); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return (IMacroEntry[])entries.toArray(new IMacroEntry[entries.size()]);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
return NO_SYMBOLENTRIES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig.AbstractDiscoveredPathContainer#getPathEntryMap()
|
||||||
|
*/
|
||||||
|
protected Map getPathEntryMap() {
|
||||||
|
return fgPathEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,6 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -19,15 +18,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
|
||||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class that handles some Scanner Config specifig collection conversions
|
* Utility class that handles some Scanner Config specifig collection conversions
|
||||||
|
@ -35,9 +27,6 @@ import org.eclipse.core.runtime.QualifiedName;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public final class ScannerConfigUtil {
|
public final class ScannerConfigUtil {
|
||||||
private static final QualifiedName dscFileNameProperty = new
|
|
||||||
QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "discoveredScannerConfigFileName"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds all new discovered symbols/values to the existing ones.
|
* Adds all new discovered symbols/values to the existing ones.
|
||||||
*
|
*
|
||||||
|
@ -298,108 +287,4 @@ public final class ScannerConfigUtil {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IPath getDiscoveredScannerConfigStore(IProject project, boolean delete) {
|
|
||||||
String fileName = project.getName() + ".sc"; //$NON-NLS-1$
|
|
||||||
String storedFileName = null;
|
|
||||||
try {
|
|
||||||
storedFileName = project.getPersistentProperty(dscFileNameProperty);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
MakeCorePlugin.log(e.getStatus());
|
|
||||||
}
|
|
||||||
if (storedFileName != null && !storedFileName.equals(fileName)) {
|
|
||||||
// try to move 2.x file name format to 3.x file name format
|
|
||||||
movePluginStateFile(storedFileName, fileName);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
project.setPersistentProperty(dscFileNameProperty, fileName);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
MakeCorePlugin.log(e.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (delete) {
|
|
||||||
deletePluginStateFile(fileName);
|
|
||||||
}
|
|
||||||
return MakeCorePlugin.getWorkingDirectory().append(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param delta
|
|
||||||
*/
|
|
||||||
public static void updateScannerConfigStore(IResourceDelta delta) {
|
|
||||||
try {
|
|
||||||
delta.accept(new IResourceDeltaVisitor() {
|
|
||||||
|
|
||||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
|
||||||
IResource resource = delta.getResource();
|
|
||||||
if (resource instanceof IProject) {
|
|
||||||
IProject project = (IProject) resource;
|
|
||||||
int kind = delta.getKind();
|
|
||||||
switch (kind) {
|
|
||||||
case IResourceDelta.REMOVED:
|
|
||||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
|
||||||
// project renamed
|
|
||||||
IPath newPath = delta.getMovedToPath();
|
|
||||||
IProject newProject = delta.getResource().getWorkspace().
|
|
||||||
getRoot().getProject(newPath.toString());
|
|
||||||
scProjectRenamed(project, newProject);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// project deleted
|
|
||||||
scProjectDeleted(project);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
MakeCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void scProjectDeleted(IProject project) {
|
|
||||||
String scFileName = project.getName() + ".sc"; //$NON-NLS-1$
|
|
||||||
deletePluginStateFile(scFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param scFileName
|
|
||||||
*/
|
|
||||||
private static void deletePluginStateFile(String scFileName) {
|
|
||||||
IPath path = MakeCorePlugin.getWorkingDirectory().append(scFileName);
|
|
||||||
File file = path.toFile();
|
|
||||||
if (file.exists()) {
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void scProjectRenamed(IProject project, IProject newProject) {
|
|
||||||
String scOldFileName = project.getName() + ".sc"; //$NON-NLS-1$
|
|
||||||
String scNewFileName = newProject.getName() + ".sc"; //$NON-NLS-1$
|
|
||||||
movePluginStateFile(scOldFileName, scNewFileName);
|
|
||||||
try {
|
|
||||||
newProject.setPersistentProperty(dscFileNameProperty, scNewFileName);
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
MakeCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param oldFileName
|
|
||||||
* @param newFileName
|
|
||||||
*/
|
|
||||||
private static void movePluginStateFile(String oldFileName, String newFileName) {
|
|
||||||
IPath oldPath = MakeCorePlugin.getWorkingDirectory().append(oldFileName);
|
|
||||||
IPath newPath = MakeCorePlugin.getWorkingDirectory().append(newFileName);
|
|
||||||
File oldFile = oldPath.toFile();
|
|
||||||
File newFile = newPath.toFile();
|
|
||||||
if (oldFile.exists()) {
|
|
||||||
oldFile.renameTo(newFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.KVPair;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.KVStringPair;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SCDOptionsEnum;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SCDOptionsEnum;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -93,10 +93,10 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void generateReport() {
|
void generateReport() {
|
||||||
TraceUtil.metricsTrace("Stats for directory ",
|
TraceUtil.metricsTrace("Stats for directory ", //$NON-NLS-1$
|
||||||
"Generic command: '", "' applicable for:",
|
"Generic command: '", "' applicable for:", //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
directoryCommandListMap);
|
directoryCommandListMap);
|
||||||
TraceUtil.summaryTrace("Discovery summary", workingDirsN, commandsN, filesN);
|
TraceUtil.summaryTrace("Discovery summary", workingDirsN, commandsN, filesN); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,8 +130,8 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
||||||
*/
|
*/
|
||||||
public CCommandDSC getNewCCommandDSC(String genericLine, boolean cppFileType) {
|
public CCommandDSC getNewCCommandDSC(String genericLine, boolean cppFileType) {
|
||||||
CCommandDSC command = new CCommandDSC(cppFileType);
|
CCommandDSC command = new CCommandDSC(cppFileType);
|
||||||
String[] tokens = genericLine.split("\\s+");
|
String[] tokens = genericLine.split("\\s+"); //$NON-NLS-1$
|
||||||
command.addSCOption(new KVPair(SCDOptionsEnum.COMMAND, tokens[0]));
|
command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[0]));
|
||||||
for (int i = 1; i < tokens.length; ++i) {
|
for (int i = 1; i < tokens.length; ++i) {
|
||||||
for (int j = SCDOptionsEnum.MIN; j <= SCDOptionsEnum.MAX; ++j) {
|
for (int j = SCDOptionsEnum.MIN; j <= SCDOptionsEnum.MAX; ++j) {
|
||||||
if (tokens[i].startsWith(SCDOptionsEnum.getSCDOptionsEnum(j).toString())) {
|
if (tokens[i].startsWith(SCDOptionsEnum.getSCDOptionsEnum(j).toString())) {
|
||||||
|
@ -144,7 +144,7 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
||||||
// ex. -I /dir
|
// ex. -I /dir
|
||||||
// take a next token
|
// take a next token
|
||||||
++i;
|
++i;
|
||||||
if (i < tokens.length && !tokens[i].startsWith("-")) {
|
if (i < tokens.length && !tokens[i].startsWith("-")) { //$NON-NLS-1$
|
||||||
option = tokens[i];
|
option = tokens[i];
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
|
@ -157,7 +157,7 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
||||||
option = (getAbsolutePath(option)).toString();
|
option = (getAbsolutePath(option)).toString();
|
||||||
}
|
}
|
||||||
// add the pair
|
// add the pair
|
||||||
command.addSCOption(new KVPair(SCDOptionsEnum.getSCDOptionsEnum(j), option));
|
command.addSCOption(new KVStringPair(SCDOptionsEnum.getSCDOptionsEnum(j).toString(), option));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,8 +171,8 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
||||||
*/
|
*/
|
||||||
IPath getAbsolutePath(String filePath) {
|
IPath getAbsolutePath(String filePath) {
|
||||||
IPath pFilePath;
|
IPath pFilePath;
|
||||||
if (filePath.startsWith("/") || filePath.startsWith("\\") ||
|
if (filePath.startsWith("/") || filePath.startsWith("\\") || //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
(!filePath.startsWith(".") &&
|
(!filePath.startsWith(".") && //$NON-NLS-1$
|
||||||
filePath.length() > 2 && filePath.charAt(1) == ':' &&
|
filePath.length() > 2 && filePath.charAt(1) == ':' &&
|
||||||
(filePath.charAt(2) == '\\' || filePath.charAt(2) == '/'))) {
|
(filePath.charAt(2) == '\\' || filePath.charAt(2) == '/'))) {
|
||||||
// absolute path
|
// absolute path
|
||||||
|
|
|
@ -25,9 +25,16 @@ import org.w3c.dom.NodeList;
|
||||||
*/
|
*/
|
||||||
public class CCommandDSC {
|
public class CCommandDSC {
|
||||||
private final static String SINGLE_SPACE = " "; //$NON-NLS-1$
|
private final static String SINGLE_SPACE = " "; //$NON-NLS-1$
|
||||||
|
private final static String CMD_DESCRIPTION_ELEM = "commandDescription"; //$NON-NLS-1$
|
||||||
|
private final static String CMD_SI_ELEM = "commandScannerInfo"; //$NON-NLS-1$
|
||||||
|
private final static String OPTION_ELEM = "option"; //$NON-NLS-1$
|
||||||
|
private final static String SI_ITEM_ELEM = "siItem"; //$NON-NLS-1$
|
||||||
|
private final static String KEY_ATTR = "key"; //$NON-NLS-1$
|
||||||
|
private final static String VALUE_ATTR = "value"; //$NON-NLS-1$
|
||||||
|
private final static String KIND_ATTR = "kind"; //$NON-NLS-1$
|
||||||
|
|
||||||
private int commandId;
|
private int commandId;
|
||||||
private List compilerCommand; // members are KVPair objects
|
private List compilerCommand; // members are KVStringPair objects
|
||||||
private boolean discovered;
|
private boolean discovered;
|
||||||
private boolean cppFileType; // C or C++ file type
|
private boolean cppFileType; // C or C++ file type
|
||||||
|
|
||||||
|
@ -40,7 +47,6 @@ public class CCommandDSC {
|
||||||
public CCommandDSC(boolean cppFileType) {
|
public CCommandDSC(boolean cppFileType) {
|
||||||
compilerCommand = new ArrayList();
|
compilerCommand = new ArrayList();
|
||||||
discovered = false;
|
discovered = false;
|
||||||
// files = null;
|
|
||||||
this.cppFileType = cppFileType;
|
this.cppFileType = cppFileType;
|
||||||
|
|
||||||
symbols = new ArrayList();
|
symbols = new ArrayList();
|
||||||
|
@ -51,7 +57,7 @@ public class CCommandDSC {
|
||||||
return cppFileType;
|
return cppFileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSCOption(KVPair option) {
|
public void addSCOption(KVStringPair option) {
|
||||||
compilerCommand.add(option);
|
compilerCommand.add(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,28 +80,11 @@ public class CCommandDSC {
|
||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void addFile(String fileName) {
|
|
||||||
// if (files == null) {
|
|
||||||
// files = new ArrayList();
|
|
||||||
// }
|
|
||||||
// if (!files.contains(fileName)) {
|
|
||||||
// files.add(fileName);
|
|
||||||
// if (!cppFileType && !fileName.endsWith(".c")) { //$NON-NLS-1$
|
|
||||||
// cppFileType = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public int getNumberOfFiles() {
|
|
||||||
// if (files == null) return 0;
|
|
||||||
// return files.size();
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String commandAsString = new String();
|
String commandAsString = new String();
|
||||||
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
||||||
KVPair optionPair = (KVPair)i.next();
|
KVStringPair optionPair = (KVStringPair)i.next();
|
||||||
commandAsString += optionPair.getKey().toString() + SINGLE_SPACE +
|
commandAsString += optionPair.getKey() + SINGLE_SPACE +
|
||||||
optionPair.getValue() + SINGLE_SPACE;
|
optionPair.getValue() + SINGLE_SPACE;
|
||||||
}
|
}
|
||||||
return commandAsString.trim();
|
return commandAsString.trim();
|
||||||
|
@ -112,15 +101,15 @@ public class CCommandDSC {
|
||||||
public String getSCDRunnableCommand() {
|
public String getSCDRunnableCommand() {
|
||||||
String commandAsString = new String();
|
String commandAsString = new String();
|
||||||
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
||||||
KVPair optionPair = (KVPair)i.next();
|
KVStringPair optionPair = (KVStringPair)i.next();
|
||||||
if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND)) {
|
if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) {
|
||||||
commandAsString += optionPair.getValue() + SINGLE_SPACE;
|
commandAsString += optionPair.getValue() + SINGLE_SPACE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE) ||
|
// if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) ||
|
||||||
// optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE))
|
// optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString()))
|
||||||
// continue;
|
// continue;
|
||||||
commandAsString += optionPair.getKey().toString() + SINGLE_SPACE +
|
commandAsString += optionPair.getKey() + SINGLE_SPACE +
|
||||||
optionPair.getValue() + SINGLE_SPACE;
|
optionPair.getValue() + SINGLE_SPACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,8 +119,8 @@ public class CCommandDSC {
|
||||||
public String[] getImacrosFile() {
|
public String[] getImacrosFile() {
|
||||||
List imacrosFiles = new ArrayList();
|
List imacrosFiles = new ArrayList();
|
||||||
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
||||||
KVPair optionPair = (KVPair)i.next();
|
KVStringPair optionPair = (KVStringPair)i.next();
|
||||||
if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE)) {
|
if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString())) {
|
||||||
imacrosFiles.add(optionPair.getValue());
|
imacrosFiles.add(optionPair.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,8 +130,8 @@ public class CCommandDSC {
|
||||||
public String[] getIncludeFile() {
|
public String[] getIncludeFile() {
|
||||||
List includeFiles = new ArrayList();
|
List includeFiles = new ArrayList();
|
||||||
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
||||||
KVPair optionPair = (KVPair)i.next();
|
KVStringPair optionPair = (KVStringPair)i.next();
|
||||||
if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE)) {
|
if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) {
|
||||||
includeFiles.add(optionPair.getValue());
|
includeFiles.add(optionPair.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,27 +203,27 @@ public class CCommandDSC {
|
||||||
public void serialize(Element cmdElem) {
|
public void serialize(Element cmdElem) {
|
||||||
Document doc = cmdElem.getOwnerDocument();
|
Document doc = cmdElem.getOwnerDocument();
|
||||||
// serialize the command
|
// serialize the command
|
||||||
Element cmdDescElem = doc.createElement("commandDescription"); //$NON-NLS-1$
|
Element cmdDescElem = doc.createElement(CMD_DESCRIPTION_ELEM);
|
||||||
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
|
||||||
Element optionElem = doc.createElement("option"); //$NON-NLS-1$
|
Element optionElem = doc.createElement(OPTION_ELEM);
|
||||||
KVPair option = (KVPair) i.next();
|
KVStringPair option = (KVStringPair) i.next();
|
||||||
optionElem.setAttribute("key", option.getKey().toString()); //$NON-NLS-1$
|
optionElem.setAttribute(KEY_ATTR, option.getKey());
|
||||||
optionElem.setAttribute("value", option.getValue()); //$NON-NLS-1$
|
optionElem.setAttribute(VALUE_ATTR, option.getValue());
|
||||||
cmdDescElem.appendChild(optionElem);
|
cmdDescElem.appendChild(optionElem);
|
||||||
}
|
}
|
||||||
cmdElem.appendChild(cmdDescElem);
|
cmdElem.appendChild(cmdDescElem);
|
||||||
// serialize includes and symbols
|
// serialize includes and symbols
|
||||||
Element siElem = doc.createElement("commandScannerInfo"); //$NON-NLS-1$
|
Element siElem = doc.createElement(CMD_SI_ELEM);
|
||||||
for (Iterator j = includes.iterator(); j.hasNext(); ) {
|
for (Iterator j = includes.iterator(); j.hasNext(); ) {
|
||||||
Element siItem = doc.createElement("siItem"); //$NON-NLS-1$
|
Element siItem = doc.createElement(SI_ITEM_ELEM);
|
||||||
siItem.setAttribute("kind", "INCLUDE_PATH"); //$NON-NLS-1$ //$NON-NLS-2$
|
siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$
|
||||||
siItem.setAttribute("value", (String) j.next()); //$NON-NLS-1$
|
siItem.setAttribute(VALUE_ATTR, (String) j.next());
|
||||||
siElem.appendChild(siItem);
|
siElem.appendChild(siItem);
|
||||||
}
|
}
|
||||||
for (Iterator j = symbols.iterator(); j.hasNext(); ) {
|
for (Iterator j = symbols.iterator(); j.hasNext(); ) {
|
||||||
Element siItem = doc.createElement("siItem"); //$NON-NLS-1$
|
Element siItem = doc.createElement(SI_ITEM_ELEM);
|
||||||
siItem.setAttribute("kind", "SYMBOL_DEFINITION"); //$NON-NLS-1$ //$NON-NLS-2$
|
siItem.setAttribute(KIND_ATTR, "SYMBOL_DEFINITION"); //$NON-NLS-1$
|
||||||
siItem.setAttribute("value", (String) j.next()); //$NON-NLS-1$
|
siItem.setAttribute(VALUE_ATTR, (String) j.next());
|
||||||
siElem.appendChild(siItem);
|
siElem.appendChild(siItem);
|
||||||
}
|
}
|
||||||
cmdElem.appendChild(siElem);
|
cmdElem.appendChild(siElem);
|
||||||
|
@ -245,32 +234,31 @@ public class CCommandDSC {
|
||||||
*/
|
*/
|
||||||
public void deserialize(Element cmdElem) {
|
public void deserialize(Element cmdElem) {
|
||||||
// read command options
|
// read command options
|
||||||
NodeList descList = cmdElem.getElementsByTagName("commandDescription");
|
NodeList descList = cmdElem.getElementsByTagName(CMD_DESCRIPTION_ELEM);
|
||||||
if (descList.getLength() > 0) {
|
if (descList.getLength() > 0) {
|
||||||
Element descElem = (Element) descList.item(0);
|
Element descElem = (Element) descList.item(0);
|
||||||
NodeList optionList = descElem.getElementsByTagName("option");
|
NodeList optionList = descElem.getElementsByTagName(OPTION_ELEM);
|
||||||
for (int i = 0; i < optionList.getLength(); ++i) {
|
for (int i = 0; i < optionList.getLength(); ++i) {
|
||||||
Element optionElem = (Element) optionList.item(i);
|
Element optionElem = (Element) optionList.item(i);
|
||||||
String key = optionElem.getAttribute("key");
|
String key = optionElem.getAttribute(KEY_ATTR);
|
||||||
SCDOptionsEnum eKey = SCDOptionsEnum.getSCDOptionsEnum(key);
|
String value = optionElem.getAttribute(VALUE_ATTR);
|
||||||
String value = optionElem.getAttribute("value");
|
KVStringPair option = new KVStringPair(key, value);
|
||||||
KVPair option = new KVPair(eKey, value);
|
|
||||||
addSCOption(option);
|
addSCOption(option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// read associated scanner info
|
// read associated scanner info
|
||||||
NodeList siList = cmdElem.getElementsByTagName("commandScannerInfo");
|
NodeList siList = cmdElem.getElementsByTagName(CMD_SI_ELEM);
|
||||||
if (siList.getLength() > 0) {
|
if (siList.getLength() > 0) {
|
||||||
Element siElem = (Element) siList.item(0);
|
Element siElem = (Element) siList.item(0);
|
||||||
NodeList siItemList = siElem.getElementsByTagName("siItem");
|
NodeList siItemList = siElem.getElementsByTagName(SI_ITEM_ELEM);
|
||||||
for (int i = 0; i < siItemList.getLength(); ++i) {
|
for (int i = 0; i < siItemList.getLength(); ++i) {
|
||||||
Element siItemElem = (Element) siItemList.item(i);
|
Element siItemElem = (Element) siItemList.item(i);
|
||||||
String kind = siItemElem.getAttribute("kind");
|
String kind = siItemElem.getAttribute(KIND_ATTR);
|
||||||
String value = siItemElem.getAttribute("value");
|
String value = siItemElem.getAttribute(VALUE_ATTR);
|
||||||
if (kind.equals("INCLUDE_PATH")) {
|
if (kind.equals("INCLUDE_PATH")) { //$NON-NLS-1$
|
||||||
includes.add(value);
|
includes.add(value);
|
||||||
}
|
}
|
||||||
else if (kind.equals("SYMBOL_DEFINITION")) {
|
else if (kind.equals("SYMBOL_DEFINITION")) { //$NON-NLS-1$
|
||||||
symbols.add(value);
|
symbols.add(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,12 @@ import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CommandLauncher;
|
import org.eclipse.cdt.core.CommandLauncher;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.ISafeRunnable;
|
import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
@ -31,15 +32,29 @@ import org.eclipse.core.runtime.Platform;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public class CygpathTranslator {
|
public class CygpathTranslator {
|
||||||
IProject project;
|
private IPath cwd;
|
||||||
String orgPath;
|
private String orgPath;
|
||||||
String transPath;
|
private String transPath;
|
||||||
|
private boolean status;
|
||||||
|
|
||||||
|
|
||||||
public CygpathTranslator(IProject project, String path) {
|
public CygpathTranslator(String path) {
|
||||||
this.project = project;
|
this(MakeCorePlugin.getDefault().getStateLocation(), path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CygpathTranslator(IPath cwd, String path) {
|
||||||
|
this.cwd = cwd;
|
||||||
orgPath = path;
|
orgPath = path;
|
||||||
|
status = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the status.
|
||||||
|
*/
|
||||||
|
public boolean isStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
public String run() {
|
public String run() {
|
||||||
ISafeRunnable runnable = new ISafeRunnable() {
|
ISafeRunnable runnable = new ISafeRunnable() {
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
|
@ -71,7 +86,7 @@ public class CygpathTranslator {
|
||||||
new Path("cygpath"), //$NON-NLS-1$
|
new Path("cygpath"), //$NON-NLS-1$
|
||||||
new String[] {"-m", orgPath}, //$NON-NLS-1$
|
new String[] {"-m", orgPath}, //$NON-NLS-1$
|
||||||
new String[0],//setEnvironment(launcher, "c:/"),//$NON-NLS-1$
|
new String[0],//setEnvironment(launcher, "c:/"),//$NON-NLS-1$
|
||||||
project.getLocation()); //$NON-NLS-1$
|
cwd); //$NON-NLS-1$
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
try {
|
try {
|
||||||
// Close the input of the Process explicitely.
|
// Close the input of the Process explicitely.
|
||||||
|
@ -82,8 +97,10 @@ public class CygpathTranslator {
|
||||||
}
|
}
|
||||||
if (launcher.waitAndRead(output, output) != CommandLauncher.OK) {
|
if (launcher.waitAndRead(output, output) != CommandLauncher.OK) {
|
||||||
//String errMsg = launcher.getErrorMessage();
|
//String errMsg = launcher.getErrorMessage();
|
||||||
|
status = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
status = true;
|
||||||
return output.toString().trim();
|
return output.toString().trim();
|
||||||
}
|
}
|
||||||
return orgPath;
|
return orgPath;
|
||||||
|
@ -111,4 +128,52 @@ public class CygpathTranslator {
|
||||||
}
|
}
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sumIncludes
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List translateIncludePaths(List sumIncludes) {
|
||||||
|
CygpathTranslator test = new CygpathTranslator("/"); //$NON-NLS-1$
|
||||||
|
test.run();
|
||||||
|
if (!test.isStatus()) return sumIncludes;
|
||||||
|
|
||||||
|
List translatedIncludePaths = new ArrayList();
|
||||||
|
for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||||
|
String includePath = (String) i.next();
|
||||||
|
IPath realPath = new Path(includePath);
|
||||||
|
if (!realPath.toFile().exists()) {
|
||||||
|
String translatedPath = includePath;
|
||||||
|
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||||
|
translatedPath = (new CygpathTranslator(includePath)).run();
|
||||||
|
}
|
||||||
|
if (translatedPath != null) {
|
||||||
|
if (!translatedPath.equals(includePath)) {
|
||||||
|
// Check if the translated path exists
|
||||||
|
IPath transPath = new Path(translatedPath);
|
||||||
|
if (transPath.toFile().exists()) {
|
||||||
|
translatedIncludePaths.add(translatedPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO VMIR for now add even if it does not exist
|
||||||
|
translatedIncludePaths.add(translatedPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO VMIR for now add even if it does not exist
|
||||||
|
translatedIncludePaths.add(translatedPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TraceUtil.outputError("CygpathTranslator unable to translate path: ",//$NON-NLS-1$
|
||||||
|
includePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
translatedIncludePaths.add(includePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return translatedIncludePaths;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,23 +11,23 @@
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig.util;
|
package org.eclipse.cdt.make.internal.core.scannerconfig.util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key - Value Pair
|
* Key - Value String Pair
|
||||||
*
|
*
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public class KVPair {
|
public class KVStringPair {
|
||||||
private SCDOptionsEnum key;
|
private String key;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public KVPair(SCDOptionsEnum key, String value) {
|
public KVStringPair(String key, String value) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SCDOptionsEnum getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class KVPair {
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object arg0) {
|
public boolean equals(Object arg0) {
|
||||||
if (arg0 != null && arg0.getClass().equals(this.getClass())) {
|
if (arg0 != null && arg0.getClass().equals(this.getClass())) {
|
||||||
KVPair arg = (KVPair) arg0;
|
KVStringPair arg = (KVStringPair) arg0;
|
||||||
return (key.equals(arg.getKey()) && value.equals(arg.getValue()));
|
return (key.equals(arg.getKey()) && value.equals(arg.getValue()));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -54,6 +54,6 @@ public class KVPair {
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return key + " -> " + value;
|
return key + " -> " + value; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,16 +21,20 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -39,6 +43,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
@ -49,9 +54,90 @@ import org.w3c.dom.NodeList;
|
||||||
*
|
*
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoCollectorCleaner,
|
public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoCollectorCleaner {
|
||||||
IDiscoveredScannerInfoSerializable {
|
public class ScannerInfoData implements IDiscoveredScannerInfoSerializable {
|
||||||
public static final String COLLECTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".PerFileSICollector"; //$NON-NLS-1$
|
private Map commandIdToFilesMap; // command id and set of files it applies to
|
||||||
|
private Map fileToCommandIdMap; // maps each file to the corresponding command id
|
||||||
|
private Map commandIdCommandMap; // map of all commands
|
||||||
|
|
||||||
|
public ScannerInfoData() {
|
||||||
|
commandIdCommandMap = new LinkedHashMap(); // [commandId, command]
|
||||||
|
fileToCommandIdMap = new HashMap(); // [file, commandId]
|
||||||
|
commandIdToFilesMap = new HashMap(); // [commandId, set of files]
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element)
|
||||||
|
*/
|
||||||
|
public void serialize(Element collectorElem) {
|
||||||
|
Document doc = collectorElem.getOwnerDocument();
|
||||||
|
|
||||||
|
List commandIds = new ArrayList(commandIdCommandMap.keySet());
|
||||||
|
Collections.sort(commandIds);
|
||||||
|
for (Iterator i = commandIds.iterator(); i.hasNext(); ) {
|
||||||
|
Integer commandId = (Integer) i.next();
|
||||||
|
CCommandDSC command = (CCommandDSC) commandIdCommandMap.get(commandId);
|
||||||
|
|
||||||
|
Element cmdElem = doc.createElement(CC_ELEM); //$NON-NLS-1$
|
||||||
|
collectorElem.appendChild(cmdElem);
|
||||||
|
cmdElem.setAttribute(ID_ATTR, commandId.toString()); //$NON-NLS-1$
|
||||||
|
cmdElem.setAttribute(FILE_TYPE_ATTR, command.appliesToCPPFileType() ? "c++" : "c"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
// write command and scanner info
|
||||||
|
command.serialize(cmdElem);
|
||||||
|
// write files command applies to
|
||||||
|
Element filesElem = doc.createElement(APPLIES_TO_ATTR); //$NON-NLS-1$
|
||||||
|
cmdElem.appendChild(filesElem);
|
||||||
|
Set files = (Set) commandIdToFilesMap.get(commandId);
|
||||||
|
if (files != null) {
|
||||||
|
for (Iterator j = files.iterator(); j.hasNext(); ) {
|
||||||
|
Element fileElem = doc.createElement(FILE_ELEM); //$NON-NLS-1$
|
||||||
|
IFile file = (IFile) j.next();
|
||||||
|
IPath path = file.getProjectRelativePath();
|
||||||
|
fileElem.setAttribute(PATH_ATTR, path.toString()); //$NON-NLS-1$
|
||||||
|
filesElem.appendChild(fileElem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
|
||||||
|
*/
|
||||||
|
public void deserialize(Element collectorElem) {
|
||||||
|
for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||||
|
if (child.getNodeName().equals(CC_ELEM)) { //$NON-NLS-1$
|
||||||
|
Element cmdElem = (Element) child;
|
||||||
|
boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++"); //$NON-NLS-1$
|
||||||
|
CCommandDSC command = new CCommandDSC(cppFileType);
|
||||||
|
command.setCommandId(Integer.parseInt(cmdElem.getAttribute(ID_ATTR)));
|
||||||
|
// deserialize command
|
||||||
|
command.deserialize(cmdElem);
|
||||||
|
// get set of files the command applies to
|
||||||
|
NodeList appliesList = cmdElem.getElementsByTagName(APPLIES_TO_ATTR);
|
||||||
|
if (appliesList.getLength() > 0) {
|
||||||
|
Element appliesElem = (Element) appliesList.item(0);
|
||||||
|
NodeList fileList = appliesElem.getElementsByTagName(FILE_ELEM);
|
||||||
|
for (int i = 0; i < fileList.getLength(); ++i) {
|
||||||
|
Element fileElem = (Element) fileList.item(i);
|
||||||
|
String fileName = fileElem.getAttribute(PATH_ATTR);
|
||||||
|
IFile file = project.getFile(fileName);
|
||||||
|
addCompilerCommand(file, command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#getCollectorId()
|
||||||
|
*/
|
||||||
|
public String getCollectorId() {
|
||||||
|
return COLLECTOR_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final String COLLECTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".PerFileSICollector"; //$NON-NLS-1$
|
||||||
private static final String CC_ELEM = "compilerCommand"; //$NON-NLS-1$
|
private static final String CC_ELEM = "compilerCommand"; //$NON-NLS-1$
|
||||||
private static final String ID_ATTR = "id"; //$NON-NLS-1$
|
private static final String ID_ATTR = "id"; //$NON-NLS-1$
|
||||||
private static final String FILE_TYPE_ATTR = "fileType"; //$NON-NLS-1$
|
private static final String FILE_TYPE_ATTR = "fileType"; //$NON-NLS-1$
|
||||||
|
@ -59,23 +145,29 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
private static final String FILE_ELEM = "file"; //$NON-NLS-1$
|
private static final String FILE_ELEM = "file"; //$NON-NLS-1$
|
||||||
private static final String PATH_ATTR = "path"; //$NON-NLS-1$
|
private static final String PATH_ATTR = "path"; //$NON-NLS-1$
|
||||||
|
|
||||||
private IProject project;
|
private static final LinkedHashMap EMPTY_LHM = new LinkedHashMap(0);
|
||||||
|
|
||||||
private Map commandIdToFilesMap; // command id and set of files it applies to
|
|
||||||
private Map fileToCommandIdMap; // maps each file to the corresponding command id
|
|
||||||
private Map commandIdCommandMap; // map of all commands
|
|
||||||
|
|
||||||
|
private IProject project;
|
||||||
|
|
||||||
|
private ScannerInfoData sid; // scanner info data
|
||||||
|
|
||||||
|
private List siChangedForFileList; // list of files for which scanner info has changed
|
||||||
|
|
||||||
private SortedSet freeCommandIdPool; // sorted set of free command ids
|
private SortedSet freeCommandIdPool; // sorted set of free command ids
|
||||||
private int commandIdCounter = 0;
|
private int commandIdCounter = 0;
|
||||||
|
|
||||||
|
private boolean siAvailable; // is there any scanner info discovered
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public PerFileSICollector() {
|
public PerFileSICollector() {
|
||||||
commandIdCommandMap = new LinkedHashMap(); // [commandId, command]
|
sid = new ScannerInfoData();
|
||||||
fileToCommandIdMap = new HashMap(); // [file, commandId]
|
|
||||||
commandIdToFilesMap = new HashMap(); // [commandId, set of files]
|
siChangedForFileList = new ArrayList();
|
||||||
|
|
||||||
freeCommandIdPool = new TreeSet();
|
freeCommandIdPool = new TreeSet();
|
||||||
|
siAvailable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -85,10 +177,12 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
this.project = project;
|
this.project = project;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
// deserialize from SI store
|
||||||
|
DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, sid);
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
MakeCorePlugin.log(e);
|
MakeCorePlugin.log(e);
|
||||||
|
siAvailable = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,12 +233,12 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
* @param scannerInfo
|
* @param scannerInfo
|
||||||
*/
|
*/
|
||||||
private void addScannerInfo(Integer commandId, Map scannerInfo) {
|
private void addScannerInfo(Integer commandId, Map scannerInfo) {
|
||||||
CCommandDSC cmd = (CCommandDSC) commandIdCommandMap.get(commandId);
|
CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(commandId);
|
||||||
if (cmd != null) {
|
if (cmd != null) {
|
||||||
List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||||
List includes = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
|
List includes = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
|
||||||
cmd.setSymbols(symbols);
|
cmd.setSymbols(symbols);
|
||||||
cmd.setIncludes(includes);
|
cmd.setIncludes(CygpathTranslator.translateIncludePaths(includes));
|
||||||
cmd.setDiscovered(true);
|
cmd.setDiscovered(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +248,7 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
* @param object
|
* @param object
|
||||||
*/
|
*/
|
||||||
private void addCompilerCommand(IFile file, CCommandDSC cmd) {
|
private void addCompilerCommand(IFile file, CCommandDSC cmd) {
|
||||||
List existingCommands = new ArrayList(commandIdCommandMap.values());
|
List existingCommands = new ArrayList(sid.commandIdCommandMap.values());
|
||||||
int index = existingCommands.indexOf(cmd);
|
int index = existingCommands.indexOf(cmd);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
cmd = (CCommandDSC) existingCommands.get(index);
|
cmd = (CCommandDSC) existingCommands.get(index);
|
||||||
|
@ -170,35 +264,64 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
commandId = ++commandIdCounter;
|
commandId = ++commandIdCounter;
|
||||||
}
|
}
|
||||||
cmd.setCommandId(commandId);
|
cmd.setCommandId(commandId);
|
||||||
commandIdCommandMap.put(cmd.getCommandIdAsInteger(), cmd);
|
sid.commandIdCommandMap.put(cmd.getCommandIdAsInteger(), cmd);
|
||||||
}
|
}
|
||||||
Integer commandId = cmd.getCommandIdAsInteger();
|
Integer commandId = cmd.getCommandIdAsInteger();
|
||||||
// update commandIdToFilesMap
|
// update sid.commandIdToFilesMap
|
||||||
Set fileSet = (Set) commandIdToFilesMap.get(commandId);
|
Set fileSet = (Set) sid.commandIdToFilesMap.get(commandId);
|
||||||
if (fileSet == null) {
|
if (fileSet == null) {
|
||||||
fileSet = new HashSet();
|
fileSet = new HashSet();
|
||||||
commandIdToFilesMap.put(commandId, fileSet);
|
sid.commandIdToFilesMap.put(commandId, fileSet);
|
||||||
}
|
}
|
||||||
fileSet.add(file);
|
if (fileSet.add(file)) {
|
||||||
// update fileToCommandIdsMap
|
// update fileToCommandIdsMap
|
||||||
boolean change = true;
|
boolean change = true;
|
||||||
Integer oldCommandId = (Integer) fileToCommandIdMap.get(file);
|
Integer oldCommandId = (Integer) sid.fileToCommandIdMap.get(file);
|
||||||
if (oldCommandId != null) {
|
if (oldCommandId != null) {
|
||||||
if (oldCommandId.equals(commandId)) {
|
if (oldCommandId.equals(commandId)) {
|
||||||
change = false;
|
change = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set oldFileSet = (Set) sid.commandIdToFilesMap.get(oldCommandId);
|
||||||
|
oldFileSet.remove(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (change) {
|
||||||
commandIdToFilesMap.remove(file);
|
sid.fileToCommandIdMap.put(file, commandId);
|
||||||
if (((Set)(commandIdToFilesMap.get(oldCommandId))).isEmpty()) {
|
// TODO generate change event for this resource
|
||||||
// old command does not apply to any files any more; remove
|
if (!siChangedForFileList.contains(file)) {
|
||||||
commandIdCommandMap.remove(oldCommandId);
|
siChangedForFileList.add(file);
|
||||||
freeCommandIdPool.add(oldCommandId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileToCommandIdMap.put(file, commandId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeUnusedCommands() {
|
||||||
|
for (Iterator i = sid.commandIdToFilesMap.entrySet().iterator(); i.hasNext(); ) {
|
||||||
|
Entry entry = (Entry) i.next();
|
||||||
|
Integer cmdId = (Integer) entry.getKey();
|
||||||
|
Set fileSet = (Set) entry.getValue();
|
||||||
|
if (fileSet.isEmpty()) {
|
||||||
|
// return cmdId to the free command id pool
|
||||||
|
freeCommandIdPool.add(cmdId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Iterator i = freeCommandIdPool.iterator(); i.hasNext(); ) {
|
||||||
|
Integer cmdId = (Integer) i.next();
|
||||||
|
// the command does not have any files associated; remove
|
||||||
|
sid.commandIdCommandMap.remove(cmdId);
|
||||||
|
sid.commandIdToFilesMap.remove(cmdId);
|
||||||
|
}
|
||||||
|
while (!freeCommandIdPool.isEmpty()) {
|
||||||
|
Integer last = (Integer) freeCommandIdPool.last();
|
||||||
|
if (last.intValue() == commandIdCounter) {
|
||||||
|
freeCommandIdPool.remove(last);
|
||||||
|
--commandIdCounter;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type
|
* @param type
|
||||||
* @param object
|
* @param object
|
||||||
|
@ -216,13 +339,16 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
|
monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
|
||||||
|
removeUnusedCommands();
|
||||||
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
|
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
|
||||||
DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, this);
|
MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
||||||
|
// DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, this);
|
||||||
monitor.worked(50);
|
monitor.worked(50);
|
||||||
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
|
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
// update scanner configuration
|
// update scanner configuration
|
||||||
DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, this);
|
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(createPathInfoObject());
|
||||||
|
// DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, this);
|
||||||
monitor.worked(50);
|
monitor.worked(50);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
MakeCorePlugin.log(e);
|
MakeCorePlugin.log(e);
|
||||||
|
@ -230,6 +356,13 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject()
|
||||||
|
*/
|
||||||
|
public IDiscoveredPathInfo createPathInfoObject() {
|
||||||
|
return new PerFileDiscoveredPathInfo();
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
|
||||||
*/
|
*/
|
||||||
|
@ -255,81 +388,19 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
}
|
}
|
||||||
else if (project.equals(((IResource)resource).getProject())) {
|
else if (project.equals(((IResource)resource).getProject())) {
|
||||||
if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) {
|
if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) {
|
||||||
rv = new ArrayList(commandIdCommandMap.values());
|
rv = new ArrayList();
|
||||||
}
|
for (Iterator i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext(); ) {
|
||||||
}
|
Integer cmdId = (Integer) i.next();
|
||||||
return rv;
|
Set fileSet = (Set) sid.commandIdToFilesMap.get(cmdId);
|
||||||
}
|
if (!fileSet.isEmpty()) {
|
||||||
|
rv.add(sid.commandIdCommandMap.get(cmdId));
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element)
|
|
||||||
*/
|
|
||||||
public void serialize(Element collectorElem) {
|
|
||||||
Document doc = collectorElem.getOwnerDocument();
|
|
||||||
|
|
||||||
List commandIds = new ArrayList(commandIdCommandMap.keySet());
|
|
||||||
Collections.sort(commandIds);
|
|
||||||
for (Iterator i = commandIds.iterator(); i.hasNext(); ) {
|
|
||||||
Integer commandId = (Integer) i.next();
|
|
||||||
CCommandDSC command = (CCommandDSC) commandIdCommandMap.get(commandId);
|
|
||||||
|
|
||||||
Element cmdElem = doc.createElement(CC_ELEM); //$NON-NLS-1$
|
|
||||||
collectorElem.appendChild(cmdElem);
|
|
||||||
cmdElem.setAttribute(ID_ATTR, commandId.toString()); //$NON-NLS-1$
|
|
||||||
cmdElem.setAttribute(FILE_TYPE_ATTR, command.appliesToCPPFileType() ? "c++" : "c");
|
|
||||||
// write command and scanner info
|
|
||||||
command.serialize(cmdElem);
|
|
||||||
// write files command applies to
|
|
||||||
Element filesElem = doc.createElement(APPLIES_TO_ATTR); //$NON-NLS-1$
|
|
||||||
cmdElem.appendChild(filesElem);
|
|
||||||
Set files = (Set) commandIdToFilesMap.get(commandId);
|
|
||||||
if (files != null) {
|
|
||||||
for (Iterator j = files.iterator(); j.hasNext(); ) {
|
|
||||||
Element fileElem = doc.createElement(FILE_ELEM); //$NON-NLS-1$
|
|
||||||
IFile file = (IFile) j.next();
|
|
||||||
IPath path = file.getProjectRelativePath();
|
|
||||||
fileElem.setAttribute(PATH_ATTR, path.toString()); //$NON-NLS-1$
|
|
||||||
filesElem.appendChild(fileElem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
|
|
||||||
*/
|
|
||||||
public void deserialize(Element collectorElem) {
|
|
||||||
for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) {
|
|
||||||
if (child.getNodeName().equals(CC_ELEM)) { //$NON-NLS-1$
|
|
||||||
Element cmdElem = (Element) child;
|
|
||||||
boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++");
|
|
||||||
CCommandDSC command = new CCommandDSC(cppFileType);
|
|
||||||
command.setCommandId(Integer.parseInt(cmdElem.getAttribute(ID_ATTR)));
|
|
||||||
// deserialize command
|
|
||||||
command.deserialize(cmdElem);
|
|
||||||
// get set of files the command applies to
|
|
||||||
NodeList appliesList = cmdElem.getElementsByTagName(APPLIES_TO_ATTR);
|
|
||||||
if (appliesList.getLength() > 0) {
|
|
||||||
Element appliesElem = (Element) appliesList.item(0);
|
|
||||||
NodeList fileList = appliesElem.getElementsByTagName(FILE_ELEM);
|
|
||||||
for (int i = 0; i < fileList.getLength(); ++i) {
|
|
||||||
Element fileElem = (Element) fileList.item(i);
|
|
||||||
String fileName = fileElem.getAttribute(PATH_ATTR);
|
|
||||||
IFile file = project.getFile(fileName);
|
|
||||||
addCompilerCommand(file, command);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#getCollectorId()
|
|
||||||
*/
|
|
||||||
public String getCollectorId() {
|
|
||||||
return COLLECTOR_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllPaths(org.eclipse.core.resources.IResource)
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllPaths(org.eclipse.core.resources.IResource)
|
||||||
*/
|
*/
|
||||||
|
@ -362,4 +433,176 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per file DPI object
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public class PerFileDiscoveredPathInfo implements IDiscoveredPathInfo {
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getProject()
|
||||||
|
*/
|
||||||
|
public IProject getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths()
|
||||||
|
*/
|
||||||
|
public IPath[] getIncludePaths() {
|
||||||
|
// return new IPath[0];
|
||||||
|
List includes = getAllIncludePaths();
|
||||||
|
List finalIncludePaths = new ArrayList(includes.size());
|
||||||
|
for (Iterator i = includes.iterator(); i.hasNext(); ) {
|
||||||
|
finalIncludePaths.add(new Path((String) i.next()));
|
||||||
|
}
|
||||||
|
return (IPath[])finalIncludePaths.toArray(new IPath[finalIncludePaths.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list of IPath(s).
|
||||||
|
*/
|
||||||
|
private List getAllIncludePaths() {
|
||||||
|
List allIncludes = new ArrayList();
|
||||||
|
for (Iterator i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext(); ) {
|
||||||
|
Integer cmdId = (Integer) i.next();
|
||||||
|
CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId);
|
||||||
|
if (cmd.isDiscovered()) {
|
||||||
|
List discovered = cmd.getIncludes();
|
||||||
|
for (Iterator j = discovered.iterator(); j.hasNext(); ) {
|
||||||
|
String include = (String) j.next();
|
||||||
|
if (!allIncludes.contains(include)) {
|
||||||
|
allIncludes.add(include);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allIncludes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols()
|
||||||
|
*/
|
||||||
|
public Map getSymbols() {
|
||||||
|
// return new HashMap();
|
||||||
|
return getAllSymbols();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Map getAllSymbols() {
|
||||||
|
Map symbols = new HashMap();
|
||||||
|
for (Iterator i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext(); ) {
|
||||||
|
Integer cmdId = (Integer) i.next();
|
||||||
|
CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId);
|
||||||
|
if (cmd.isDiscovered()) {
|
||||||
|
List discovered = cmd.getSymbols();
|
||||||
|
for (Iterator j = discovered.iterator(); j.hasNext(); ) {
|
||||||
|
String symbol = (String) j.next();
|
||||||
|
String key = ScannerConfigUtil.getSymbolKey(symbol);
|
||||||
|
String value = ScannerConfigUtil.getSymbolValue(symbol);
|
||||||
|
symbols.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return symbols;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#setIncludeMap(java.util.LinkedHashMap)
|
||||||
|
*/
|
||||||
|
public void setIncludeMap(LinkedHashMap map) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#setSymbolMap(java.util.LinkedHashMap)
|
||||||
|
*/
|
||||||
|
public void setSymbolMap(LinkedHashMap map) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludeMap()
|
||||||
|
*/
|
||||||
|
public LinkedHashMap getIncludeMap() {
|
||||||
|
return EMPTY_LHM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbolMap()
|
||||||
|
*/
|
||||||
|
public LinkedHashMap getSymbolMap() {
|
||||||
|
return EMPTY_LHM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath)
|
||||||
|
*/
|
||||||
|
public IPath[] getIncludePaths(IPath path) {
|
||||||
|
IFile file = project.getWorkspace().getRoot().getFile(path);
|
||||||
|
if (file != null) {
|
||||||
|
Integer cmdId = (Integer) sid.fileToCommandIdMap.get(file);
|
||||||
|
if (cmdId != null) {
|
||||||
|
// get the command
|
||||||
|
CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId);
|
||||||
|
if (cmd != null && cmd.isDiscovered()) {
|
||||||
|
List includes = cmd.getIncludes();
|
||||||
|
List includePaths = new ArrayList(includes.size());
|
||||||
|
for (Iterator i = includes.iterator(); i.hasNext(); ) {
|
||||||
|
includePaths.add(new Path((String) i.next()));
|
||||||
|
}
|
||||||
|
return (IPath[])includePaths.toArray(new IPath[includePaths.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new IPath[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath)
|
||||||
|
*/
|
||||||
|
public Map getSymbols(IPath path) {
|
||||||
|
IFile file = project.getFile(path);
|
||||||
|
if (file != null) {
|
||||||
|
Integer cmdId = (Integer) sid.fileToCommandIdMap.get(file);
|
||||||
|
if (cmdId != null) {
|
||||||
|
// get the command
|
||||||
|
CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId);
|
||||||
|
if (cmd != null && cmd.isDiscovered()) {
|
||||||
|
List symbols = cmd.getSymbols();
|
||||||
|
Map definedSymbols = new HashMap(symbols.size());
|
||||||
|
for (Iterator i = symbols.iterator(); i.hasNext(); ) {
|
||||||
|
String symbol = (String) i.next();
|
||||||
|
String key = ScannerConfigUtil.getSymbolKey(symbol);
|
||||||
|
String value = ScannerConfigUtil.getSymbolValue(symbol);
|
||||||
|
definedSymbols.put(key, value);
|
||||||
|
}
|
||||||
|
return definedSymbols;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new HashMap(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable()
|
||||||
|
*/
|
||||||
|
public IDiscoveredScannerInfoSerializable getSerializable() {
|
||||||
|
return sid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getScope()
|
||||||
|
*/
|
||||||
|
public ScannerConfigScope getScope() {
|
||||||
|
return ScannerConfigScope.FILE_SCOPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,17 +26,17 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,7 +233,7 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
|
||||||
addedIncludes = addItemsWithOrder(sumDiscoveredIncludes, discoveredIncludes, true);
|
addedIncludes = addItemsWithOrder(sumDiscoveredIncludes, discoveredIncludes, true);
|
||||||
|
|
||||||
// try to translate cygpaths to absolute paths
|
// try to translate cygpaths to absolute paths
|
||||||
List finalSumIncludes = translateIncludePaths(sumDiscoveredIncludes);
|
List finalSumIncludes = CygpathTranslator.translateIncludePaths(sumDiscoveredIncludes);
|
||||||
|
|
||||||
// Step 2. Get project's scanner config
|
// Step 2. Get project's scanner config
|
||||||
LinkedHashMap persistedIncludes = discPathInfo.getIncludeMap();
|
LinkedHashMap persistedIncludes = discPathInfo.getIncludeMap();
|
||||||
|
@ -298,49 +298,6 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
|
||||||
return addedSymbols;
|
return addedSymbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param sumIncludes
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List translateIncludePaths(List sumIncludes) {
|
|
||||||
List translatedIncludePaths = new ArrayList();
|
|
||||||
for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) {
|
|
||||||
String includePath = (String) i.next();
|
|
||||||
IPath realPath = new Path(includePath);
|
|
||||||
if (!realPath.toFile().exists()) {
|
|
||||||
String translatedPath = includePath;
|
|
||||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
|
||||||
translatedPath = new CygpathTranslator(project, includePath).run();
|
|
||||||
}
|
|
||||||
if (translatedPath != null) {
|
|
||||||
if (!translatedPath.equals(includePath)) {
|
|
||||||
// Check if the translated path exists
|
|
||||||
IPath transPath = new Path(translatedPath);
|
|
||||||
if (transPath.toFile().exists()) {
|
|
||||||
translatedIncludePaths.add(translatedPath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// TODO VMIR for now add even if it does not exist
|
|
||||||
translatedIncludePaths.add(translatedPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// TODO VMIR for now add even if it does not exist
|
|
||||||
translatedIncludePaths.add(translatedPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
TraceUtil.outputError("CygpathTranslator unable to translate path: ",//$NON-NLS-1$
|
|
||||||
includePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
translatedIncludePaths.add(includePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return translatedIncludePaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
|
||||||
*/
|
*/
|
||||||
|
@ -440,4 +397,18 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject()
|
||||||
|
*/
|
||||||
|
public IDiscoveredPathInfo createPathInfoObject() {
|
||||||
|
DiscoveredPathInfo pathInfo = new DiscoveredPathInfo(project);
|
||||||
|
try {
|
||||||
|
DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, pathInfo);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
return pathInfo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,10 +454,10 @@ public class ScannerConfigInfoFactory2 {
|
||||||
((Element)sc).getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue();
|
((Element)sc).getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue();
|
||||||
}
|
}
|
||||||
else if (sc.getNodeName().equals(PROFILE)) {
|
else if (sc.getNodeName().equals(PROFILE)) {
|
||||||
//if (selectedProfile.equals(((Element)sc).getAttribute(ID))) {
|
if (profileIds.contains(((Element)sc).getAttribute(ID))) {
|
||||||
load(sc);
|
load(sc);
|
||||||
loadedProfiles.add(((Element)sc).getAttribute(ID));
|
loadedProfiles.add(((Element)sc).getAttribute(ID));
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loadedProfiles.size() < 1) {
|
if (loadedProfiles.size() < 1) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
|
@ -29,7 +30,7 @@ import org.eclipse.core.runtime.Platform;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public class ScannerConfigProfile {
|
public class ScannerConfigProfile {
|
||||||
/**
|
/**
|
||||||
* scannerInfoCollector element
|
* scannerInfoCollector element
|
||||||
*
|
*
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
|
@ -48,6 +49,9 @@ public class ScannerConfigProfile {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public String getScope() {
|
||||||
|
return configElem.getAttribute("scope"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* scannerInfoConsoleParser element
|
* scannerInfoConsoleParser element
|
||||||
|
@ -296,6 +300,20 @@ public class ScannerConfigProfile {
|
||||||
public ScannerInfoCollector getScannerInfoCollectorElement() {
|
public ScannerInfoCollector getScannerInfoCollectorElement() {
|
||||||
return scannerInfoCollector;
|
return scannerInfoCollector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScannerConfigScope getProfileScope() {
|
||||||
|
ScannerConfigScope scope = null;
|
||||||
|
if (scannerInfoCollector != null) {
|
||||||
|
if (scannerInfoCollector.getScope().equals(ScannerConfigScope.PROJECT_SCOPE.toString())) {
|
||||||
|
scope = ScannerConfigScope.PROJECT_SCOPE;
|
||||||
|
}
|
||||||
|
else if (scannerInfoCollector.getScope().equals(ScannerConfigScope.FILE_SCOPE.toString())) {
|
||||||
|
scope = ScannerConfigScope.FILE_SCOPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the scannerInfoProviders.
|
* @return Returns the scannerInfoProviders.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -234,6 +234,14 @@ ScannerConfigOptionsDialog.siProvider.browse.runCommandDialog='gcc' command:
|
||||||
ScannerConfigOptionsDialog.siProvider.command.errorMessage=Must enter compiler invocation command
|
ScannerConfigOptionsDialog.siProvider.command.errorMessage=Must enter compiler invocation command
|
||||||
ScannerConfigOptionsDialog.apply.progressMessage=Setting scanner configuration discovery options...
|
ScannerConfigOptionsDialog.apply.progressMessage=Setting scanner configuration discovery options...
|
||||||
|
|
||||||
|
ScannerConfigOptionsDialog.unsavedchanges.title=Setting C/C++ Make Project Discovery Options
|
||||||
|
ScannerConfigOptionsDialog.unsavedchanges.message=The C/C++ Make Project Discovery Options property page contains unsaved modifications. Do you want to save changes so that other discovery related settings can be updated?
|
||||||
|
ScannerConfigOptionsDialog.unsavedchanges.button.save=Apply
|
||||||
|
ScannerConfigOptionsDialog.unsavedchanges.button.cancel=Cancel
|
||||||
|
|
||||||
|
ScannerConfigOptionsDialog.error.title=Error Setting Project Discovery options
|
||||||
|
ScannerConfigOptionsDialog.error.message=An error occurred while setting the project discovery options
|
||||||
|
|
||||||
# --- DiscoveredScannerConfigurationContainerPage ---
|
# --- DiscoveredScannerConfigurationContainerPage ---
|
||||||
DiscoveredScannerConfigurationContainerPage.title=Edit container
|
DiscoveredScannerConfigurationContainerPage.title=Edit container
|
||||||
DiscoveredScannerConfigurationContainerPage.description=Manage discovered scanner configuration
|
DiscoveredScannerConfigurationContainerPage.description=Manage discovered scanner configuration
|
||||||
|
|
|
@ -10,12 +10,15 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.ui.dialogs;
|
package org.eclipse.cdt.make.ui.dialogs;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
|
@ -26,8 +29,12 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||||
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
@ -37,10 +44,21 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage {
|
public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage {
|
||||||
|
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
||||||
|
private static final String UNSAVEDCHANGES_TITLE = PREFIX + ".unsavedchanges.title"; //$NON-NLS-1$
|
||||||
|
private static final String UNSAVEDCHANGES_MESSAGE = PREFIX + ".unsavedchanges.message"; //$NON-NLS-1$
|
||||||
|
private static final String UNSAVEDCHANGES_BSAVE = PREFIX + ".unsavedchanges.button.save"; //$NON-NLS-1$
|
||||||
|
private static final String UNSAVEDCHANGES_BCANCEL = PREFIX + ".unsavedchanges.button.cancel"; //$NON-NLS-1$
|
||||||
|
private static final String ERROR_TITLE = PREFIX + ".error.title"; //$NON-NLS-1$
|
||||||
|
private static final String ERROR_MESSAGE = PREFIX + ".error.message"; //$NON-NLS-1$
|
||||||
|
private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$
|
||||||
|
private static final String PROFILE_ID = "profileId"; //$NON-NLS-1$
|
||||||
|
|
||||||
private Preferences fPrefs;
|
private Preferences fPrefs;
|
||||||
private IScannerConfigBuilderInfo2 fBuildInfo;
|
private IScannerConfigBuilderInfo2 fBuildInfo;
|
||||||
private boolean fInitialized = false;
|
private boolean fInitialized = false;
|
||||||
|
private String fPersistedProfileId = null;
|
||||||
|
|
||||||
private Map fProfilePageMap = null;
|
private Map fProfilePageMap = null;
|
||||||
|
|
||||||
// Composite parent provided by the block.
|
// Composite parent provided by the block.
|
||||||
|
@ -77,6 +95,41 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
|
||||||
protected void setInitialized(boolean initialized) {
|
protected void setInitialized(boolean initialized) {
|
||||||
fInitialized = initialized;
|
fInitialized = initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true - OK to continue
|
||||||
|
*/
|
||||||
|
public boolean checkDialogForChanges() {
|
||||||
|
boolean rc = true;
|
||||||
|
if (isProfileDifferentThenPersisted()) {
|
||||||
|
String title = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_TITLE);
|
||||||
|
String message = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_MESSAGE);
|
||||||
|
String[] buttonLabels = new String[]{
|
||||||
|
MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BSAVE),
|
||||||
|
MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BCANCEL),
|
||||||
|
};
|
||||||
|
MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
|
||||||
|
buttonLabels, 0);
|
||||||
|
int res = dialog.open();
|
||||||
|
if (res == 0) { // OK
|
||||||
|
callPerformApply();
|
||||||
|
rc = true;
|
||||||
|
} else if (res == 1) { // CANCEL
|
||||||
|
rc = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isProfileDifferentThenPersisted() {
|
||||||
|
return (fPersistedProfileId != null &&
|
||||||
|
!fPersistedProfileId.equals(getBuildInfo().getSelectedProfileId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePersistedProfile() {
|
||||||
|
fPersistedProfileId = getBuildInfo().getSelectedProfileId();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a profile page only on request
|
* Create a profile page only on request
|
||||||
*
|
*
|
||||||
|
@ -128,8 +181,8 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
|
||||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(MakeUIPlugin.getPluginId(), "DiscoveryProfilePage"); //$NON-NLS-1$
|
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(MakeUIPlugin.getPluginId(), "DiscoveryProfilePage"); //$NON-NLS-1$
|
||||||
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
|
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
|
||||||
for (int i = 0; i < infos.length; i++) {
|
for (int i = 0; i < infos.length; i++) {
|
||||||
if (infos[i].getName().equals("profilePage")) { //$NON-NLS-1$
|
if (infos[i].getName().equals(PROFILE_PAGE)) { //$NON-NLS-1$
|
||||||
String id = infos[i].getAttribute("profileId"); //$NON-NLS-1$
|
String id = infos[i].getAttribute(PROFILE_ID); //$NON-NLS-1$
|
||||||
fProfilePageMap.put(id, new DiscoveryProfilePageConfiguration(infos[i]));
|
fProfilePageMap.put(id, new DiscoveryProfilePageConfiguration(infos[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,6 +209,9 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
|
||||||
} else {
|
} else {
|
||||||
fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
|
fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
|
||||||
}
|
}
|
||||||
|
if (fBuildInfo != null) {
|
||||||
|
fPersistedProfileId = fBuildInfo.getSelectedProfileId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateContainer() {
|
protected void updateContainer() {
|
||||||
|
@ -215,7 +271,7 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification that the user changed the selection of the Binary Parser.
|
* Notification that the user changed the selection of the SCD profile.
|
||||||
*/
|
*/
|
||||||
protected void handleDiscoveryProfileChanged() {
|
protected void handleDiscoveryProfileChanged() {
|
||||||
if (getCompositeParent() == null) {
|
if (getCompositeParent() == null) {
|
||||||
|
@ -297,5 +353,31 @@ public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String getCurrentProfileId();
|
protected abstract String getCurrentProfileId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void callPerformApply() {
|
||||||
|
try {
|
||||||
|
new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() {
|
||||||
|
|
||||||
|
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||||
|
try {
|
||||||
|
performApply(monitor);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
throw new InvocationTargetException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
String title = CPathEntryMessages.getString(ERROR_TITLE); //$NON-NLS-1$
|
||||||
|
String message = CPathEntryMessages.getString(ERROR_MESSAGE); //$NON-NLS-1$
|
||||||
|
ExceptionHandler.handle(e, getShell(), title, message);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// cancelled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,15 @@ import org.eclipse.jface.dialogs.DialogPage;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Provide description
|
* Abstract SCD profile page
|
||||||
*
|
*
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractDiscoveryPage extends DialogPage {
|
public abstract class AbstractDiscoveryPage extends DialogPage {
|
||||||
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
||||||
protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
|
protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
|
||||||
|
|
||||||
protected AbstractDiscoveryOptionsBlock fContainer;
|
protected AbstractDiscoveryOptionsBlock fContainer; // parent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the fContainer.
|
* @return Returns the fContainer.
|
||||||
|
|
|
@ -22,8 +22,10 @@ import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.MakeProjectNature;
|
import org.eclipse.cdt.make.core.MakeProjectNature;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
import org.eclipse.cdt.make.internal.ui.preferences.TabFolderLayout;
|
import org.eclipse.cdt.make.internal.ui.preferences.TabFolderLayout;
|
||||||
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
|
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
|
||||||
|
@ -55,7 +57,6 @@ import org.eclipse.ui.help.WorkbenchHelp;
|
||||||
public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
|
public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
|
||||||
private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
|
private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
|
||||||
private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
|
private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
|
||||||
private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
|
private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
|
||||||
private static final String SC_GROUP_LABEL = PREFIX + ".scGroup.label"; //$NON-NLS-1$
|
private static final String SC_GROUP_LABEL = PREFIX + ".scGroup.label"; //$NON-NLS-1$
|
||||||
|
@ -73,6 +74,7 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
|
||||||
private boolean needsSCNature = false;
|
private boolean needsSCNature = false;
|
||||||
private boolean fCreatePathContainer = false;
|
private boolean fCreatePathContainer = false;
|
||||||
private boolean isValid = true;
|
private boolean isValid = true;
|
||||||
|
private boolean persistedProfileChanged = false; // new persisted selected profile different than the old one
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -227,6 +229,16 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
||||||
*/
|
*/
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
|
if (!visible) {
|
||||||
|
if (!checkDialogForChanges()) {
|
||||||
|
createBuildInfo();
|
||||||
|
restoreFromBuildinfo(getBuildInfo());
|
||||||
|
enableAllControls();
|
||||||
|
handleDiscoveryProfileChanged();
|
||||||
|
|
||||||
|
getCurrentPage().performDefaults();
|
||||||
|
}
|
||||||
|
}
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
enableAllControls();
|
enableAllControls();
|
||||||
}
|
}
|
||||||
|
@ -267,6 +279,10 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
|
||||||
configureProject(project, monitor);
|
configureProject(project, monitor);
|
||||||
}
|
}
|
||||||
getBuildInfo().save();
|
getBuildInfo().save();
|
||||||
|
if (isProfileDifferentThenPersisted()) {
|
||||||
|
changeDiscoveryContainer(project);
|
||||||
|
updatePersistedProfile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
|
@ -308,17 +324,21 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
|
||||||
MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
|
MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
private void changeDiscoveryContainer(IProject project) {
|
||||||
|
String profileId = getBuildInfo().getSelectedProfileId();
|
||||||
|
ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
|
||||||
|
getSCProfileConfiguration(profileId).getProfileScope();
|
||||||
|
MakeCorePlugin.getDefault().getDiscoveryManager().changeDiscoveredContainer(project, profileScope);
|
||||||
|
}
|
||||||
|
|
||||||
private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
|
private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
|
||||||
if (buildInfo != null) {
|
if (buildInfo != null) {
|
||||||
buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
|
buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
|
||||||
String profileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
|
String profileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
|
||||||
String oldProfileId = buildInfo.getSelectedProfileId();
|
|
||||||
buildInfo.setSelectedProfileId(getDiscoveryProfileId(profileName));
|
buildInfo.setSelectedProfileId(getDiscoveryProfileId(profileName));
|
||||||
String newProfileId = buildInfo.getSelectedProfileId();
|
|
||||||
if (!oldProfileId.equals(newProfileId) && getProject() != null) {
|
|
||||||
// invalidate scanner config store and reload
|
|
||||||
// MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(getProject());
|
|
||||||
}
|
|
||||||
buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
|
buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +365,7 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
|
||||||
private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
|
private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
|
||||||
if (buildInfo != null) {
|
if (buildInfo != null) {
|
||||||
scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
|
scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
|
||||||
String profileId = buildInfo.getSelectedProfileId();
|
String profileId = buildInfo.getSelectedProfileId();
|
||||||
profileComboBox.setText(getDiscoveryProfileName(profileId));
|
profileComboBox.setText(getDiscoveryProfileName(profileId));
|
||||||
scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled());
|
scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled());
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,7 @@ public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleBOPLoadFileButtonSelected() {
|
private void handleBOPLoadFileButtonSelected() {
|
||||||
|
if (!getContainer().checkDialogForChanges()) return;
|
||||||
loadButtonInitialEnabled = false;
|
loadButtonInitialEnabled = false;
|
||||||
bopLoadButton.setEnabled(false);
|
bopLoadButton.setEnabled(false);
|
||||||
|
|
||||||
|
|
|
@ -294,6 +294,7 @@ public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleBOPLoadFileButtonSelected() {
|
private void handleBOPLoadFileButtonSelected() {
|
||||||
|
if (!getContainer().checkDialogForChanges()) return;
|
||||||
loadButtonInitialEnabled = false;
|
loadButtonInitialEnabled = false;
|
||||||
bopLoadButton.setEnabled(false);
|
bopLoadButton.setEnabled(false);
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,9 @@
|
||||||
id="GCCManagedMakePerProjectProfile"
|
id="GCCManagedMakePerProjectProfile"
|
||||||
name="GNU C/C++ managed make per project SCD profile"
|
name="GNU C/C++ managed make per project SCD profile"
|
||||||
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
||||||
<scannerInfoCollector class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"/>
|
<scannerInfoCollector
|
||||||
|
class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"
|
||||||
|
scope="project"/>
|
||||||
<scannerInfoProvider providerId="specsFile">
|
<scannerInfoProvider providerId="specsFile">
|
||||||
<run
|
<run
|
||||||
arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}"
|
arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}"
|
||||||
|
@ -101,7 +103,9 @@
|
||||||
id="GCCWinManagedMakePerProjectProfile"
|
id="GCCWinManagedMakePerProjectProfile"
|
||||||
name="GNU C/C++ managed make per project SCD profile (Windows)"
|
name="GNU C/C++ managed make per project SCD profile (Windows)"
|
||||||
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
||||||
<scannerInfoCollector class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGnuWinScannerInfoCollector"/>
|
<scannerInfoCollector
|
||||||
|
class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGnuWinScannerInfoCollector"
|
||||||
|
scope="project"/>
|
||||||
<scannerInfoProvider providerId="specsFile">
|
<scannerInfoProvider providerId="specsFile">
|
||||||
<run
|
<run
|
||||||
arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}"
|
arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}"
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoColl
|
||||||
*/
|
*/
|
||||||
private String convertPath(String includePath) {
|
private String convertPath(String includePath) {
|
||||||
// Convert a POSIX-style path to Win32
|
// Convert a POSIX-style path to Win32
|
||||||
String translatedPath = new CygpathTranslator(project, includePath).run();
|
String translatedPath = new CygpathTranslator(includePath).run();
|
||||||
return translatedPath;
|
return translatedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IPathEntry[] removeCachedResovedPathEntries(ICProject cproject) {
|
protected IPathEntry[] removeCachedResolvedPathEntries(ICProject cproject) {
|
||||||
ArrayList resolvedListEntries = (ArrayList)resolvedMap.remove(cproject);
|
ArrayList resolvedListEntries = (ArrayList)resolvedMap.remove(cproject);
|
||||||
if (resolvedListEntries != null) {
|
if (resolvedListEntries != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -742,7 +742,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
remaining++;
|
remaining++;
|
||||||
oldResolvedEntries[i] = removeCachedResovedPathEntries(affectedProject);
|
oldResolvedEntries[i] = removeCachedResolvedPathEntries(affectedProject);
|
||||||
// ArrayList listEntries = (ArrayList)resolvedMap.remove(affectedProject);
|
// ArrayList listEntries = (ArrayList)resolvedMap.remove(affectedProject);
|
||||||
// if (listEntries != null) {
|
// if (listEntries != null) {
|
||||||
// oldResolvedEntries[i] = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
|
// oldResolvedEntries[i] = (IPathEntry[])listEntries.toArray(NO_PATHENTRIES);
|
||||||
|
@ -1460,7 +1460,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
if (project.isAccessible()) {
|
if (project.isAccessible()) {
|
||||||
try {
|
try {
|
||||||
// Clear the old cache entries.
|
// Clear the old cache entries.
|
||||||
IPathEntry[] oldResolvedEntries = removeCachedResovedPathEntries(cproject);
|
IPathEntry[] oldResolvedEntries = removeCachedResolvedPathEntries(cproject);
|
||||||
IPathEntry[] newResolvedEntries = getResolvedPathEntries(cproject);
|
IPathEntry[] newResolvedEntries = getResolvedPathEntries(cproject);
|
||||||
ICElementDelta[] deltas = generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
|
ICElementDelta[] deltas = generatePathEntryDeltas(cproject, oldResolvedEntries, newResolvedEntries);
|
||||||
if (deltas.length > 0) {
|
if (deltas.length > 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue