mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
IndexerOutput refactoring to use IIndexEntry
CTags indexer refactoring to use new IIndexEntry hierarchy, store modifiers, function signatures
This commit is contained in:
parent
a6affc1fdc
commit
fa2d057c98
16 changed files with 589 additions and 62 deletions
|
@ -0,0 +1,95 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
public abstract class CIndexStorageEntry implements ICIndexStorageEntry {
|
||||
|
||||
int meta_kind;
|
||||
int entry_type;
|
||||
|
||||
int nameOffset;
|
||||
int nameOffsetLength;
|
||||
int nameOffsetType;
|
||||
|
||||
int elementOffset;
|
||||
int elementOffsetLength;
|
||||
int elementOffsetType;
|
||||
|
||||
int fileNumber;
|
||||
|
||||
public CIndexStorageEntry(int meta_kind, int entry_type, int fileNumber){
|
||||
this.meta_kind = meta_kind;
|
||||
this.entry_type = entry_type;
|
||||
this.fileNumber = fileNumber;
|
||||
}
|
||||
|
||||
public int getMetaKind() {
|
||||
return meta_kind;
|
||||
}
|
||||
|
||||
public int getEntryType() {
|
||||
return entry_type;
|
||||
}
|
||||
|
||||
public int getFileNumber(){
|
||||
return fileNumber;
|
||||
}
|
||||
|
||||
public int getNameOffset(){
|
||||
return nameOffset;
|
||||
}
|
||||
|
||||
public int getNameLength(){
|
||||
return nameOffsetLength;
|
||||
}
|
||||
|
||||
public int getNameOffsetType(){
|
||||
return nameOffsetType;
|
||||
}
|
||||
|
||||
public int getElementOffset(){
|
||||
return elementOffset;
|
||||
}
|
||||
|
||||
public int getElementLength(){
|
||||
return elementOffsetLength;
|
||||
}
|
||||
|
||||
public int getElementOffsetType(){
|
||||
return elementOffsetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name offset
|
||||
* @param offsetStart - the start of the name offset
|
||||
* @param offsetLength - the length of the name offset
|
||||
* @param offsetType - IIndex.LINE or IIndex.OFFSET
|
||||
*/
|
||||
public void setNameOffset(int offsetStart, int offsetLength, int offsetType){
|
||||
this.nameOffset = offsetStart;
|
||||
this.nameOffsetLength = offsetLength;
|
||||
this.nameOffsetType = offsetType;
|
||||
}
|
||||
/**
|
||||
* Sets the element offset
|
||||
* @param offsetStart - the start of the name offset
|
||||
* @param offsetLength - the length of the name offset
|
||||
* @param offsetType - IIndex.LINE or IIndex.OFFSET
|
||||
*/
|
||||
public void setElementOffset(int offsetStart, int offsetLength, int offsetType){
|
||||
this.elementOffset = offsetStart;
|
||||
this.elementOffsetLength = offsetLength;
|
||||
this.elementOffsetType = offsetType;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
public class FunctionEntry extends NamedEntry implements IFunctionEntry {
|
||||
|
||||
|
||||
char[][] signature;
|
||||
|
||||
public FunctionEntry(int metakind, int entry_type, char[][] fullName, int modifiers,int fileNumber){
|
||||
super(metakind,entry_type,fullName, modifiers, fileNumber);
|
||||
}
|
||||
|
||||
public void setSignature(char[][] signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public char[][] getSignature() {
|
||||
return signature;
|
||||
|
||||
}
|
||||
|
||||
public void serialize(IIndexerOutput output) {
|
||||
output.addIndexEntry(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
public interface ICIndexStorageEntry {
|
||||
|
||||
/**
|
||||
* @return Returns the metakind of this entry as defined in IIndex
|
||||
*/
|
||||
public int getMetaKind();
|
||||
/**
|
||||
* @return Returns the file number associated with this particular entry or 0 if file number has not been set
|
||||
*/
|
||||
public int getFileNumber();
|
||||
/**
|
||||
* @return Returns the starting offset for the name of this entry or 0 if the offset has not been set
|
||||
*/
|
||||
public int getNameOffset();
|
||||
/**
|
||||
* @return Returns the length of the name of this entry or 0 if the offset has not been set
|
||||
*/
|
||||
public int getNameLength();
|
||||
/**
|
||||
* @returns Returns the offset type for the name offset - IIndex.LINE or IIndex.OFFSET
|
||||
*/
|
||||
public int getNameOffsetType();
|
||||
/**
|
||||
* @return Returns the starting offset for the entry
|
||||
*/
|
||||
public int getElementOffset();
|
||||
/**
|
||||
* @returns Returns the length of this entry
|
||||
*/
|
||||
public int getElementLength();
|
||||
/**
|
||||
* @returns Returns the offset type for this element offset - IIndex.LINE or IIndex.OFFSET
|
||||
*/
|
||||
public int getElementOffsetType();
|
||||
}
|
|
@ -1,15 +1,19 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
|
||||
public interface IFunctionEntry extends IIndexEntry {
|
||||
public interface IFunctionEntry extends INamedEntry {
|
||||
|
||||
public void setSignature();
|
||||
public void getSignature();
|
||||
public char[][] getSignature();
|
||||
|
||||
public void setReturnType();
|
||||
public void getReturnType();
|
||||
|
||||
public void setStatic(boolean staticVar);
|
||||
public boolean isStatic();
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,25 @@ public interface IIndex {
|
|||
final static int DECLARATION = 1;
|
||||
final static int REFERENCE = 2;
|
||||
final static int DEFINITION = 3;
|
||||
|
||||
|
||||
|
||||
// modifiers
|
||||
final static int privateAccessSpecifier = 1;
|
||||
final static int publicAccessSpecifier = 2;
|
||||
final static int protectedAccessSpecifier = 4;
|
||||
final static int constQualifier = 8;
|
||||
final static int volatileQualifier = 16;
|
||||
final static int staticSpecifier = 32;
|
||||
final static int externSpecifier = 64;
|
||||
final static int inlineSpecifier = 128;
|
||||
final static int virtualSpecifier = 256;
|
||||
final static int pureVirtualSpecifier = 512;
|
||||
final static int explicitSpecifier = 1024;
|
||||
final static int autoSpecifier = 2048;
|
||||
final static int registerSpecifier = 4096;
|
||||
final static int mutableSpecifier = 8192;
|
||||
|
||||
|
||||
/**
|
||||
* Adds the given file to the index.
|
||||
*/
|
||||
|
|
|
@ -1,11 +1,27 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
public interface IIndexEntry {
|
||||
|
||||
//DECLARATION, DEFINITION, or REFERENCE as defined in IIndex
|
||||
public void setEntryType(int type);
|
||||
/**
|
||||
* Returns the type for this index entry.
|
||||
* @return IIndex.DECLARATION, IIndex.DEFINITION or IIndex.REFERENCE
|
||||
*/
|
||||
public int getEntryType();
|
||||
|
||||
/**
|
||||
* Write the entry to the passed in indexer output
|
||||
* @param output
|
||||
*/
|
||||
public void serialize(IIndexerOutput output);
|
||||
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ public interface IIndexerOutput {
|
|||
public void addFwd_UnionDecl(int indexedFileNumber, char [][] name, int offset, int offsetLength, int offsetType);
|
||||
public void addFwd_UnionRef(int indexedFileNumber, char [][] name, int offset, int offsetLength, int offsetType);
|
||||
|
||||
public void addIndexEntry(IIndexEntry indexEntry);
|
||||
|
||||
public IndexedFileEntry getIndexedFile(String path);
|
||||
public IndexedFileEntry addIndexedFile(String path);
|
||||
//For Dep Tree
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
public interface INamedEntry extends IIndexEntry, ICIndexStorageEntry {
|
||||
/**
|
||||
* @return Returns the fully qualified name of this entry
|
||||
*/
|
||||
public char[][] getFullName();
|
||||
/**
|
||||
* @return Returns the modifier bit field
|
||||
*/
|
||||
public int getModifiers();
|
||||
}
|
|
@ -1,14 +1,46 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
public interface ITypeEntry extends IIndexEntry {
|
||||
/**
|
||||
* Interface used to encode type entries for the CIndexStorgage format
|
||||
* Type entry constants are defined in IIndex. The list of types are:
|
||||
*
|
||||
* TYPE_CLASS
|
||||
* TYPE_STRUCT
|
||||
* TYPE_UNION
|
||||
* TYPE_ENUM
|
||||
* TYPE_VAR
|
||||
* TYPE_TYPEDEF
|
||||
* TYPE_DERIVED
|
||||
* TYPE_FRIEND
|
||||
* TYPE_FWD_CLASS
|
||||
* TYPE_FWD_STRUCT
|
||||
* TYPE_FWD_UNION
|
||||
*
|
||||
* @author bgheorgh
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface ITypeEntry extends INamedEntry {
|
||||
|
||||
public void setKind(int meta_kind);
|
||||
public int getKind();
|
||||
/**
|
||||
* Returns the kind of this type entry
|
||||
* @return int representing type kind defined in IIndex.
|
||||
*/
|
||||
public int getTypeKind();
|
||||
/**
|
||||
* Returns the types that are inherited
|
||||
* @return an array of char arrays - each representing a separate type that this entry inherits from
|
||||
*/
|
||||
public char[][] getBaseTypes();
|
||||
|
||||
public void setReturnType();
|
||||
public void getReturnType();
|
||||
|
||||
public void isStatic();
|
||||
|
||||
public void setName(String name);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
public class NamedEntry extends CIndexStorageEntry implements INamedEntry {
|
||||
|
||||
char[][] fullName;
|
||||
int modifiers;
|
||||
|
||||
public NamedEntry(int meta_kind, int entry_type, char[][] fullName, int modifiers, int fileNumber){
|
||||
super(meta_kind, entry_type, fileNumber);
|
||||
this.fullName = fullName;
|
||||
this.modifiers = modifiers;
|
||||
}
|
||||
|
||||
public char[][] getFullName(){
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public int getModifiers(){
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
public void serialize(IIndexerOutput output) {
|
||||
output.addIndexEntry(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
public class TypeEntry extends NamedEntry implements ITypeEntry {
|
||||
|
||||
int type_kind;
|
||||
char[][] baseTypes;
|
||||
|
||||
public TypeEntry(int type_kind, int entry_type, char[][] fullName, int modifiers, int fileNumber){
|
||||
super(IIndex.TYPE, entry_type, fullName, modifiers, fileNumber);
|
||||
this.type_kind = type_kind;
|
||||
}
|
||||
|
||||
public void serialize(IIndexerOutput output) {
|
||||
output.addIndexEntry(this);
|
||||
}
|
||||
|
||||
public int getTypeKind() {
|
||||
return type_kind;
|
||||
}
|
||||
|
||||
public void setBaseTypes(char[][] baseTypes) {
|
||||
this.baseTypes=baseTypes;
|
||||
}
|
||||
|
||||
public char[][] getBaseTypes() {
|
||||
return baseTypes;
|
||||
}
|
||||
|
||||
}
|
|
@ -85,34 +85,24 @@ public interface ICIndexStorageConstants {
|
|||
"FWD Struct", //$NON-NLS-1$
|
||||
"FWD Union" //$NON-NLS-1$
|
||||
};
|
||||
final static char [][] accessSpecifiers = {
|
||||
"".toCharArray(), // not used //$NON-NLS-1$
|
||||
"private".toCharArray(), // private //$NON-NLS-1$
|
||||
"protected".toCharArray(), // protected //$NON-NLS-1$
|
||||
"public".toCharArray() // public //$NON-NLS-1$
|
||||
|
||||
final static String[] allSpecifiers = {
|
||||
"private", // private //$NON-NLS-1$
|
||||
"public", // public //$NON-NLS-1$
|
||||
"protected", // protected //$NON-NLS-1$
|
||||
"const", // const //$NON-NLS-1$
|
||||
"volatile", // volatile //$NON-NLS-1$
|
||||
"static", // static //$NON-NLS-1$
|
||||
"extern", // extern //$NON-NLS-1$
|
||||
"inline", // inline //$NON-NLS-1$
|
||||
"virtual", // virtual //$NON-NLS-1$
|
||||
"pure virtual", // pure virtual //$NON-NLS-1$
|
||||
"explicit", // explicit //$NON-NLS-1$
|
||||
"auto", // auto //$NON-NLS-1$
|
||||
"register", // register //$NON-NLS-1$
|
||||
"mutable" // mutable //$NON-NLS-1$
|
||||
};
|
||||
|
||||
final static char [][] cvQualifiers = {
|
||||
"".toCharArray(), // not used //$NON-NLS-1$
|
||||
"const".toCharArray(), // const //$NON-NLS-1$
|
||||
"volatile".toCharArray(), // volatile //$NON-NLS-1$
|
||||
};
|
||||
|
||||
final static char [][] storageClassSpecifiers = {
|
||||
"".toCharArray(), // not used //$NON-NLS-1$
|
||||
"auto".toCharArray(), // auto //$NON-NLS-1$
|
||||
"register".toCharArray(), // register //$NON-NLS-1$
|
||||
"static".toCharArray(), // static //$NON-NLS-1$
|
||||
"extern".toCharArray(), // extern //$NON-NLS-1$
|
||||
"mutable".toCharArray(), // mutable //$NON-NLS-1$
|
||||
};
|
||||
|
||||
final static char [][] functionSpecifiers = {
|
||||
"".toCharArray(), // not used //$NON-NLS-1$
|
||||
"inline".toCharArray(), // inline //$NON-NLS-1$
|
||||
"virtual".toCharArray(), // virtual //$NON-NLS-1$
|
||||
"explicit".toCharArray(), // explicit //$NON-NLS-1$
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.cindexstorage;
|
||||
|
||||
import org.eclipse.cdt.internal.core.index.IFunctionEntry;
|
||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexEntry;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
|
||||
import org.eclipse.cdt.internal.core.index.INamedEntry;
|
||||
import org.eclipse.cdt.internal.core.index.ITypeEntry;
|
||||
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
|
||||
|
||||
/**
|
||||
|
@ -322,6 +326,61 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addIndexEntry(IIndexEntry indexEntry) {
|
||||
|
||||
if (indexEntry == null)
|
||||
return;
|
||||
|
||||
if (indexEntry instanceof ITypeEntry){
|
||||
ITypeEntry typeEntry = (ITypeEntry) indexEntry;
|
||||
int indexedFileNumber=typeEntry.getFileNumber();
|
||||
int meta_type = typeEntry.getMetaKind();
|
||||
int type_kind = typeEntry.getTypeKind();
|
||||
int entryType = typeEntry.getEntryType();
|
||||
int modifiers = typeEntry.getModifiers();
|
||||
|
||||
char[][]name=typeEntry.getFullName();
|
||||
|
||||
int nameOffset=typeEntry.getNameOffset();
|
||||
int nameOffsetLength=typeEntry.getNameLength();
|
||||
int nameOffsetType=typeEntry.getNameOffsetType();
|
||||
|
||||
int elementOffset=typeEntry.getElementOffset();
|
||||
int elementOffsetLength=typeEntry.getElementLength();
|
||||
int elementOffsetType=typeEntry.getElementOffsetType();
|
||||
|
||||
addRef(indexedFileNumber, name, ICIndexStorageConstants.typeConstants[type_kind], entryType, nameOffset,nameOffsetLength, nameOffsetType);
|
||||
|
||||
} else if (indexEntry instanceof IFunctionEntry) {
|
||||
IFunctionEntry functionEntry = (IFunctionEntry) indexEntry;
|
||||
int indexedFileNumber=functionEntry.getFileNumber();
|
||||
int meta_type = functionEntry.getMetaKind();
|
||||
int entryType = functionEntry.getEntryType();
|
||||
int modifiers = functionEntry.getModifiers();
|
||||
char[][] sig=functionEntry.getSignature();
|
||||
char[][]name=functionEntry.getFullName();
|
||||
int nameOffset=functionEntry.getNameOffset();
|
||||
int nameOffsetLength=functionEntry.getNameLength();
|
||||
int nameOffsetType=functionEntry.getNameOffsetType();
|
||||
addRef(indexedFileNumber, name, meta_type, entryType, nameOffset,nameOffsetLength, nameOffsetType);
|
||||
}
|
||||
else if (indexEntry instanceof INamedEntry){
|
||||
INamedEntry nameEntry = (INamedEntry) indexEntry;
|
||||
int indexedFileNumber=nameEntry.getFileNumber();
|
||||
int meta_type = nameEntry.getMetaKind();
|
||||
int entryType = nameEntry.getEntryType();
|
||||
int modifiers = nameEntry.getModifiers();
|
||||
char[][]name=nameEntry.getFullName();
|
||||
int nameOffset=nameEntry.getNameOffset();
|
||||
int nameOffsetLength=nameEntry.getNameLength();
|
||||
int nameOffsetType=nameEntry.getNameOffsetType();
|
||||
int elementOffset=nameEntry.getElementOffset();
|
||||
int elementOffsetLength=nameEntry.getElementLength();
|
||||
int elementOffsetType=nameEntry.getElementOffsetType();
|
||||
addRef(indexedFileNumber, name, meta_type, entryType, nameOffset,nameOffsetLength, nameOffsetType);
|
||||
}
|
||||
}
|
||||
|
||||
// public static final char[] encodeEntry(char[][] elementName, int entryType, int encodeType) {
|
||||
// // Temporarily
|
||||
|
|
|
@ -11,10 +11,16 @@
|
|||
package org.eclipse.cdt.internal.core.index.ctagsindexer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.cdt.internal.core.index.FunctionEntry;
|
||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
|
||||
import org.eclipse.cdt.internal.core.index.NamedEntry;
|
||||
import org.eclipse.cdt.internal.core.index.TypeEntry;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.ICIndexStorageConstants;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
|
||||
|
||||
class CTagEntry{
|
||||
|
@ -121,31 +127,150 @@ class CTagEntry{
|
|||
char[][] fullName = getQualifiedName();
|
||||
|
||||
if (kind.equals(CTagsConsoleParser.CLASS)){
|
||||
output.addClassDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_CLASS,IIndex.DECLARATION, fullName, getModifiers(), fileNum);
|
||||
typeEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
typeEntry.setBaseTypes(getInherits());
|
||||
typeEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.MACRO)){
|
||||
output.addMacroDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
NamedEntry namedEntry = new NamedEntry(IIndex.MACRO, IIndex.DECLARATION,fullName,getModifiers(),fileNum);
|
||||
namedEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
namedEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.ENUMERATOR)){
|
||||
output.addEnumtorDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
NamedEntry namedEntry = new NamedEntry(IIndex.ENUMTOR, IIndex.DECLARATION,fullName,getModifiers(),fileNum);
|
||||
namedEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
namedEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.FUNCTION)){
|
||||
output.addFunctionDefn(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
//Both methods and functions are reported back as functions - methods can be distinguished
|
||||
//from functions by the presence of a class field in the type entry
|
||||
String isMethod = (String) tagExtensionField.get(CTagsConsoleParser.CLASS);
|
||||
if (isMethod != null){
|
||||
//method
|
||||
FunctionEntry funEntry = new FunctionEntry(IIndex.METHOD, IIndex.DEFINITION,fullName,getModifiers(),fileNum);
|
||||
funEntry.setSignature(getFunctionSignature());
|
||||
funEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
funEntry.serialize(output);
|
||||
} else {
|
||||
//function
|
||||
FunctionEntry funEntry = new FunctionEntry(IIndex.FUNCTION, IIndex.DEFINITION,fullName,getModifiers(), fileNum);
|
||||
funEntry.setSignature(getFunctionSignature());
|
||||
funEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
funEntry.serialize(output);
|
||||
}
|
||||
} else if (kind.equals(CTagsConsoleParser.ENUM)){
|
||||
output.addEnumDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_ENUM ,IIndex.DECLARATION, fullName, getModifiers(), fileNum);
|
||||
typeEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
typeEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.MEMBER)){
|
||||
output.addFieldDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
NamedEntry namedEntry = new NamedEntry(IIndex.FIELD, IIndex.DECLARATION,fullName,getModifiers(),fileNum);
|
||||
namedEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
namedEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.NAMESPACE)){
|
||||
output.addNamespaceDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
NamedEntry namedEntry = new NamedEntry(IIndex.NAMESPACE, IIndex.DECLARATION,fullName,getModifiers(),fileNum);
|
||||
namedEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
namedEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.PROTOTYPE)){
|
||||
output.addFunctionDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
//Both methods and functions are reported back as functions - methods can be distinguished
|
||||
//from functions by the presence of a class field in the type entry
|
||||
String isMethod = (String) tagExtensionField.get(CTagsConsoleParser.CLASS);
|
||||
if (isMethod != null){
|
||||
//method
|
||||
FunctionEntry funEntry = new FunctionEntry(IIndex.METHOD, IIndex.DECLARATION,fullName,getModifiers(), fileNum);
|
||||
funEntry.setSignature(getFunctionSignature());
|
||||
funEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
funEntry.serialize(output);
|
||||
} else {
|
||||
//function
|
||||
FunctionEntry funEntry = new FunctionEntry(IIndex.FUNCTION, IIndex.DECLARATION,fullName,getModifiers(),fileNum);
|
||||
funEntry.setSignature(getFunctionSignature());
|
||||
funEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
funEntry.serialize(output);
|
||||
}
|
||||
} else if (kind.equals(CTagsConsoleParser.STRUCT)){
|
||||
output.addStructDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_STRUCT,IIndex.DECLARATION, fullName, getModifiers(), fileNum);
|
||||
typeEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
typeEntry.setBaseTypes(getInherits());
|
||||
typeEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.TYPEDEF)){
|
||||
output.addTypedefDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_TYPEDEF,IIndex.DECLARATION, fullName, getModifiers(), fileNum);
|
||||
typeEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
typeEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.UNION)){
|
||||
output.addUnionDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_UNION,IIndex.DECLARATION, fullName, getModifiers(), fileNum);
|
||||
typeEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
typeEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.VARIABLE)){
|
||||
output.addVariableDecl(fileNum, fullName, lineNumber, 1, IIndex.LINE);
|
||||
TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_VAR,IIndex.DECLARATION, fullName, getModifiers(), fileNum);
|
||||
typeEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
typeEntry.serialize(output);
|
||||
} else if (kind.equals(CTagsConsoleParser.EXTERNALVAR)){
|
||||
|
||||
//Have to specifically set external bit flag in modifier;
|
||||
int modifiers = getModifiers();
|
||||
modifiers |= 1 << 6;
|
||||
TypeEntry typeEntry = new TypeEntry(IIndex.TYPE_VAR,IIndex.DECLARATION, fullName, modifiers, fileNum);
|
||||
typeEntry.setNameOffset(lineNumber, 1, IIndex.LINE);
|
||||
typeEntry.serialize(output);
|
||||
}
|
||||
}
|
||||
|
||||
private char[][] getFunctionSignature() {
|
||||
String signature = (String) tagExtensionField.get(CTagsConsoleParser.SIGNATURE);
|
||||
|
||||
LinkedList list = CSearchPattern.scanForParameters(signature);
|
||||
char [][] parameters = new char [0][];
|
||||
parameters = (char[][])list.toArray( parameters );
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
private int getModifiers() {
|
||||
|
||||
int modifier=0;
|
||||
|
||||
//Check access modifier
|
||||
String access = (String) tagExtensionField.get(CTagsConsoleParser.ACCESS);
|
||||
|
||||
if (access != null){
|
||||
for (int i=0; i<ICIndexStorageConstants.allSpecifiers.length; i++){
|
||||
if (access.equals(ICIndexStorageConstants.allSpecifiers[i])){
|
||||
int tempNum = 1 << i;
|
||||
modifier |= tempNum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check implementation modifier
|
||||
String implementation=(String) tagExtensionField.get(CTagsConsoleParser.IMPLEMENTATION);
|
||||
|
||||
if (implementation != null){
|
||||
for (int i=0; i<ICIndexStorageConstants.allSpecifiers.length; i++){
|
||||
if (implementation.equals(ICIndexStorageConstants.allSpecifiers[i])){
|
||||
int tempNum = 1 << i;
|
||||
modifier |= tempNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return modifier;
|
||||
}
|
||||
|
||||
private char[][] getInherits() {
|
||||
|
||||
//Check inherits modifier
|
||||
String access = (String) tagExtensionField.get(CTagsConsoleParser.INHERITS);
|
||||
|
||||
if (access != null){
|
||||
StringTokenizer tokenizer = new StringTokenizer(access, ","); //$NON-NLS-1$
|
||||
LinkedList list = new LinkedList();
|
||||
while (tokenizer.hasMoreTokens()){
|
||||
list.add(tokenizer.nextToken().toCharArray());
|
||||
}
|
||||
char[][] inherits = new char[0][];
|
||||
inherits = (char [][]) list.toArray(inherits);
|
||||
return inherits;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ public class CTagsConsoleParser implements IConsoleParser {
|
|||
final static String INHERITS = "inherits"; //$NON-NLS-1$
|
||||
final static String ACCESS = "access"; //$NON-NLS-1$
|
||||
final static String IMPLEMENTATION = "implementation"; //$NON-NLS-1$
|
||||
final static String SIGNATURE = "signature"; //$NON-NLS-1$
|
||||
|
||||
final static String CLASS = "class"; //$NON-NLS-1$
|
||||
final static String MACRO = "macro"; //$NON-NLS-1$
|
||||
|
@ -41,7 +42,7 @@ public class CTagsConsoleParser implements IConsoleParser {
|
|||
final static String TYPEDEF = "typedef"; //$NON-NLS-1$
|
||||
final static String UNION = "union"; //$NON-NLS-1$
|
||||
final static String VARIABLE = "variable"; //$NON-NLS-1$
|
||||
final static String EXTERNALVAR = ""; //$NON-NLS-1$
|
||||
final static String EXTERNALVAR = "externvar"; //$NON-NLS-1$
|
||||
|
||||
private CTagsIndexerRunner indexer;
|
||||
|
||||
|
|
|
@ -456,7 +456,7 @@ public abstract class CSearchPattern implements ICSearchConstants, ICSearchPatte
|
|||
* @param object
|
||||
* @return
|
||||
*/
|
||||
private static LinkedList scanForParameters( String paramString ) {
|
||||
public static LinkedList scanForParameters( String paramString ) {
|
||||
LinkedList list = new LinkedList();
|
||||
|
||||
if( paramString == null || paramString.equals("") ) //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue