mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 18:35:32 +02:00
Hooked up the ctags preferences/property page. Optimized the use of Strings and extracting them out of the database. Fixed up the ctags delta handling.
This commit is contained in:
parent
bfb871dd28
commit
71f9b034c8
25 changed files with 381 additions and 286 deletions
|
@ -6,6 +6,7 @@ import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.DBString;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
|
@ -148,7 +149,7 @@ public class DBTest extends TestCase {
|
||||||
int record = new FindVisitor(db, name).findIn(btree);
|
int record = new FindVisitor(db, name).findIn(btree);
|
||||||
assertTrue(record != 0);
|
assertTrue(record != 0);
|
||||||
assertEquals(i, db.getInt(record));
|
assertEquals(i, db.getInt(record));
|
||||||
String rname = db.getString(record + Database.INT_SIZE);
|
DBString rname = db.getString(record + Database.INT_SIZE);
|
||||||
assertEquals(name, rname);
|
assertEquals(name, rname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,12 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
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.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
@ -70,7 +73,9 @@ public class PDOM extends PlatformObject
|
||||||
public static final int LINKAGES = Database.DATA_AREA;
|
public static final int LINKAGES = Database.DATA_AREA;
|
||||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||||
|
|
||||||
|
// Local caches
|
||||||
private BTree fileIndex;
|
private BTree fileIndex;
|
||||||
|
private Map linkageCache = new HashMap();
|
||||||
|
|
||||||
private static final QualifiedName dbNameProperty
|
private static final QualifiedName dbNameProperty
|
||||||
= new QualifiedName(CCorePlugin.PLUGIN_ID, "dbName"); //$NON-NLS-1$
|
= new QualifiedName(CCorePlugin.PLUGIN_ID, "dbName"); //$NON-NLS-1$
|
||||||
|
@ -95,6 +100,13 @@ public class PDOM extends PlatformObject
|
||||||
// TODO Conversion might be a nicer story down the road
|
// TODO Conversion might be a nicer story down the road
|
||||||
if (db.getVersion() != VERSION) {
|
if (db.getVersion() != VERSION) {
|
||||||
indexer.reindex();
|
indexer.reindex();
|
||||||
|
} else {
|
||||||
|
// populate the linkage cache
|
||||||
|
PDOMLinkage linkage = getFirstLinkage();
|
||||||
|
while (linkage != null) {
|
||||||
|
linkageCache.put(linkage.getLanguage().getId(), linkage);
|
||||||
|
linkage = linkage.getNextLinkage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +255,7 @@ public class PDOM extends PlatformObject
|
||||||
db.clear();
|
db.clear();
|
||||||
db.setVersion(VERSION);
|
db.setVersion(VERSION);
|
||||||
fileIndex = null;
|
fileIndex = null;
|
||||||
|
linkageCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() throws CoreException {
|
public boolean isEmpty() throws CoreException {
|
||||||
|
@ -310,11 +323,16 @@ public class PDOM extends PlatformObject
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMLinkage getLinkage(ILanguage language) throws CoreException {
|
public PDOMLinkage getLinkage(ILanguage language) throws CoreException {
|
||||||
|
PDOMLinkage linkage = (PDOMLinkage)linkageCache.get(language.getId());
|
||||||
|
if (linkage != null)
|
||||||
|
return linkage;
|
||||||
|
|
||||||
|
// Need to create it
|
||||||
IPDOMLinkageFactory factory = (IPDOMLinkageFactory)language.getAdapter(IPDOMLinkageFactory.class);
|
IPDOMLinkageFactory factory = (IPDOMLinkageFactory)language.getAdapter(IPDOMLinkageFactory.class);
|
||||||
String id = language.getId();
|
String id = language.getId();
|
||||||
int linkrec = db.getInt(LINKAGES);
|
int linkrec = db.getInt(LINKAGES);
|
||||||
while (linkrec != 0) {
|
while (linkrec != 0) {
|
||||||
if (id.equals(PDOMLinkage.getId(this, linkrec)))
|
if (PDOMLinkage.getId(this, linkrec).equals(id))
|
||||||
return factory.getLinkage(this, linkrec);
|
return factory.getLinkage(this, linkrec);
|
||||||
else
|
else
|
||||||
linkrec = PDOMLinkage.getNextLinkageRecord(this, linkrec);
|
linkrec = PDOMLinkage.getNextLinkageRecord(this, linkrec);
|
||||||
|
@ -327,7 +345,16 @@ public class PDOM extends PlatformObject
|
||||||
if (record == 0)
|
if (record == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
String id = PDOMLinkage.getId(this, record);
|
// First check the cache. We do a linear search since there will be very few linkages
|
||||||
|
// in a given database.
|
||||||
|
Iterator i = linkageCache.values().iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
PDOMLinkage linkage = (PDOMLinkage)i.next();
|
||||||
|
if (linkage.getRecord() == record)
|
||||||
|
return linkage;
|
||||||
|
}
|
||||||
|
|
||||||
|
String id = PDOMLinkage.getId(this, record).getString();
|
||||||
ILanguage language = LanguageManager.getInstance().getLanguage(id);
|
ILanguage language = LanguageManager.getInstance().getLanguage(id);
|
||||||
return getLinkage(language);
|
return getLinkage(language);
|
||||||
}
|
}
|
||||||
|
@ -336,9 +363,14 @@ public class PDOM extends PlatformObject
|
||||||
return getLinkage(db.getInt(LINKAGES));
|
return getLinkage(db.getInt(LINKAGES));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PDOMLinkage[] getLinkages() {
|
||||||
|
Collection values = linkageCache.values();
|
||||||
|
return (PDOMLinkage[])values.toArray(new PDOMLinkage[values.size()]);
|
||||||
|
}
|
||||||
public void insertLinkage(PDOMLinkage linkage) throws CoreException {
|
public void insertLinkage(PDOMLinkage linkage) throws CoreException {
|
||||||
linkage.setNext(db.getInt(LINKAGES));
|
linkage.setNext(db.getInt(LINKAGES));
|
||||||
db.putInt(LINKAGES, linkage.getRecord());
|
db.putInt(LINKAGES, linkage.getRecord());
|
||||||
|
linkageCache.put(linkage.getLanguage().getId(), linkage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMBinding getBinding(int record) throws CoreException {
|
public PDOMBinding getBinding(int record) throws CoreException {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.DBString;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ public class PDOMLanguage {
|
||||||
return pdom.getDB().getChar(record + ID);
|
return pdom.getDB().getChar(record + ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() throws CoreException {
|
public DBString getName() throws CoreException {
|
||||||
return pdom.getDB().getString(record + NAME);
|
return pdom.getDB().getString(record + NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public IPDOM getPDOM(ICProject project) {
|
public synchronized IPDOM getPDOM(ICProject project) {
|
||||||
try {
|
try {
|
||||||
IProject rproject = project.getProject();
|
IProject rproject = project.getProject();
|
||||||
IPDOM pdom = (IPDOM)rproject.getSessionProperty(pdomProperty);
|
IPDOM pdom = (IPDOM)rproject.getSessionProperty(pdomProperty);
|
||||||
|
@ -150,7 +150,8 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
if (indexerId == null) {
|
if (indexerId == null) {
|
||||||
// See if it is in the ICDescriptor
|
// See if it is in the ICDescriptor
|
||||||
try {
|
try {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project.getProject(), true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project.getProject(), false);
|
||||||
|
if (desc != null) {
|
||||||
ICExtensionReference[] ref = desc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
ICExtensionReference[] ref = desc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
if (ref != null && ref.length > 0) {
|
if (ref != null && ref.length > 0) {
|
||||||
indexerId = ref[0].getID();
|
indexerId = ref[0].getID();
|
||||||
|
@ -164,6 +165,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
indexerId = null;
|
indexerId = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,10 +90,6 @@ public class Chunk {
|
||||||
buffer.putChar(value.charAt(i));
|
buffer.putChar(value.charAt(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(int offset) {
|
|
||||||
return new String(getChars(offset));
|
|
||||||
}
|
|
||||||
|
|
||||||
Chunk getNextChunk() {
|
Chunk getNextChunk() {
|
||||||
return nextChunk;
|
return nextChunk;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 QNX Software Systems 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:
|
||||||
|
* QNX - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A String class for strings stored in the database. The idea
|
||||||
|
* is to minimize how often we extract the string.
|
||||||
|
*
|
||||||
|
* @author Doug Schaefer
|
||||||
|
*/
|
||||||
|
public class DBString {
|
||||||
|
|
||||||
|
private final Database db;
|
||||||
|
private final int offset;
|
||||||
|
|
||||||
|
DBString(Database db, int offset) {
|
||||||
|
this.db = db;
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == this)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (obj instanceof DBString) {
|
||||||
|
DBString string = (DBString)obj;
|
||||||
|
if (db == string.db && offset == string.offset)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Chunk chunk1 = db.getChunk(offset);
|
||||||
|
Chunk chunk2 = string.db.getChunk(string.offset);
|
||||||
|
|
||||||
|
int n1 = chunk1.getChar(offset);
|
||||||
|
int n2 = chunk2.getChar(string.offset);
|
||||||
|
if (n1 != n2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int i = 0; i < n1; ++i) {
|
||||||
|
int coffset1 = offset + 2 + i * 2;
|
||||||
|
int coffset2 = string.offset + 2 + i * 2;
|
||||||
|
if (chunk1.getChar(coffset1) != chunk2.getChar(coffset2))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (obj instanceof String) {
|
||||||
|
String string = (String)obj;
|
||||||
|
Chunk chunk = db.getChunk(offset);
|
||||||
|
|
||||||
|
// Make sure size is the same
|
||||||
|
int n = chunk.getChar(offset);
|
||||||
|
if (n != string.length())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Check each character
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
int coffset = offset + 2 + i * 2;
|
||||||
|
if (chunk.getChar(coffset) != string.charAt(i))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
// Custom hash code function to allow DBStrings in hashmaps.
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString() throws CoreException {
|
||||||
|
return new String(db.getChars(offset));
|
||||||
|
}
|
||||||
|
}
|
|
@ -297,9 +297,8 @@ public class Database {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(int offset) throws CoreException {
|
public DBString getString(int offset) throws CoreException {
|
||||||
Chunk chunk = getChunk(offset);
|
return new DBString(this, offset);
|
||||||
return chunk.getString(offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumChunks() {
|
public int getNumChunks() {
|
||||||
|
|
|
@ -144,7 +144,7 @@ public abstract class PDOMBinding extends PDOMNode implements IBinding {
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
try {
|
try {
|
||||||
return super.getName();
|
return super.getDBName().getString();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.DBString;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
|
@ -94,7 +95,7 @@ public class PDOMFile {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileName() throws CoreException {
|
public DBString getFileName() throws CoreException {
|
||||||
return pdom.getDB().getString(record + FILE_NAME);
|
return pdom.getDB().getString(record + FILE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ public class PDOMFile {
|
||||||
LinkedList todo = new LinkedList();
|
LinkedList todo = new LinkedList();
|
||||||
|
|
||||||
// Add me in to make sure we don't get caught in a circular include
|
// Add me in to make sure we don't get caught in a circular include
|
||||||
String myFileName = getFileName();
|
DBString myFileName = getFileName();
|
||||||
files.put(myFileName, this);
|
files.put(myFileName, this);
|
||||||
|
|
||||||
todo.addLast(this);
|
todo.addLast(this);
|
||||||
|
@ -187,7 +188,7 @@ public class PDOMFile {
|
||||||
PDOMInclude includedBy = getFirstIncludedBy();
|
PDOMInclude includedBy = getFirstIncludedBy();
|
||||||
while (includedBy != null) {
|
while (includedBy != null) {
|
||||||
PDOMFile incFile = includedBy.getIncludedBy();
|
PDOMFile incFile = includedBy.getIncludedBy();
|
||||||
String incFileName = incFile.getFileName();
|
DBString incFileName = incFile.getFileName();
|
||||||
if (files.get(incFileName) == null) {
|
if (files.get(incFileName) == null) {
|
||||||
files.put(incFileName, incFile);
|
files.put(incFileName, incFile);
|
||||||
todo.addLast(incFile);
|
todo.addLast(incFile);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.DBString;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -87,7 +88,7 @@ public abstract class PDOMLinkage extends PDOMNode {
|
||||||
return RECORD_SIZE;
|
return RECORD_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getId(PDOM pdom, int record) throws CoreException {
|
public static DBString getId(PDOM pdom, int record) throws CoreException {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
int namerec = db.getInt(record + ID_OFFSET);
|
int namerec = db.getInt(record + ID_OFFSET);
|
||||||
return db.getString(namerec);
|
return db.getString(namerec);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.DBString;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -287,7 +288,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
try {
|
try {
|
||||||
PDOMFile file = getFile();
|
PDOMFile file = getFile();
|
||||||
return file != null ? file.getFileName() : null;
|
return file != null ? file.getFileName().getString() : null;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.DBString;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
|
@ -89,7 +90,7 @@ public abstract class PDOMNode implements IPDOMNode{
|
||||||
return pdom.getLinkage(linkagerec);
|
return pdom.getLinkage(linkagerec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() throws CoreException {
|
public DBString getDBName() throws CoreException {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
int namerec = db.getInt(record + NAME_OFFSET);
|
int namerec = db.getInt(record + NAME_OFFSET);
|
||||||
return db.getString(namerec);
|
return db.getString(namerec);
|
||||||
|
|
|
@ -13,10 +13,8 @@ package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVariable;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
|
@ -31,9 +29,11 @@ public class PDOMCVariable extends PDOMBinding implements IVariable {
|
||||||
|
|
||||||
public PDOMCVariable(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
public PDOMCVariable(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||||
super(pdom, parent, name, PDOMCLinkage.CVARIABLE);
|
super(pdom, parent, name, PDOMCLinkage.CVARIABLE);
|
||||||
CVariable binding = (CVariable)name.getBinding();
|
IVariable binding = (IVariable)name.getBinding();
|
||||||
|
if (binding != null) {
|
||||||
IType type = binding.getType();
|
IType type = binding.getType();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public PDOMCVariable(PDOM pdom, int record) {
|
public PDOMCVariable(PDOM pdom, int record) {
|
||||||
super(pdom, record);
|
super(pdom, record);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class CtagsBindingFinder implements IPDOMVisitor {
|
||||||
|
|
||||||
public boolean visit(IPDOMNode node) throws CoreException {
|
public boolean visit(IPDOMNode node) throws CoreException {
|
||||||
PDOMBinding binding = (PDOMBinding)node;
|
PDOMBinding binding = (PDOMBinding)node;
|
||||||
if (binding.getName().equals(name)) {
|
if (name.equals(binding.getDBName())) {
|
||||||
int type = binding.getBindingType();
|
int type = binding.getBindingType();
|
||||||
for (int i = 0; i < types.length; ++i) {
|
for (int i = 0; i < types.length; ++i) {
|
||||||
if (type == types[i]) {
|
if (type == types[i]) {
|
||||||
|
|
|
@ -13,6 +13,8 @@ package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
|
@ -21,12 +23,13 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkage;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCVariable;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +43,7 @@ public class CtagsCName implements IASTName, IASTFileLocation {
|
||||||
private final int lineNum;
|
private final int lineNum;
|
||||||
private final String elementName;
|
private final String elementName;
|
||||||
private final Map fields;
|
private final Map fields;
|
||||||
|
private PDOMBinding binding;
|
||||||
private int kind; // Enum from below
|
private int kind; // Enum from below
|
||||||
|
|
||||||
private final static int K_UNKNOWN = 0;
|
private final static int K_UNKNOWN = 0;
|
||||||
|
@ -99,7 +103,7 @@ public class CtagsCName implements IASTName, IASTFileLocation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding getBinding() {
|
public IBinding getBinding() {
|
||||||
throw new PDOMNotImplementedError();
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeclaration() {
|
public boolean isDeclaration() {
|
||||||
|
@ -107,7 +111,8 @@ public class CtagsCName implements IASTName, IASTFileLocation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDefinition() {
|
public boolean isDefinition() {
|
||||||
throw new PDOMNotImplementedError();
|
// TODO base on kind
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReference() {
|
public boolean isReference() {
|
||||||
|
@ -115,13 +120,49 @@ public class CtagsCName implements IASTName, IASTFileLocation {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding resolveBinding() {
|
private PDOMBinding makeNewBinding(IPDOMNode scope) throws CoreException {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
case K_VARIABLE:
|
||||||
|
return new PDOMCVariable(linkage.getPDOM(), (PDOMNode)scope, this);
|
||||||
|
case K_FUNCTION:
|
||||||
|
return new PDOMCFunction(linkage.getPDOM(), (PDOMNode)scope, this);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IBinding resolveBinding() {
|
||||||
|
try {
|
||||||
|
IPDOMNode scope = linkage;
|
||||||
|
int[] types = null;
|
||||||
|
switch (kind) {
|
||||||
|
case K_VARIABLE:
|
||||||
|
types = new int[] { PDOMCLinkage.CVARIABLE };
|
||||||
|
break;
|
||||||
|
case K_FUNCTION:
|
||||||
|
types = new int[] { PDOMCLinkage.CFUNCTION };
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
CtagsBindingFinder finder = new CtagsBindingFinder(elementName, types);
|
||||||
|
scope.accept(finder);
|
||||||
|
PDOMBinding[] bindings = finder.getBindings();
|
||||||
|
if (bindings.length == 0)
|
||||||
|
binding = makeNewBinding(scope);
|
||||||
|
else if (bindings.length == 1)
|
||||||
|
binding = bindings[0];
|
||||||
|
else
|
||||||
|
// TODO resolve overloads
|
||||||
|
binding = bindings[0];
|
||||||
|
return binding;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IBinding[] resolvePrefix() {
|
public IBinding[] resolvePrefix() {
|
||||||
throw new PDOMNotImplementedError();
|
throw new PDOMNotImplementedError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPFunction;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkage;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPVariable;
|
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPVariable;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -59,6 +60,8 @@ public class CtagsCPPName implements IASTName, IASTFileLocation {
|
||||||
private final static int K_VARIABLE = 12;
|
private final static int K_VARIABLE = 12;
|
||||||
private final static int K_EXTERNALVAR = 13;
|
private final static int K_EXTERNALVAR = 13;
|
||||||
|
|
||||||
|
private PDOMBinding binding;
|
||||||
|
|
||||||
private final static String[] kinds = { // Order must match value of enum above
|
private final static String[] kinds = { // Order must match value of enum above
|
||||||
null, // unknown kinds
|
null, // unknown kinds
|
||||||
"class", //$NON-NLS-1$
|
"class", //$NON-NLS-1$
|
||||||
|
@ -100,7 +103,7 @@ public class CtagsCPPName implements IASTName, IASTFileLocation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding getBinding() {
|
public IBinding getBinding() {
|
||||||
throw new PDOMNotImplementedError();
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeclaration() {
|
public boolean isDeclaration() {
|
||||||
|
@ -121,6 +124,8 @@ public class CtagsCPPName implements IASTName, IASTFileLocation {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case K_VARIABLE:
|
case K_VARIABLE:
|
||||||
return new PDOMCPPVariable(linkage.getPDOM(), (PDOMNode)scope, this);
|
return new PDOMCPPVariable(linkage.getPDOM(), (PDOMNode)scope, this);
|
||||||
|
case K_FUNCTION:
|
||||||
|
return new PDOMCPPFunction(linkage.getPDOM(), (PDOMNode)scope, this);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -134,6 +139,9 @@ public class CtagsCPPName implements IASTName, IASTFileLocation {
|
||||||
case K_VARIABLE:
|
case K_VARIABLE:
|
||||||
types = new int[] { PDOMCPPLinkage.CPPVARIABLE };
|
types = new int[] { PDOMCPPLinkage.CPPVARIABLE };
|
||||||
break;
|
break;
|
||||||
|
case K_FUNCTION:
|
||||||
|
types = new int[] { PDOMCPPLinkage.CPPFUNCTION };
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -142,12 +150,13 @@ public class CtagsCPPName implements IASTName, IASTFileLocation {
|
||||||
scope.accept(finder);
|
scope.accept(finder);
|
||||||
PDOMBinding[] bindings = finder.getBindings();
|
PDOMBinding[] bindings = finder.getBindings();
|
||||||
if (bindings.length == 0)
|
if (bindings.length == 0)
|
||||||
return makeNewBinding(scope);
|
binding = makeNewBinding(scope);
|
||||||
else if (bindings.length == 1)
|
else if (bindings.length == 1)
|
||||||
return bindings[0];
|
binding = bindings[0];
|
||||||
else
|
else
|
||||||
// TODO resolve overloads
|
// TODO resolve overloads
|
||||||
return bindings[0];
|
binding = bindings[0];
|
||||||
|
return binding;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -92,6 +91,8 @@ public class CtagsHandleDelta extends CtagsIndexerJob {
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
|
} finally {
|
||||||
|
pdom.fireChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.core.dom.IPDOM;
|
import org.eclipse.cdt.core.dom.IPDOM;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
@ -38,7 +40,7 @@ public class CtagsIndexer implements IPDOMIndexer {
|
||||||
private String ctagsFileName = ""; //$NON-NLS-1$
|
private String ctagsFileName = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
public void handleDelta(ICElementDelta delta) {
|
public void handleDelta(ICElementDelta delta) {
|
||||||
// TODO Auto-generated method stub
|
new CtagsHandleDelta(this,delta).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reindex() throws CoreException {
|
public void reindex() throws CoreException {
|
||||||
|
@ -67,17 +69,55 @@ public class CtagsIndexer implements IPDOMIndexer {
|
||||||
if (prefs == null)
|
if (prefs == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ctagsCommand = prefs.get(ctagsCommandId, null);
|
||||||
|
if (ctagsCommand != null) {
|
||||||
useCtagsOnPath = prefs.getBoolean(useCtagsOnPathId, getDefaultUseCtagsOnPath());
|
useCtagsOnPath = prefs.getBoolean(useCtagsOnPathId, getDefaultUseCtagsOnPath());
|
||||||
ctagsCommand = prefs.get(ctagsCommandId, getDefaultCtagsCommand());
|
|
||||||
useInternalCtagsFile = prefs.getBoolean(useInternalCtagsFileId, getDefaultUseInternalCtagsFile());
|
useInternalCtagsFile = prefs.getBoolean(useInternalCtagsFileId, getDefaultUseInternalCtagsFile());
|
||||||
ctagsFileName = prefs.get(ctagsFileNameId, getDefaultCtagsFileName());
|
ctagsFileName = prefs.get(ctagsFileNameId, getDefaultCtagsFileName());
|
||||||
|
} else {
|
||||||
|
// Not defined yet check in cdescriptor
|
||||||
|
try {
|
||||||
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
||||||
|
if (desc != null) {
|
||||||
|
ICExtensionReference[] cext = desc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||||
|
if (cext.length > 0) {
|
||||||
|
for (int i = 0; i < cext.length; i++) {
|
||||||
|
String orig = cext[i].getExtensionData("ctagslocationtype"); //$NON-NLS-1$
|
||||||
|
useCtagsOnPath = orig != null
|
||||||
|
? !orig.equals("ctags_path_specified")
|
||||||
|
: getDefaultUseCtagsOnPath();
|
||||||
|
|
||||||
|
orig = cext[i].getExtensionData("ctagslocation"); //$NON-NLS-1$
|
||||||
|
ctagsCommand = orig != null ? orig : getDefaultCtagsCommand();
|
||||||
|
|
||||||
|
orig = cext[i].getExtensionData("ctagfiletype"); //$NON-NLS-1$
|
||||||
|
useInternalCtagsFile = orig != null
|
||||||
|
? !orig.equals("ctags_external") //$NON-NLS-1$
|
||||||
|
: getDefaultUseInternalCtagsFile();
|
||||||
|
|
||||||
|
orig = cext[i].getExtensionData("ctagfilelocation"); //$NON-NLS-1$
|
||||||
|
ctagsFileName = orig != null ? orig : getDefaultCtagsFileName();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctagsCommand == null) {
|
||||||
|
useCtagsOnPath = getDefaultUseCtagsOnPath();
|
||||||
|
ctagsCommand = getDefaultCtagsCommand();
|
||||||
|
useInternalCtagsFile = getDefaultUseInternalCtagsFile();
|
||||||
|
ctagsFileName = getDefaultCtagsFileName();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPreferences(
|
public void setPreferences(
|
||||||
boolean useCtagsOnPath,
|
boolean useCtagsOnPath,
|
||||||
String ctagsCommand,
|
String ctagsCommand,
|
||||||
boolean useInternalCtagsFile,
|
boolean useInternalCtagsFile,
|
||||||
String ctagsFileName) {
|
String ctagsFileName) throws CoreException {
|
||||||
|
|
||||||
IProject project = pdom.getProject().getProject();
|
IProject project = pdom.getProject().getProject();
|
||||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||||
|
@ -115,6 +155,7 @@ public class CtagsIndexer implements IPDOMIndexer {
|
||||||
} catch (BackingStoreException e) {
|
} catch (BackingStoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
reindex();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -46,6 +47,10 @@ public abstract class CtagsIndexerJob extends Job {
|
||||||
// Indexing functions
|
// Indexing functions
|
||||||
void runCtags(IPath sourcePath) {
|
void runCtags(IPath sourcePath) {
|
||||||
String ctagsFileName = indexer.getResolvedCtagsFileName();
|
String ctagsFileName = indexer.getResolvedCtagsFileName();
|
||||||
|
File ctagsFile = new File(ctagsFileName);
|
||||||
|
if (ctagsFile.exists())
|
||||||
|
ctagsFile.delete();
|
||||||
|
|
||||||
String[] cmd = new String[] {
|
String[] cmd = new String[] {
|
||||||
indexer.getResolvedCtagsCommand(),
|
indexer.getResolvedCtagsCommand(),
|
||||||
"--excmd=number", //$NON-NLS-1$
|
"--excmd=number", //$NON-NLS-1$
|
||||||
|
|
|
@ -12,9 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
package org.eclipse.cdt.internal.core.pdom.indexer.ctags;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IIncludeReference;
|
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|
||||||
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.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -35,33 +33,34 @@ public class CtagsReindex extends CtagsIndexerJob {
|
||||||
try {
|
try {
|
||||||
// What do we need to index
|
// What do we need to index
|
||||||
final ICProject project = pdom.getProject();
|
final ICProject project = pdom.getProject();
|
||||||
final IIncludeReference[] pincludes = project.getIncludeReferences();
|
// final IIncludeReference[] pincludes = project.getIncludeReferences();
|
||||||
IIncludeReference[] includes = new IIncludeReference[pincludes.length];
|
// IIncludeReference[] includes = new IIncludeReference[pincludes.length];
|
||||||
System.arraycopy(pincludes, 0, includes, 0, pincludes.length);
|
// System.arraycopy(pincludes, 0, includes, 0, pincludes.length);
|
||||||
|
|
||||||
// Find common prefix paths
|
// Find common prefix paths
|
||||||
for (int i = 0; i < includes.length; ++i) {
|
// for (int i = 0; i < includes.length; ++i) {
|
||||||
if (includes[i] == null)
|
// if (includes[i] == null)
|
||||||
continue;
|
// continue;
|
||||||
IPath pathi = includes[i].getPath();
|
// IPath pathi = includes[i].getPath();
|
||||||
for (int j = i + 1; j < includes.length; ++j) {
|
// for (int j = i + 1; j < includes.length; ++j) {
|
||||||
if (includes[j] == null)
|
// if (includes[j] == null)
|
||||||
continue;
|
// continue;
|
||||||
IPath pathj = includes[j].getPath();
|
// IPath pathj = includes[j].getPath();
|
||||||
if (pathi.isPrefixOf(pathj)) {
|
// if (pathi.isPrefixOf(pathj)) {
|
||||||
includes[j] = null;
|
// includes[j] = null;
|
||||||
} else if (pathj.isPrefixOf(pathi)) {
|
// } else if (pathj.isPrefixOf(pathi)) {
|
||||||
includes[i] = null;
|
// includes[i] = null;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
includes = (IIncludeReference[])ArrayUtil.removeNulls(IIncludeReference.class, includes);
|
// includes = (IIncludeReference[])ArrayUtil.removeNulls(IIncludeReference.class, includes);
|
||||||
|
|
||||||
ISourceRoot[] sourceRoots = project.getAllSourceRoots();
|
ISourceRoot[] sourceRoots = project.getAllSourceRoots();
|
||||||
|
|
||||||
monitor.beginTask("Indexing", sourceRoots.length + includes.length + 1);
|
monitor.beginTask("Indexing", sourceRoots.length + 1);
|
||||||
|
// + includes.length + 1);
|
||||||
|
|
||||||
// Clear out the PDOM
|
// Clear out the PDOM
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
|
@ -71,13 +70,13 @@ public class CtagsReindex extends CtagsIndexerJob {
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
|
|
||||||
// Index the include path
|
// Index the include path
|
||||||
for (int i = 0; i < includes.length; ++i) {
|
// for (int i = 0; i < includes.length; ++i) {
|
||||||
if (monitor.isCanceled())
|
// if (monitor.isCanceled())
|
||||||
return Status.CANCEL_STATUS;
|
// return Status.CANCEL_STATUS;
|
||||||
monitor.subTask(includes[i].getElementName());
|
// monitor.subTask(includes[i].getElementName());
|
||||||
runCtags(includes[i].getPath());
|
// runCtags(includes[i].getPath());
|
||||||
monitor.worked(1);
|
// monitor.worked(1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Index the source roots
|
// Index the source roots
|
||||||
for (int i = 0; i < sourceRoots.length; ++i) {
|
for (int i = 0; i < sourceRoots.length; ++i) {
|
||||||
|
@ -95,6 +94,7 @@ public class CtagsReindex extends CtagsIndexerJob {
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
pdom.fireChange();
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
||||||
if (includedBy.length > 0) {
|
if (includedBy.length > 0) {
|
||||||
IProject project = tu.getCProject().getProject();
|
IProject project = tu.getCProject().getProject();
|
||||||
for (int i = 0; i < includedBy.length; ++i) {
|
for (int i = 0; i < includedBy.length; ++i) {
|
||||||
String incfilename = includedBy[i].getFileName();
|
String incfilename = includedBy[i].getFileName().getString();
|
||||||
if (CoreModel.isValidSourceUnitName(project, incfilename)) {
|
if (CoreModel.isValidSourceUnitName(project, incfilename)) {
|
||||||
if (changed.get(incfilename) == null) {
|
if (changed.get(incfilename) == null) {
|
||||||
IFile[] rfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(incfilename));
|
IFile[] rfiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(incfilename));
|
||||||
|
|
|
@ -219,12 +219,12 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
try {
|
try {
|
||||||
if (element instanceof ICProject) {
|
if (element instanceof ICProject) {
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM((ICProject)element);
|
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM((ICProject)element);
|
||||||
PDOMLinkage firstLinkage = pdom.getFirstLinkage();
|
PDOMLinkage[] linkages = pdom.getLinkages();
|
||||||
if (firstLinkage == null)
|
if (linkages.length == 0)
|
||||||
return false;
|
return false;
|
||||||
else if (firstLinkage.getNextLinkage() == null)
|
else if (linkages.length == 1)
|
||||||
// Skipping linkages if only one
|
// Skipping linkages if only one
|
||||||
return hasChildren(firstLinkage);
|
return hasChildren(linkages[0]);
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
} else if (element instanceof IPDOMNode) {
|
} else if (element instanceof IPDOMNode) {
|
||||||
|
@ -270,13 +270,13 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
return "null :(";
|
return "null :(";
|
||||||
} else if (element instanceof PDOMNode) {
|
} else if (element instanceof PDOMNode) {
|
||||||
try {
|
try {
|
||||||
return ((PDOMNode)element).getName();
|
return ((PDOMNode)element).getDBName().getString();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return e.getMessage();
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
} else if (element instanceof LinkageCache) {
|
} else if (element instanceof LinkageCache) {
|
||||||
try {
|
try {
|
||||||
return ((LinkageCache)element).getName();
|
return ((LinkageCache)element).getName().getString();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return e.getMessage();
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.ui.indexview;
|
package org.eclipse.cdt.internal.ui.indexview;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.DBString;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
|
@ -82,7 +83,7 @@ public class LinkageCache {
|
||||||
return pdom.getBinding(cache[index]);
|
return pdom.getBinding(cache[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() throws CoreException {
|
public DBString getName() throws CoreException {
|
||||||
return linkage.getName();
|
return linkage.getDBName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,19 @@
|
||||||
package org.eclipse.cdt.ui.dialogs;
|
package org.eclipse.cdt.ui.dialogs;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
import org.eclipse.cdt.core.ICExtensionReference;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.indexer.ctags.CtagsIndexer;
|
||||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
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.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -39,16 +40,15 @@ import org.eclipse.swt.widgets.Text;
|
||||||
*/
|
*/
|
||||||
public class CTagsIndexerBlock extends AbstractIndexerPage {
|
public class CTagsIndexerBlock extends AbstractIndexerPage {
|
||||||
|
|
||||||
|
protected CtagsIndexer ctagsIndexer;
|
||||||
|
|
||||||
protected boolean internalTagsFile = true;
|
protected boolean internalTagsFile = true;
|
||||||
protected boolean externalTagsFile = false;
|
|
||||||
protected Button internalCTagsFile;
|
protected Button internalCTagsFile;
|
||||||
protected Button externalCTagsFile;
|
protected Button externalCTagsFile;
|
||||||
protected Button indexIncludePaths;
|
|
||||||
protected Button browseButton;
|
protected Button browseButton;
|
||||||
protected Text cTagsFile;
|
protected Text cTagsFile;
|
||||||
|
|
||||||
protected boolean useDefaultCTags = true;
|
protected boolean useDefaultCTags = true;
|
||||||
protected boolean useSpecifiedCTagsExecutable = false;
|
|
||||||
protected Button useCTagsPath;
|
protected Button useCTagsPath;
|
||||||
protected Button useCTagsExecutable;
|
protected Button useCTagsExecutable;
|
||||||
protected Button browseButtonCTagsExec;
|
protected Button browseButtonCTagsExec;
|
||||||
|
@ -60,119 +60,49 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
|
||||||
public final static String PREF_CTAGS_LOCATION_TYPE = CUIPlugin.PLUGIN_ID + ".ctagslocationtype"; //$NON-NLS-1$
|
public final static String PREF_CTAGS_LOCATION_TYPE = CUIPlugin.PLUGIN_ID + ".ctagslocationtype"; //$NON-NLS-1$
|
||||||
public final static String PREF_CTAGS_LOCATION = CUIPlugin.PLUGIN_ID + ".ctagslocation"; //$NON-NLS-1$
|
public final static String PREF_CTAGS_LOCATION = CUIPlugin.PLUGIN_ID + ".ctagslocation"; //$NON-NLS-1$
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.ui.index.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
|
|
||||||
*/
|
|
||||||
public void initialize(ICProject project) {
|
public void initialize(ICProject project) {
|
||||||
|
|
||||||
this.currentProject = project;
|
this.currentProject = project;
|
||||||
try {
|
try {
|
||||||
loadPersistedValues(project.getProject());
|
loadPersistedValues(project);
|
||||||
} catch (CoreException e) {}
|
} catch (CoreException e) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
|
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
|
||||||
ICOptionContainer container = getContainer();
|
if (ctagsIndexer != null) {
|
||||||
IProject proj = null;
|
ctagsIndexer.setPreferences(
|
||||||
String internalExternalCTagsString = ""; //internalTagsFile ? CTagsIndexer.CTAGS_INTERNAL : CTagsIndexer.CTAGS_EXTERNAL;
|
useDefaultCTags,
|
||||||
String cTagsFileLocation = ""; //$NON-NLS-1$
|
cTagsExecutable.getText(),
|
||||||
if (!internalTagsFile)
|
internalTagsFile,
|
||||||
cTagsFileLocation = cTagsFile.getText();
|
cTagsFile.getText());
|
||||||
|
|
||||||
String indexIncludeFiles = new Boolean(indexIncludePaths.getSelection()).toString();
|
|
||||||
|
|
||||||
String cTagsLocationType = ""; //useDefaultCTags ? CTagsIndexer.CTAGS_PATH_DEFAULT : CTagsIndexer.CTAGS_PATH_SPECIFIED;
|
|
||||||
String cTagsLocation = ""; //$NON-NLS-1$
|
|
||||||
if (!useDefaultCTags)
|
|
||||||
cTagsLocation=cTagsExecutable.getText();
|
|
||||||
|
|
||||||
//if external has been chosen, ensure that there is a cTagsFileLocation selected; otherwise default
|
|
||||||
//to internal file
|
|
||||||
// if (internalExternalCTagsString.equals(CTagsIndexer.CTAGS_EXTERNAL) && cTagsFileLocation.equals("")) //$NON-NLS-1$
|
|
||||||
// internalExternalCTagsString=CTagsIndexer.CTAGS_INTERNAL;
|
|
||||||
|
|
||||||
//if an external CPaths has been selected but no path has been provided, switch back to default setting
|
|
||||||
// if (cTagsLocationType.equals(CTagsIndexer.CTAGS_PATH_SPECIFIED) && cTagsLocation.equals("")) //$NON-NLS-1$
|
|
||||||
// cTagsLocationType=CTagsIndexer.CTAGS_PATH_DEFAULT;
|
|
||||||
|
|
||||||
if (container != null){
|
|
||||||
proj = container.getProject();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
proj = currentProject.getProject();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proj != null) {
|
|
||||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
|
|
||||||
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
|
||||||
if (cext.length > 0) {
|
|
||||||
for (int i = 0; i < cext.length; i++) {
|
|
||||||
String orig = cext[i].getExtensionData("ctagfiletype"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(internalExternalCTagsString)) {
|
|
||||||
cext[i].setExtensionData("ctagfiletype", internalExternalCTagsString); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
orig = cext[i].getExtensionData("ctagfilelocation"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(cTagsFileLocation)) {
|
|
||||||
cext[i].setExtensionData("ctagfilelocation", cTagsFileLocation); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
orig = cext[i].getExtensionData("ctagsindexincludes"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(indexIncludeFiles)) {
|
|
||||||
cext[i].setExtensionData("ctagsindexincludes", indexIncludeFiles); //$NON-NLS-1$
|
|
||||||
if (indexIncludeFiles.equals( "true")){ //$NON-NLS-1$
|
|
||||||
// CCorePlugin.getDefault().getCoreModel().getIndexManager().addResource(proj,proj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
orig = cext[i].getExtensionData("ctagslocationtype"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(cTagsLocationType)) {
|
|
||||||
cext[i].setExtensionData("ctagslocationtype", cTagsLocationType); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
orig = cext[i].getExtensionData("ctagslocation"); //$NON-NLS-1$
|
|
||||||
if (orig == null || !orig.equals(cTagsLocation)) {
|
|
||||||
cext[i].setExtensionData("ctagslocation", cTagsLocation); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (prefStore != null) {
|
CtagsIndexer.setDefaultPreferences(
|
||||||
prefStore.setValue(PREF_INTOREXT_CTAGS, internalExternalCTagsString);
|
useDefaultCTags,
|
||||||
prefStore.setValue(PREF_CTAGS_FILE_LOCATION_CTAGS,cTagsFileLocation);
|
cTagsExecutable.getText(),
|
||||||
prefStore.setValue(PREF_CTAGS_INDEXINCLUDEFILES,indexIncludeFiles);
|
internalTagsFile,
|
||||||
prefStore.setValue(PREF_CTAGS_LOCATION_TYPE,cTagsLocationType);
|
cTagsFile.getText());
|
||||||
prefStore.setValue(PREF_CTAGS_LOCATION,cTagsLocation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
|
||||||
*/
|
|
||||||
public void performDefaults() {
|
public void performDefaults() {
|
||||||
//ctag file options
|
//ctag file options
|
||||||
internalTagsFile=true;
|
internalTagsFile=true;
|
||||||
externalTagsFile=false;
|
|
||||||
internalCTagsFile.setSelection(true);
|
internalCTagsFile.setSelection(true);
|
||||||
externalCTagsFile.setSelection(false);
|
externalCTagsFile.setSelection(false);
|
||||||
cTagsFile.setText(""); //$NON-NLS-1$
|
cTagsFile.setText(""); //$NON-NLS-1$
|
||||||
browseButton.setEnabled(false);
|
browseButton.setEnabled(false);
|
||||||
//ctag path options
|
//ctag path options
|
||||||
useDefaultCTags=true;
|
useDefaultCTags=true;
|
||||||
useSpecifiedCTagsExecutable=false;
|
|
||||||
useCTagsPath.setSelection(true);
|
useCTagsPath.setSelection(true);
|
||||||
useCTagsExecutable.setSelection(false);
|
useCTagsExecutable.setSelection(false);
|
||||||
cTagsExecutable.setText(""); //$NON-NLS-1$
|
cTagsExecutable.setText(""); //$NON-NLS-1$
|
||||||
browseButtonCTagsExec.setEnabled(false);
|
browseButtonCTagsExec.setEnabled(false);
|
||||||
//index include paths
|
|
||||||
indexIncludePaths.setSelection(false);
|
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
Composite page = ControlFactory.createComposite(parent, 1);
|
Composite page = ControlFactory.createComposite(parent, 1);
|
||||||
|
|
||||||
|
@ -184,13 +114,8 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
|
||||||
SelectionListener cTagsListener = new SelectionAdapter() {
|
SelectionListener cTagsListener = new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
useDefaultCTags = useCTagsPath.getSelection();
|
useDefaultCTags = useCTagsPath.getSelection();
|
||||||
useSpecifiedCTagsExecutable = useCTagsExecutable.getSelection();
|
|
||||||
|
|
||||||
if (useDefaultCTags){
|
if (useDefaultCTags){
|
||||||
// setButtonState(CTagsIndexer.CTAGS_PATH_DEFAULT);
|
setCommandState();
|
||||||
}
|
|
||||||
if (useSpecifiedCTagsExecutable){
|
|
||||||
// setButtonState(CTagsIndexer.CTAGS_PATH_SPECIFIED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -223,15 +148,6 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
|
|
||||||
Group includeGroup = ControlFactory.createGroup(page,CUIMessages.getString("CTagsIndexerBlock.includeGroup"),1); //$NON-NLS-1$
|
|
||||||
GridData gd2 = (GridData) includeGroup.getLayoutData();
|
|
||||||
gd2.grabExcessHorizontalSpace = true;
|
|
||||||
gd2.horizontalAlignment = GridData.FILL;
|
|
||||||
|
|
||||||
indexIncludePaths = ControlFactory.createCheckBox(includeGroup,CUIMessages.getString("CTagsIndexerBlock.indexIncludes"));//$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
((GridData)indexIncludePaths.getLayoutData()).horizontalSpan =1;
|
|
||||||
((GridData)indexIncludePaths.getLayoutData()).grabExcessHorizontalSpace = true;
|
|
||||||
|
|
||||||
Group group = ControlFactory.createGroup(page, CUIMessages.getString("CTagsIndexerBlock.blockName"),3); //$NON-NLS-1$
|
Group group = ControlFactory.createGroup(page, CUIMessages.getString("CTagsIndexerBlock.blockName"),3); //$NON-NLS-1$
|
||||||
|
|
||||||
GridData gd = (GridData) group.getLayoutData();
|
GridData gd = (GridData) group.getLayoutData();
|
||||||
|
@ -242,13 +158,8 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
|
||||||
SelectionListener cListener = new SelectionAdapter() {
|
SelectionListener cListener = new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
internalTagsFile = internalCTagsFile.getSelection();
|
internalTagsFile = internalCTagsFile.getSelection();
|
||||||
externalTagsFile = externalCTagsFile.getSelection();
|
|
||||||
|
|
||||||
if (externalTagsFile){
|
|
||||||
// setButtonState(CTagsIndexer.CTAGS_EXTERNAL);
|
|
||||||
}
|
|
||||||
if (internalTagsFile){
|
if (internalTagsFile){
|
||||||
// setButtonState(CTagsIndexer.CTAGS_INTERNAL);
|
setFilenameState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -294,83 +205,41 @@ public class CTagsIndexerBlock extends AbstractIndexerPage {
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadPersistedValues(IProject project) throws CoreException {
|
public void loadPersistedValues(ICProject project) throws CoreException {
|
||||||
|
IPDOMIndexer indexer = CCorePlugin.getPDOMManager().getPDOM(project).getIndexer();
|
||||||
|
if (!(indexer instanceof CtagsIndexer))
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Wrong indexer", null));
|
||||||
|
ctagsIndexer = (CtagsIndexer)indexer;
|
||||||
|
|
||||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
useDefaultCTags = ctagsIndexer.useCtagsOnPath();
|
||||||
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
cTagsExecutable.setText(ctagsIndexer.getCtagsCommand());
|
||||||
if (cext.length > 0) {
|
setCommandState();
|
||||||
for (int i = 0; i < cext.length; i++) {
|
|
||||||
String orig = cext[i].getExtensionData("ctagfiletype"); //$NON-NLS-1$
|
internalTagsFile = ctagsIndexer.useInternalCtagsFile();
|
||||||
if (orig != null){
|
cTagsFile.setText(ctagsIndexer.getCtagsFileName());
|
||||||
setButtonState(orig);
|
setFilenameState();
|
||||||
}
|
}
|
||||||
|
|
||||||
orig = cext[i].getExtensionData("ctagfilelocation"); //$NON-NLS-1$
|
private void setCommandState() {
|
||||||
if (orig != null){
|
useCTagsPath.setSelection(useDefaultCTags);
|
||||||
cTagsFile.setText(orig);
|
useCTagsExecutable.setSelection(!useDefaultCTags);
|
||||||
|
browseButtonCTagsExec.setEnabled(!useDefaultCTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
orig = cext[i].getExtensionData("ctagsindexincludes"); //$NON-NLS-1$
|
private void setFilenameState() {
|
||||||
if (orig != null){
|
internalCTagsFile.setSelection(internalTagsFile);
|
||||||
if (new Boolean(orig).booleanValue()){
|
externalCTagsFile.setSelection(!internalTagsFile);
|
||||||
indexIncludePaths.setSelection(true);
|
browseButton.setEnabled(!internalTagsFile);
|
||||||
} else {
|
|
||||||
indexIncludePaths.setSelection(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
orig = cext[i].getExtensionData("ctagslocationtype"); //$NON-NLS-1$
|
|
||||||
if (orig != null){
|
|
||||||
setButtonState(orig);
|
|
||||||
}
|
|
||||||
|
|
||||||
orig = cext[i].getExtensionData("ctagslocation"); //$NON-NLS-1$
|
|
||||||
if (orig != null){
|
|
||||||
cTagsExecutable.setText(orig);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setButtonState(String orig){
|
|
||||||
// if (orig.equals(CTagsIndexer.CTAGS_INTERNAL)){
|
|
||||||
// internalTagsFile=true;
|
|
||||||
// externalTagsFile=false;
|
|
||||||
// internalCTagsFile.setSelection(true);
|
|
||||||
// externalCTagsFile.setSelection(false);
|
|
||||||
// browseButton.setEnabled(false);
|
|
||||||
// } else if (orig.equals(CTagsIndexer.CTAGS_EXTERNAL)){
|
|
||||||
// externalTagsFile=true;
|
|
||||||
// internalTagsFile=false;
|
|
||||||
// externalCTagsFile.setSelection(true);
|
|
||||||
// internalCTagsFile.setSelection(false);
|
|
||||||
// browseButton.setEnabled(true);
|
|
||||||
// } else if(orig.equals(CTagsIndexer.CTAGS_PATH_DEFAULT)){
|
|
||||||
// useDefaultCTags=true;
|
|
||||||
// useSpecifiedCTagsExecutable=false;
|
|
||||||
// useCTagsPath.setSelection(true);
|
|
||||||
// useCTagsExecutable.setSelection(false);
|
|
||||||
// browseButtonCTagsExec.setEnabled(false);
|
|
||||||
// } else if(orig.equals(CTagsIndexer.CTAGS_PATH_SPECIFIED)){
|
|
||||||
// useDefaultCTags=false;
|
|
||||||
// useSpecifiedCTagsExecutable=true;
|
|
||||||
// useCTagsPath.setSelection(false);
|
|
||||||
// useCTagsExecutable.setSelection(true);
|
|
||||||
// browseButtonCTagsExec.setEnabled(true);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadPreferences() {
|
public void loadPreferences() {
|
||||||
String indexerId=prefStore.getString(PREF_INTOREXT_CTAGS);
|
useDefaultCTags = CtagsIndexer.getDefaultUseCtagsOnPath();
|
||||||
if (!indexerId.equals("")) { //$NON-NLS-1$
|
cTagsExecutable.setText(CtagsIndexer.getDefaultCtagsCommand());
|
||||||
setButtonState(indexerId);
|
setCommandState();
|
||||||
}
|
|
||||||
|
|
||||||
indexerId=prefStore.getString(PREF_CTAGS_FILE_LOCATION_CTAGS);
|
internalTagsFile = CtagsIndexer.getDefaultUseInternalCtagsFile();
|
||||||
if (!indexerId.equals("")) { //$NON-NLS-1$
|
cTagsFile.setText(CtagsIndexer.getDefaultCtagsFileName());
|
||||||
cTagsFile.setText(indexerId);
|
setFilenameState();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePreferences() {
|
public void removePreferences() {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||||
|
@ -338,7 +339,9 @@ public class IndexerBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
if ( project != null) {
|
if ( project != null) {
|
||||||
ICProject cproject = CoreModel.getDefault().create(project);
|
ICProject cproject = CoreModel.getDefault().create(project);
|
||||||
CCorePlugin.getPDOMManager().setIndexerId(cproject, indexerID);
|
IPDOMManager manager = CCorePlugin.getPDOMManager();
|
||||||
|
if (!indexerID.equals(manager.getIndexerId(cproject)))
|
||||||
|
manager.setIndexerId(cproject, indexerID);
|
||||||
if (currentPage != null && currentPage.getControl() != null) {
|
if (currentPage != null && currentPage.getControl() != null) {
|
||||||
currentPage.performApply(new SubProgressMonitor(monitor, 1));
|
currentPage.performApply(new SubProgressMonitor(monitor, 1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue