mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Getting ready to PDOM-ize the completion processor.
This commit is contained in:
parent
21dde9f148
commit
9b82414491
6 changed files with 113 additions and 210 deletions
|
@ -78,14 +78,19 @@ public interface ILanguage extends IAdaptable {
|
||||||
int style) throws CoreException;
|
int style) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the AST Completion Node for the given working copy at the given
|
* Return the AST completion node for the given offset.
|
||||||
* offset.
|
|
||||||
*
|
*
|
||||||
* @param workingCopy
|
* @param reader
|
||||||
|
* @param scanInfo
|
||||||
|
* @param fileCreator
|
||||||
|
* @param index
|
||||||
|
* @param log
|
||||||
* @param offset
|
* @param offset
|
||||||
* @return
|
* @return
|
||||||
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset) throws CoreException;
|
public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gather the list of IASTNames that appear the selection with the given start offset
|
* Gather the list of IASTNames that appear the selection with the given start offset
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
@ -456,4 +457,15 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException;
|
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the completion node using the given index and parsing style at the given offset.
|
||||||
|
*
|
||||||
|
* @param index
|
||||||
|
* @param style
|
||||||
|
* @param offset
|
||||||
|
* @return
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public ASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ 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;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
@ -303,47 +304,29 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ISourceManipulation#copy(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
public void copy(ICElement container, ICElement sibling, String rename, boolean force,
|
public void copy(ICElement container, ICElement sibling, String rename, boolean force,
|
||||||
IProgressMonitor monitor) throws CModelException {
|
IProgressMonitor monitor) throws CModelException {
|
||||||
getSourceManipulationInfo().copy(container, sibling, rename, force, monitor);
|
getSourceManipulationInfo().copy(container, sibling, rename, force, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
public void delete(boolean force, IProgressMonitor monitor) throws CModelException {
|
public void delete(boolean force, IProgressMonitor monitor) throws CModelException {
|
||||||
getSourceManipulationInfo().delete(force, monitor);
|
getSourceManipulationInfo().delete(force, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ISourceManipulation#move(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
public void move(ICElement container, ICElement sibling, String rename, boolean force,
|
public void move(ICElement container, ICElement sibling, String rename, boolean force,
|
||||||
IProgressMonitor monitor) throws CModelException {
|
IProgressMonitor monitor) throws CModelException {
|
||||||
getSourceManipulationInfo().move(container, sibling, rename, force, monitor);
|
getSourceManipulationInfo().move(container, sibling, rename, force, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
public void rename(String name, boolean force, IProgressMonitor monitor)
|
public void rename(String name, boolean force, IProgressMonitor monitor)
|
||||||
throws CModelException {
|
throws CModelException {
|
||||||
getSourceManipulationInfo().rename(name, force, monitor);
|
getSourceManipulationInfo().rename(name, force, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ISourceReference#getSource()
|
|
||||||
*/
|
|
||||||
public String getSource() throws CModelException {
|
public String getSource() throws CModelException {
|
||||||
return getSourceManipulationInfo().getSource();
|
return getSourceManipulationInfo().getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ISourceReference#getSourceRange()
|
|
||||||
*/
|
|
||||||
public ISourceRange getSourceRange() throws CModelException {
|
public ISourceRange getSourceRange() throws CModelException {
|
||||||
return getSourceManipulationInfo().getSourceRange();
|
return getSourceManipulationInfo().getSourceRange();
|
||||||
}
|
}
|
||||||
|
@ -376,9 +359,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return super.equals(o) && !((ITranslationUnit) o).isWorkingCopy();
|
return super.equals(o) && !((ITranslationUnit) o).isWorkingCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#findSharedWorkingCopy(org.eclipse.cdt.internal.core.model.IBufferFactory)
|
|
||||||
*/
|
|
||||||
public IWorkingCopy findSharedWorkingCopy(IBufferFactory factory) {
|
public IWorkingCopy findSharedWorkingCopy(IBufferFactory factory) {
|
||||||
|
|
||||||
// if factory is null, default factory must be used
|
// if factory is null, default factory must be used
|
||||||
|
@ -394,23 +374,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return (WorkingCopy) perFactoryWorkingCopies.get(this);
|
return (WorkingCopy) perFactoryWorkingCopies.get(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.Openable#isOpen()
|
|
||||||
*/
|
|
||||||
public synchronized boolean isOpen() {
|
public synchronized boolean isOpen() {
|
||||||
return super.isOpen();
|
return super.isOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.CElement#getElementInfo(org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
public synchronized CElementInfo getElementInfo(IProgressMonitor monitor) throws CModelException {
|
public synchronized CElementInfo getElementInfo(IProgressMonitor monitor) throws CModelException {
|
||||||
return super.getElementInfo(monitor);
|
return super.getElementInfo(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.Openable#buildStructure(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.runtime.IProgressMonitor, java.util.Map, org.eclipse.core.resources.IResource)
|
|
||||||
*/
|
|
||||||
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException {
|
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException {
|
||||||
TranslationUnitInfo unitInfo = (TranslationUnitInfo) info;
|
TranslationUnitInfo unitInfo = (TranslationUnitInfo) info;
|
||||||
|
|
||||||
|
@ -436,9 +407,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return unitInfo.isStructureKnown();
|
return unitInfo.isStructureKnown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getContents()
|
|
||||||
*/
|
|
||||||
public char[] getContents() {
|
public char[] getContents() {
|
||||||
try {
|
try {
|
||||||
IBuffer buffer = this.getBuffer();
|
IBuffer buffer = this.getBuffer();
|
||||||
|
@ -448,17 +416,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getSharedWorkingCopy(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.cdt.internal.core.model.IBufferFactory)
|
|
||||||
*/
|
|
||||||
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor,IBufferFactory factory)
|
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor,IBufferFactory factory)
|
||||||
throws CModelException {
|
throws CModelException {
|
||||||
return getSharedWorkingCopy(monitor, factory, null);
|
return getSharedWorkingCopy(monitor, factory, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getSharedWorkingCopy(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.cdt.internal.core.model.IBufferFactory, org.eclipse.cdt.core.model.IProblemRequestor)
|
|
||||||
*/
|
|
||||||
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor,IBufferFactory factory, IProblemRequestor requestor)
|
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor,IBufferFactory factory, IProblemRequestor requestor)
|
||||||
throws CModelException {
|
throws CModelException {
|
||||||
|
|
||||||
|
@ -487,16 +449,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return (IWorkingCopy) op.getResultElements()[0];
|
return (IWorkingCopy) op.getResultElements()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getWorkingCopy()
|
|
||||||
*/
|
|
||||||
public IWorkingCopy getWorkingCopy() throws CModelException {
|
public IWorkingCopy getWorkingCopy() throws CModelException {
|
||||||
return this.getWorkingCopy(null, null);
|
return this.getWorkingCopy(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.cdt.internal.core.model.IBufferFactory)
|
|
||||||
*/
|
|
||||||
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory)throws CModelException{
|
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory)throws CModelException{
|
||||||
WorkingCopy workingCopy = new WorkingCopy(getParent(), getFile(), getContentTypeId(), factory);
|
WorkingCopy workingCopy = new WorkingCopy(getParent(), getFile(), getContentTypeId(), factory);
|
||||||
// open the working copy now to ensure contents are that of the current state of this element
|
// open the working copy now to ensure contents are that of the current state of this element
|
||||||
|
@ -511,9 +467,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see Openable#openParent
|
|
||||||
*/
|
|
||||||
protected void openParent(Object childInfo, Map newElements, IProgressMonitor pm) throws CModelException {
|
protected void openParent(Object childInfo, Map newElements, IProgressMonitor pm) throws CModelException {
|
||||||
try {
|
try {
|
||||||
super.openParent(childInfo, newElements, pm);
|
super.openParent(childInfo, newElements, pm);
|
||||||
|
@ -525,16 +478,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.IOpenable#isConsistent()
|
|
||||||
*/
|
|
||||||
public boolean isConsistent() throws CModelException {
|
public boolean isConsistent() throws CModelException {
|
||||||
return CModelManager.getDefault().getElementsOutOfSynchWithBuffers().get(this) == null;
|
return CModelManager.getDefault().getElementsOutOfSynchWithBuffers().get(this) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.Openable#makeConsistent(org.eclipse.core.runtime.IProgressMonitor, boolean)
|
|
||||||
*/
|
|
||||||
public void makeConsistent(IProgressMonitor monitor, boolean forced) throws CModelException {
|
public void makeConsistent(IProgressMonitor monitor, boolean forced) throws CModelException {
|
||||||
makeConsistent(false, monitor);
|
makeConsistent(false, monitor);
|
||||||
}
|
}
|
||||||
|
@ -584,23 +531,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.Openable#isSourceElement()
|
|
||||||
*/
|
|
||||||
protected boolean isSourceElement() {
|
protected boolean isSourceElement() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isWorkingCopy()
|
|
||||||
*/
|
|
||||||
public boolean isWorkingCopy() {
|
public boolean isWorkingCopy() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.Openable#openBuffer(org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
|
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
|
||||||
|
|
||||||
// create buffer - translation units only use default buffer factory
|
// create buffer - translation units only use default buffer factory
|
||||||
|
@ -626,9 +564,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#parse()
|
|
||||||
*/
|
|
||||||
public Map parse() {
|
public Map parse() {
|
||||||
throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$
|
throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -681,9 +616,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return problemRequestor;
|
return problemRequestor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isHeaderUnit()
|
|
||||||
*/
|
|
||||||
public boolean isHeaderUnit() {
|
public boolean isHeaderUnit() {
|
||||||
return (
|
return (
|
||||||
CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId)
|
CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId)
|
||||||
|
@ -691,9 +623,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isSourceUnit()
|
|
||||||
*/
|
|
||||||
public boolean isSourceUnit() {
|
public boolean isSourceUnit() {
|
||||||
if (isHeaderUnit())
|
if (isHeaderUnit())
|
||||||
return false;
|
return false;
|
||||||
|
@ -706,9 +635,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isCLanguage()
|
|
||||||
*/
|
|
||||||
public boolean isCLanguage() {
|
public boolean isCLanguage() {
|
||||||
return (
|
return (
|
||||||
CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)
|
CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)
|
||||||
|
@ -716,9 +642,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isCXXLanguage()
|
|
||||||
*/
|
|
||||||
public boolean isCXXLanguage() {
|
public boolean isCXXLanguage() {
|
||||||
return (
|
return (
|
||||||
CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|
CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|
||||||
|
@ -726,17 +649,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#isASMLanguage()
|
|
||||||
*/
|
|
||||||
public boolean isASMLanguage() {
|
public boolean isASMLanguage() {
|
||||||
return CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId);
|
return CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ICElement#exists()
|
|
||||||
*/
|
|
||||||
public boolean exists() {
|
public boolean exists() {
|
||||||
IResource res = getResource();
|
IResource res = getResource();
|
||||||
if (res != null)
|
if (res != null)
|
||||||
|
@ -763,9 +679,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getContentTypeId()
|
|
||||||
*/
|
|
||||||
public String getContentTypeId() {
|
public String getContentTypeId() {
|
||||||
return contentTypeId;
|
return contentTypeId;
|
||||||
}
|
}
|
||||||
|
@ -774,9 +687,6 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
contentTypeId = id;
|
contentTypeId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.Openable#closing(java.lang.Object)
|
|
||||||
*/
|
|
||||||
protected void closing(Object info) throws CModelException {
|
protected void closing(Object info) throws CModelException {
|
||||||
IContentType cType = CCorePlugin.getContentType(getCProject().getProject(), getElementName());
|
IContentType cType = CCorePlugin.getContentType(getCProject().getProject(), getElementName());
|
||||||
if (cType != null) {
|
if (cType != null) {
|
||||||
|
@ -799,16 +709,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getAST()
|
|
||||||
*/
|
|
||||||
public IASTTranslationUnit getAST() throws CoreException {
|
public IASTTranslationUnit getAST() throws CoreException {
|
||||||
return getAST(null, 0);
|
return getAST(null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getAST(org.eclipse.cdt.core.index.IIndex, int)
|
|
||||||
*/
|
|
||||||
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException {
|
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException {
|
||||||
ICodeReaderFactory codeReaderFactory;
|
ICodeReaderFactory codeReaderFactory;
|
||||||
if (index != null && (style & (ITranslationUnit.AST_SKIP_INDEXED_HEADERS | ITranslationUnit.AST_SKIP_ALL_HEADERS)) != 0) {
|
if (index != null && (style & (ITranslationUnit.AST_SKIP_INDEXED_HEADERS | ITranslationUnit.AST_SKIP_ALL_HEADERS)) != 0) {
|
||||||
|
@ -833,6 +737,30 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException {
|
||||||
|
ICodeReaderFactory codeReaderFactory;
|
||||||
|
if (index != null && (style & (ITranslationUnit.AST_SKIP_INDEXED_HEADERS | ITranslationUnit.AST_SKIP_ALL_HEADERS)) != 0) {
|
||||||
|
codeReaderFactory= new IndexBasedCodeReaderFactory(index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
codeReaderFactory = SavedCodeReaderFactory.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
IScannerInfo scanInfo = getScannerInfo( (style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0);
|
||||||
|
if (scanInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeReader reader;
|
||||||
|
reader = getCodeReader();
|
||||||
|
|
||||||
|
ILanguage language= getLanguage();
|
||||||
|
if (language != null) {
|
||||||
|
return language.getCompletionNode(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService(), offset);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public CodeReader getCodeReader() {
|
public CodeReader getCodeReader() {
|
||||||
CodeReader reader;
|
CodeReader reader;
|
||||||
IPath location= getLocation();
|
IPath location= getLocation();
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.ArrayList;
|
||||||
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.CDOM;
|
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -26,20 +25,16 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
|
||||||
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||||
|
@ -48,8 +43,6 @@ import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfigur
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
|
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,33 +86,7 @@ public class GCCLanguage extends AbstractLanguage {
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset) throws CoreException {
|
public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException {
|
||||||
IResource resource = workingCopy.getResource();
|
|
||||||
ICProject project = workingCopy.getCProject();
|
|
||||||
IProject rproject = project.getProject();
|
|
||||||
|
|
||||||
IScannerInfo scanInfo = null;
|
|
||||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
|
||||||
if (provider != null){
|
|
||||||
IResource infoResource = resource != null ? resource : rproject;
|
|
||||||
IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
|
|
||||||
if (buildScanInfo != null)
|
|
||||||
scanInfo = buildScanInfo;
|
|
||||||
else
|
|
||||||
scanInfo = new ScannerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO use the pdom once we get enough info into it
|
|
||||||
// PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject()).getAdapter(PDOM.class);
|
|
||||||
// ICodeReaderFactory fileCreator = new PDOMCodeReaderFactory(pdom);
|
|
||||||
|
|
||||||
ICodeReaderFactory fileCreator = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
|
||||||
|
|
||||||
String path
|
|
||||||
= resource != null
|
|
||||||
? resource.getLocation().toOSString()
|
|
||||||
: workingCopy.getOriginalElement().getPath().toOSString();
|
|
||||||
CodeReader reader = new CodeReader(path, workingCopy.getContents());
|
|
||||||
IScannerExtensionConfiguration scannerExtensionConfiguration
|
IScannerExtensionConfiguration scannerExtensionConfiguration
|
||||||
= C_GNU_SCANNER_EXTENSION;
|
= C_GNU_SCANNER_EXTENSION;
|
||||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.ArrayList;
|
||||||
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.CDOM;
|
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -26,20 +25,16 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
|
||||||
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||||
|
@ -48,8 +43,6 @@ import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfigur
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,29 +86,7 @@ public class GPPLanguage extends AbstractLanguage {
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset) throws CoreException {
|
public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException {
|
||||||
IResource resource = workingCopy.getResource();
|
|
||||||
ICProject project = workingCopy.getCProject();
|
|
||||||
IProject rproject = project.getProject();
|
|
||||||
|
|
||||||
IScannerInfo scanInfo = null;
|
|
||||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
|
||||||
if (provider != null){
|
|
||||||
IResource infoResource = resource != null ? resource : rproject;
|
|
||||||
IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
|
|
||||||
if (buildScanInfo != null)
|
|
||||||
scanInfo = buildScanInfo;
|
|
||||||
else
|
|
||||||
scanInfo = new ScannerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO use the pdom once we get enough info into it
|
|
||||||
// PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject()).getAdapter(PDOM.class);
|
|
||||||
// ICodeReaderFactory fileCreator = new PDOMCodeReaderFactory(pdom);
|
|
||||||
|
|
||||||
ICodeReaderFactory fileCreator = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
|
||||||
|
|
||||||
CodeReader reader = new CodeReader(resource.getLocation().toOSString(), workingCopy.getContents());
|
|
||||||
IScannerExtensionConfiguration scannerExtensionConfiguration
|
IScannerExtensionConfiguration scannerExtensionConfiguration
|
||||||
= CPP_GNU_SCANNER_EXTENSION;
|
= CPP_GNU_SCANNER_EXTENSION;
|
||||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||||
|
|
|
@ -13,15 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
|
||||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
|
||||||
import org.eclipse.cdt.internal.ui.preferences.ProposalFilterPreferencesUtil;
|
|
||||||
import org.eclipse.cdt.internal.ui.text.CParameterListValidator;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
|
||||||
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
|
|
||||||
import org.eclipse.cdt.ui.text.contentassist.IProposalFilter;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
|
@ -37,6 +28,20 @@ import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
|
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||||
|
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
|
||||||
|
import org.eclipse.cdt.ui.text.contentassist.IProposalFilter;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||||
|
import org.eclipse.cdt.internal.ui.preferences.ProposalFilterPreferencesUtil;
|
||||||
|
import org.eclipse.cdt.internal.ui.text.CParameterListValidator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*/
|
*/
|
||||||
|
@ -60,10 +65,23 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, int offset) {
|
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, int offset) {
|
||||||
try {
|
try {
|
||||||
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
||||||
|
IIndex index = CCorePlugin.getIndexManager().getIndex(workingCopy.getCProject(),
|
||||||
|
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
||||||
|
|
||||||
|
try {
|
||||||
|
index.acquireReadLock();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
String prefix = null;
|
String prefix = null;
|
||||||
|
|
||||||
if (workingCopy != null) {
|
if (workingCopy != null) {
|
||||||
fCurrentCompletionNode = workingCopy.getLanguage().getCompletionNode(workingCopy, offset);
|
// TODO, to improve performance, we want to skip all headers
|
||||||
|
// But right now we're not getting any completions
|
||||||
|
// fCurrentCompletionNode = workingCopy.getCompletionNode(index, ITranslationUnit.AST_SKIP_ALL_HEADERS, offset);
|
||||||
|
fCurrentCompletionNode = workingCopy.getCompletionNode(index, 0, offset);
|
||||||
|
|
||||||
if (fCurrentCompletionNode != null)
|
if (fCurrentCompletionNode != null)
|
||||||
prefix = fCurrentCompletionNode.getPrefix();
|
prefix = fCurrentCompletionNode.getPrefix();
|
||||||
|
@ -99,7 +117,9 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
ICCompletionProposal[] proposalsFiltered = filter.filterProposals(proposalsInput);
|
ICCompletionProposal[] proposalsFiltered = filter.filterProposals(proposalsInput);
|
||||||
|
|
||||||
return proposalsFiltered;
|
return proposalsFiltered;
|
||||||
|
} finally {
|
||||||
|
index.releaseReadLock();
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
errorMessage = e.toString();
|
errorMessage = e.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue