mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Further IASTNodeLocation & framework updates.
This commit is contained in:
parent
da52887933
commit
d4bd5b2942
12 changed files with 93 additions and 113 deletions
|
@ -25,10 +25,4 @@ public interface IASTFileLocation extends IASTNodeLocation {
|
||||||
public String getFileName();
|
public String getFileName();
|
||||||
public void setFileName( String fileName );
|
public void setFileName( String fileName );
|
||||||
|
|
||||||
/**
|
|
||||||
* @param b
|
|
||||||
*/
|
|
||||||
public void setResolved(boolean b);
|
|
||||||
public boolean getResolved();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,8 @@ public interface IASTTranslationUnit extends IASTNode {
|
||||||
public IASTNodeLocation getLocationInfo( int offset );
|
public IASTNodeLocation getLocationInfo( int offset );
|
||||||
public IASTNodeLocation [] getLocationInfo( int offset, int length );
|
public IASTNodeLocation [] getLocationInfo( int offset, int length );
|
||||||
|
|
||||||
public IASTNode getNodeForLocation( IASTNodeLocation location );
|
public IASTNode[] selectNodesForLocation( String path, int offset, int length );
|
||||||
|
public IASTNode[] selectNodesForLocation( int offset, int length );
|
||||||
|
|
||||||
public IASTMacroDefinition [] getMacroDefinitions();
|
public IASTMacroDefinition [] getMacroDefinitions();
|
||||||
public IASTPreprocessorIncludeStatement [] getIncludeDirectives();
|
public IASTPreprocessorIncludeStatement [] getIncludeDirectives();
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
public class ASTFileLocation implements IASTFileLocation {
|
public class ASTFileLocation implements IASTFileLocation {
|
||||||
|
|
||||||
private String fn;
|
private String fn;
|
||||||
private boolean resolved;
|
|
||||||
private int o;
|
private int o;
|
||||||
private int l;
|
private int l;
|
||||||
|
|
||||||
|
@ -36,20 +35,6 @@ public class ASTFileLocation implements IASTFileLocation {
|
||||||
fn = fileName;
|
fn = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTFileLocation#setResolved(boolean)
|
|
||||||
*/
|
|
||||||
public void setResolved(boolean b) {
|
|
||||||
resolved = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTFileLocation#getResolved()
|
|
||||||
*/
|
|
||||||
public boolean getResolved() {
|
|
||||||
return resolved;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTNodeLocation#getNodeOffset()
|
* @see org.eclipse.cdt.core.dom.ast.IASTNodeLocation#getNodeOffset()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,6 +36,10 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
//Binding
|
//Binding
|
||||||
private CScope compilationUnit = null;
|
private CScope compilationUnit = null;
|
||||||
private ILocationResolver resolver;
|
private ILocationResolver resolver;
|
||||||
|
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
||||||
|
private static final IASTNodeLocation[] EMPTY_PREPROCESSOR_LOCATION_ARRAY = new IASTNodeLocation[0];
|
||||||
|
private static final IASTMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = new IASTMacroDefinition[0];
|
||||||
|
private static final IASTPreprocessorIncludeStatement[] EMPTY_PREPROCESSOR_INCLUSION_ARRAY = new IASTPreprocessorIncludeStatement[0];
|
||||||
|
|
||||||
public void addDeclaration( IASTDeclaration d )
|
public void addDeclaration( IASTDeclaration d )
|
||||||
{
|
{
|
||||||
|
@ -111,6 +115,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLocationInfo(int)
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLocationInfo(int)
|
||||||
*/
|
*/
|
||||||
public IASTNodeLocation getLocationInfo(int offset) {
|
public IASTNodeLocation getLocationInfo(int offset) {
|
||||||
|
if( resolver == null ) return null;
|
||||||
return resolver.getLocation(offset);
|
return resolver.getLocation(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +124,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLocationInfo(int, int)
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLocationInfo(int, int)
|
||||||
*/
|
*/
|
||||||
public IASTNodeLocation[] getLocationInfo(int offset, int length) {
|
public IASTNodeLocation[] getLocationInfo(int offset, int length) {
|
||||||
|
if( resolver == null ) return EMPTY_PREPROCESSOR_LOCATION_ARRAY;
|
||||||
return resolver.getLocations(offset,length);
|
return resolver.getLocations(offset,length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +132,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
|
||||||
*/
|
*/
|
||||||
public IASTNode getNodeForLocation(IASTNodeLocation location) {
|
public IASTNode[] selectNodesForLocation(String path, int offset, int length) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -136,6 +142,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions()
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions()
|
||||||
*/
|
*/
|
||||||
public IASTMacroDefinition[] getMacroDefinitions() {
|
public IASTMacroDefinition[] getMacroDefinitions() {
|
||||||
|
if( resolver == null ) return EMPTY_PREPROCESSOR_MACRODEF_ARRAY;
|
||||||
return resolver.getMacroDefinitions(this);
|
return resolver.getMacroDefinitions(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +151,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getIncludeDirectives()
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getIncludeDirectives()
|
||||||
*/
|
*/
|
||||||
public IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
|
public IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
|
||||||
|
if( resolver == null ) return EMPTY_PREPROCESSOR_INCLUSION_ARRAY;
|
||||||
return resolver.getIncludeDirectives(this);
|
return resolver.getIncludeDirectives(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +160,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getAllPreprocessorStatements()
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getAllPreprocessorStatements()
|
||||||
*/
|
*/
|
||||||
public IASTPreprocessorStatement[] getAllPreprocessorStatements() {
|
public IASTPreprocessorStatement[] getAllPreprocessorStatements() {
|
||||||
|
if( resolver == null ) return EMPTY_PREPROCESSOR_STATEMENT_ARRAY;
|
||||||
return resolver.getAllPreprocessorStatements(this);
|
return resolver.getAllPreprocessorStatements(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,4 +171,20 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
public void setLocationResolver(ILocationResolver resolver) {
|
public void setLocationResolver(ILocationResolver resolver) {
|
||||||
this.resolver = resolver;
|
this.resolver = resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#selectNodesForLocation(int, int)
|
||||||
|
*/
|
||||||
|
public IASTNode[] selectNodesForLocation(int offset, int length) {
|
||||||
|
return selectNodesForLocation( "", offset, length ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#finalize()
|
||||||
|
*/
|
||||||
|
protected void finalize() throws Throwable {
|
||||||
|
if( resolver != null ) resolver.cleanup();
|
||||||
|
super.finalize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,7 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
|
||||||
*/
|
*/
|
||||||
public IASTNode getNodeForLocation(IASTNodeLocation location) {
|
public IASTNode[] selectNodesForLocation(String path, int offset, int length) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,4 +160,12 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
public void setLocationResolver(ILocationResolver resolver) {
|
public void setLocationResolver(ILocationResolver resolver) {
|
||||||
this.resolver = resolver;
|
this.resolver = resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#selectNodesForLocation(int, int)
|
||||||
|
*/
|
||||||
|
public IASTNode[] selectNodesForLocation(int offset, int length) {
|
||||||
|
return selectNodesForLocation( resolver.getTranslationUnitPath(), offset, length ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ 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.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -27,5 +28,11 @@ public interface ILocationResolver {
|
||||||
|
|
||||||
public IASTNodeLocation [] getLocations( int offset, int length );
|
public IASTNodeLocation [] getLocations( int offset, int length );
|
||||||
public IASTNodeLocation getLocation( int offset );
|
public IASTNodeLocation getLocation( int offset );
|
||||||
|
public IProblem [] getScannerProblems();
|
||||||
|
|
||||||
|
public String getTranslationUnitPath();
|
||||||
|
public String [] getInclusionsPaths();
|
||||||
|
|
||||||
|
public void cleanup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
|
@ -54,4 +56,6 @@ public interface IScannerPreprocessorLog {
|
||||||
public void encounterPoundElif(int startOffset, int endOffset);
|
public void encounterPoundElif(int startOffset, int endOffset);
|
||||||
|
|
||||||
public void encounterPoundEndIf(int startOffset, int endOffset);
|
public void encounterPoundEndIf(int startOffset, int endOffset);
|
||||||
|
|
||||||
|
public void encounterProblem( IProblem problem );
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@ 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.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -209,4 +210,43 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getTranslationUnitPath()
|
||||||
|
*/
|
||||||
|
public String getTranslationUnitPath() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getInclusionsPaths()
|
||||||
|
*/
|
||||||
|
public String[] getInclusionsPaths() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#cleanup()
|
||||||
|
*/
|
||||||
|
public void cleanup() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getScannerProblems()
|
||||||
|
*/
|
||||||
|
public IProblem[] getScannerProblems() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterIProblem(org.eclipse.cdt.core.parser.IProblem)
|
||||||
|
*/
|
||||||
|
public void encounterProblem(IProblem problem) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3466,9 +3466,10 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
* @see org.eclipse.cdt.core.parser.IScanner#getLocationResolver()
|
* @see org.eclipse.cdt.core.parser.IScanner#getLocationResolver()
|
||||||
*/
|
*/
|
||||||
public ILocationResolver getLocationResolver() {
|
public ILocationResolver getLocationResolver() {
|
||||||
// TODO Auto-generated method stub
|
if( locationMap instanceof ILocationResolver )
|
||||||
|
return (ILocationResolver) locationMap;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final IScannerPreprocessorLog locationMap = new LocationMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.core.dom;
|
package org.eclipse.cdt.core.dom;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLocationFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.InternalASTServiceProvider;
|
import org.eclipse.cdt.internal.core.dom.InternalASTServiceProvider;
|
||||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||||
|
|
||||||
|
@ -88,9 +87,6 @@ public class CDOM {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTLocationFactory getLocationFactory()
|
|
||||||
{
|
|
||||||
return new EclipseLocationFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM - Initial API and implementation
|
|
||||||
**********************************************************************/
|
|
||||||
package org.eclipse.cdt.core.dom;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLocationFactory;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTResourceLocation;
|
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTFileLocation;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public class EclipseLocationFactory implements IASTLocationFactory {
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTLocationFactory#createUnresolvedFileLocation(java.lang.String, int, int)
|
|
||||||
*/
|
|
||||||
public IASTFileLocation createUnresolvedFileLocation(String path,
|
|
||||||
int offset, int length) {
|
|
||||||
IASTFileLocation result = new ASTFileLocation();
|
|
||||||
result.setResolved(false);
|
|
||||||
result.setNodeOffset( offset );
|
|
||||||
result.setNodeLength( length );
|
|
||||||
result.setFileName( path );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTLocationFactory#createUnresolvedResourceLocation(org.eclipse.core.resources.IResource, int, int)
|
|
||||||
*/
|
|
||||||
public IASTResourceLocation createUnresolvedResourceLocation(
|
|
||||||
IResource resource, int offset, int length) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTLocationFactory#createUnresolvedWorkingCopyLocation(org.eclipse.cdt.core.model.IWorkingCopy, int, int)
|
|
||||||
*/
|
|
||||||
public IASTResourceLocation createUnresolvedWorkingCopyLocation(
|
|
||||||
IWorkingCopy workingCopy, int offset, int length) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM - Initial API and implementation
|
|
||||||
**********************************************************************/
|
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public interface IASTLocationFactory {
|
|
||||||
|
|
||||||
public IASTFileLocation createUnresolvedFileLocation( String path, int offset, int length );
|
|
||||||
public IASTResourceLocation createUnresolvedResourceLocation( IResource resource, int offset, int length );
|
|
||||||
public IASTResourceLocation createUnresolvedWorkingCopyLocation( IWorkingCopy workingCopy, int offset, int length );
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue