1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

bug 43014, 62979: Reporting IProblems encountered during indexing. Only preprocessor problems to start

This commit is contained in:
Andrew Niefer 2004-05-21 20:33:16 +00:00
parent 34df8b137e
commit 4b1ecbf65b
17 changed files with 470 additions and 91 deletions

View file

@ -1,3 +1,10 @@
2004-05-21 Andrew Niefer
Indexer problem reporting
* index/org/eclipse/cdt/internal/core/messages.properties
* index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java
* index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
* index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
2004-05-18 Bogdan Gheorghe
IndexAllProject - restored the save request.

View file

@ -14,6 +14,9 @@ engine.searching = Searching...
exception.wrongFormat = Wrong format
process.name = CDT Indexer
manager.filesToIndex = {0} files to index
indexerJob = C/C++ Indexer
indexerMarker.prefix= C/C++ Indexer Problem:
indexerMarker.processing= Processing C/C++ Index Markers
convention.illegalIdentifier= Illegal identifier
convention.invalid= Invalid identifier

View file

@ -20,9 +20,11 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.zip.CRC32;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICLogConstants;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.impl.Index;
@ -41,8 +43,12 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -78,11 +84,15 @@ public class IndexManager extends JobManager implements IIndexConstants {
public final static String INDEX_MODEL_ID = CCorePlugin.PLUGIN_ID + ".newindexmodel"; //$NON-NLS-1$
public final static String ACTIVATION = "enable"; //$NON-NLS-1$
public final static String PROBLEM_ACTIVATION = "problemEnable"; //$NON-NLS-1$
public final static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, 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_PROBLEMS_ENABLED = "indexerProblemsEnabled"; //$NON-NLS-1$
public static final String CDT_INDEXER = "cdt_indexer"; //$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 synchronized void aboutToUpdateIndex(IPath path, Integer newIndexState) {
// newIndexState is either UPDATING_STATE or REBUILDING_STATE
@ -309,7 +319,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
try {
//Load value for project
indexValue = loadIndexerEnabledromCDescriptor(project);
indexValue = loadIndexerEnabledFromCDescriptor(project);
if (indexValue != null){
project.setSessionProperty(IndexManager.activationKey, indexValue);
return indexValue.booleanValue();
@ -329,6 +339,35 @@ public class IndexManager extends JobManager implements IIndexConstants {
return false;
}
public boolean isIndexProblemsEnabled(IProject project) {
Boolean value = null;
try {
value = (Boolean) project.getSessionProperty(problemsActivationKey);
} catch (CoreException e) {
}
if (value != null)
return value.booleanValue();
try {
//Load value for project
value = loadIndexerProblemsEnabledFromCDescriptor(project);
if (value != null){
project.setSessionProperty(IndexManager.problemsActivationKey, value);
return value.booleanValue();
}
//TODO: Indexer Block Place holder for Managed Make - take out
value = new Boolean(false);
project.setSessionProperty(IndexManager.problemsActivationKey, value);
return value.booleanValue();
} catch (CoreException e1) {
}
return false;
}
/**
* Index the content of the given source folder.
*/
@ -685,7 +724,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
}
}
private Boolean loadIndexerEnabledromCDescriptor(IProject project) throws CoreException {
private Boolean loadIndexerEnabledFromCDescriptor(IProject project) throws CoreException {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
Node child = descriptor.getProjectData(CDT_INDEXER).getFirstChild();
@ -701,5 +740,43 @@ public class IndexManager extends JobManager implements IIndexConstants {
return strBool;
}
private Boolean loadIndexerProblemsEnabledFromCDescriptor(IProject project) throws CoreException {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
Node child = descriptor.getProjectData(CDT_INDEXER).getFirstChild();
Boolean strBool = null;
while (child != null) {
if (child.getNodeName().equals(INDEXER_PROBLEMS_ENABLED))
strBool = Boolean.valueOf(((Element)child).getAttribute(INDEXER_PROBLEMS_VALUE));
child = child.getNextSibling();
}
return strBool;
}
static private class RemoveIndexMarkersJob extends Job{
private final IProject project;
public RemoveIndexMarkersJob( IProject project, String name ){
super( name );
this.project = project;
}
protected IStatus run(IProgressMonitor monitor) {
try {
project.deleteMarkers( ICModelMarker.INDEXER_MARKER, true, IResource.DEPTH_INFINITE );
} catch (CoreException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
public void removeAllIndexerProblems( IProject project){
String jobName = "remove markers";
RemoveIndexMarkersJob job = new RemoveIndexMarkersJob( project, jobName );
job.setPriority( Job.DECORATE );
job.schedule();
}
}

View file

@ -84,7 +84,11 @@ public class SourceIndexer extends AbstractIndexer {
output.addDocument(document);
// Create a new Parser
SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, resourceFile, timeOut);
//requestor.removeMarkers(resourceFile);
IndexManager manager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
boolean problemsEnabled = manager.isIndexProblemsEnabled( resourceFile.getProject() );
requestor.setProblemMarkersEnabled( problemsEnabled );
requestor.requestRemoveMarkers( resourceFile, null );
//Get the scanner info
IProject currentProject = resourceFile.getProject();
@ -98,7 +102,7 @@ public class SourceIndexer extends AbstractIndexer {
}
//C or CPP?
ParserLanguage language = CoreModel.getDefault().hasCCNature(currentProject) ? ParserLanguage.CPP : ParserLanguage.C;
ParserLanguage language = CoreModel.hasCCNature(currentProject) ? ParserLanguage.CPP : ParserLanguage.C;
IParser parser = null;
@ -149,6 +153,10 @@ public class SourceIndexer extends AbstractIndexer {
}
finally{
requestor.stopTimer();
//if the user disable problem reporting since we last checked, don't report the collected problems
if( manager.isIndexProblemsEnabled( resourceFile.getProject() ) )
requestor.reportProblems();
//Release all resources
parser=null;
currentProject = null;

View file

@ -17,9 +17,14 @@ package org.eclipse.cdt.internal.core.search.indexing;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.parser.DefaultProblemHandler;
import org.eclipse.cdt.core.parser.IProblem;
@ -62,13 +67,20 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.utils.TimeOut;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
/**
* @author bgheorgh
@ -89,9 +101,16 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
private IASTInclusion currentInclude = null;
private LinkedList includeStack = new LinkedList();
private boolean problemMarkersEnabled = false;
private Map problemsMap = null;
private IProgressMonitor pm = new NullProgressMonitor();
private TimeOut timeoutThread = null;
private static final String INDEXER_MARKER_ORIGINATOR = ICModelMarker.INDEXER_MARKER + ".originator"; //$NON-NLS-1$
private static final String INDEXER_MARKER_PREFIX = Util.bind("indexerMarker.prefix" ) + " "; //$NON-NLS-1$ //$NON-NLS-2$
private static final String INDEXER_MARKER_PROCESSING = Util.bind( "indexerMarker.processing" ); //$NON-NLS-1$
public SourceIndexerRequestor(SourceIndexer indexer, IFile resourceFile, TimeOut timeOut) {
super();
this.indexer = indexer;
@ -102,30 +121,30 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
*/
public boolean acceptProblem(IProblem problem) {
/* IASTInclusion include = peekInclude();
IFile tempFile = resourceFile;
int lineNumber = problem.getSourceLineNumber();
if( areProblemMarkersEnabled() && shouldRecordProblem( problem ) ){
IASTInclusion include = peekInclude();
IFile tempFile = resourceFile;
//If we are in an include file, get the include file
if (include != null){
//If we are in an include file, get the include file
if (include != null){
IPath newPath = new Path(include.getFullFileName());
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
}
IPath newPath = new Path(include.getFullFileName());
IPath problemPath = new Path(new String(problem.getOriginatingFileName()));
if( tempFile != null ){
Problem tempProblem = new AddMarkerProblem(tempFile, resourceFile, problem );
if( problemsMap.containsKey( tempFile ) ){
List list = (List) problemsMap.get( tempFile );
list.add( tempProblem );
} else {
List list = new ArrayList();
list.add( new RemoveMarkerProblem( tempFile, resourceFile ) ); //remove existing markers
list.add( tempProblem );
problemsMap.put( tempFile, list );
}
}
}
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
//Needed for external files
if (tempFile == null)
tempFile = resourceFile;
if (!newPath.equals(problemPath)){
lineNumber = include.getStartingLine();
}
}
addMarkers(tempFile,problem, lineNumber);
*/
return DefaultProblemHandler.ruleOnProblem( problem, ParserMode.COMPLETE_PARSE );
}
@ -225,16 +244,15 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
*/
public void enterInclusion(IASTInclusion inclusion) {
// TODO Auto-generated method stub
/* IPath newPath = new Path(inclusion.getFullFileName());
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
if (tempFile !=null){
removeMarkers(tempFile);
if( areProblemMarkersEnabled() ){
IPath newPath = new Path(inclusion.getFullFileName());
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
if (tempFile !=null){
requestRemoveMarkers(tempFile, resourceFile);
} else{
//File is out of workspace
}
}
else{
//File is out of workspace
}*/
IASTInclusion parent = peekInclude();
indexer.addInclude(inclusion, parent);
@ -547,26 +565,55 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
return ParserUtil.createReader(finalPath,workingCopies);
}
protected void processMarkers( List problemsList ){
Iterator i = problemsList.iterator();
while( i.hasNext() ){
Problem prob = (Problem) i.next();
if( prob.isAddProblem() ){
addMarkers( prob.file, prob.originator, prob.getIProblem() );
} else {
removeMarkers( prob.file, prob.originator );
}
}
}
/**
*
*/
public void removeMarkers(IFile resource) {
int depth = IResource.DEPTH_INFINITE;
try {
IMarker[] markers = resource.findMarkers(ICModelMarker.INDEXER_MARKER,true,depth);
if (markers.length > 0){
resource.deleteMarkers(ICModelMarker.INDEXER_MARKER, true, depth);
}
} catch (CoreException e) {
// something went wrong
}
public void removeMarkers(IFile resource, IFile originator) {
if( originator == null ){
//remove all markers
try {
resource.deleteMarkers( ICModelMarker.INDEXER_MARKER, true, IResource.DEPTH_INFINITE );
} catch (CoreException e) {
}
return;
}
// else remove only those markers with matching originator
IMarker[] markers;
try {
markers = resource.findMarkers(ICModelMarker.INDEXER_MARKER, true, IResource.DEPTH_INFINITE);
} catch (CoreException e1) {
return;
}
String origPath = originator.getFullPath().toString();
IMarker mark = null;
String orig = null;
for( int i = 0; i < markers.length; i++ ){
mark = markers[ i ];
try {
orig = (String) mark.getAttribute( INDEXER_MARKER_ORIGINATOR );
if( orig != null && orig.equals( origPath ) ){
mark.delete();
}
} catch (CoreException e) {
}
}
}
private void addMarkers(IFile tempFile, IProblem problem, int lineNumber){
private void addMarkers(IFile tempFile, IFile originator, IProblem problem){
try {
IMarker[] markers = tempFile.findMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_INFINITE);
//we only ever add index markers on the file, so DEPTH_ZERO is far enough
IMarker[] markers = tempFile.findMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_ZERO);
boolean newProblem = true;
@ -580,7 +627,8 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
tempInt = (Integer) tempMarker.getAttribute(IMarker.LINE_NUMBER);
tempMsgString = (String) tempMarker.getAttribute(IMarker.MESSAGE);
if (tempInt.intValue()==problem.getSourceLineNumber() &&
tempMsgString.equals(problem.getMessage())){
tempMsgString.equals( INDEXER_MARKER_PREFIX + problem.getMessage()))
{
newProblem = false;
break;
}
@ -591,11 +639,12 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
IMarker marker = tempFile.createMarker(ICModelMarker.INDEXER_MARKER);
marker.setAttribute(IMarker.LOCATION, problem.getSourceLineNumber());
marker.setAttribute(IMarker.MESSAGE, /*"Resource File: " + resourceFile.getName() + " - " +*/ problem.getMessage());
marker.setAttribute(IMarker.MESSAGE, INDEXER_MARKER_PREFIX + problem.getMessage());
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
marker.setAttribute(IMarker.CHAR_START,-1);
marker.setAttribute(IMarker.CHAR_END, -1);
marker.setAttribute(IMarker.LINE_NUMBER, problem.getSourceLineNumber());
marker.setAttribute(IMarker.CHAR_START, problem.getSourceStart());
marker.setAttribute(IMarker.CHAR_END, problem.getSourceEnd());
marker.setAttribute(INDEXER_MARKER_ORIGINATOR, originator.getFullPath().toString() );
}
} catch (CoreException e) {
@ -649,5 +698,134 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
}
public boolean areProblemMarkersEnabled(){
return problemMarkersEnabled;
}
public void setProblemMarkersEnabled( boolean enabled ){
if( enabled ){
problemsMap = new HashMap();
}
this.problemMarkersEnabled = enabled;
}
public void reportProblems(){
if( !areProblemMarkersEnabled() )
return;
Iterator i = problemsMap.keySet().iterator();
while (i.hasNext()){
IFile resource = (IFile) i.next();
List problemList = (List) problemsMap.get( resource );
//only bother scheduling a job if we have problems to add or remove
if( problemList.size() <= 1 ){
IMarker [] marker;
try {
marker = resource.findMarkers( ICModelMarker.INDEXER_MARKER, true, IResource.DEPTH_ZERO);
} catch (CoreException e) {
continue;
}
if( marker.length == 0 )
continue;
}
String jobName = INDEXER_MARKER_PROCESSING;
jobName += " (";
jobName += resource.getFullPath();
jobName += ')';
ProcessMarkersJob job = new ProcessMarkersJob( resource, problemList, jobName );
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
IProgressMonitor group = indexManager.getIndexJobProgressGroup();
job.setRule( resource );
if( group != null )
job.setProgressGroup( group, 0 );
job.setPriority( Job.DECORATE );
job.schedule();
}
}
public boolean shouldRecordProblem( IProblem problem ){
return problem.checkCategory( IProblem.PREPROCESSOR_RELATED );
}
public void requestRemoveMarkers(IFile resource, IFile originator ){
if( !areProblemMarkersEnabled() )
return;
Problem prob = new RemoveMarkerProblem( resource, originator );
//a remove request will erase any previous requests for this resource
if( problemsMap.containsKey( resource ) ){
List list = (List) problemsMap.get( resource );
list.clear();
list.add( prob );
} else {
List list = new ArrayList();
list.add( prob );
problemsMap.put( resource, list );
}
}
private class ProcessMarkersJob extends Job{
private final List problems;
private final IFile resource;
public ProcessMarkersJob( IFile resource, List problems, String name ){
super( name );
this.problems = problems;
this.resource = resource;
}
protected IStatus run(IProgressMonitor monitor) {
IWorkspaceRunnable job = new IWorkspaceRunnable( ){
public void run(IProgressMonitor monitor){
processMarkers( problems );
}
};
try {
CCorePlugin.getWorkspace().run(job, resource, 0, null);
} catch (CoreException e) {
}
return Status.OK_STATUS;
}
};
abstract private class Problem {
public IFile file;
public IFile originator;
public Problem( IFile file, IFile orig ){
this.file = file;
this.originator = orig;
}
abstract public boolean isAddProblem();
abstract public IProblem getIProblem();
}
private class AddMarkerProblem extends Problem {
private IProblem problem;
public AddMarkerProblem(IFile file, IFile orig, IProblem problem) {
super( file, orig );
this.problem = problem;
}
public boolean isAddProblem(){
return true;
}
public IProblem getIProblem(){
return problem;
}
}
private class RemoveMarkerProblem extends Problem {
public RemoveMarkerProblem(IFile file, IFile orig) {
super(file, orig);
}
public boolean isAddProblem() {
return false;
}
public IProblem getIProblem() {
return null;
}
}
}

View file

@ -48,7 +48,7 @@ ASTProblemFactory.error.semantic.invalidConversionType=Invalid arithmetic conver
LineOffsetReconciler.error.couldNotResetReader=Could not reset Reader
BaseProblemFactory.problemPattern=IProblem : {0} in file: {1} on line: {2, number, integer}.
BaseProblemFactory.problemPattern={0} in file: {1} on line: {2, number, integer}.
ASTProblemFactory.error.semantic.pst.ambiguousLookup=Ambiguity encountered during lookup: {0}
ASTProblemFactory.error.semantic.pst.invalidType=Invalid type encountered in: {0}

View file

@ -1,3 +1,6 @@
2004-05-21 Andrew Niefer
Indexer problems reporting: group problems under the indexer job in progress view
2004-05-21 Andrew Niefer
bug 62731 - [Search] typedefs are appearing as union declarations
* search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java

View file

@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.search.processing;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
/**
@ -26,19 +27,29 @@ public class IndexingJob extends Job {
* @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
*/
IProgressMonitor progressMonitor = null;
IProgressMonitor group = null;
JobManager jobManager = null;
Thread indexThread = null;
static final String JOB_NAME = Util.bind( "indexerJob" ); //$NON-NLS-1$
int ticks = 0;
int maxTicks = 0;
int workDone = 0;
public IndexingJob( Thread thread, JobManager manager )
{
super( "C/C++ Indexer" ); //$NON-NLS-1$
super( JOB_NAME ); //$NON-NLS-1$
group = Platform.getJobManager().createProgressGroup();
group.beginTask( JOB_NAME, 100 );
jobManager = manager;
indexThread = thread;
setPriority( LONG );
setProgressGroup( group, 100 );
tickUp();
schedule();
}
@ -97,9 +108,13 @@ public class IndexingJob extends Job {
return;
int work = (( maxTicks - ticks ) * 100 / maxTicks ) - workDone;
if( work > 0 ){
workDone += work;
progressMonitor.worked( work );
}
workDone += work;
progressMonitor.worked( work );
if( workDone < 0 ) workDone = 0;
}
public IProgressMonitor getProgressGroup(){
return group;
}
}

View file

@ -58,6 +58,13 @@ public abstract class JobManager implements Runnable {
System.out.println("(" + Thread.currentThread() + ") " + log); //$NON-NLS-1$//$NON-NLS-2$
}
public IProgressMonitor getIndexJobProgressGroup(){
if( indexJob == null )
return null;
return indexJob.getProgressGroup();
}
/**
* Invoked exactly once, in background, before starting processing any job
*/

View file

@ -1,3 +1,12 @@
2004-05-21 Andrew Niefer
Indexer Problem reporting (bug 43014, 62979)
* plugin.xml
* plugin.properties
* src/org/eclipse/cdt/internal/ui/CUIMessages.properties
* src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
* src/org/eclipse/cdt/ui/dialogs/IndexerOptionDialogPage.java
* src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java
2004-05-21 Alain Magloire
$&#*$(^#&^$(^#

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 900 B

View file

@ -166,3 +166,5 @@ CEditorFontDefintion.description= The editor text font is used by C/C++ editors.
#--- presentation
CPresentation.label= C/C++
CEditorPresentation.label= Editor
CDTIndexerMarker.label= C/C++ Indexer Markers

View file

@ -619,30 +619,23 @@
<extension
point="org.eclipse.ui.editors.markerAnnotationSpecification">
<specification
colorPreferenceValue="192,192,192"
colorPreferenceValue="254,155,0"
annotationType="org.eclipse.cdt.ui.indexmarker"
verticalRulerPreferenceValue="false"
verticalRulerPreferenceValue="true"
colorPreferenceKey="indexResultIndicationColor"
contributesToHeader="false"
overviewRulerPreferenceValue="false"
overviewRulerPreferenceValue="true"
presentationLayer="3"
textStylePreferenceValue="NONE"
symbolicIcon="warning"
icon="icons/full/obj16/unknown_obj.gif"
label="Index Markers"
textPreferenceValue="false"
label="%CDTIndexerMarker.label"
textPreferenceValue="true"
textPreferenceKey="indexResultIndication"
verticalRulerPreferenceKey="indexResultIndicationInVerticalRuler"
overviewRulerPreferenceKey="indexResultIndicationInOverviewRuler">
</specification>
</extension>
<extension
point="org.eclipse.ui.editors.annotationTypes">
<type
markerType="org.eclipse.cdt.core.indexermarker"
name="org.eclipse.cdt.ui.indexmarker">
</type>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
@ -731,5 +724,9 @@
markerType="org.eclipse.cdt.core.problem"
markerSeverity="0">
</type>
<type
markerType="org.eclipse.cdt.core.indexermarker"
name="org.eclipse.cdt.ui.indexmarker">
</type>
</extension>
</plugin>

View file

@ -49,3 +49,7 @@ AbstractErrorParserBlock.label.unselectAll=Unselect All
AbstractErrorParserBlock.label.errorParsers=Error Parsers
ICElementPropertyConstants.catagory=Binary Info
IndexerOptions.indexer = C/C++ Indexer
IndexerOptions.enableIndexing = Enable C/C++ Indexing
IndexerOptions.enableProblems = Enable C/C++ Index problem reporting

View file

@ -43,9 +43,10 @@ public class IndexerBlock extends AbstractCOptionPage {
IProject newProject = null;
newProject = getContainer().getProject();
optionPage.persistIndexerValue(newProject);
optionPage.persistIndexerValues(newProject);
boolean indexProject = optionPage.getIndexerValue();
if (indexProject && newProject != null)
CCorePlugin.getDefault().getCoreModel().getIndexManager().indexAll(newProject);

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.ui.dialogs;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.DialogPage;
@ -31,7 +32,12 @@ import org.w3c.dom.Node;
public class IndexerOptionDialogPage extends DialogPage {
private static final String ENABLE_PROBLEMS = CUIMessages.getString( "IndexerOptions.enableProblems" ); //$NON-NLS-1$
private static final String ENABLE_INDEXING = CUIMessages.getString( "IndexerOptions.enableIndexing" ); //$NON-NLS-1$
private static final String INDEXER = CUIMessages.getString("IndexerOptions.indexer" ); //$NON-NLS-1$
private Button indexerEnabled;
private Button indexerProblemsEnabled;
public IndexerOptionDialogPage(){
super();
@ -51,9 +57,10 @@ public class IndexerOptionDialogPage extends DialogPage {
Group group= new Group(result, SWT.NONE);
group.setLayout(new GridLayout());
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setText("CDT Indexer"); //$NON-NLS-1$
group.setText( INDEXER );
indexerEnabled = createCheckButton(group, "Enable CDT Indexing"); //$NON-NLS-1$
indexerEnabled = createCheckButton(group, ENABLE_INDEXING );
indexerProblemsEnabled = createCheckButton( group, ENABLE_PROBLEMS );
setControl(result);
}
@ -76,11 +83,19 @@ public class IndexerOptionDialogPage extends DialogPage {
indexerEnabled.setSelection(value);
}
public void setIndexerProblemsValue( boolean value ){
indexerProblemsEnabled.setSelection( value );
}
public boolean getIndexerValue(){
return indexerEnabled.getSelection();
}
public void persistIndexerValue(IProject project){
public boolean getIndexerProblemsValue(){
return indexerProblemsEnabled.getSelection();
}
public void persistIndexerValues(IProject project){
ICDescriptor descriptor = null;
Element rootElement = null;
IProject newProject = null;
@ -100,14 +115,17 @@ public class IndexerOptionDialogPage extends DialogPage {
Document doc = rootElement.getOwnerDocument();
boolean indexProject = getIndexerValue();
boolean problemsEnabled = getIndexerProblemsValue();
saveIndexerEnabled(indexProject, rootElement, doc);
saveIndexerProblemsEnabled( problemsEnabled, rootElement, doc );
descriptor.saveProjectData();
//Update project session property
project.setSessionProperty(IndexManager.activationKey,new Boolean(indexProject));
project.setSessionProperty(IndexManager.problemsActivationKey, new Boolean( problemsEnabled ));
} catch (CoreException e) {
@ -116,7 +134,6 @@ public class IndexerOptionDialogPage extends DialogPage {
}
}
private static void saveIndexerEnabled (boolean indexerEnabled, Element rootElement, Document doc ) {
Element indexEnabled = doc.createElement(IndexManager.INDEXER_ENABLED);
@ -126,4 +143,13 @@ public class IndexerOptionDialogPage extends DialogPage {
rootElement.appendChild(indexEnabled);
}
private static void saveIndexerProblemsEnabled (boolean problemsEnabled, Element rootElement, Document doc ) {
Element enabled = doc.createElement(IndexManager.INDEXER_PROBLEMS_ENABLED);
Boolean tempValue= new Boolean( problemsEnabled );
enabled.setAttribute(IndexManager.INDEXER_PROBLEMS_VALUE,tempValue.toString());
rootElement.appendChild(enabled);
}
}

View file

@ -29,6 +29,7 @@ public class IndexerOptionPropertyPage extends PropertyPage {
private IndexerOptionDialogPage optionPage;
private boolean oldIndexerValue;
private boolean oldIndexerProblemsValue;
public IndexerOptionPropertyPage(){
super();
@ -57,15 +58,16 @@ public class IndexerOptionPropertyPage extends PropertyPage {
private void initialize(){
IProject project = getProject();
try {
oldIndexerValue = getIndexerEnabled(project);
oldIndexerProblemsValue = getIndexerProblemsEnabled( project );
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
optionPage.setIndexerValue(oldIndexerValue);
optionPage.setIndexerProblemsValue( oldIndexerProblemsValue );
}
/*
@ -73,20 +75,24 @@ public class IndexerOptionPropertyPage extends PropertyPage {
*/
public boolean performOk() {
boolean newIndexerValue = optionPage.getIndexerValue();
boolean newIndexerValue = optionPage.getIndexerValue();
boolean newIndexerProblemsValue = optionPage.getIndexerProblemsValue();
if (oldIndexerValue != newIndexerValue){
//persist new value
boolean indexChanged = (oldIndexerValue != newIndexerValue);
boolean problemsChanged = (oldIndexerProblemsValue != newIndexerProblemsValue);
if ( indexChanged || problemsChanged){
//persist new values
IProject tempProject = getProject();
optionPage.persistIndexerValue(tempProject);
optionPage.persistIndexerValues(tempProject);
//if indexer is now on send a index all request
if (newIndexerValue)
if( (indexChanged && newIndexerValue) || (problemsChanged && newIndexerProblemsValue && newIndexerValue) )
CCorePlugin.getDefault().getCoreModel().getIndexManager().indexAll(tempProject);
else if( problemsChanged && !newIndexerProblemsValue ){
CCorePlugin.getDefault().getCoreModel().getIndexManager().removeAllIndexerProblems(tempProject);
}
}
return true;
}
@ -100,15 +106,13 @@ public class IndexerOptionPropertyPage extends PropertyPage {
}
public boolean getIndexerEnabled(IProject project) throws CoreException {
boolean indexerEnabled = false;
// See if there's already one associated with the resource for this
// session
Boolean indexValue = (Boolean) project.getSessionProperty(IndexManager.activationKey);
// Try to load one for the project
if (indexValue == null) {
indexValue = loadIndexerEnabledromCDescriptor(project);
indexValue = loadIndexerEnabledFromCDescriptor(project);
}
// There is nothing persisted for the session, or saved in a file so
@ -120,12 +124,35 @@ public class IndexerOptionPropertyPage extends PropertyPage {
//Hmm, no persisted indexer value. Could be an old project - set to true and persist
indexValue = new Boolean(true);
optionPage.setIndexerValue(true);
optionPage.persistIndexerValue(project);
optionPage.persistIndexerValues(project);
}
return indexValue.booleanValue();
}
public boolean getIndexerProblemsEnabled( IProject project ) throws CoreException
{
// See if there's already one associated with the resource for this session
Boolean value = (Boolean) project.getSessionProperty(IndexManager.problemsActivationKey);
// 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(IndexManager.problemsActivationKey, value);
} else {
//Hmm, no persisted indexer value. Could be an old project - set to false and persist
value = new Boolean(false);
optionPage.setIndexerProblemsValue(false);
optionPage.persistIndexerValues(project);
}
return value.booleanValue();
}
/**
* Loads dis from .cdtproject file
* @param project
@ -133,7 +160,7 @@ public class IndexerOptionPropertyPage extends PropertyPage {
* @param symbols
* @throws CoreException
*/
private Boolean loadIndexerEnabledromCDescriptor(IProject project) throws CoreException {
private Boolean loadIndexerEnabledFromCDescriptor(IProject project) throws CoreException {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
Node child = descriptor.getProjectData(IndexManager.CDT_INDEXER).getFirstChild();
@ -150,5 +177,20 @@ public class IndexerOptionPropertyPage extends PropertyPage {
return strBool;
}
private Boolean loadIndexerProblemsEnabledFromCDescriptor( IProject project ) throws CoreException
{
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
Node child = descriptor.getProjectData(IndexManager.CDT_INDEXER).getFirstChild();
Boolean strBool = null;
while (child != null) {
if (child.getNodeName().equals(IndexManager.INDEXER_PROBLEMS_ENABLED))
strBool = Boolean.valueOf(((Element)child).getAttribute(IndexManager.INDEXER_VALUE));
child = child.getNextSibling();
}
return strBool;
}
}