mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Patch for Bog. Update the Index Manager to use the CDescriptor framework to manage which indexer to instantiate for each project.
This commit is contained in:
parent
c63b26f8dc
commit
ec85b24cb7
14 changed files with 409 additions and 836 deletions
|
@ -26,12 +26,17 @@ public class MakeProject implements ICOwner {
|
||||||
cDescriptor.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
cDescriptor.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
||||||
cDescriptor.remove(CCorePlugin.BUILDER_MODEL_ID);
|
cDescriptor.remove(CCorePlugin.BUILDER_MODEL_ID);
|
||||||
updateBinaryParsers(cDescriptor);
|
updateBinaryParsers(cDescriptor);
|
||||||
|
updateIndexers(cDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(ICDescriptor cDescriptor, String extensionID) throws CoreException {
|
public void update(ICDescriptor cDescriptor, String extensionID) throws CoreException {
|
||||||
if (extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) {
|
if (extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) {
|
||||||
updateBinaryParsers(cDescriptor);
|
updateBinaryParsers(cDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extensionID.equals(CCorePlugin.INDEXER_UNIQ_ID)) {
|
||||||
|
updateIndexers(cDescriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBinaryParsers(ICDescriptor cDescriptor) throws CoreException {
|
private void updateBinaryParsers(ICDescriptor cDescriptor) throws CoreException {
|
||||||
|
@ -45,7 +50,18 @@ public class MakeProject implements ICOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateIndexers(ICDescriptor cDescriptor) throws CoreException {
|
||||||
|
cDescriptor.remove(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
|
Preferences corePrefs = CCorePlugin.getDefault().getPluginPreferences();
|
||||||
|
String id = corePrefs.getString(CCorePlugin.PREF_INDEXER);
|
||||||
|
if (id != null && id.length() != 0) {
|
||||||
|
String[] ids = parseStringToArray(id);
|
||||||
|
for (int i = 0; i < ids.length; i++) {
|
||||||
|
cDescriptor.create(CCorePlugin.INDEXER_UNIQ_ID, ids[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String[] parseStringToArray(String syms) {
|
private String[] parseStringToArray(String syms) {
|
||||||
if (syms != null && syms.length() > 0) {
|
if (syms != null && syms.length() > 0) {
|
||||||
|
|
|
@ -11,10 +11,14 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.ICOwner;
|
import org.eclipse.cdt.core.ICOwner;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
|
@ -36,6 +40,8 @@ public class ManagedMakeProject implements ICOwner {
|
||||||
cproject.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
cproject.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
||||||
cproject.remove(CCorePlugin.BUILDER_MODEL_ID);
|
cproject.remove(CCorePlugin.BUILDER_MODEL_ID);
|
||||||
cproject.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
cproject.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||||
|
|
||||||
|
updateIndexers(cproject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -43,10 +49,37 @@ public class ManagedMakeProject implements ICOwner {
|
||||||
*/
|
*/
|
||||||
public void update(ICDescriptor cproject, String extensionID)
|
public void update(ICDescriptor cproject, String extensionID)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
if (extensionID.equals(CCorePlugin.INDEXER_UNIQ_ID)) {
|
||||||
|
updateIndexers(cproject);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBinaryParsers(ICDescriptor cproject) throws CoreException {
|
private void updateBinaryParsers(ICDescriptor cproject) throws CoreException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateIndexers(ICDescriptor cDescriptor) throws CoreException {
|
||||||
|
cDescriptor.remove(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
|
Preferences corePrefs = CCorePlugin.getDefault().getPluginPreferences();
|
||||||
|
String id = corePrefs.getString(CCorePlugin.PREF_INDEXER);
|
||||||
|
if (id != null && id.length() != 0) {
|
||||||
|
String[] ids = parseStringToArray(id);
|
||||||
|
for (int i = 0; i < ids.length; i++) {
|
||||||
|
cDescriptor.create(CCorePlugin.INDEXER_UNIQ_ID, ids[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] parseStringToArray(String syms) {
|
||||||
|
if (syms != null && syms.length() > 0) {
|
||||||
|
StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
|
||||||
|
ArrayList list = new ArrayList(tok.countTokens());
|
||||||
|
while (tok.hasMoreElements()) {
|
||||||
|
list.add(tok.nextToken());
|
||||||
|
}
|
||||||
|
return (String[]) list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ import org.eclipse.core.runtime.Platform;
|
||||||
indexFile.delete();
|
indexFile.delete();
|
||||||
|
|
||||||
testProject.setSessionProperty(IndexManager.indexerIDKey, SourceIndexerTests.sourceIndexerID);
|
testProject.setSessionProperty(IndexManager.indexerIDKey, SourceIndexerTests.sourceIndexerID);
|
||||||
testProject.setSessionProperty(SourceIndexer.activationKey,new Boolean(true));
|
testProject.setSessionProperty(SourceIndexer.activationKey,new Boolean(true));
|
||||||
|
|
||||||
if (testProject==null)
|
if (testProject==null)
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
|
|
|
@ -18,6 +18,8 @@ import java.io.FileInputStream;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.search.BasicSearchResultCollector;
|
import org.eclipse.cdt.core.search.BasicSearchResultCollector;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
@ -55,13 +57,14 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
||||||
static protected SearchEngine searchEngine;
|
static protected SearchEngine searchEngine;
|
||||||
static protected FileManager fileManager;
|
static protected FileManager fileManager;
|
||||||
static final String sourceIndexerID = "org.eclipse.cdt.core.originalsourceindexer"; //$NON-NLS-1$
|
static final String sourceIndexerID = "org.eclipse.cdt.core.originalsourceindexer"; //$NON-NLS-1$
|
||||||
|
static protected SourceIndexer sourceIndexer;
|
||||||
{
|
{
|
||||||
|
|
||||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
|
|
||||||
workspace = ResourcesPlugin.getWorkspace();
|
workspace = ResourcesPlugin.getWorkspace();
|
||||||
|
CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.DEFAULT_INDEXER_UNIQ_ID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Create temp project
|
//Create temp project
|
||||||
|
@ -71,7 +74,9 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
||||||
|
|
||||||
//Set the id of the source indexer extension point as a session property to allow
|
//Set the id of the source indexer extension point as a session property to allow
|
||||||
//index manager to instantiate it
|
//index manager to instantiate it
|
||||||
testProject.setSessionProperty(IndexManager.indexerIDKey, sourceIndexerID);
|
//testProject.setSessionProperty(IndexManager.indexerIDKey, sourceIndexerID);
|
||||||
|
sourceIndexer = (SourceIndexer) CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(testProject);
|
||||||
|
int x=0;
|
||||||
} catch (CoreException e) {}
|
} catch (CoreException e) {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,7 +112,6 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
|
|
|
@ -50,9 +50,6 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite();
|
final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite();
|
||||||
|
|
||||||
//TODO: BOG Take this out once null indexer id added to suite project creation
|
|
||||||
CCorePlugin.getDefault().getCoreModel().getIndexManager().setEnableUpdates(false);
|
|
||||||
|
|
||||||
// Add all success tests
|
// Add all success tests
|
||||||
suite.addTest(CDescriptorTests.suite());
|
suite.addTest(CDescriptorTests.suite());
|
||||||
//suite.addTest(GCCErrorParserTests.suite());
|
//suite.addTest(GCCErrorParserTests.suite());
|
||||||
|
|
|
@ -16,8 +16,10 @@ import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.AbstractCExtension;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.core.ICLogConstants;
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
import org.eclipse.cdt.core.index.ICDTIndexer;
|
import org.eclipse.cdt.core.index.ICDTIndexer;
|
||||||
import org.eclipse.cdt.core.index.IIndexChangeListener;
|
import org.eclipse.cdt.core.index.IIndexChangeListener;
|
||||||
|
@ -49,13 +51,11 @@ import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bogdan Gheorghe
|
* @author Bogdan Gheorghe
|
||||||
*/
|
*/
|
||||||
public class SourceIndexer implements ICDTIndexer {
|
public class SourceIndexer extends AbstractCExtension implements ICDTIndexer {
|
||||||
|
|
||||||
public static boolean VERBOSE = false;
|
public static boolean VERBOSE = false;
|
||||||
|
|
||||||
|
@ -73,21 +73,27 @@ public class SourceIndexer implements ICDTIndexer {
|
||||||
public final static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
|
public final static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
|
||||||
public final static QualifiedName problemsActivationKey = new QualifiedName( INDEX_MODEL_ID, PROBLEM_ACTIVATION );
|
public final static QualifiedName problemsActivationKey = new QualifiedName( INDEX_MODEL_ID, PROBLEM_ACTIVATION );
|
||||||
|
|
||||||
public static final String INDEXER_ENABLED = "indexEnabled"; //$NON-NLS-1$
|
/*public static final String INDEXER_ENABLED = "indexEnabled"; //$NON-NLS-1$
|
||||||
public static final String INDEXER_PROBLEMS_ENABLED = "indexerProblemsEnabled"; //$NON-NLS-1$
|
public static final String INDEXER_PROBLEMS_ENABLED = "indexerProblemsEnabled"; //$NON-NLS-1$
|
||||||
public static final String SOURCE_INDEXER = "cdt_source_indexer"; //$NON-NLS-1$
|
public static final String SOURCE_INDEXER = "cdt_source_indexer"; //$NON-NLS-1$
|
||||||
public static final String INDEXER_VALUE = "indexValue"; //$NON-NLS-1$
|
public static final String INDEXER_VALUE = "indexValue"; //$NON-NLS-1$
|
||||||
public static final String INDEXER_PROBLEMS_VALUE = "indexProblemsValue"; //$NON-NLS-1$
|
public static final String INDEXER_PROBLEMS_VALUE = "indexProblemsValue"; //$NON-NLS-1$
|
||||||
|
*/
|
||||||
public static final int PREPROCESSOR_PROBLEMS_BIT = 1;
|
public static final int PREPROCESSOR_PROBLEMS_BIT = 1;
|
||||||
public static final int SEMANTIC_PROBLEMS_BIT = 1 << 1;
|
public static final int SEMANTIC_PROBLEMS_BIT = 1 << 1;
|
||||||
public static final int SYNTACTIC_PROBLEMS_BIT = 1 << 2;
|
public static final int SYNTACTIC_PROBLEMS_BIT = 1 << 2;
|
||||||
|
|
||||||
|
public static final String SOURCE_INDEXER_ID = "originalsourceindexer"; //$NON-NLS-1$
|
||||||
|
public static final String SOURCE_INDEXER_UNIQUE_ID = CCorePlugin.PLUGIN_ID + "." + SOURCE_INDEXER_ID; //$NON-NLS-1$;
|
||||||
|
|
||||||
|
|
||||||
private CIndexStorage indexStorage = null;
|
private CIndexStorage indexStorage = null;
|
||||||
public ReadWriteMonitor storageMonitor = null;
|
public ReadWriteMonitor storageMonitor = null;
|
||||||
private IndexManager indexManager = null;
|
private IndexManager indexManager = null;
|
||||||
|
|
||||||
private HashSet jobSet = null;
|
private HashSet jobSet = null;
|
||||||
|
private boolean indexEnabled = false;
|
||||||
|
|
||||||
|
|
||||||
public SourceIndexer(){
|
public SourceIndexer(){
|
||||||
this.indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
this.indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||||
|
@ -211,10 +217,6 @@ public class SourceIndexer implements ICDTIndexer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param project
|
* @param project
|
||||||
* @return
|
* @return
|
||||||
|
@ -227,59 +229,65 @@ public class SourceIndexer implements ICDTIndexer {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
indexValue = (Boolean) project.getSessionProperty(activationKey);
|
indexValue = (Boolean) project.getSessionProperty(activationKey);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {}
|
||||||
}
|
|
||||||
|
|
||||||
if (indexValue != null)
|
if (indexValue != null)
|
||||||
return indexValue.booleanValue();
|
return indexValue.booleanValue();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Load value for project
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
||||||
indexValue = loadIndexerEnabledFromCDescriptor(project);
|
if (cdesc == null)
|
||||||
if (indexValue != null){
|
return false;
|
||||||
project.setSessionProperty(SourceIndexer.activationKey, indexValue);
|
|
||||||
return indexValue.booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Indexer Block Place holder for Managed Make - take out
|
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
indexValue = new Boolean(true);
|
if (cext.length > 0) {
|
||||||
project.setSessionProperty(SourceIndexer.activationKey, indexValue);
|
//initializeIndexerId();
|
||||||
return indexValue.booleanValue();
|
for (int i = 0; i < cext.length; i++) {
|
||||||
} catch (CoreException e1) {
|
String id = cext[i].getID();
|
||||||
}
|
String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$
|
||||||
|
if (orig != null){
|
||||||
|
Boolean tempBool = new Boolean(orig);
|
||||||
|
indexEnabled = tempBool.booleanValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
|
} catch (CoreException e) {}
|
||||||
|
|
||||||
|
return indexEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int indexProblemsEnabled(IProject project) {
|
public int indexProblemsEnabled(IProject project) {
|
||||||
Integer value = null;
|
|
||||||
|
|
||||||
|
if( project == null || !project.exists() || !project.isOpen() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int indexProblemsEnabled = 0;
|
||||||
try {
|
try {
|
||||||
value = (Integer) project.getSessionProperty(problemsActivationKey);
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
||||||
} catch (CoreException e) {
|
if (cdesc == null)
|
||||||
}
|
return 0;
|
||||||
|
|
||||||
if (value != null)
|
|
||||||
return value.intValue();
|
|
||||||
|
|
||||||
try {
|
|
||||||
//Load value for project
|
|
||||||
value = loadIndexerProblemsEnabledFromCDescriptor(project);
|
|
||||||
if (value != null){
|
|
||||||
project.setSessionProperty(SourceIndexer.problemsActivationKey, value);
|
|
||||||
return value.intValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Indexer Block Place holder for Managed Make - take out
|
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
value = new Integer(0);
|
if (cext.length > 0) {
|
||||||
project.setSessionProperty(SourceIndexer.problemsActivationKey, value);
|
//initializeIndexerId();
|
||||||
return value.intValue();
|
for (int i = 0; i < cext.length; i++) {
|
||||||
} catch (CoreException e1) {
|
String id = cext[i].getID();
|
||||||
}
|
String orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$
|
||||||
|
if (orig != null){
|
||||||
|
Integer tempInt = new Integer(orig);
|
||||||
|
indexProblemsEnabled = tempInt.intValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
} catch (CoreException e) {}
|
||||||
|
|
||||||
|
return indexProblemsEnabled;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Index the content of the given source folder.
|
* Index the content of the given source folder.
|
||||||
|
@ -334,56 +342,6 @@ public class SourceIndexer implements ICDTIndexer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Boolean loadIndexerEnabledFromCDescriptor(IProject project) throws CoreException {
|
|
||||||
// Check if we have the property in the descriptor
|
|
||||||
// We pass false since we do not want to create the descriptor if it does not exists.
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
|
||||||
Boolean strBool = null;
|
|
||||||
if (descriptor != null) {
|
|
||||||
Node child = descriptor.getProjectData(SOURCE_INDEXER).getFirstChild();
|
|
||||||
|
|
||||||
while (child != null) {
|
|
||||||
if (child.getNodeName().equals(INDEXER_ENABLED))
|
|
||||||
strBool = Boolean.valueOf(((Element)child).getAttribute(INDEXER_VALUE));
|
|
||||||
|
|
||||||
|
|
||||||
child = child.getNextSibling();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return strBool;
|
|
||||||
}
|
|
||||||
private Integer loadIndexerProblemsEnabledFromCDescriptor(IProject project) throws CoreException {
|
|
||||||
// we are only checking for the settings do not create the descriptor.
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
|
||||||
Integer strInt = null;
|
|
||||||
if( descriptor != null ){
|
|
||||||
Node child = descriptor.getProjectData(SourceIndexer.SOURCE_INDEXER).getFirstChild();
|
|
||||||
|
|
||||||
while (child != null) {
|
|
||||||
if (child.getNodeName().equals(INDEXER_PROBLEMS_ENABLED)){
|
|
||||||
String val = ((Element)child).getAttribute(INDEXER_PROBLEMS_VALUE);
|
|
||||||
try{
|
|
||||||
strInt = Integer.valueOf( val );
|
|
||||||
} catch( NumberFormatException e ){
|
|
||||||
//some old projects might have a boolean stored, translate that into just preprocessors
|
|
||||||
Boolean bool = Boolean.valueOf( val );
|
|
||||||
if( bool.booleanValue() )
|
|
||||||
strInt = new Integer( SourceIndexer.PREPROCESSOR_PROBLEMS_BIT );
|
|
||||||
else
|
|
||||||
strInt = new Integer( 0 );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
child = child.getNextSibling();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return strInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
static private class RemoveIndexMarkersJob extends Job{
|
static private class RemoveIndexMarkersJob extends Job{
|
||||||
private final IResource resource;
|
private final IResource resource;
|
||||||
public RemoveIndexMarkersJob( IResource resource, String name ){
|
public RemoveIndexMarkersJob( IResource resource, String name ){
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.core.index.ICDTIndexer;
|
import org.eclipse.cdt.core.index.ICDTIndexer;
|
||||||
import org.eclipse.cdt.core.index.IIndexStorage;
|
import org.eclipse.cdt.core.index.IIndexStorage;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
@ -27,21 +28,16 @@ import org.eclipse.cdt.internal.core.search.processing.JobManager;
|
||||||
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.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
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.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bogdan Gheorghe
|
* @author Bogdan Gheorghe
|
||||||
|
@ -60,198 +56,30 @@ public class IndexManager extends JobManager{
|
||||||
|
|
||||||
public static boolean VERBOSE = false;
|
public static boolean VERBOSE = false;
|
||||||
|
|
||||||
//Map of Contributed Indexers; keyed by project
|
|
||||||
private HashMap contributedIndexerMap = null;
|
|
||||||
|
|
||||||
//Map of Persisted Indexers; keyed by project
|
//Map of Persisted Indexers; keyed by project
|
||||||
private HashMap indexerMap = null;
|
private HashMap indexerMap = null;
|
||||||
|
|
||||||
//Upgrade index version
|
|
||||||
private boolean upgradeIndexEnabled = false;
|
|
||||||
private int upgradeIndexProblems = 0;
|
|
||||||
|
|
||||||
private ReadWriteMonitor monitor = new ReadWriteMonitor();
|
private ReadWriteMonitor monitor = new ReadWriteMonitor();
|
||||||
private boolean enableUpdates = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an indexer only on request
|
|
||||||
*/
|
|
||||||
protected static class CDTIndexer {
|
|
||||||
|
|
||||||
IConfigurationElement element;
|
|
||||||
ICDTIndexer indexer;
|
|
||||||
|
|
||||||
public CDTIndexer(IConfigurationElement _element) {
|
|
||||||
element = _element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICDTIndexer getIndexer() throws CoreException {
|
|
||||||
if (indexer == null) {
|
|
||||||
indexer = (ICDTIndexer) element.createExecutableExtension("class"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
return indexer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return element.getAttribute("name"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class UpdateIndexVersionJob extends Job{
|
|
||||||
private final IProject project;
|
|
||||||
public UpdateIndexVersionJob( IProject project, String name ){
|
|
||||||
super( name );
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
IWorkspaceRunnable job = new IWorkspaceRunnable( ){
|
|
||||||
public void run(IProgressMonitor monitor){
|
|
||||||
doProjectUpgrade(project);
|
|
||||||
doSourceIndexerUpgrade(project);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
CCorePlugin.getWorkspace().run(job, project, 0, null);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush current state
|
* Flush current state
|
||||||
*/
|
*/
|
||||||
public synchronized void reset() {
|
public void reset() {
|
||||||
super.reset();
|
|
||||||
|
|
||||||
initializeIndexersMap();
|
|
||||||
this.indexerMap = new HashMap(5);
|
|
||||||
try{
|
try{
|
||||||
monitor.enterWrite();
|
monitor.enterWrite();
|
||||||
initializeIndexerID();
|
super.reset();
|
||||||
} finally {
|
//Set default upgrade values
|
||||||
monitor.exitWrite();
|
CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.DEFAULT_INDEXER_UNIQ_ID);
|
||||||
|
this.indexerMap = new HashMap(5);
|
||||||
|
} finally{
|
||||||
|
monitor.exitWrite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void initializeIndexerID() {
|
|
||||||
IProject[] projects = CCorePlugin.getWorkspace().getRoot().getProjects();
|
|
||||||
//Make sure that all projects are added to the indexer map and updated
|
|
||||||
//where neccesary
|
|
||||||
for (int i=0; i<projects.length; i++){
|
|
||||||
try {
|
|
||||||
if (projects[i].isAccessible())
|
|
||||||
initializeIndexer(projects[i]);
|
|
||||||
} catch (CoreException e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICDTIndexer initializeIndexer(IProject project) throws CoreException {
|
|
||||||
|
|
||||||
ICDTIndexer indexer = null;
|
|
||||||
indexer = (ICDTIndexer) indexerMap.get(project);
|
|
||||||
|
|
||||||
if (indexer == null){
|
|
||||||
String indexerID = null;
|
|
||||||
try {
|
|
||||||
//Indexer has not been created yet for this session
|
|
||||||
//Check to see if the indexer has been set in a session property
|
|
||||||
indexerID = (String) project.getSessionProperty(indexerIDKey);
|
|
||||||
} catch (CoreException e) {}
|
|
||||||
|
|
||||||
if (indexerID == null){
|
|
||||||
try{
|
|
||||||
//Need to load the indexer from descriptor
|
|
||||||
indexerID = loadIndexerIDFromCDescriptor(project);
|
|
||||||
} catch (CoreException e){}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Make sure that we have an indexer ID
|
|
||||||
if (indexerID == null &&
|
|
||||||
enableUpdates) {
|
|
||||||
//No persisted info on file? Must be old project - run temp. upgrade
|
|
||||||
UpdateIndexVersionJob job = new UpdateIndexVersionJob(project, "Update Index Version" ); //$NON-NLS-1$
|
|
||||||
|
|
||||||
IProgressMonitor group = this.getIndexJobProgressGroup();
|
|
||||||
|
|
||||||
job.setRule( project );
|
|
||||||
if( group != null )
|
|
||||||
job.setProgressGroup( group, 0 );
|
|
||||||
job.setPriority( Job.SHORT );
|
|
||||||
job.schedule();
|
|
||||||
}
|
|
||||||
|
|
||||||
//If we're asking for the null indexer,return null
|
|
||||||
if (indexerID == null ||
|
|
||||||
indexerID.equals(nullIndexerID))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
//Create the indexer and store it
|
|
||||||
indexer = getIndexer(indexerID);
|
|
||||||
indexerMap.put(project,indexer);
|
|
||||||
|
|
||||||
}
|
|
||||||
return indexer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads indexerID from .cdtproject file
|
|
||||||
* @param project
|
|
||||||
* @param includes
|
|
||||||
* @param symbols
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
private String loadIndexerIDFromCDescriptor(IProject project) throws CoreException {
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true);
|
|
||||||
|
|
||||||
Node child = descriptor.getProjectData(CDT_INDEXER).getFirstChild();
|
|
||||||
|
|
||||||
String indexerID = null;
|
|
||||||
|
|
||||||
while (child != null) {
|
|
||||||
if (child.getNodeName().equals(INDEXER_ID))
|
|
||||||
indexerID = ((Element)child).getAttribute(INDEXER_ID_VALUE);
|
|
||||||
|
|
||||||
child = child.getNextSibling();
|
|
||||||
}
|
|
||||||
|
|
||||||
return indexerID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds all the contributed Indexer Pages to a map
|
|
||||||
*/
|
|
||||||
private void initializeIndexersMap() {
|
|
||||||
|
|
||||||
contributedIndexerMap = new HashMap(5);
|
|
||||||
|
|
||||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "CIndexer"); //$NON-NLS-1$
|
|
||||||
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
|
|
||||||
for (int i = 0; i < infos.length; i++) {
|
|
||||||
if (infos[i].getName().equals("indexer")) { //$NON-NLS-1$
|
|
||||||
String id = infos[i].getAttribute("id"); //$NON-NLS-1$
|
|
||||||
contributedIndexerMap.put(id, new CDTIndexer(infos[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify indexer which scheduled this job that the job has completed
|
* Notify indexer which scheduled this job that the job has completed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected synchronized void jobFinishedNotification(IIndexJob job) {
|
protected void jobFinishedNotification(IIndexJob job) {
|
||||||
if (job instanceof IndexRequest ){
|
if (job instanceof IndexRequest ){
|
||||||
IndexRequest indexRequest = (IndexRequest) job;
|
IndexRequest indexRequest = (IndexRequest) job;
|
||||||
IPath path = indexRequest.getIndexPath();
|
IPath path = indexRequest.getIndexPath();
|
||||||
|
@ -262,10 +90,6 @@ public class IndexManager extends JobManager{
|
||||||
indexer.indexJobFinishedNotification(job);
|
indexer.indexJobFinishedNotification(job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param project
|
* @param project
|
||||||
* @param element
|
* @param element
|
||||||
|
@ -277,13 +101,6 @@ public class IndexManager extends JobManager{
|
||||||
|
|
||||||
if (indexer != null)
|
if (indexer != null)
|
||||||
indexer.addRequest(element, delta);
|
indexer.addRequest(element, delta);
|
||||||
else{
|
|
||||||
//Maybe indexer hasn't been created for this project yet
|
|
||||||
//Scenarios:
|
|
||||||
//1) New Project created - UI has set env var telling which indexer to use
|
|
||||||
//2) Existing Project - the indexer has been persisted to file, need to load it up from CCorePlugin
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -375,26 +192,21 @@ public class IndexManager extends JobManager{
|
||||||
return new CIndexStorage(indexer);
|
return new CIndexStorage(indexer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int getJobStart(){
|
public int getJobStart(){
|
||||||
return jobStart;
|
return jobStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int getJobEnd(){
|
public int getJobEnd(){
|
||||||
return jobEnd;
|
return jobEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the job at position in the awaiting job queue
|
* Returns the job at position in the awaiting job queue
|
||||||
* @param position
|
* @param position
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public synchronized IIndexJob getAwaitingJobAt(int position){
|
public IIndexJob getAwaitingJobAt(int position){
|
||||||
return this.awaitingJobs[position];
|
return this.awaitingJobs[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if the indexer associated with this project
|
* Check to see if the indexer associated with this project
|
||||||
* requires dependency update notifications
|
* requires dependency update notifications
|
||||||
|
@ -408,238 +220,95 @@ public class IndexManager extends JobManager{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized ICDTIndexer getIndexerForProject(IProject project){
|
public ICDTIndexer getIndexerForProject(IProject project){
|
||||||
//Make sure we're not updating list
|
|
||||||
monitor.enterRead();
|
|
||||||
//All indexers that were previously persisted should have been loaded at
|
|
||||||
//this point
|
|
||||||
ICDTIndexer indexer = null;
|
ICDTIndexer indexer = null;
|
||||||
indexer = (ICDTIndexer) indexerMap.get(project);
|
|
||||||
try {
|
try {
|
||||||
if (indexer == null){
|
//Make sure we're not updating list
|
||||||
String indexerID = null;
|
monitor.enterRead();
|
||||||
|
|
||||||
|
//See if indexer exists already
|
||||||
|
indexer = (ICDTIndexer) indexerMap.get(project);
|
||||||
|
|
||||||
|
//Create the indexer and store it
|
||||||
|
if (indexer == null) {
|
||||||
|
monitor.exitRead();
|
||||||
try {
|
try {
|
||||||
//Indexer has not been created yet for this session
|
monitor.enterWrite();
|
||||||
//Check to see if the indexer has been set in a session property
|
indexer = getIndexer(project);
|
||||||
indexerID = (String) project.getSessionProperty(indexerIDKey);
|
//Make sure we're not putting null in map
|
||||||
} catch (CoreException e) {}
|
if (indexer != null)
|
||||||
|
indexerMap.put(project,indexer);
|
||||||
//Project was either closed at startup or imported
|
} finally{
|
||||||
if (indexerID == null &&
|
monitor.exitWriteEnterRead();
|
||||||
project.isAccessible()){
|
|
||||||
try {
|
|
||||||
indexer=initializeIndexer(project);
|
|
||||||
} catch (CoreException e1) {}
|
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
//Create the indexer and store it
|
|
||||||
indexer = getIndexer(indexerID);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Make sure we're not putting null in map
|
|
||||||
if (indexer != null)
|
|
||||||
indexerMap.put(project,indexer);
|
|
||||||
}
|
}
|
||||||
} finally {
|
return indexer;
|
||||||
monitor.exitRead();
|
|
||||||
|
}finally {
|
||||||
|
monitor.exitRead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICDTIndexer getDefaultIndexer(IProject project) throws CoreException {
|
||||||
|
ICDTIndexer indexer = null;
|
||||||
|
String id = CCorePlugin.getDefault().getPluginPreferences().getDefaultString(CCorePlugin.PREF_INDEXER);
|
||||||
|
if (id == null || id.length() == 0) {
|
||||||
|
id = CCorePlugin.DEFAULT_INDEXER_UNIQ_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.INDEXER_SIMPLE_ID);
|
||||||
|
IExtension extension = extensionPoint.getExtension(id);
|
||||||
|
if (extension != null) {
|
||||||
|
IConfigurationElement element[] = extension.getConfigurationElements();
|
||||||
|
for (int i = 0; i < element.length; i++) {
|
||||||
|
if (element[i].getName().equalsIgnoreCase("cextension")) { //$NON-NLS-1$
|
||||||
|
indexer = (ICDTIndexer) element[i].createExecutableExtension("run"); //$NON-NLS-1$
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,"No Indexer Found", null); //$NON-NLS-1$
|
||||||
|
throw new CoreException(s);
|
||||||
|
}
|
||||||
return indexer;
|
return indexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected ICDTIndexer getIndexer(IProject project) {
|
||||||
* @param project
|
ICDTIndexer indexer = null;
|
||||||
*/
|
try{
|
||||||
private synchronized void doSourceIndexerUpgrade(IProject project) {
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project,true);
|
||||||
ICDescriptor descriptor = null;
|
ICExtensionReference[] cextensions = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID, true);
|
||||||
Element rootElement = null;
|
|
||||||
IProject newProject = null;
|
|
||||||
|
|
||||||
try {
|
if (cextensions != null && cextensions.length > 0)
|
||||||
newProject = project;
|
indexer = (ICDTIndexer) cextensions[0].createExtension();
|
||||||
descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
|
|
||||||
rootElement = descriptor.getProjectData(SourceIndexer.SOURCE_INDEXER);
|
|
||||||
|
|
||||||
// Clear out all current children
|
|
||||||
Node child = rootElement.getFirstChild();
|
|
||||||
while (child != null) {
|
|
||||||
rootElement.removeChild(child);
|
|
||||||
child = rootElement.getFirstChild();
|
|
||||||
}
|
|
||||||
Document doc = rootElement.getOwnerDocument();
|
|
||||||
|
|
||||||
|
} catch (CoreException e){}
|
||||||
saveIndexerEnabled(upgradeIndexEnabled, rootElement, doc);
|
|
||||||
saveIndexerProblemsEnabled( upgradeIndexProblems, rootElement, doc );
|
if (indexer == null)
|
||||||
|
|
||||||
descriptor.saveProjectData();
|
|
||||||
|
|
||||||
//Update project session property
|
|
||||||
|
|
||||||
project.setSessionProperty(SourceIndexer.activationKey,new Boolean(upgradeIndexEnabled));
|
|
||||||
project.setSessionProperty(SourceIndexer.problemsActivationKey, new Integer( upgradeIndexProblems ));
|
|
||||||
|
|
||||||
} catch (CoreException e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void saveIndexerEnabled (boolean indexerEnabled, Element rootElement, Document doc ) {
|
|
||||||
|
|
||||||
Element indexEnabled = doc.createElement(SourceIndexer.INDEXER_ENABLED);
|
|
||||||
Boolean tempValue= new Boolean(indexerEnabled);
|
|
||||||
|
|
||||||
indexEnabled.setAttribute(SourceIndexer.INDEXER_VALUE,tempValue.toString());
|
|
||||||
rootElement.appendChild(indexEnabled);
|
|
||||||
|
|
||||||
}
|
|
||||||
private static void saveIndexerProblemsEnabled ( int problemValues, Element rootElement, Document doc ) {
|
|
||||||
|
|
||||||
Element enabled = doc.createElement(SourceIndexer.INDEXER_PROBLEMS_ENABLED);
|
|
||||||
Integer tempValue= new Integer( problemValues );
|
|
||||||
|
|
||||||
enabled.setAttribute(SourceIndexer.INDEXER_PROBLEMS_VALUE, tempValue.toString());
|
|
||||||
rootElement.appendChild(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private synchronized String doProjectUpgrade(IProject project) {
|
|
||||||
ICDescriptor descriptor = null;
|
|
||||||
Element rootElement = null;
|
|
||||||
IProject newProject = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Get the old values from .cdtproject before upgrading
|
indexer = getDefaultIndexer(project);
|
||||||
Boolean tempEnabled = loadIndexerEnabledFromCDescriptor(project);
|
|
||||||
if (tempEnabled != null)
|
|
||||||
upgradeIndexEnabled = tempEnabled.booleanValue();
|
|
||||||
|
|
||||||
Integer tempProblems = loadIndexerProblemsEnabledFromCDescriptor(project);
|
|
||||||
if (tempProblems != null)
|
|
||||||
upgradeIndexProblems = tempProblems.intValue();
|
|
||||||
|
|
||||||
} catch (CoreException e1) {}
|
} catch (CoreException e1) {}
|
||||||
|
|
||||||
|
|
||||||
//For now all upgrades will be to the old source indexer
|
|
||||||
String indexerPageID = "org.eclipse.cdt.ui.originalSourceIndexerUI"; //$NON-NLS-1$
|
|
||||||
String indexerID = "org.eclipse.cdt.core.originalsourceindexer"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
try {
|
|
||||||
newProject = project;
|
|
||||||
descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
|
|
||||||
rootElement = descriptor.getProjectData(IndexManager.CDT_INDEXER);
|
|
||||||
|
|
||||||
// Clear out all current children
|
|
||||||
Node child = rootElement.getFirstChild();
|
|
||||||
while (child != null) {
|
|
||||||
rootElement.removeChild(child);
|
|
||||||
child = rootElement.getFirstChild();
|
|
||||||
}
|
|
||||||
Document doc = rootElement.getOwnerDocument();
|
|
||||||
|
|
||||||
saveIndexerInfo(indexerID, indexerPageID, rootElement, doc);
|
|
||||||
|
|
||||||
descriptor.saveProjectData();
|
|
||||||
|
|
||||||
//Update project session property
|
|
||||||
|
|
||||||
project.setSessionProperty(IndexManager.indexerIDKey, indexerID);
|
|
||||||
//project.setSessionProperty(indexerUIIDKey, indexerPageID);
|
|
||||||
|
|
||||||
} catch (CoreException e) {}
|
return indexer;
|
||||||
|
|
||||||
return indexerID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static void saveIndexerInfo (String indexerID, String indexerUIID, Element rootElement, Document doc ) {
|
|
||||||
|
|
||||||
//Save the indexer id
|
|
||||||
Element indexerIDElement = doc.createElement(IndexManager.INDEXER_ID);
|
|
||||||
indexerIDElement.setAttribute(IndexManager.INDEXER_ID_VALUE,indexerID);
|
|
||||||
rootElement.appendChild(indexerIDElement);
|
|
||||||
|
|
||||||
//Save the indexer UI id
|
|
||||||
Element indexerUIIDElement = doc.createElement("indexerUI"); //$NON-NLS-1$
|
|
||||||
indexerUIIDElement.setAttribute("indexerUIValue",indexerUIID); //$NON-NLS-1$
|
|
||||||
rootElement.appendChild(indexerUIIDElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean loadIndexerEnabledFromCDescriptor(IProject project) throws CoreException {
|
|
||||||
// Check if we have the property in the descriptor
|
|
||||||
// We pass false since we do not want to create the descriptor if it does not exists.
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
|
||||||
Boolean strBool = null;
|
|
||||||
if (descriptor != null) {
|
|
||||||
Node child = descriptor.getProjectData(CDT_INDEXER).getFirstChild();
|
|
||||||
|
|
||||||
while (child != null) {
|
|
||||||
if (child.getNodeName().equals(SourceIndexer.INDEXER_ENABLED))
|
|
||||||
strBool = Boolean.valueOf(((Element)child).getAttribute(SourceIndexer.INDEXER_VALUE));
|
|
||||||
|
|
||||||
|
|
||||||
child = child.getNextSibling();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return strBool;
|
|
||||||
}
|
|
||||||
private Integer loadIndexerProblemsEnabledFromCDescriptor(IProject project) throws CoreException {
|
|
||||||
// we are only checking for the settings do not create the descriptor.
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
|
||||||
Integer strInt = null;
|
|
||||||
if( descriptor != null ){
|
|
||||||
Node child = descriptor.getProjectData(CDT_INDEXER).getFirstChild();
|
|
||||||
|
|
||||||
while (child != null) {
|
|
||||||
if (child.getNodeName().equals(SourceIndexer.INDEXER_PROBLEMS_ENABLED)){
|
|
||||||
String val = ((Element)child).getAttribute(SourceIndexer.INDEXER_PROBLEMS_VALUE);
|
|
||||||
try{
|
|
||||||
strInt = Integer.valueOf( val );
|
|
||||||
} catch( NumberFormatException e ){
|
|
||||||
//some old projects might have a boolean stored, translate that into just preprocessors
|
|
||||||
Boolean bool = Boolean.valueOf( val );
|
|
||||||
if( bool.booleanValue() )
|
|
||||||
strInt = new Integer( SourceIndexer.PREPROCESSOR_PROBLEMS_BIT );
|
|
||||||
else
|
|
||||||
strInt = new Integer( 0 );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
child = child.getNextSibling();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return strInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ICDTIndexer getIndexer(String indexerId) {
|
|
||||||
CDTIndexer configElement = (CDTIndexer) contributedIndexerMap.get(indexerId);
|
|
||||||
if (configElement != null) {
|
|
||||||
try {
|
|
||||||
return configElement.getIndexer();
|
|
||||||
} catch (CoreException e) {}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void notifyIdle(long idlingTime) {
|
protected void notifyIdle(long idlingTime) {
|
||||||
//Notify all indexers
|
//Notify all indexers
|
||||||
if (indexerMap == null)
|
monitor.enterRead();
|
||||||
return;
|
try{
|
||||||
|
if (indexerMap == null)
|
||||||
Set mapKeys = indexerMap.keySet();
|
return;
|
||||||
Iterator i = mapKeys.iterator();
|
|
||||||
while (i.hasNext()){
|
Set mapKeys = indexerMap.keySet();
|
||||||
IProject tempProject = (IProject) i.next();
|
Iterator i = mapKeys.iterator();
|
||||||
ICDTIndexer indexer = (ICDTIndexer) indexerMap.get(tempProject);
|
while (i.hasNext()){
|
||||||
if (indexer != null)
|
IProject tempProject = (IProject) i.next();
|
||||||
indexer.notifyIdle(idlingTime);
|
ICDTIndexer indexer = (ICDTIndexer) indexerMap.get(tempProject);
|
||||||
|
if (indexer != null)
|
||||||
|
indexer.notifyIdle(idlingTime);
|
||||||
|
}
|
||||||
|
} finally{
|
||||||
|
monitor.exitRead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnableUpdates(boolean enableUpdates) {
|
|
||||||
this.enableUpdates = enableUpdates;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
<extension-point id="PathEntryContainerInitializer" name="%PathEntryContainerInitializer" schema="schema/PathEntryContainerInitializer.exsd"/>
|
<extension-point id="PathEntryContainerInitializer" name="%PathEntryContainerInitializer" schema="schema/PathEntryContainerInitializer.exsd"/>
|
||||||
<extension-point id="CodeFormatter" name="%CodeFormatter.name" schema="schema/CodeFormatter.exsd"/>
|
<extension-point id="CodeFormatter" name="%CodeFormatter.name" schema="schema/CodeFormatter.exsd"/>
|
||||||
<extension-point id="CIndexer" name="C/C++ Indexer" schema="schema/CIndexer.exsd"/>
|
<extension-point id="CIndexer" name="C/C++ Indexer" />
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
<!-- Define the list of the Binary Parser provided by the CDT -->
|
<!-- Define the list of the Binary Parser provided by the CDT -->
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
|
@ -528,13 +528,15 @@
|
||||||
<extension point="org.eclipse.core.runtime.preferences">
|
<extension point="org.eclipse.core.runtime.preferences">
|
||||||
<initializer class="org.eclipse.cdt.internal.core.CCorePreferenceInitializer"/>
|
<initializer class="org.eclipse.cdt.internal.core.CCorePreferenceInitializer"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
name="Original C/C++ Indexer"
|
||||||
|
id="originalsourceindexer"
|
||||||
point="org.eclipse.cdt.core.CIndexer">
|
point="org.eclipse.cdt.core.CIndexer">
|
||||||
<indexer
|
<cextension>
|
||||||
class="org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer"
|
<run
|
||||||
name="Original C/C++ Indexer"
|
class="org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer">
|
||||||
id="org.eclipse.cdt.core.originalsourceindexer">
|
</run>
|
||||||
</indexer>
|
</cextension>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
|
|
|
@ -39,38 +39,6 @@
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="indexer">
|
|
||||||
<complexType>
|
|
||||||
<sequence>
|
|
||||||
<element ref="indexer" minOccurs="1" maxOccurs="unbounded"/>
|
|
||||||
</sequence>
|
|
||||||
<attribute name="id" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
a unique name for this indexer
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="name" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
a name that will be used for this indexer in the UI
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="class" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
the class that implements <code>org.eclipse.cdt.core.index2.IIndexer</code>
|
|
||||||
</documentation>
|
|
||||||
<appInfo>
|
|
||||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.index2.IIndexer"/>
|
|
||||||
</appInfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<annotation>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.section type="since"/>
|
<meta.section type="since"/>
|
||||||
|
|
|
@ -76,6 +76,12 @@ public class CCorePlugin extends Plugin {
|
||||||
public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$
|
public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$
|
||||||
public final static String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$
|
public final static String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static final String INDEXER_SIMPLE_ID = "CIndexer"; //$NON-NLS-1$
|
||||||
|
public static final String INDEXER_UNIQ_ID = PLUGIN_ID + "." + INDEXER_SIMPLE_ID; //$NON-NLS-1$
|
||||||
|
public final static String PREF_INDEXER = "indexer"; //$NON-NLS-1$
|
||||||
|
public final static String DEFAULT_INDEXER_SIMPLE_ID = "originalsourceindexer"; //$NON-NLS-1$
|
||||||
|
public final static String DEFAULT_INDEXER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_INDEXER_SIMPLE_ID; //$NON-NLS-1$
|
||||||
|
|
||||||
public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
|
public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
|
||||||
|
|
||||||
// default store for pathentry
|
// default store for pathentry
|
||||||
|
|
|
@ -62,6 +62,7 @@ IndexerOptions.problemReporting = C/C++ Index problem reporting
|
||||||
IndexerOptions.enablePreprocessor = Report &preprocessor problems
|
IndexerOptions.enablePreprocessor = Report &preprocessor problems
|
||||||
IndexerOptions.enableSemantic = Report &semantic problems
|
IndexerOptions.enableSemantic = Report &semantic problems
|
||||||
IndexerOptions.enableSyntactic = Report s&yntactic problems
|
IndexerOptions.enableSyntactic = Report s&yntactic problems
|
||||||
|
IndexerOptiosn.task.savingAttributes = Saving Attributes
|
||||||
|
|
||||||
StatusBarUpdater.num_elements_selected={0} items selected
|
StatusBarUpdater.num_elements_selected={0} items selected
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||||
|
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
|
@ -27,8 +28,11 @@ 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.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.Font;
|
import org.eclipse.swt.graphics.Font;
|
||||||
|
@ -37,9 +41,6 @@ import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Combo;
|
import org.eclipse.swt.widgets.Combo;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Group;
|
import org.eclipse.swt.widgets.Group;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bogdan Gheorghe
|
* @author Bogdan Gheorghe
|
||||||
|
@ -71,7 +72,8 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
private Composite parentComposite;
|
private Composite parentComposite;
|
||||||
private ICOptionPage currentPage;
|
private ICOptionPage currentPage;
|
||||||
|
|
||||||
|
String initialSelected;
|
||||||
|
|
||||||
public IndexerBlock(){
|
public IndexerBlock(){
|
||||||
super(INDEXER_LABEL);
|
super(INDEXER_LABEL);
|
||||||
setDescription(INDEXER_DESCRIPTION);
|
setDescription(INDEXER_DESCRIPTION);
|
||||||
|
@ -104,10 +106,6 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,9 +145,6 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
parent.layout(true);
|
parent.layout(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -176,7 +171,6 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
setCurrentPage(page);
|
setCurrentPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param page
|
* @param page
|
||||||
*/
|
*/
|
||||||
|
@ -184,15 +178,15 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
currentPage = page;
|
currentPage = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected String getCurrentIndexPageId() {
|
protected String getCurrentIndexPageId() {
|
||||||
String selectedIndexPageName = getSelectedIndexerID();
|
String selectedIndexPageName = getSelectedIndexerID();
|
||||||
|
|
||||||
if (selectedIndexPageName == null)
|
if (selectedIndexPageName == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
||||||
String selectedIndexPageId = getIndexerPageId(selectedIndexPageName);
|
String selectedIndexPageId = getIndexerPageId(selectedIndexPageName);
|
||||||
|
|
||||||
return selectedIndexPageId;
|
return selectedIndexPageId;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -239,9 +233,6 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds all the contributed Indexer Pages to a map
|
* Adds all the contributed Indexer Pages to a map
|
||||||
*/
|
*/
|
||||||
|
@ -252,7 +243,7 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
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("indexerUI")) { //$NON-NLS-1$
|
if (infos[i].getName().equals("indexerUI")) { //$NON-NLS-1$
|
||||||
String id = infos[i].getAttribute("id"); //$NON-NLS-1$
|
String id = infos[i].getAttribute("indexerID"); //$NON-NLS-1$
|
||||||
indexerPageMap.put(id, new IndexerPageConfiguration(infos[i]));
|
indexerPageMap.put(id, new IndexerPageConfiguration(infos[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,50 +313,6 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
IProject newProject = null;
|
|
||||||
newProject = getContainer().getProject();
|
|
||||||
|
|
||||||
persistIndexerSettings(newProject, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Persists BasicIndexerBlock settings to disk and allows current indexer page to persist settings
|
|
||||||
* This is needed since we need to pass in the project if we are trying to save changes made to the
|
|
||||||
* property page.
|
|
||||||
*/
|
|
||||||
public void persistIndexerSettings(IProject project, IProgressMonitor monitor) throws CoreException{
|
|
||||||
|
|
||||||
persistIndexerValues(project);
|
|
||||||
|
|
||||||
if (currentPage instanceof AbstractIndexerPage)
|
|
||||||
((AbstractIndexerPage)currentPage).setCurrentProject(project);
|
|
||||||
|
|
||||||
//Give the chosen indexer a chance to persist its values
|
|
||||||
if (currentPage != null){
|
|
||||||
currentPage.performApply(monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void performDefaults() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isIndexEnabled() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Storage section
|
|
||||||
|
|
||||||
public void persistIndexerValues(IProject project){
|
|
||||||
ICDescriptor descriptor = null;
|
|
||||||
Element rootElement = null;
|
|
||||||
IProject newProject = null;
|
|
||||||
|
|
||||||
//Get the currently selected indexer from the UI
|
//Get the currently selected indexer from the UI
|
||||||
String indexerName = getSelectedIndexerID();
|
String indexerName = getSelectedIndexerID();
|
||||||
//If no indexer has been selected, return
|
//If no indexer has been selected, return
|
||||||
|
@ -380,33 +327,91 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Get the id of the indexer that goes along with this UI page - this gets persisted
|
//Get the id of the indexer that goes along with this UI page - this gets persisted
|
||||||
String indexerID = getIndexerIdName(indexerPageID);
|
final String indexerID = getIndexerIdName(indexerPageID);
|
||||||
|
//
|
||||||
try {
|
if (monitor == null) {
|
||||||
newProject = project;
|
monitor = new NullProgressMonitor();
|
||||||
descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
|
|
||||||
rootElement = descriptor.getProjectData(IndexManager.CDT_INDEXER);
|
|
||||||
|
|
||||||
// Clear out all current children
|
|
||||||
Node child = rootElement.getFirstChild();
|
|
||||||
while (child != null) {
|
|
||||||
rootElement.removeChild(child);
|
|
||||||
child = rootElement.getFirstChild();
|
|
||||||
}
|
|
||||||
Document doc = rootElement.getOwnerDocument();
|
|
||||||
|
|
||||||
saveIndexerInfo(indexerID, indexerPageID, rootElement, doc);
|
|
||||||
|
|
||||||
descriptor.saveProjectData();
|
|
||||||
|
|
||||||
//Update project session property
|
|
||||||
|
|
||||||
project.setSessionProperty(IndexManager.indexerIDKey, indexerID);
|
|
||||||
project.setSessionProperty(indexerUIIDKey, indexerPageID);
|
|
||||||
|
|
||||||
} catch (CoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
monitor.beginTask(CUIMessages.getString("IndexerOptions.task.savingAttributes"), 2); //$NON-NLS-1$
|
||||||
|
final String selected = indexerID;
|
||||||
|
|
||||||
|
if (indexerID != null) {
|
||||||
|
ICOptionContainer container = getContainer();
|
||||||
|
IProject project = null;
|
||||||
|
if (container != null){
|
||||||
|
project=container.getProject();
|
||||||
|
} else {
|
||||||
|
project = ((AbstractIndexerPage) currentPage).getCurrentProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( project != null) {
|
||||||
|
ICDescriptorOperation op = new ICDescriptorOperation() {
|
||||||
|
|
||||||
|
public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
|
||||||
|
if (initialSelected == null || !selected.equals(initialSelected)) {
|
||||||
|
descriptor.remove(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
|
descriptor.create(CCorePlugin.INDEXER_UNIQ_ID,indexerID);
|
||||||
|
}
|
||||||
|
monitor.worked(1);
|
||||||
|
// Give a chance to the contributions to save.
|
||||||
|
// We have to do it last to make sure the indexer id
|
||||||
|
// is saved in .cdtproject
|
||||||
|
ICOptionPage page = currentPage; //egetBinaryParserPage(((BinaryParserConfiguration) selected.get(i)).getID());
|
||||||
|
if (page != null && page.getControl() != null) {
|
||||||
|
page.performApply(new SubProgressMonitor(monitor, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(project, op, monitor);
|
||||||
|
} else {
|
||||||
|
if (initialSelected == null || !selected.equals(initialSelected)) {
|
||||||
|
if (container != null){
|
||||||
|
Preferences store = container.getPreferences();
|
||||||
|
if (store != null) {
|
||||||
|
store.setValue(CCorePlugin.PREF_INDEXER, indexerID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitor.worked(1);
|
||||||
|
// Give a chance to the contributions to save.
|
||||||
|
ICOptionPage page = currentPage;
|
||||||
|
if (page != null && page.getControl() != null) {
|
||||||
|
page.performApply(new SubProgressMonitor(monitor, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
initialSelected = selected;
|
||||||
|
}
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persists BasicIndexerBlock settings to disk and allows current indexer page to persist settings
|
||||||
|
* This is needed since we need to pass in the project if we are trying to save changes made to the
|
||||||
|
* property page.
|
||||||
|
*/
|
||||||
|
public void persistIndexerSettings(IProject project, IProgressMonitor monitor) throws CoreException{
|
||||||
|
if (currentPage instanceof AbstractIndexerPage)
|
||||||
|
((AbstractIndexerPage)currentPage).setCurrentProject(project);
|
||||||
|
|
||||||
|
this.performApply(monitor);
|
||||||
|
/*//Give the chosen indexer a chance to persist its values
|
||||||
|
if (currentPage != null){
|
||||||
|
currentPage.performApply(monitor);*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void performDefaults() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isIndexEnabled() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -416,7 +421,12 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
public void setIndexerID(String oldIndexerID, IProject project) {
|
public void setIndexerID(String oldIndexerID, IProject project) {
|
||||||
//Get the corresponding text for the given indexer id
|
//Get the corresponding text for the given indexer id
|
||||||
selectedIndexerId = getIndexerPageName(oldIndexerID);
|
selectedIndexerId = getIndexerPageName(oldIndexerID);
|
||||||
|
|
||||||
|
if (selectedIndexerId == null){
|
||||||
|
CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.DEFAULT_INDEXER_UNIQ_ID);
|
||||||
|
selectedIndexerId = CCorePlugin.DEFAULT_INDEXER_UNIQ_ID;
|
||||||
|
}
|
||||||
|
|
||||||
//Set the appropriate indexer in the combo box
|
//Set the appropriate indexer in the combo box
|
||||||
indexersComboBox.setText(selectedIndexerId);
|
indexersComboBox.setText(selectedIndexerId);
|
||||||
//Load the appropriate page
|
//Load the appropriate page
|
||||||
|
@ -428,19 +438,6 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void saveIndexerInfo (String indexerID, String indexerUIID, Element rootElement, Document doc ) {
|
|
||||||
|
|
||||||
//Save the indexer id
|
|
||||||
Element indexerIDElement = doc.createElement(IndexManager.INDEXER_ID);
|
|
||||||
indexerIDElement.setAttribute(IndexManager.INDEXER_ID_VALUE,indexerID);
|
|
||||||
rootElement.appendChild(indexerIDElement);
|
|
||||||
|
|
||||||
//Save the indexer UI id
|
|
||||||
Element indexerUIIDElement = doc.createElement(INDEXER_UI);
|
|
||||||
indexerUIIDElement.setAttribute(INDEXER_UI_VALUE,indexerUIID);
|
|
||||||
rootElement.appendChild(indexerUIIDElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSelectedIndexerID(){
|
public String getSelectedIndexerID(){
|
||||||
String indexerID = null;
|
String indexerID = null;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.ui.dialogs;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -116,23 +117,13 @@ public class IndexerOptionPropertyPage extends PropertyPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexerID(IProject project) throws CoreException {
|
public String getIndexerID(IProject project) throws CoreException {
|
||||||
//See if there's already one associated with the resource for this session
|
|
||||||
String indexerID = (String) project.getSessionProperty(IndexerBlock.indexerUIIDKey);
|
|
||||||
|
|
||||||
if (indexerID != null)
|
|
||||||
return indexerID;
|
|
||||||
|
|
||||||
// Try to load one for the project
|
|
||||||
indexerID = loadIndexerIDFromCDescriptor(project);
|
|
||||||
|
|
||||||
// There is nothing persisted for the session, or saved in a file so
|
|
||||||
// create a build info object
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project, true);
|
||||||
if (indexerID != null) {
|
ICExtensionReference[] ref = desc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
project.setSessionProperty(IndexerBlock.indexerUIIDKey, indexerID);
|
String indexerID = null;
|
||||||
}
|
for (int i = 0; i < ref.length; i++) {
|
||||||
else{
|
indexerID = ref[i].getID();
|
||||||
//Hmm, no persisted indexer value. Could be an old project - need to run project
|
|
||||||
//update code here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return indexerID;
|
return indexerID;
|
||||||
|
|
|
@ -13,25 +13,29 @@ package org.eclipse.cdt.ui.dialogs;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.core.index.ICDTIndexer;
|
import org.eclipse.cdt.core.index.ICDTIndexer;
|
||||||
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
||||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
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;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Group;
|
import org.eclipse.swt.widgets.Group;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
|
|
||||||
|
|
||||||
public class SourceIndexerBlock extends AbstractIndexerPage {
|
public class SourceIndexerBlock extends AbstractIndexerPage {
|
||||||
|
|
||||||
|
public final static String PREF_INDEX_ENABLED = CUIPlugin.PLUGIN_ID + ".indexenabled"; //$NON-NLS-1$
|
||||||
|
public final static String PREF_INDEX_MARKERS = CUIPlugin.PLUGIN_ID + ".indexmarkers"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String ENABLE_PREPROCESSOR_PROBLEMS = CUIMessages.getString( "IndexerOptions.enablePreprocessor" ); //$NON-NLS-1$
|
private static final String ENABLE_PREPROCESSOR_PROBLEMS = CUIMessages.getString( "IndexerOptions.enablePreprocessor" ); //$NON-NLS-1$
|
||||||
private static final String ENABLE_SEMANTIC_PROBLEMS = CUIMessages.getString( "IndexerOptions.enableSemantic" ); //$NON-NLS-1$
|
private static final String ENABLE_SEMANTIC_PROBLEMS = CUIMessages.getString( "IndexerOptions.enableSemantic" ); //$NON-NLS-1$
|
||||||
private static final String ENABLE_SYNTACTIC_PROBLEMS = CUIMessages.getString( "IndexerOptions.enableSyntactic" ); //$NON-NLS-1$
|
private static final String ENABLE_SYNTACTIC_PROBLEMS = CUIMessages.getString( "IndexerOptions.enableSyntactic" ); //$NON-NLS-1$
|
||||||
|
@ -44,15 +48,63 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
|
||||||
private Button syntacticProblemsEnabled;
|
private Button syntacticProblemsEnabled;
|
||||||
private Button semanticProblemsEnabled;
|
private Button semanticProblemsEnabled;
|
||||||
|
|
||||||
private boolean oldIndexerValue;
|
private boolean oldIndexerValue = false;
|
||||||
private int oldIndexerProblemsValue;
|
private int oldIndexerProblemsValue = 0;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
||||||
this.persistIndexerValues(currentProject);
|
if (monitor == null) {
|
||||||
|
monitor = new NullProgressMonitor();
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
|
||||||
|
ICOptionContainer container = getContainer();
|
||||||
|
IProject proj = null;
|
||||||
|
|
||||||
|
if (container != null){
|
||||||
|
proj = container.getProject();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
proj = currentProject;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proj != null) {
|
||||||
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
|
||||||
|
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
|
if (cext.length > 0) {
|
||||||
|
//initializeIndexerId();
|
||||||
|
for (int i = 0; i < cext.length; i++) {
|
||||||
|
String id = cext[i].getID();
|
||||||
|
//if (cext[i].getID().equals(parserID)) {
|
||||||
|
String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$
|
||||||
|
String indexEnabled = getIndexerEnabledString();
|
||||||
|
if (orig == null || !orig.equals(indexEnabled)) {
|
||||||
|
cext[i].setExtensionData("indexenabled", indexEnabled); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$
|
||||||
|
String indexProblems = getIndexerProblemsValuesString();
|
||||||
|
if (orig == null || !orig.equals(indexProblems)) {
|
||||||
|
cext[i].setExtensionData("indexmarkers", indexProblems); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Preferences store = null;
|
||||||
|
if (container != null){
|
||||||
|
store = container.getPreferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (store != null) {
|
||||||
|
String indexEnabled = getIndexerEnabledString();
|
||||||
|
String indexMarkers = getIndexerProblemsValuesString();
|
||||||
|
store.setValue(PREF_INDEX_ENABLED, indexEnabled);
|
||||||
|
store.setValue(PREF_INDEX_MARKERS, indexMarkers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean indexProject = getIndexerValue();
|
boolean indexProject = getIndexerValue();
|
||||||
|
|
||||||
|
@ -102,82 +154,35 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void persistIndexerValues(IProject project){
|
|
||||||
ICDescriptor descriptor = null;
|
|
||||||
Element rootElement = null;
|
|
||||||
IProject newProject = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
newProject = project;
|
|
||||||
descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject, true);
|
|
||||||
rootElement = descriptor.getProjectData(SourceIndexer.SOURCE_INDEXER);
|
|
||||||
|
|
||||||
// Clear out all current children
|
|
||||||
Node child = rootElement.getFirstChild();
|
|
||||||
while (child != null) {
|
|
||||||
rootElement.removeChild(child);
|
|
||||||
child = rootElement.getFirstChild();
|
|
||||||
}
|
|
||||||
Document doc = rootElement.getOwnerDocument();
|
|
||||||
|
|
||||||
boolean indexProject = getIndexerValue();
|
|
||||||
int problemValues = getIndexerProblemsValues();
|
|
||||||
|
|
||||||
saveIndexerEnabled(indexProject, rootElement, doc);
|
|
||||||
saveIndexerProblemsEnabled( problemValues, rootElement, doc );
|
|
||||||
|
|
||||||
descriptor.saveProjectData();
|
|
||||||
|
|
||||||
//Update project session property
|
|
||||||
|
|
||||||
project.setSessionProperty(SourceIndexer.activationKey,new Boolean(indexProject));
|
|
||||||
project.setSessionProperty(SourceIndexer.problemsActivationKey, new Integer( problemValues ));
|
|
||||||
|
|
||||||
} catch (CoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean getIndexerValue(){
|
public boolean getIndexerValue(){
|
||||||
return indexerEnabled.getSelection();
|
return indexerEnabled.getSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndexerProblemsValues(){
|
public String getIndexerProblemsValuesString(){
|
||||||
int result = 0;
|
int result = 0;
|
||||||
result |= preprocessorProblemsEnabled.getSelection() ? SourceIndexer.PREPROCESSOR_PROBLEMS_BIT : 0;
|
result |= preprocessorProblemsEnabled.getSelection() ? SourceIndexer.PREPROCESSOR_PROBLEMS_BIT : 0;
|
||||||
if( syntacticProblemsEnabled != null )
|
if( syntacticProblemsEnabled != null )
|
||||||
result |= syntacticProblemsEnabled.getSelection() ? SourceIndexer.SYNTACTIC_PROBLEMS_BIT : 0;
|
result |= syntacticProblemsEnabled.getSelection() ? SourceIndexer.SYNTACTIC_PROBLEMS_BIT : 0;
|
||||||
result |= semanticProblemsEnabled.getSelection() ? SourceIndexer.SEMANTIC_PROBLEMS_BIT : 0;
|
result |= semanticProblemsEnabled.getSelection() ? SourceIndexer.SEMANTIC_PROBLEMS_BIT : 0;
|
||||||
return result;
|
Integer tempInt = new Integer(result);
|
||||||
|
|
||||||
|
return tempInt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void saveIndexerEnabled (boolean indexerEnabled, Element rootElement, Document doc ) {
|
private String getIndexerEnabledString(){
|
||||||
|
if (indexerEnabled.getSelection())
|
||||||
|
return "true"; //$NON-NLS-1$
|
||||||
|
|
||||||
Element indexEnabled = doc.createElement(SourceIndexer.INDEXER_ENABLED);
|
return "false"; //$NON-NLS-1$
|
||||||
Boolean tempValue= new Boolean(indexerEnabled);
|
|
||||||
|
|
||||||
indexEnabled.setAttribute(SourceIndexer.INDEXER_VALUE,tempValue.toString());
|
|
||||||
rootElement.appendChild(indexEnabled);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private static void saveIndexerProblemsEnabled ( int problemValues, Element rootElement, Document doc ) {
|
|
||||||
|
|
||||||
Element enabled = doc.createElement(SourceIndexer.INDEXER_PROBLEMS_ENABLED);
|
|
||||||
Integer tempValue= new Integer( problemValues );
|
|
||||||
|
|
||||||
enabled.setAttribute(SourceIndexer.INDEXER_PROBLEMS_VALUE, tempValue.toString());
|
|
||||||
rootElement.appendChild(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.ui.index2.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
|
* @see org.eclipse.cdt.ui.index2.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
|
||||||
*/
|
*/
|
||||||
public void initialize(IProject project) {
|
public void initialize(IProject project) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
oldIndexerValue = getIndexerEnabled(project);
|
loadPersistedValues(project);
|
||||||
oldIndexerProblemsValue = getIndexerProblemsEnabled( project );
|
|
||||||
this.currentProject = project;
|
this.currentProject = project;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -190,53 +195,30 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
|
||||||
setIndexerProblemValues(oldIndexerProblemsValue);
|
setIndexerProblemValues(oldIndexerProblemsValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIndexerEnabled(IProject project) throws CoreException {
|
public void loadPersistedValues(IProject project) throws CoreException {
|
||||||
// See if there's already one associated with the resource for this
|
|
||||||
// session
|
|
||||||
Boolean indexValue = (Boolean) project.getSessionProperty(SourceIndexer.activationKey);
|
|
||||||
|
|
||||||
// Try to load one for the project
|
|
||||||
if (indexValue == null) {
|
|
||||||
indexValue = loadIndexerEnabledFromCDescriptor(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is nothing persisted for the session, or saved in a file so
|
|
||||||
// create a build info object
|
|
||||||
if (indexValue != null) {
|
|
||||||
project.setSessionProperty(SourceIndexer.activationKey, indexValue);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//Hmm, no persisted indexer value. Could be an old project - set to true and persist
|
|
||||||
indexValue = new Boolean(true);
|
|
||||||
setIndexerValue(true);
|
|
||||||
persistIndexerValues(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
return indexValue.booleanValue();
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
||||||
}
|
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
|
if (cext.length > 0) {
|
||||||
|
//initializeIndexerId();
|
||||||
|
for (int i = 0; i < cext.length; i++) {
|
||||||
|
String id = cext[i].getID();
|
||||||
|
//if (cext[i].getID().equals(parserID)) {
|
||||||
|
String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$
|
||||||
|
if (orig != null){
|
||||||
|
Boolean tempBool = new Boolean(orig);
|
||||||
|
oldIndexerValue = tempBool.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
public int getIndexerProblemsEnabled( IProject project ) throws CoreException
|
orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$
|
||||||
{
|
if (orig != null){
|
||||||
// See if there's already one associated with the resource for this session
|
Integer tempInt = new Integer(orig);
|
||||||
Integer value = (Integer) project.getSessionProperty( SourceIndexer.problemsActivationKey );
|
oldIndexerProblemsValue = tempInt.intValue();
|
||||||
|
}
|
||||||
// Try to load one for the project
|
//}
|
||||||
if (value == null) {
|
}
|
||||||
value = loadIndexerProblemsEnabledFromCDescriptor(project);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is nothing persisted for the session, or saved in a file so
|
|
||||||
// create a build info object
|
|
||||||
if (value != null) {
|
|
||||||
project.setSessionProperty(SourceIndexer.problemsActivationKey, value);
|
|
||||||
} else {
|
|
||||||
//Hmm, no persisted indexer value. Could be an old project - set all to false and persist
|
|
||||||
value = new Integer( 0 );
|
|
||||||
setIndexerProblemValues( 0 );
|
|
||||||
persistIndexerValues(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
return value.intValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndexerValue(boolean value){
|
public void setIndexerValue(boolean value){
|
||||||
|
@ -250,55 +232,4 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
|
||||||
semanticProblemsEnabled.setSelection( (value & SourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0 );
|
semanticProblemsEnabled.setSelection( (value & SourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads dis from .cdtproject file
|
|
||||||
* @param project
|
|
||||||
* @param includes
|
|
||||||
* @param symbols
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
private Boolean loadIndexerEnabledFromCDescriptor(IProject project) throws CoreException {
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true);
|
|
||||||
|
|
||||||
Node child = descriptor.getProjectData(SourceIndexer.SOURCE_INDEXER).getFirstChild();
|
|
||||||
Boolean strBool = null;
|
|
||||||
|
|
||||||
while (child != null) {
|
|
||||||
if (child.getNodeName().equals(SourceIndexer.INDEXER_ENABLED))
|
|
||||||
strBool = Boolean.valueOf(((Element)child).getAttribute(SourceIndexer.INDEXER_VALUE));
|
|
||||||
|
|
||||||
|
|
||||||
child = child.getNextSibling();
|
|
||||||
}
|
|
||||||
|
|
||||||
return strBool;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer loadIndexerProblemsEnabledFromCDescriptor( IProject project ) throws CoreException
|
|
||||||
{
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true);
|
|
||||||
|
|
||||||
Node child = descriptor.getProjectData(SourceIndexer.SOURCE_INDEXER).getFirstChild();
|
|
||||||
Integer strInt = null;
|
|
||||||
|
|
||||||
while (child != null) {
|
|
||||||
if (child.getNodeName().equals(SourceIndexer.INDEXER_PROBLEMS_ENABLED)) {
|
|
||||||
String val = ((Element)child).getAttribute(SourceIndexer.INDEXER_PROBLEMS_VALUE);
|
|
||||||
try{
|
|
||||||
strInt = Integer.valueOf( val );
|
|
||||||
} catch( NumberFormatException e ){
|
|
||||||
//some old projects might have a boolean stored, translate that into just preprocessors
|
|
||||||
Boolean bool = Boolean.valueOf( val );
|
|
||||||
if( bool.booleanValue() )
|
|
||||||
strInt = new Integer( SourceIndexer.PREPROCESSOR_PROBLEMS_BIT );
|
|
||||||
else
|
|
||||||
strInt = new Integer( 0 );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
child = child.getNextSibling();
|
|
||||||
}
|
|
||||||
return strInt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue