mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 08:15:48 +02:00
Option for indexer to skip implicit references, bug 268383.
This commit is contained in:
parent
0c98984ff0
commit
4b27284fa6
9 changed files with 63 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,7 +9,6 @@
|
|||
* Markus Schorn - initial API and implementation
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.indexer;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -25,39 +24,43 @@ import org.eclipse.cdt.core.parser.IParserLogService;
|
|||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMWriter;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* The base class for standalone index population tools.
|
||||
* The base class for stand-alone index population tools.
|
||||
*
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
*
|
||||
* This class is not thread safe.
|
||||
* </p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class StandaloneIndexer {
|
||||
|
||||
/**
|
||||
* Parser should not skip any references.
|
||||
*/
|
||||
public static final int SKIP_NO_REFERENCES= 0;
|
||||
public static final int SKIP_NO_REFERENCES= PDOMWriter.SKIP_NO_REFERENCES;
|
||||
|
||||
/**
|
||||
* Parser to skip all references.
|
||||
*/
|
||||
public static final int SKIP_ALL_REFERENCES= 1;
|
||||
public static final int SKIP_ALL_REFERENCES= PDOMWriter.SKIP_ALL_REFERENCES;
|
||||
|
||||
/**
|
||||
* Parser to skp type references.
|
||||
* Parser to skip implicit references.
|
||||
*/
|
||||
public static final int SKIP_TYPE_REFERENCES= 2;
|
||||
public static final int SKIP_IMPLICIT_REFERENCES= PDOMWriter.SKIP_IMPLICIT_REFERENCES;
|
||||
|
||||
/**
|
||||
* Parser to skip type references.
|
||||
*/
|
||||
public static final int SKIP_TYPE_REFERENCES= PDOMWriter.SKIP_TYPE_REFERENCES;
|
||||
|
||||
/**
|
||||
* Parser to skip type references.
|
||||
*/
|
||||
public static final int SKIP_MACRO_REFERENCES= PDOMWriter.SKIP_MACRO_REFERENCES;
|
||||
|
||||
/**
|
||||
* Constant for indicating to update all translation units.
|
||||
|
|
|
@ -70,6 +70,7 @@ abstract public class PDOMWriter {
|
|||
public static int SKIP_ALL_REFERENCES= -1;
|
||||
public static int SKIP_TYPE_REFERENCES= 1;
|
||||
public static int SKIP_MACRO_REFERENCES= 2;
|
||||
public static int SKIP_IMPLICIT_REFERENCES= 4;
|
||||
public static int SKIP_NO_REFERENCES= 0;
|
||||
|
||||
private static class Symbols {
|
||||
|
@ -120,7 +121,7 @@ abstract public class PDOMWriter {
|
|||
/**
|
||||
* Determines whether references are skipped or not. Provide one of
|
||||
* {@link #SKIP_ALL_REFERENCES}, {@link #SKIP_NO_REFERENCES} or a combination of
|
||||
* {@link #SKIP_TYPE_REFERENCES} or {@link #SKIP_MACRO_REFERENCES}.
|
||||
* {@link #SKIP_IMPLICIT_REFERENCES}, {@link #SKIP_TYPE_REFERENCES} and {@link #SKIP_MACRO_REFERENCES}.
|
||||
*/
|
||||
public void setSkipReferences(int options) {
|
||||
fSkipReferences= options;
|
||||
|
@ -325,7 +326,7 @@ abstract public class PDOMWriter {
|
|||
}
|
||||
|
||||
// names
|
||||
final IndexerASTVisitor visitor = new IndexerASTVisitor() {
|
||||
final IndexerASTVisitor visitor = new IndexerASTVisitor((fSkipReferences & SKIP_IMPLICIT_REFERENCES) == 0) {
|
||||
@Override
|
||||
public void visit(IASTName name, IASTName caller) {
|
||||
if (fSkipReferences == SKIP_ALL_REFERENCES) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,7 +8,6 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -30,6 +29,7 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
|||
fProperties.put(IndexerPreferences.KEY_INCLUDE_HEURISTICS, String.valueOf(true));
|
||||
fProperties.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, ""); //$NON-NLS-1$
|
||||
fProperties.put(IndexerPreferences.KEY_SKIP_ALL_REFERENCES, String.valueOf(false));
|
||||
fProperties.put(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES, String.valueOf(false));
|
||||
fProperties.put(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES, String.valueOf(false));
|
||||
fProperties.put(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES, String.valueOf(false));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,7 +8,6 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -28,7 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
|
||||
abstract public class IndexerASTVisitor extends ASTVisitor {
|
||||
private static class Definition {
|
||||
|
@ -45,9 +44,9 @@ abstract public class IndexerASTVisitor extends ASTVisitor {
|
|||
private ArrayList<Definition> fStack= new ArrayList<Definition>();
|
||||
private ArrayList<IASTProblem> fProblems= new ArrayList<IASTProblem>();
|
||||
|
||||
public IndexerASTVisitor() {
|
||||
public IndexerASTVisitor(boolean visitImplicitNames) {
|
||||
shouldVisitNames= true;
|
||||
shouldVisitImplicitNames = true;
|
||||
shouldVisitImplicitNames = visitImplicitNames;
|
||||
shouldVisitDeclarations= true;
|
||||
shouldVisitInitializers= true;
|
||||
shouldVisitDeclSpecifiers= true;
|
||||
|
@ -174,7 +173,7 @@ abstract public class IndexerASTVisitor extends ASTVisitor {
|
|||
if (!(fDefinitionNode instanceof IASTFunctionDefinition)) {
|
||||
IASTNode cand= initializer.getParent();
|
||||
if (cand instanceof IASTDeclarator) {
|
||||
cand= CVisitor.findInnermostDeclarator((IASTDeclarator) cand);
|
||||
cand= ASTQueries.findInnermostDeclarator((IASTDeclarator) cand);
|
||||
push(((IASTDeclarator) cand).getName(), initializer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -48,6 +48,7 @@ public class IndexerPreferences {
|
|||
public static final String KEY_INCLUDE_HEURISTICS= "useHeuristicIncludeResolution"; //$NON-NLS-1$
|
||||
public static final String KEY_FILES_TO_PARSE_UP_FRONT= "filesToParseUpFront"; //$NON-NLS-1$
|
||||
public static final String KEY_SKIP_ALL_REFERENCES= "skipReferences"; //$NON-NLS-1$
|
||||
public static final String KEY_SKIP_IMPLICIT_REFERENCES= "skipImplicitReferences"; //$NON-NLS-1$
|
||||
public static final String KEY_SKIP_TYPE_REFERENCES= "skipTypeReferences"; //$NON-NLS-1$
|
||||
public static final String KEY_SKIP_MACRO_REFERENCES= "skipMacroReferences"; //$NON-NLS-1$
|
||||
public static final String KEY_UPDATE_POLICY= "updatePolicy"; //$NON-NLS-1$
|
||||
|
@ -303,6 +304,7 @@ public class IndexerPreferences {
|
|||
prefs.putBoolean(KEY_INDEX_ALL_FILES, false);
|
||||
prefs.putBoolean(KEY_INCLUDE_HEURISTICS, true);
|
||||
prefs.putBoolean(KEY_SKIP_ALL_REFERENCES, false);
|
||||
prefs.putBoolean(KEY_SKIP_IMPLICIT_REFERENCES, false);
|
||||
prefs.putBoolean(KEY_SKIP_TYPE_REFERENCES, false);
|
||||
prefs.putBoolean(KEY_SKIP_MACRO_REFERENCES, false);
|
||||
prefs.put(KEY_INDEX_IMPORT_LOCATION, DEFAULT_INDEX_IMPORT_LOCATION);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,7 +11,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -45,6 +44,8 @@ import org.eclipse.core.runtime.Status;
|
|||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
|
||||
/**
|
||||
* Configures the abstract indexer task suitable for indexing projects.
|
||||
*/
|
||||
|
@ -68,6 +69,9 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
|
|||
}
|
||||
else {
|
||||
int skipRefs= 0;
|
||||
if (checkProperty(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES)) {
|
||||
skipRefs |= SKIP_IMPLICIT_REFERENCES;
|
||||
}
|
||||
if (checkProperty(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES)) {
|
||||
skipRefs |= SKIP_TYPE_REFERENCES;
|
||||
}
|
||||
|
@ -251,12 +255,14 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
|
|||
+ info.fCompletedHeaders + " headers)"); //$NON-NLS-1$
|
||||
boolean allFiles= getIndexAllFiles();
|
||||
boolean skipRefs= checkProperty(IndexerPreferences.KEY_SKIP_ALL_REFERENCES);
|
||||
boolean skipImplRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES);
|
||||
boolean skipTypeRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES);
|
||||
boolean skipMacroRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES);
|
||||
System.out.println(ident + " Options: " //$NON-NLS-1$
|
||||
+ "indexer='" + kind //$NON-NLS-1$
|
||||
+ "', parseAllFiles=" + allFiles //$NON-NLS-1$
|
||||
+ ", skipReferences=" + skipRefs //$NON-NLS-1$
|
||||
+ ", skipImplicitReferences=" + skipImplRefs //$NON-NLS-1$
|
||||
+ ", skipTypeReferences=" + skipTypeRefs //$NON-NLS-1$
|
||||
+ ", skipMacroReferences=" + skipMacroRefs //$NON-NLS-1$
|
||||
+ "."); //$NON-NLS-1$
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -40,6 +40,7 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
private Text fFilesToParseUpFront;
|
||||
private Button fSkipReferences;
|
||||
private Button fSkipTypeReferences;
|
||||
private Button fSkipImplicitReferences;
|
||||
private Button fSkipMacroReferences;
|
||||
|
||||
protected AbstractIndexerPage() {
|
||||
|
@ -60,6 +61,7 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
fAllFiles= createAllFilesButton(page);
|
||||
fIncludeHeuristics= createIncludeHeuristicsButton(page);
|
||||
fSkipReferences= createSkipReferencesButton(page);
|
||||
fSkipImplicitReferences= createSkipImplicitReferencesButton(page);
|
||||
fSkipTypeReferences= createSkipTypeReferencesButton(page);
|
||||
fSkipMacroReferences= createSkipMacroReferencesButton(page);
|
||||
fFilesToParseUpFront= createParseUpFrontTextField(page);
|
||||
|
@ -92,6 +94,10 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
boolean skipReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_ALL_REFERENCES));
|
||||
fSkipReferences.setSelection(skipReferences);
|
||||
}
|
||||
if (fSkipImplicitReferences != null) {
|
||||
boolean skipImplicitReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES));
|
||||
fSkipImplicitReferences.setSelection(skipImplicitReferences);
|
||||
}
|
||||
if (fSkipTypeReferences != null) {
|
||||
boolean skipTypeReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES));
|
||||
fSkipTypeReferences.setSelection(skipTypeReferences);
|
||||
|
@ -125,6 +131,9 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
if (fSkipReferences != null) {
|
||||
props.put(IndexerPreferences.KEY_SKIP_ALL_REFERENCES, String.valueOf(fSkipReferences.getSelection()));
|
||||
}
|
||||
if (fSkipImplicitReferences != null) {
|
||||
props.put(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES, String.valueOf(fSkipImplicitReferences.getSelection()));
|
||||
}
|
||||
if (fSkipTypeReferences != null) {
|
||||
props.put(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES, String.valueOf(fSkipTypeReferences.getSelection()));
|
||||
}
|
||||
|
@ -152,11 +161,15 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
|
||||
public void updateEnablement() {
|
||||
if (fSkipReferences != null) {
|
||||
final boolean skipReferences = fSkipReferences.getSelection();
|
||||
if (fSkipImplicitReferences != null) {
|
||||
fSkipImplicitReferences.setEnabled(!skipReferences);
|
||||
}
|
||||
if (fSkipTypeReferences != null) {
|
||||
fSkipTypeReferences.setEnabled(!fSkipReferences.getSelection());
|
||||
fSkipTypeReferences.setEnabled(!skipReferences);
|
||||
}
|
||||
if (fSkipMacroReferences != null) {
|
||||
fSkipMacroReferences.setEnabled(!fSkipReferences.getSelection());
|
||||
fSkipMacroReferences.setEnabled(!skipReferences);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,6 +200,10 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipAllReferences);
|
||||
}
|
||||
|
||||
private Button createSkipImplicitReferencesButton(Composite page) {
|
||||
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipImplicitReferences);
|
||||
}
|
||||
|
||||
private Button createSkipTypeReferencesButton(Composite page) {
|
||||
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipTypeReferences);
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ import org.eclipse.osgi.util.NLS;
|
|||
*/
|
||||
public class DialogsMessages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.dialogs.DialogsMessages"; //$NON-NLS-1$
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
/** @since 5.1 */
|
||||
public static String AbstractIndexerPage_heuristicIncludes;
|
||||
public static String AbstractIndexerPage_indexAllFiles;
|
||||
public static String AbstractIndexerPage_indexUpFront;
|
||||
public static String AbstractIndexerPage_skipAllReferences;
|
||||
/** @since 5.1 */
|
||||
public static String AbstractIndexerPage_skipImplicitReferences;
|
||||
public static String AbstractIndexerPage_skipTypeReferences;
|
||||
public static String AbstractIndexerPage_skipMacroReferences;
|
||||
public static String CacheSizeBlock_MB;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||
# Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
|
@ -16,6 +16,7 @@ PreferenceScopeBlock_preferenceLink=<a>Configure Workspace Settings...</a>
|
|||
AbstractIndexerPage_heuristicIncludes=Allow heuristic resolution of includes
|
||||
AbstractIndexerPage_indexAllFiles=Index all files (files neither built nor included, also)
|
||||
AbstractIndexerPage_skipAllReferences=Skip all references (Call Hierarchy and Search will not work)
|
||||
AbstractIndexerPage_skipImplicitReferences=Skip implicit references (e.g. overloaded operators)
|
||||
AbstractIndexerPage_skipTypeReferences=Skip type references (Search for type references will not work)
|
||||
AbstractIndexerPage_skipMacroReferences=Skip macro references (Search for macro references will not work)
|
||||
AbstractIndexerPage_indexUpFront=Files to index up-front:
|
||||
|
|
Loading…
Add table
Reference in a new issue