mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
New DOM AST based indexer and property page.
Indexer infrastructure and CPP/C AST visitors. Generates the same index as the old one. Work in progress: - include directives dependency - problem marker generation
This commit is contained in:
parent
6ad34a2f75
commit
159eeee20f
20 changed files with 1312 additions and 272 deletions
|
@ -1,3 +1,26 @@
|
||||||
|
2005-03-24 Vladimir Hirsl
|
||||||
|
New DOM AST based indexer.
|
||||||
|
Indexer infrastructure and CPP/C AST visitors.
|
||||||
|
Generates the same index as the old one.
|
||||||
|
Work in progress:
|
||||||
|
- include directives dependency
|
||||||
|
- problem marker generation
|
||||||
|
+ index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java
|
||||||
|
+ index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java
|
||||||
|
+ index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMAddCompilationUnitToIndex.java
|
||||||
|
+ index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexer.java
|
||||||
|
+ index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java
|
||||||
|
+ index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexerEncoderUtil.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/AbstractIndexer.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/AddCompilationUnitToIndex.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/AddFileToIndex.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexer.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRequestor.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRunner.java
|
||||||
|
+ index/org/eclipse/cdt/internal/core/search/indexing/IIndexEncodingConstants.java
|
||||||
|
* src/org/eclipse/cdt/core/CCorePlugin.java
|
||||||
|
* plugin.xml
|
||||||
|
|
||||||
2005-03-23 Alain Magloire
|
2005-03-23 Alain Magloire
|
||||||
Fix PR 87443.
|
Fix PR 87443.
|
||||||
* model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
|
* model/org/eclipse/cdt/internal/core/model/DeltaProcessor.java
|
||||||
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
|
||||||
|
public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
|
private DOMSourceIndexerRunner indexer;
|
||||||
|
private IFile resourceFile;
|
||||||
|
private List problems;
|
||||||
|
{
|
||||||
|
shouldVisitNames = true;
|
||||||
|
// shouldVisitDeclarations = false;
|
||||||
|
// shouldVisitInitializers = false;
|
||||||
|
// shouldVisitParameterDeclarations = false;
|
||||||
|
// shouldVisitDeclarators = false;
|
||||||
|
// shouldVisitDeclSpecifiers = false;
|
||||||
|
// shouldVisitExpressions = false;
|
||||||
|
// shouldVisitStatements = false;
|
||||||
|
// shouldVisitTypeIds = false;
|
||||||
|
// shouldVisitEnumerators = false;
|
||||||
|
// shouldVisitTranslationUnit = false;
|
||||||
|
shouldVisitProblems = true;
|
||||||
|
|
||||||
|
// shouldVisitDesignators = false
|
||||||
|
}
|
||||||
|
|
||||||
|
public CGenerateIndexVisitor(DOMSourceIndexerRunner indexer, IFile resourceFile) {
|
||||||
|
super();
|
||||||
|
this.indexer = indexer;
|
||||||
|
this.resourceFile = resourceFile;
|
||||||
|
problems = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public int visit(IASTName name) {
|
||||||
|
//Check to see if this reference actually occurs in the file being indexed
|
||||||
|
//or if it occurs in another file
|
||||||
|
int indexFlag = IndexEncoderUtil.calculateIndexFlags(indexer, name);
|
||||||
|
|
||||||
|
// qualified names are going to be handled segment by segment
|
||||||
|
// if (name instanceof ICPPASTQualifiedName) return PROCESS_CONTINUE;
|
||||||
|
|
||||||
|
try {
|
||||||
|
processName(name, indexFlag);
|
||||||
|
}
|
||||||
|
catch (DOMException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
||||||
|
*/
|
||||||
|
public int visit(IASTProblem problem) {
|
||||||
|
problems.add(problem);
|
||||||
|
return super.visit(problem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param indexFlag
|
||||||
|
* @throws DOMException
|
||||||
|
*/
|
||||||
|
private void processName(IASTName name, int indexFlag) throws DOMException {
|
||||||
|
IBinding binding = name.resolveBinding();
|
||||||
|
// check for IProblemBinding
|
||||||
|
if (binding instanceof IProblemBinding) {
|
||||||
|
IProblemBinding problem = (IProblemBinding) binding;
|
||||||
|
problems.add(problem);
|
||||||
|
if (indexer.isProblemReportingEnabled()) {
|
||||||
|
// TODO report problem
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
processNameBinding(name, binding, indexFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param binding
|
||||||
|
* @param indexFlag
|
||||||
|
* @throws DOMException
|
||||||
|
*/
|
||||||
|
private void processNameBinding(IASTName name, IBinding binding, int indexFlag) throws DOMException {
|
||||||
|
// determine type
|
||||||
|
EntryType entryType = null;
|
||||||
|
if (binding instanceof ICompositeType) {
|
||||||
|
int compositeKey = ((ICompositeType) binding).getKey();
|
||||||
|
ASTNodeProperty prop = name.getPropertyInParent();
|
||||||
|
switch (compositeKey) {
|
||||||
|
case ICompositeType.k_struct:
|
||||||
|
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.FWD_STRUCT;
|
||||||
|
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.STRUCT;
|
||||||
|
break;
|
||||||
|
case ICompositeType.k_union:
|
||||||
|
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.FWD_UNION;
|
||||||
|
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.UNION;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (binding instanceof IEnumeration)
|
||||||
|
entryType = IIndexEncodingConstants.ENUM;
|
||||||
|
else if (binding instanceof ITypedef)
|
||||||
|
entryType = IIndexEncodingConstants.TYPEDEF;
|
||||||
|
else if (binding instanceof IEnumerator)
|
||||||
|
entryType = IIndexEncodingConstants.ENUMERATOR;
|
||||||
|
else if (binding instanceof IField)
|
||||||
|
entryType = IIndexEncodingConstants.FIELD;
|
||||||
|
else if (binding instanceof IParameter ||
|
||||||
|
binding instanceof IVariable)
|
||||||
|
entryType = IIndexEncodingConstants.VAR;
|
||||||
|
else if (binding instanceof IFunction)
|
||||||
|
entryType = IIndexEncodingConstants.FUNCTION;
|
||||||
|
|
||||||
|
if (entryType != null) {
|
||||||
|
if (name.isDeclaration()) {
|
||||||
|
indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry(
|
||||||
|
getFullyQualifiedName(name),
|
||||||
|
entryType,
|
||||||
|
ICSearchConstants.DECLARATIONS),
|
||||||
|
indexFlag);
|
||||||
|
}
|
||||||
|
else if (name.isReference()) {
|
||||||
|
indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry(
|
||||||
|
getFullyQualifiedName(name),
|
||||||
|
entryType,
|
||||||
|
ICSearchConstants.REFERENCES),
|
||||||
|
indexFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private char[][] getFullyQualifiedName(IASTName name) {
|
||||||
|
return new char[][] {name.toCharArray()};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,267 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||||
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBaseClause.CPPBaseProblem;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
|
||||||
|
public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
|
private DOMSourceIndexerRunner indexer;
|
||||||
|
private IFile resourceFile;
|
||||||
|
private List problems;
|
||||||
|
|
||||||
|
{
|
||||||
|
shouldVisitNames = true;
|
||||||
|
// shouldVisitDeclarations = false;
|
||||||
|
// shouldVisitInitializers = false;
|
||||||
|
// shouldVisitParameterDeclarations = false;
|
||||||
|
// shouldVisitDeclarators = false;
|
||||||
|
// shouldVisitDeclSpecifiers = false;
|
||||||
|
// shouldVisitExpressions = false;
|
||||||
|
// shouldVisitStatements = false;
|
||||||
|
// shouldVisitTypeIds = false;
|
||||||
|
// shouldVisitEnumerators = false;
|
||||||
|
// shouldVisitTranslationUnit = false;
|
||||||
|
shouldVisitProblems = true;
|
||||||
|
|
||||||
|
// shouldVisitBaseSpecifiers = false;
|
||||||
|
// shouldVisitNamespaces = false;
|
||||||
|
// shouldVisitTemplateParameters = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CPPGenerateIndexVisitor(DOMSourceIndexerRunner indexer, IFile resourceFile) {
|
||||||
|
super();
|
||||||
|
this.indexer = indexer;
|
||||||
|
this.resourceFile = resourceFile;
|
||||||
|
problems = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public int visit(IASTName name) {
|
||||||
|
//Check to see if this reference actually occurs in the file being indexed
|
||||||
|
//or if it occurs in another file
|
||||||
|
int indexFlag = IndexEncoderUtil.calculateIndexFlags(indexer, name);
|
||||||
|
|
||||||
|
// qualified names are going to be handled segment by segment
|
||||||
|
if (name instanceof ICPPASTQualifiedName) return PROCESS_CONTINUE;
|
||||||
|
|
||||||
|
try {
|
||||||
|
processName(name, indexFlag);
|
||||||
|
}
|
||||||
|
catch (DOMException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
||||||
|
*/
|
||||||
|
public int visit(IASTProblem problem) {
|
||||||
|
problems.add(problem);
|
||||||
|
return super.visit(problem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param indexFlag
|
||||||
|
* @throws DOMException
|
||||||
|
*/
|
||||||
|
private void processName(IASTName name, int indexFlag) throws DOMException {
|
||||||
|
IBinding binding = name.resolveBinding();
|
||||||
|
// check for IProblemBinding
|
||||||
|
if (binding instanceof IProblemBinding) {
|
||||||
|
IProblemBinding problem = (IProblemBinding) binding;
|
||||||
|
problems.add(problem);
|
||||||
|
if (indexer.isProblemReportingEnabled()) {
|
||||||
|
// TODO report problem
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
processNameBinding(name, binding, indexFlag, null); // function will determine limitTo
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private char[][] createEnumeratorFullyQualifiedName(IASTName name) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param binding
|
||||||
|
* @param indexFlag
|
||||||
|
* @param limitTo
|
||||||
|
* @throws DOMException
|
||||||
|
*/
|
||||||
|
private void processNameBinding(IASTName name, IBinding binding, int indexFlag, LimitTo limitTo) throws DOMException {
|
||||||
|
// determine LimitTo
|
||||||
|
if (limitTo == null) {
|
||||||
|
if (name.isDeclaration()) {
|
||||||
|
limitTo = ICSearchConstants.DECLARATIONS;
|
||||||
|
}
|
||||||
|
else if (name.isReference()) {
|
||||||
|
limitTo = ICSearchConstants.REFERENCES;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
limitTo = ICSearchConstants.UNKNOWN_LIMIT_TO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine type
|
||||||
|
EntryType entryType = null;
|
||||||
|
if (binding instanceof ICompositeType) {
|
||||||
|
int compositeKey = ((ICompositeType) binding).getKey();
|
||||||
|
ASTNodeProperty prop = name.getPropertyInParent();
|
||||||
|
switch (compositeKey) {
|
||||||
|
case ICPPClassType.k_class:
|
||||||
|
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.FWD_CLASS;
|
||||||
|
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.CLASS;
|
||||||
|
break;
|
||||||
|
case ICompositeType.k_struct:
|
||||||
|
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.FWD_STRUCT;
|
||||||
|
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.STRUCT;
|
||||||
|
break;
|
||||||
|
case ICompositeType.k_union:
|
||||||
|
if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.FWD_UNION;
|
||||||
|
else if (prop == IASTCompositeTypeSpecifier.TYPE_NAME)
|
||||||
|
entryType = IIndexEncodingConstants.UNION;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (binding instanceof IEnumeration)
|
||||||
|
entryType = IIndexEncodingConstants.ENUM;
|
||||||
|
else if (binding instanceof ITypedef)
|
||||||
|
entryType = IIndexEncodingConstants.TYPEDEF;
|
||||||
|
else if (binding instanceof ICPPNamespace)
|
||||||
|
entryType = IIndexEncodingConstants.NAMESPACE;
|
||||||
|
else if (binding instanceof IEnumerator)
|
||||||
|
entryType = IIndexEncodingConstants.ENUMERATOR;
|
||||||
|
else if (binding instanceof IField)
|
||||||
|
entryType = IIndexEncodingConstants.FIELD;
|
||||||
|
else if (binding instanceof IParameter ||
|
||||||
|
binding instanceof IVariable)
|
||||||
|
entryType = IIndexEncodingConstants.VAR;
|
||||||
|
else if (binding instanceof ICPPMethod)
|
||||||
|
entryType = IIndexEncodingConstants.METHOD;
|
||||||
|
else if (binding instanceof IFunction)
|
||||||
|
entryType = IIndexEncodingConstants.FUNCTION;
|
||||||
|
else if (binding instanceof ICPPUsingDeclaration) {
|
||||||
|
ICPPDelegate[] delegates = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||||
|
for (int i = 0; i < delegates.length; i++) {
|
||||||
|
IBinding orig = delegates[i].getBinding();
|
||||||
|
processNameBinding(name, orig, indexFlag, ICSearchConstants.REFERENCES); // reference to the original binding
|
||||||
|
processNameBinding(name, delegates[i], indexFlag, ICSearchConstants.DECLARATIONS); // declaration of the new name
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entryType != null && limitTo != null) {
|
||||||
|
indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry(
|
||||||
|
getFullyQualifiedName(binding),
|
||||||
|
entryType,
|
||||||
|
limitTo),
|
||||||
|
indexFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add base classes and friends
|
||||||
|
if (binding instanceof ICPPClassType &&
|
||||||
|
limitTo.equals(ICSearchConstants.DECLARATIONS) &&
|
||||||
|
(IIndexEncodingConstants.CLASS.equals(entryType) ||
|
||||||
|
IIndexEncodingConstants.STRUCT.equals(entryType))) {
|
||||||
|
ICPPClassType classBinding = (ICPPClassType) binding;
|
||||||
|
//Get base clauses
|
||||||
|
ICPPBase[] baseClauses = classBinding.getBases();
|
||||||
|
for (int i = 0; i < baseClauses.length; ++i) {
|
||||||
|
if (!(baseClauses[i] instanceof CPPBaseProblem)) {
|
||||||
|
ICompositeType baseClass = (ICompositeType) ((ICPPBase)baseClauses[i]).getBaseClass();
|
||||||
|
indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry(
|
||||||
|
getFullyQualifiedName(baseClass),
|
||||||
|
IIndexEncodingConstants.DERIVED,
|
||||||
|
ICSearchConstants.DECLARATIONS),
|
||||||
|
indexFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Get friends
|
||||||
|
IBinding[] friendClauses = classBinding.getFriends();
|
||||||
|
for (int i = 0; i < friendClauses.length; ++i) {
|
||||||
|
IBinding friendClause = friendClauses[i];
|
||||||
|
if (friendClause instanceof ICompositeType) {
|
||||||
|
indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry(
|
||||||
|
getFullyQualifiedName(friendClause),
|
||||||
|
IIndexEncodingConstants.FRIEND,
|
||||||
|
ICSearchConstants.DECLARATIONS),
|
||||||
|
indexFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param binding
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private char[][] getFullyQualifiedName(IBinding binding) {
|
||||||
|
try {
|
||||||
|
if (binding instanceof ICPPBinding) {
|
||||||
|
return ((ICPPBinding) binding).getQualifiedNameCharArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (DOMException e) {
|
||||||
|
}
|
||||||
|
return new char[][] {binding.getNameCharArray()};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
|
||||||
|
import org.eclipse.cdt.internal.core.index.sourceindexer.AddCompilationUnitToIndex;
|
||||||
|
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
public class DOMAddCompilationUnitToIndex extends AddCompilationUnitToIndex {
|
||||||
|
|
||||||
|
public DOMAddCompilationUnitToIndex(IFile resource, IPath indexedContainer,
|
||||||
|
SourceIndexer indexer, boolean checkEncounteredHeaders) {
|
||||||
|
super(resource, indexedContainer, indexer, checkEncounteredHeaders);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AddCompilationUnitToIndex#indexDocument(org.eclipse.cdt.internal.core.index.IIndex)
|
||||||
|
*/
|
||||||
|
protected boolean indexDocument(IIndex index) throws IOException {
|
||||||
|
if (!initializeContents()) return false;
|
||||||
|
index.add(new IFileDocument(resource, contents), new DOMSourceIndexerRunner(resource, indexer));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.index.sourceindexer.CIndexStorage;
|
||||||
|
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
public class DOMSourceIndexer extends SourceIndexer {
|
||||||
|
|
||||||
|
public DOMSourceIndexer() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer#addSource(org.eclipse.core.resources.IFile, org.eclipse.core.runtime.IPath, boolean)
|
||||||
|
*/
|
||||||
|
public void addSource(IFile resource, IPath indexedContainers, boolean checkEncounteredHeaders) {
|
||||||
|
IProject project = resource.getProject();
|
||||||
|
|
||||||
|
boolean indexEnabled = false;
|
||||||
|
if (project != null)
|
||||||
|
indexEnabled = isIndexEnabled(project);
|
||||||
|
else
|
||||||
|
org.eclipse.cdt.internal.core.model.Util.log(null, "IndexManager addSource: File has no project associated : " + resource.getName(), ICLogConstants.CDT); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (CCorePlugin.getDefault() == null) return;
|
||||||
|
|
||||||
|
if (indexEnabled){
|
||||||
|
DOMAddCompilationUnitToIndex job = new DOMAddCompilationUnitToIndex(resource, indexedContainers, this, checkEncounteredHeaders);
|
||||||
|
|
||||||
|
//If we are in WAITING mode, we need to kick ourselves into enablement
|
||||||
|
if (!jobSet.add(resource.getLocation()) &&
|
||||||
|
indexManager.enabledState()==IndexManager.ENABLED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
if (indexManager.awaitingJobsCount() < CIndexStorage.MAX_FILES_IN_MEMORY) {
|
||||||
|
// reduces the chance that the file is open later on, preventing it from being deleted
|
||||||
|
if (!job.initializeContents()) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.indexManager.request(job);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,199 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
|
import org.eclipse.cdt.core.dom.CDOM;
|
||||||
|
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.parser.ParseError;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
|
||||||
|
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
|
||||||
|
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DOMSourceIndexerRunner indexes source files using the DOMAST. The following items are indexed:
|
||||||
|
* Declarations:
|
||||||
|
* - Classes
|
||||||
|
* - Structs
|
||||||
|
* - Unions
|
||||||
|
* References:
|
||||||
|
* - Classes
|
||||||
|
* - Structs
|
||||||
|
* - Unions
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
|
|
||||||
|
private IFile resourceFile;
|
||||||
|
private SourceIndexer indexer;
|
||||||
|
private boolean problemReportingEnabled = false;
|
||||||
|
|
||||||
|
public DOMSourceIndexerRunner(IFile resource, SourceIndexer indexer) {
|
||||||
|
this.resourceFile = resource;
|
||||||
|
this.indexer = indexer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IIndexerOutput getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFile getResourceFile() {
|
||||||
|
return resourceFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the problemReportingEnabled.
|
||||||
|
*/
|
||||||
|
public boolean isProblemReportingEnabled() {
|
||||||
|
return problemReportingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileTypes(String[] fileTypes) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void indexFile(IDocument document) throws IOException {
|
||||||
|
// Add the name of the file to the index
|
||||||
|
output.addDocument(document);
|
||||||
|
problemReportingEnabled = indexer.indexProblemsEnabled(resourceFile.getProject()) != 0;
|
||||||
|
|
||||||
|
//C or CPP?
|
||||||
|
ParserLanguage language = CoreModel.hasCCNature(resourceFile.getProject()) ?
|
||||||
|
ParserLanguage.CPP : ParserLanguage.C;
|
||||||
|
|
||||||
|
try {
|
||||||
|
IASTTranslationUnit tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||||
|
resourceFile,
|
||||||
|
CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_SAVED_RESOURCES));
|
||||||
|
|
||||||
|
// TODO Use new method to get ordered include directives instead of
|
||||||
|
// IASTTranslationUnit.getIncludeDirectives
|
||||||
|
processIncludeDirectives(tu.getIncludeDirectives());
|
||||||
|
processMacroDefinitions(tu.getMacroDefinitions());
|
||||||
|
|
||||||
|
ASTVisitor visitor = null;
|
||||||
|
if (language == ParserLanguage.CPP) {
|
||||||
|
visitor = new CPPGenerateIndexVisitor(this, resourceFile);
|
||||||
|
} else {
|
||||||
|
visitor = new CGenerateIndexVisitor(this, resourceFile);
|
||||||
|
}
|
||||||
|
tu.accept(visitor);
|
||||||
|
|
||||||
|
if (AbstractIndexer.VERBOSE){
|
||||||
|
AbstractIndexer.verbose("DOM AST TRAVERSAL FINISHED " + resourceFile.getName().toString()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( VirtualMachineError vmErr){
|
||||||
|
if (vmErr instanceof OutOfMemoryError){
|
||||||
|
org.eclipse.cdt.internal.core.model.Util.log(null, "Out Of Memory error: " + vmErr.getMessage() + " on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ParseError e){
|
||||||
|
org.eclipse.cdt.internal.core.model.Util.log(null, "Parser Timeout on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
catch (UnsupportedDialectException e) {
|
||||||
|
org.eclipse.cdt.internal.core.model.Util.log(null, "Unsupported C/C++ dialect on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
if (ex instanceof IOException)
|
||||||
|
throw (IOException) ex;
|
||||||
|
}
|
||||||
|
finally{
|
||||||
|
//if the user disable problem reporting since we last checked, don't report the collected problems
|
||||||
|
// if( manager.indexProblemsEnabled( resourceFile.getProject() ) != 0 )
|
||||||
|
// requestor.reportProblems();
|
||||||
|
//
|
||||||
|
// //Report events
|
||||||
|
// ArrayList filesTrav = requestor.getFilesTraversed();
|
||||||
|
// IndexDelta indexDelta = new IndexDelta(resourceFile.getProject(),filesTrav, IIndexDelta.INDEX_FINISHED_DELTA);
|
||||||
|
// CCorePlugin.getDefault().getCoreModel().getIndexManager().notifyListeners(indexDelta);
|
||||||
|
//Release all resources
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param includeDirectives
|
||||||
|
*/
|
||||||
|
private void processIncludeDirectives(IASTPreprocessorIncludeStatement[] includeDirectives) {
|
||||||
|
IProject resourceProject = resourceFile.getProject();
|
||||||
|
for (int i = 0; i < includeDirectives.length; i++) {
|
||||||
|
String include = includeDirectives[i].getPath();
|
||||||
|
// TODO reimplement when ordered collection becomes available
|
||||||
|
// getOutput().addIncludeRef(include);
|
||||||
|
// // where is this header file included
|
||||||
|
// IASTNodeLocation[] locations = includeDirectives[i].getNodeLocations();
|
||||||
|
// for (int j = 0; j < locations.length; j++) {
|
||||||
|
// if (locations[j] instanceof IASTFileLocation) {
|
||||||
|
// IASTFileLocation fileLocation = (IASTFileLocation) locations[j];
|
||||||
|
// String parent = fileLocation.getFileName();
|
||||||
|
// /* Check to see if this is a header file */
|
||||||
|
// ICFileType type = CCorePlugin.getDefault().getFileType(resourceProject, parent);
|
||||||
|
//
|
||||||
|
// if (type.isHeader()) {
|
||||||
|
// getOutput().addRelatives(include, parent);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
int indexFlag = getOutput().getIndexedFile(
|
||||||
|
getResourceFile().getFullPath().toString()).getFileNumber();
|
||||||
|
getOutput().addRef(IndexEncoderUtil.encodeEntry(
|
||||||
|
new char[][] {include.toCharArray()},
|
||||||
|
IIndexEncodingConstants.INCLUDE,
|
||||||
|
ICSearchConstants.REFERENCES),
|
||||||
|
indexFlag);
|
||||||
|
|
||||||
|
/* See if this file has been encountered before */
|
||||||
|
indexer.haveEncounteredHeader(resourceProject.getFullPath(),new Path(include));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param macroDefinitions
|
||||||
|
*/
|
||||||
|
private void processMacroDefinitions(IASTPreprocessorMacroDefinition[] macroDefinitions) {
|
||||||
|
for (int i = 0; i < macroDefinitions.length; i++) {
|
||||||
|
IASTName macro = macroDefinitions[i].getName();
|
||||||
|
int indexFlag = IndexEncoderUtil.calculateIndexFlags(this, macro);
|
||||||
|
getOutput().addRef(IndexEncoderUtil.encodeEntry(
|
||||||
|
new char[][] {macro.toCharArray()},
|
||||||
|
IIndexEncodingConstants.MACRO,
|
||||||
|
ICSearchConstants.DECLARATIONS),
|
||||||
|
indexFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object)
|
||||||
|
*/
|
||||||
|
protected void addMarkers(IFile tempFile, IFile originator, Object problem) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
|
||||||
|
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
|
||||||
|
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
|
||||||
|
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
public class IndexEncoderUtil {
|
||||||
|
static final char[] encodeEntry(char[][] elementName, EntryType entryType, LimitTo encodeType) {
|
||||||
|
int pos, nameLength = 0;
|
||||||
|
for (int i=0; i < elementName.length; i++){
|
||||||
|
char[] namePart = elementName[i];
|
||||||
|
nameLength += namePart.length;
|
||||||
|
}
|
||||||
|
char[][] encodedTypeNames = null;
|
||||||
|
if (encodeType == ICSearchConstants.DECLARATIONS) {
|
||||||
|
encodedTypeNames = IIndexEncodingConstants.encodedTypeNames_Decl;
|
||||||
|
}
|
||||||
|
else if (encodeType == ICSearchConstants.REFERENCES) {
|
||||||
|
encodedTypeNames = IIndexEncodingConstants.encodedTypeNames_Ref;
|
||||||
|
}
|
||||||
|
char[] encodedTypeName = encodedTypeNames[entryType.toInt()];
|
||||||
|
|
||||||
|
//char[] has to be of size - [type length + length of the name (including qualifiers) +
|
||||||
|
//separators (need one less than fully qualified name length)
|
||||||
|
char[] result = new char[encodedTypeName.length + nameLength + elementName.length - 1];
|
||||||
|
System.arraycopy(encodedTypeName, 0, result, 0, pos = encodedTypeName.length);
|
||||||
|
if (elementName.length > 0) {
|
||||||
|
//Extract the name first
|
||||||
|
char [] tempName = elementName[elementName.length-1];
|
||||||
|
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
||||||
|
pos += tempName.length;
|
||||||
|
}
|
||||||
|
//Extract the qualifiers
|
||||||
|
for (int i=elementName.length - 2; i>=0; i--){
|
||||||
|
result[pos++] = IIndexEncodingConstants.SEPARATOR;
|
||||||
|
char [] tempName = elementName[i];
|
||||||
|
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
||||||
|
pos+=tempName.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AbstractIndexer.VERBOSE)
|
||||||
|
AbstractIndexer.verbose(new String(result));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int calculateIndexFlags(DOMSourceIndexerRunner indexer, IASTName name) {
|
||||||
|
int fileNum= 0;
|
||||||
|
|
||||||
|
//Initialize the file number to be the file number for the file that triggerd
|
||||||
|
//the indexing. Note that we should always be able to get a number for this as
|
||||||
|
//the first step in the Source Indexer is to add the file being indexed to the index
|
||||||
|
//which actually creates an entry for the file in the index.
|
||||||
|
|
||||||
|
IndexedFile mainIndexFile = indexer.getOutput().getIndexedFile(
|
||||||
|
indexer.getResourceFile().getFullPath().toString());
|
||||||
|
if (mainIndexFile != null)
|
||||||
|
fileNum = mainIndexFile.getFileNumber();
|
||||||
|
|
||||||
|
String fileName = null;
|
||||||
|
IASTNodeLocation[] nameLocations = name.getNodeLocations();
|
||||||
|
if (nameLocations.length > 0) {
|
||||||
|
if (nameLocations[0] instanceof IASTFileLocation) {
|
||||||
|
fileName = ((IASTFileLocation) nameLocations[0]).getFileName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileName != null) {
|
||||||
|
//We are not in the file that has triggered the index. Thus, we need to find the
|
||||||
|
//file number for the current file (if it has one). If the current file does not
|
||||||
|
//have a file number, we need to add it to the index.
|
||||||
|
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
||||||
|
String filePath = ""; //$NON-NLS-1$
|
||||||
|
if (tempFile != null){
|
||||||
|
//File is local to workspace
|
||||||
|
filePath = tempFile.getFullPath().toString();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//File is external to workspace
|
||||||
|
filePath = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tempFile.equals(indexer.getResourceFile())) {
|
||||||
|
IndexedFile indFile = indexer.getOutput().getIndexedFile(filePath);
|
||||||
|
if (indFile != null){
|
||||||
|
fileNum = indFile.getFileNumber();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//Need to add file to index
|
||||||
|
if (tempFile != null){
|
||||||
|
indFile = indexer.getOutput().addSecondaryIndexedFile(new IFileDocument(tempFile));
|
||||||
|
if (indFile != null)
|
||||||
|
fileNum = indFile.getFileNumber();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
indFile = indexer.getOutput().addSecondaryExternalIndexedFile(fileName);
|
||||||
|
if (indFile != null)
|
||||||
|
fileNum = indFile.getFileNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,10 +12,15 @@
|
||||||
package org.eclipse.cdt.internal.core.index.sourceindexer;
|
package org.eclipse.cdt.internal.core.index.sourceindexer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.filetype.ICFileType;
|
import org.eclipse.cdt.core.filetype.ICFileType;
|
||||||
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
|
@ -35,15 +40,28 @@ import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexer;
|
import org.eclipse.cdt.internal.core.index.IIndexer;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
|
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
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.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
|
||||||
public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSearchConstants {
|
public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSearchConstants {
|
||||||
|
protected static final String INDEXER_MARKER_PREFIX = Util.bind("indexerMarker.prefix" ) + " "; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
protected static final String INDEXER_MARKER_ORIGINATOR = ICModelMarker.INDEXER_MARKER + ".originator"; //$NON-NLS-1$
|
||||||
|
private static final String INDEXER_MARKER_PROCESSING = Util.bind( "indexerMarker.processing" ); //$NON-NLS-1$
|
||||||
|
|
||||||
IIndexerOutput output;
|
protected IIndexerOutput output;
|
||||||
final static int CLASS = 1;
|
final static int CLASS = 1;
|
||||||
final static int STRUCT = 2;
|
final static int STRUCT = 2;
|
||||||
final static int UNION = 3;
|
final static int UNION = 3;
|
||||||
|
@ -58,6 +76,10 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
|
|
||||||
public static boolean VERBOSE = false;
|
public static boolean VERBOSE = false;
|
||||||
|
|
||||||
|
// problem marker related
|
||||||
|
private int problemMarkersEnabled = 0;
|
||||||
|
private Map problemsMap = null;
|
||||||
|
|
||||||
//IDs defined in plugin.xml for file types
|
//IDs defined in plugin.xml for file types
|
||||||
private final static String C_SOURCE_ID = "org.eclipse.cdt.core.fileType.c_source"; //$NON-NLS-1$
|
private final static String C_SOURCE_ID = "org.eclipse.cdt.core.fileType.c_source"; //$NON-NLS-1$
|
||||||
private final static String C_HEADER_ID = "org.eclipse.cdt.core.fileType.c_header"; //$NON-NLS-1$
|
private final static String C_HEADER_ID = "org.eclipse.cdt.core.fileType.c_header"; //$NON-NLS-1$
|
||||||
|
@ -840,5 +862,205 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
int BOGUS_ENTRY = 1;
|
int BOGUS_ENTRY = 1;
|
||||||
this.output.addRef(encodeEntry(incName, INCLUDE_REF, INCLUDE_REF_LENGTH),fileNumber);
|
this.output.addRef(encodeEntry(incName, INCLUDE_REF, INCLUDE_REF_LENGTH),fileNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 Object getProblem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AddMarkerProblem extends Problem {
|
||||||
|
private Object problem;
|
||||||
|
public AddMarkerProblem(IFile file, IFile orig, Object problem) {
|
||||||
|
super( file, orig );
|
||||||
|
this.problem = problem;
|
||||||
|
}
|
||||||
|
public boolean isAddProblem(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public Object getProblem(){
|
||||||
|
return problem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RemoveMarkerProblem extends Problem {
|
||||||
|
public RemoveMarkerProblem(IFile file, IFile orig) {
|
||||||
|
super(file, orig);
|
||||||
|
}
|
||||||
|
public boolean isAddProblem() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public Object getProblem() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Problem markers ******************************
|
||||||
|
|
||||||
|
|
||||||
|
public boolean areProblemMarkersEnabled(){
|
||||||
|
return problemMarkersEnabled != 0;
|
||||||
|
}
|
||||||
|
public int getProblemMarkersEnabled() {
|
||||||
|
return problemMarkersEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProblemMarkersEnabled(int value) {
|
||||||
|
if (value != 0) {
|
||||||
|
problemsMap = new HashMap();
|
||||||
|
}
|
||||||
|
this.problemMarkersEnabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tempFile - not null
|
||||||
|
* @param resourceFile
|
||||||
|
* @param problem
|
||||||
|
*/
|
||||||
|
public void generateMarkerProblem(IFile tempFile, IFile resourceFile, Object problem) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 += " ("; //$NON-NLS-1$
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProcessMarkersJob extends Job {
|
||||||
|
protected 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.getProblem());
|
||||||
|
} else {
|
||||||
|
removeMarkers(prob.file, prob.originator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected void addMarkers(IFile tempFile, IFile originator, Object problem);
|
||||||
|
|
||||||
|
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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class AddCompilationUnitToIndex extends AddFileToIndex {
|
public class AddCompilationUnitToIndex extends AddFileToIndex {
|
||||||
char[] contents;
|
protected char[] contents;
|
||||||
|
|
||||||
public AddCompilationUnitToIndex(IFile resource, IPath indexedContainer, SourceIndexer indexer, boolean checkEncounteredHeaders) {
|
public AddCompilationUnitToIndex(IFile resource, IPath indexedContainer, SourceIndexer indexer, boolean checkEncounteredHeaders) {
|
||||||
super(resource, indexedContainer, indexer, checkEncounteredHeaders);
|
super(resource, indexedContainer, indexer, checkEncounteredHeaders);
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public abstract class AddFileToIndex extends IndexRequest {
|
public abstract class AddFileToIndex extends IndexRequest {
|
||||||
IFile resource;
|
protected IFile resource;
|
||||||
private boolean checkEncounteredHeaders;
|
private boolean checkEncounteredHeaders;
|
||||||
|
|
||||||
public AddFileToIndex(IFile resource, IPath indexPath, SourceIndexer indexer, boolean checkEncounteredHeaders) {
|
public AddFileToIndex(IFile resource, IPath indexPath, SourceIndexer indexer, boolean checkEncounteredHeaders) {
|
||||||
|
|
|
@ -89,9 +89,9 @@ public class SourceIndexer extends AbstractCExtension implements ICDTIndexer {
|
||||||
|
|
||||||
private CIndexStorage indexStorage = null;
|
private CIndexStorage indexStorage = null;
|
||||||
public ReadWriteMonitor storageMonitor = null;
|
public ReadWriteMonitor storageMonitor = null;
|
||||||
private IndexManager indexManager = null;
|
protected IndexManager indexManager = null;
|
||||||
|
|
||||||
private HashSet jobSet = null;
|
protected HashSet jobSet = null;
|
||||||
private boolean indexEnabled = false;
|
private boolean indexEnabled = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,15 +17,11 @@ package org.eclipse.cdt.internal.core.index.sourceindexer;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.filetype.ICFileType;
|
import org.eclipse.cdt.core.filetype.ICFileType;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
@ -68,25 +64,16 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
|
||||||
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
|
import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
|
||||||
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
|
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IndexProblemHandler;
|
import org.eclipse.cdt.internal.core.search.indexing.IndexProblemHandler;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IMarker;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
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.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bgheorgh
|
* @author bgheorgh
|
||||||
|
@ -107,15 +94,8 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
private IASTInclusion currentInclude = null;
|
private IASTInclusion currentInclude = null;
|
||||||
private LinkedList includeStack = new LinkedList();
|
private LinkedList includeStack = new LinkedList();
|
||||||
|
|
||||||
private int problemMarkersEnabled = 0;
|
|
||||||
private Map problemsMap = null;
|
|
||||||
|
|
||||||
private IProgressMonitor pm = new NullProgressMonitor();
|
private IProgressMonitor pm = new NullProgressMonitor();
|
||||||
|
|
||||||
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$
|
|
||||||
|
|
||||||
private ArrayList filesTraversed = null;
|
private ArrayList filesTraversed = null;
|
||||||
private IParser parser;
|
private IParser parser;
|
||||||
|
|
||||||
|
@ -128,7 +108,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptProblem(IProblem problem) {
|
public boolean acceptProblem(IProblem problem) {
|
||||||
if( areProblemMarkersEnabled() && shouldRecordProblem( problem ) ){
|
if( indexer.areProblemMarkersEnabled() && shouldRecordProblem( problem ) ){
|
||||||
IASTInclusion include = peekInclude();
|
IASTInclusion include = peekInclude();
|
||||||
IFile tempFile = resourceFile;
|
IFile tempFile = resourceFile;
|
||||||
|
|
||||||
|
@ -139,16 +119,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
}
|
}
|
||||||
|
|
||||||
if( tempFile != null ){
|
if( tempFile != null ){
|
||||||
Problem tempProblem = new AddMarkerProblem(tempFile, resourceFile, problem );
|
indexer.generateMarkerProblem(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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,11 +183,11 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {}
|
public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {}
|
||||||
|
|
||||||
public void enterInclusion(IASTInclusion inclusion) {
|
public void enterInclusion(IASTInclusion inclusion) {
|
||||||
if( areProblemMarkersEnabled() ){
|
if( indexer.areProblemMarkersEnabled() ){
|
||||||
IPath newPath = new Path(inclusion.getFullFileName());
|
IPath newPath = new Path(inclusion.getFullFileName());
|
||||||
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
|
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
|
||||||
if (tempFile !=null){
|
if (tempFile !=null){
|
||||||
requestRemoveMarkers(tempFile, resourceFile);
|
indexer.requestRemoveMarkers(tempFile, resourceFile);
|
||||||
} else{
|
} else{
|
||||||
//File is out of workspace
|
//File is out of workspace
|
||||||
}
|
}
|
||||||
|
@ -488,153 +459,13 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
return ParserUtil.createReader(finalPath,workingCopies);
|
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, 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, IFile originator, IProblem problem){
|
|
||||||
try {
|
|
||||||
//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;
|
|
||||||
|
|
||||||
if (markers.length > 0){
|
|
||||||
IMarker tempMarker = null;
|
|
||||||
Integer tempInt = null;
|
|
||||||
String tempMsgString = null;
|
|
||||||
|
|
||||||
for (int i=0; i<markers.length; i++){
|
|
||||||
tempMarker = markers[i];
|
|
||||||
tempInt = (Integer) tempMarker.getAttribute(IMarker.LINE_NUMBER);
|
|
||||||
tempMsgString = (String) tempMarker.getAttribute(IMarker.MESSAGE);
|
|
||||||
if (tempInt != null && tempInt.intValue()==problem.getSourceLineNumber() &&
|
|
||||||
tempMsgString.equalsIgnoreCase( INDEXER_MARKER_PREFIX + problem.getMessage()))
|
|
||||||
{
|
|
||||||
newProblem = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newProblem){
|
|
||||||
IMarker marker = tempFile.createMarker(ICModelMarker.INDEXER_MARKER);
|
|
||||||
int start = problem.getSourceStart();
|
|
||||||
int end = problem.getSourceEnd();
|
|
||||||
if( end <= start )
|
|
||||||
end = start + 1;
|
|
||||||
marker.setAttribute(IMarker.LOCATION, problem.getSourceLineNumber());
|
|
||||||
marker.setAttribute(IMarker.MESSAGE, INDEXER_MARKER_PREFIX + problem.getMessage());
|
|
||||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
|
||||||
marker.setAttribute(IMarker.LINE_NUMBER, problem.getSourceLineNumber());
|
|
||||||
marker.setAttribute(IMarker.CHAR_START, start);
|
|
||||||
marker.setAttribute(IMarker.CHAR_END, end);
|
|
||||||
marker.setAttribute(INDEXER_MARKER_ORIGINATOR, originator.getFullPath().toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (CoreException e) {
|
|
||||||
// You need to handle the cases where attribute value is rejected
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areProblemMarkersEnabled(){
|
|
||||||
return problemMarkersEnabled != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProblemMarkersEnabled( int value ){
|
|
||||||
if( value != 0 ){
|
|
||||||
problemsMap = new HashMap();
|
|
||||||
}
|
|
||||||
this.problemMarkersEnabled = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 += " ("; //$NON-NLS-1$
|
|
||||||
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 ){
|
public boolean shouldRecordProblem( IProblem problem ){
|
||||||
if( problem.getSourceLineNumber() == -1 )
|
if( problem.getSourceLineNumber() == -1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean preprocessor = ( problemMarkersEnabled & SourceIndexer.PREPROCESSOR_PROBLEMS_BIT ) != 0;
|
boolean preprocessor = ( indexer.getProblemMarkersEnabled() & SourceIndexer.PREPROCESSOR_PROBLEMS_BIT ) != 0;
|
||||||
boolean semantics = ( problemMarkersEnabled & SourceIndexer.SEMANTIC_PROBLEMS_BIT ) != 0;
|
boolean semantics = ( indexer.getProblemMarkersEnabled() & SourceIndexer.SEMANTIC_PROBLEMS_BIT ) != 0;
|
||||||
boolean syntax = ( problemMarkersEnabled & SourceIndexer.SYNTACTIC_PROBLEMS_BIT ) != 0;
|
boolean syntax = ( indexer.getProblemMarkersEnabled() & SourceIndexer.SYNTACTIC_PROBLEMS_BIT ) != 0;
|
||||||
|
|
||||||
if( problem.checkCategory( IProblem.PREPROCESSOR_RELATED ) || problem.checkCategory( IProblem.SCANNER_RELATED ) )
|
if( problem.checkCategory( IProblem.PREPROCESSOR_RELATED ) || problem.checkCategory( IProblem.SCANNER_RELATED ) )
|
||||||
return preprocessor && problem.getID() != IProblem.PREPROCESSOR_CIRCULAR_INCLUSION;
|
return preprocessor && problem.getID() != IProblem.PREPROCESSOR_CIRCULAR_INCLUSION;
|
||||||
|
@ -646,82 +477,6 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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{
|
|
||||||
protected 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the filesTraversed.
|
* @return Returns the filesTraversed.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,8 +23,10 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICLogConstants;
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
import org.eclipse.cdt.core.index.IIndexDelta;
|
import org.eclipse.cdt.core.index.IIndexDelta;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
@ -36,7 +38,9 @@ import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||||
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
@ -73,8 +77,8 @@ public class SourceIndexerRunner extends AbstractIndexer {
|
||||||
SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, resourceFile);
|
SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, resourceFile);
|
||||||
|
|
||||||
int problems = indexer.indexProblemsEnabled( resourceFile.getProject() );
|
int problems = indexer.indexProblemsEnabled( resourceFile.getProject() );
|
||||||
requestor.setProblemMarkersEnabled( problems );
|
setProblemMarkersEnabled( problems );
|
||||||
requestor.requestRemoveMarkers( resourceFile, null );
|
requestRemoveMarkers( resourceFile, null );
|
||||||
|
|
||||||
//Get the scanner info
|
//Get the scanner info
|
||||||
IProject currentProject = resourceFile.getProject();
|
IProject currentProject = resourceFile.getProject();
|
||||||
|
@ -129,7 +133,7 @@ public class SourceIndexerRunner extends AbstractIndexer {
|
||||||
finally{
|
finally{
|
||||||
//if the user disable problem reporting since we last checked, don't report the collected problems
|
//if the user disable problem reporting since we last checked, don't report the collected problems
|
||||||
if( indexer.indexProblemsEnabled( resourceFile.getProject() ) != 0 )
|
if( indexer.indexProblemsEnabled( resourceFile.getProject() ) != 0 )
|
||||||
requestor.reportProblems();
|
reportProblems();
|
||||||
|
|
||||||
//Report events
|
//Report events
|
||||||
ArrayList filesTrav = requestor.getFilesTraversed();
|
ArrayList filesTrav = requestor.getFilesTraversed();
|
||||||
|
@ -158,4 +162,56 @@ public class SourceIndexerRunner extends AbstractIndexer {
|
||||||
public boolean haveEncounteredHeader(IPath fullPath, Path path) {
|
public boolean haveEncounteredHeader(IPath fullPath, Path path) {
|
||||||
return indexer.haveEncounteredHeader(fullPath, path);
|
return indexer.haveEncounteredHeader(fullPath, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object)
|
||||||
|
*/
|
||||||
|
protected void addMarkers(IFile tempFile, IFile originator, Object problem) {
|
||||||
|
if (problem instanceof IProblem) {
|
||||||
|
IProblem iProblem = (IProblem) problem;
|
||||||
|
|
||||||
|
try {
|
||||||
|
//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;
|
||||||
|
|
||||||
|
if (markers.length > 0) {
|
||||||
|
IMarker tempMarker = null;
|
||||||
|
Integer tempInt = null;
|
||||||
|
String tempMsgString = null;
|
||||||
|
|
||||||
|
for (int i=0; i<markers.length; i++) {
|
||||||
|
tempMarker = markers[i];
|
||||||
|
tempInt = (Integer) tempMarker.getAttribute(IMarker.LINE_NUMBER);
|
||||||
|
tempMsgString = (String) tempMarker.getAttribute(IMarker.MESSAGE);
|
||||||
|
if (tempInt != null && tempInt.intValue()==iProblem.getSourceLineNumber() &&
|
||||||
|
tempMsgString.equalsIgnoreCase( INDEXER_MARKER_PREFIX + iProblem.getMessage()))
|
||||||
|
{
|
||||||
|
newProblem = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newProblem) {
|
||||||
|
IMarker marker = tempFile.createMarker(ICModelMarker.INDEXER_MARKER);
|
||||||
|
int start = iProblem.getSourceStart();
|
||||||
|
int end = iProblem.getSourceEnd();
|
||||||
|
if (end <= start)
|
||||||
|
end = start + 1;
|
||||||
|
marker.setAttribute(IMarker.LOCATION, iProblem.getSourceLineNumber());
|
||||||
|
marker.setAttribute(IMarker.MESSAGE, INDEXER_MARKER_PREFIX + iProblem.getMessage());
|
||||||
|
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
||||||
|
marker.setAttribute(IMarker.LINE_NUMBER, iProblem.getSourceLineNumber());
|
||||||
|
marker.setAttribute(IMarker.CHAR_START, start);
|
||||||
|
marker.setAttribute(IMarker.CHAR_END, end);
|
||||||
|
marker.setAttribute(INDEXER_MARKER_ORIGINATOR, originator.getFullPath().toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// You need to handle the cases where attribute value is rejected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.search.indexing;
|
||||||
|
|
||||||
|
|
||||||
|
public interface IIndexEncodingConstants {
|
||||||
|
public class EntryType {
|
||||||
|
public int toInt() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
private EntryType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
}
|
||||||
|
// entry types
|
||||||
|
final static EntryType CLASS = new EntryType(1);
|
||||||
|
final static EntryType STRUCT = new EntryType(2);
|
||||||
|
final static EntryType UNION = new EntryType(3);
|
||||||
|
final static EntryType ENUM = new EntryType(4);
|
||||||
|
final static EntryType VAR = new EntryType(5);
|
||||||
|
final static EntryType TYPEDEF = new EntryType(6);
|
||||||
|
final static EntryType DERIVED = new EntryType(7);
|
||||||
|
final static EntryType FRIEND = new EntryType(8);
|
||||||
|
final static EntryType FWD_CLASS = new EntryType(9);
|
||||||
|
final static EntryType FWD_STRUCT = new EntryType(10);
|
||||||
|
final static EntryType FWD_UNION = new EntryType(11);
|
||||||
|
final static EntryType NAMESPACE = new EntryType(12);
|
||||||
|
final static EntryType ENUMERATOR = new EntryType(13);
|
||||||
|
final static EntryType FIELD = new EntryType(14);
|
||||||
|
final static EntryType METHOD = new EntryType(15);
|
||||||
|
final static EntryType FUNCTION = new EntryType(16);
|
||||||
|
final static EntryType MACRO = new EntryType(17);
|
||||||
|
final static EntryType INCLUDE = new EntryType(18);
|
||||||
|
|
||||||
|
final static char[][] encodedTypeNames_Decl = {
|
||||||
|
new char[] {' '}, // not used
|
||||||
|
"typeDecl/C/".toCharArray(), // CLASS //$NON-NLS-1$
|
||||||
|
"typeDecl/S/".toCharArray(), // STRUCT //$NON-NLS-1$
|
||||||
|
"typeDecl/U/".toCharArray(), // UNION //$NON-NLS-1$
|
||||||
|
"typeDecl/E/".toCharArray(), // ENUM //$NON-NLS-1$
|
||||||
|
"typeDecl/V/".toCharArray(), // VAR //$NON-NLS-1$
|
||||||
|
"typeDecl/T/".toCharArray(), // TYPEDEF //$NON-NLS-1$
|
||||||
|
"typeDecl/D/".toCharArray(), // DERIVED //$NON-NLS-1$
|
||||||
|
"typeDecl/F/".toCharArray(), // FIREND //$NON-NLS-1$
|
||||||
|
"typeDecl/G/".toCharArray(), // FWD_CLASS //$NON-NLS-1$
|
||||||
|
"typeDecl/H/".toCharArray(), // FWD_STRUCT //$NON-NLS-1$
|
||||||
|
"typeDecl/I/".toCharArray(), // FWD_UNION //$NON-NLS-1$
|
||||||
|
"namespaceDecl/".toCharArray(), // NAMESPACE //$NON-NLS-1$
|
||||||
|
"enumtorDecl/".toCharArray(), // ENUMERATOR //$NON-NLS-1$
|
||||||
|
"fieldDecl/".toCharArray(), // FIELD //$NON-NLS-1$
|
||||||
|
"methodDecl/".toCharArray(), // METHOD //$NON-NLS-1$
|
||||||
|
"functionDecl/".toCharArray(), // FUNCTION //$NON-NLS-1$
|
||||||
|
"macroDecl/".toCharArray(), // MACRO //$NON-NLS-1$
|
||||||
|
"includeDecl/".toCharArray() // INCLUDE-unused //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
final static char[][] encodedTypeNames_Ref = {
|
||||||
|
new char[] {' '}, // not used
|
||||||
|
"typeRef/C/".toCharArray(), // CLASS //$NON-NLS-1$
|
||||||
|
"typeRef/S/".toCharArray(), // STRUCT //$NON-NLS-1$
|
||||||
|
"typeRef/U/".toCharArray(), // UNION //$NON-NLS-1$
|
||||||
|
"typeRef/E/".toCharArray(), // ENUM //$NON-NLS-1$
|
||||||
|
"typeRef/V/".toCharArray(), // VAR //$NON-NLS-1$
|
||||||
|
"typeRef/T/".toCharArray(), // TYPEDEF //$NON-NLS-1$
|
||||||
|
"typeRef/D/".toCharArray(), // DERIVED //$NON-NLS-1$
|
||||||
|
"typeRef/F/".toCharArray(), // FIREND //$NON-NLS-1$
|
||||||
|
"typeRef/G/".toCharArray(), // FWD_CLASS //$NON-NLS-1$
|
||||||
|
"typeRef/H/".toCharArray(), // FWD_STRUCT //$NON-NLS-1$
|
||||||
|
"typeRef/I/".toCharArray(), // FWD_UNION //$NON-NLS-1$
|
||||||
|
"namespaceRef/".toCharArray(), // NAMESPACE //$NON-NLS-1$
|
||||||
|
"enumtorRef/".toCharArray(), // ENUMERATOR //$NON-NLS-1$
|
||||||
|
"fieldRef/".toCharArray(), // FIELD //$NON-NLS-1$
|
||||||
|
"methodRef/".toCharArray(), // METHOD //$NON-NLS-1$
|
||||||
|
"functionRef/".toCharArray(), // FUNCTION //$NON-NLS-1$
|
||||||
|
"macroRef/".toCharArray(), // MACRO-unused //$NON-NLS-1$
|
||||||
|
"includeRef/".toCharArray() // INCLUDE //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
final static char SEPARATOR= '/';
|
||||||
|
|
||||||
|
}
|
|
@ -538,6 +538,16 @@
|
||||||
</run>
|
</run>
|
||||||
</cextension>
|
</cextension>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
name="DOM AST C/C++ Indexer"
|
||||||
|
id="domsourceindexer"
|
||||||
|
point="org.eclipse.cdt.core.CIndexer">
|
||||||
|
<cextension>
|
||||||
|
<run
|
||||||
|
class="org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer">
|
||||||
|
</run>
|
||||||
|
</cextension>
|
||||||
|
</extension>
|
||||||
|
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
<!-- Dynamic Variables -->
|
<!-- Dynamic Variables -->
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.cdt.core.search.SearchEngine;
|
||||||
import org.eclipse.cdt.internal.core.CDTLogWriter;
|
import org.eclipse.cdt.internal.core.CDTLogWriter;
|
||||||
import org.eclipse.cdt.internal.core.CDescriptorManager;
|
import org.eclipse.cdt.internal.core.CDescriptorManager;
|
||||||
import org.eclipse.cdt.internal.core.PathEntryVariableManager;
|
import org.eclipse.cdt.internal.core.PathEntryVariableManager;
|
||||||
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexerRunner;
|
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
|
||||||
import org.eclipse.cdt.internal.core.model.BufferManager;
|
import org.eclipse.cdt.internal.core.model.BufferManager;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||||
import org.eclipse.cdt.internal.core.model.DeltaProcessor;
|
import org.eclipse.cdt.internal.core.model.DeltaProcessor;
|
||||||
|
@ -895,7 +895,7 @@ public class CCorePlugin extends Plugin {
|
||||||
} //$NON-NLS-1$
|
} //$NON-NLS-1$
|
||||||
|
|
||||||
option = Platform.getDebugOption(INDEXER);
|
option = Platform.getDebugOption(INDEXER);
|
||||||
if(option != null) SourceIndexerRunner.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
if(option != null) AbstractIndexer.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||||
|
|
||||||
option = Platform.getDebugOption(SEARCH);
|
option = Platform.getDebugOption(SEARCH);
|
||||||
if(option != null) SearchEngine.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
if(option != null) SearchEngine.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2005-03-24 Vladimir Hirsl
|
||||||
|
Ironing of the Indexer property page block.
|
||||||
|
DOM AST based indexer property options page.
|
||||||
|
* src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
|
||||||
|
* src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java
|
||||||
|
* plugin.xml
|
||||||
|
|
||||||
2005-03-20 Alain Magloire
|
2005-03-20 Alain Magloire
|
||||||
Fix for 77978.
|
Fix for 77978.
|
||||||
* src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java
|
* src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java
|
||||||
|
|
|
@ -1337,6 +1337,11 @@
|
||||||
indexerID="org.eclipse.cdt.core.nullindexer"
|
indexerID="org.eclipse.cdt.core.nullindexer"
|
||||||
name="No Indexer"
|
name="No Indexer"
|
||||||
id="org.eclipse.cdt.ui.nullindexerUI"/>
|
id="org.eclipse.cdt.ui.nullindexerUI"/>
|
||||||
|
<indexerUI
|
||||||
|
class="org.eclipse.cdt.ui.dialogs.SourceIndexerBlock"
|
||||||
|
id="org.eclipse.cdt.ui.DOMASTSourceIndexerUI"
|
||||||
|
indexerID="org.eclipse.cdt.core.domsourceindexer"
|
||||||
|
name="DOM AST C/C++ Indexer"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.ui.completionContributors">
|
point="org.eclipse.cdt.ui.completionContributors">
|
||||||
|
|
|
@ -131,11 +131,7 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
// create a composite for discovery profile options
|
// create a composite for discovery profile options
|
||||||
Composite indexPageComposite = ControlFactory.createComposite(composite, 1);
|
Composite indexPageComposite = ControlFactory.createComposite(composite, 1);
|
||||||
indexPageComposite.setFont(font);
|
indexPageComposite.setFont(font);
|
||||||
GridData gd = (GridData) indexPageComposite.getLayoutData();
|
indexPageComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
|
||||||
gd.grabExcessHorizontalSpace = true;
|
|
||||||
// gd.grabExcessVerticalSpace = true;
|
|
||||||
gd.horizontalAlignment = GridData.FILL;
|
|
||||||
gd.verticalAlignment = GridData.FILL;
|
|
||||||
indexPageComposite.setLayout(new TabFolderLayout());
|
indexPageComposite.setLayout(new TabFolderLayout());
|
||||||
// Must set the composite parent to super class.
|
// Must set the composite parent to super class.
|
||||||
parentComposite = indexPageComposite;
|
parentComposite = indexPageComposite;
|
||||||
|
@ -162,9 +158,9 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
page.setContainer(getContainer());
|
page.setContainer(getContainer());
|
||||||
page.createControl(parentComposite);
|
page.createControl(parentComposite);
|
||||||
parentComposite.layout(true);
|
parentComposite.layout(true);
|
||||||
parentComposite.pack(true);
|
// parentComposite.pack(true);
|
||||||
} else {
|
} if (currentPage != null) {
|
||||||
page.setVisible(false);
|
currentPage.setVisible(false);
|
||||||
}
|
}
|
||||||
page.setVisible(true);
|
page.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
||||||
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.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +50,8 @@ public class NullIndexerBlock extends AbstractIndexerPage {
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
setControl(parent);
|
Composite comp = new Composite(parent, SWT.NULL);
|
||||||
|
setControl(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue