From fa2d057c9813222f528cb3a8efb73eeb472b1486 Mon Sep 17 00:00:00 2001 From: Bogdan Gheorghe Date: Fri, 20 May 2005 14:16:38 +0000 Subject: [PATCH] IndexerOutput refactoring to use IIndexEntry CTags indexer refactoring to use new IIndexEntry hierarchy, store modifiers, function signatures --- .../core/index/CIndexStorageEntry.java | 95 +++++++++++ .../internal/core/index/FunctionEntry.java | 37 +++++ .../core/index/ICIndexStorageEntry.java | 48 ++++++ .../internal/core/index/IFunctionEntry.java | 22 +-- .../cdt/internal/core/index/IIndex.java | 20 ++- .../cdt/internal/core/index/IIndexEntry.java | 22 ++- .../internal/core/index/IIndexerOutput.java | 2 + .../cdt/internal/core/index/INamedEntry.java | 23 +++ .../cdt/internal/core/index/ITypeEntry.java | 50 ++++-- .../cdt/internal/core/index/NamedEntry.java | 37 +++++ .../cdt/internal/core/index/TypeEntry.java | 40 +++++ .../ICIndexStorageConstants.java | 42 ++--- .../index/cindexstorage/IndexerOutput.java | 59 +++++++ .../core/index/ctagsindexer/CTagEntry.java | 149 ++++++++++++++++-- .../ctagsindexer/CTagsConsoleParser.java | 3 +- .../core/search/matching/CSearchPattern.java | 2 +- 16 files changed, 589 insertions(+), 62 deletions(-) create mode 100644 core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CIndexStorageEntry.java create mode 100644 core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/FunctionEntry.java create mode 100644 core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ICIndexStorageEntry.java create mode 100644 core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/INamedEntry.java create mode 100644 core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/NamedEntry.java create mode 100644 core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/TypeEntry.java diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CIndexStorageEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CIndexStorageEntry.java new file mode 100644 index 00000000000..60fe88d8e4f --- /dev/null +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CIndexStorageEntry.java @@ -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; + } + + +} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/FunctionEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/FunctionEntry.java new file mode 100644 index 00000000000..f597a8d8ebd --- /dev/null +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/FunctionEntry.java @@ -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); + } + + +} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ICIndexStorageEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ICIndexStorageEntry.java new file mode 100644 index 00000000000..ff07fc7a47a --- /dev/null +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ICIndexStorageEntry.java @@ -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(); +} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IFunctionEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IFunctionEntry.java index 22cec4cfe06..2b880db8e50 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IFunctionEntry.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IFunctionEntry.java @@ -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(); - } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java index 891240b3e98..2c3d419490b 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java @@ -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. */ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexEntry.java index 5770aa4e6b9..51f725b7433 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexEntry.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexEntry.java @@ -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); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java index fdbd9fcda34..3dcb7dd4131 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java @@ -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 diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/INamedEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/INamedEntry.java new file mode 100644 index 00000000000..d20d333bc06 --- /dev/null +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/INamedEntry.java @@ -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(); +} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ITypeEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ITypeEntry.java index 8f5b4ac3642..902e6c2c5ad 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ITypeEntry.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ITypeEntry.java @@ -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); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/NamedEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/NamedEntry.java new file mode 100644 index 00000000000..6e3c4757d6f --- /dev/null +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/NamedEntry.java @@ -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); + } + +} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/TypeEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/TypeEntry.java new file mode 100644 index 00000000000..2f667cf46fe --- /dev/null +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/TypeEntry.java @@ -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; + } + +} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java index 416eb41cef5..40e3c9c3762 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/ICIndexStorageConstants.java @@ -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$ - }; } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java index 21010393bfb..1b8f8c750ca 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexerOutput.java @@ -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 diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java index aa7d5316bd1..c9f3f8ab8bc 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagEntry.java @@ -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