mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix warnings.
This commit is contained in:
parent
344265a6a1
commit
4b12c3a302
72 changed files with 838 additions and 966 deletions
|
@ -43,6 +43,7 @@ public class AsmModelBuilderTest extends BaseTestCase {
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
fCProject= CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER);
|
||||
|
@ -52,6 +53,7 @@ public class AsmModelBuilderTest extends BaseTestCase {
|
|||
assertNotNull(fTU);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
CProjectHelper.delete(fCProject);
|
||||
super.tearDown();
|
||||
|
@ -101,10 +103,10 @@ public class AsmModelBuilderTest extends BaseTestCase {
|
|||
|
||||
public void testAsmLabelRanges() throws Exception {
|
||||
String source= fTU.getBuffer().getContents();
|
||||
ICElement[] labels= (ICElement[]) fTU.getChildrenOfType(ICElement.ASM_LABEL).toArray(new ICElement[0]);
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
String name= labels[i].getElementName();
|
||||
ISourceReference label= (ISourceReference)labels[i];
|
||||
ICElement[] labels= fTU.getChildrenOfType(ICElement.ASM_LABEL).toArray(new ICElement[0]);
|
||||
for (ICElement label2 : labels) {
|
||||
String name= label2.getElementName();
|
||||
ISourceReference label= (ISourceReference)label2;
|
||||
ISourceRange range= label.getSourceRange();
|
||||
assertEquals(source.substring(range.getIdStartPos(), range.getIdStartPos() + range.getIdLength()), name);
|
||||
int endOfLabel= source.indexOf("/* end */", range.getIdStartPos());
|
||||
|
|
|
@ -360,7 +360,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
|||
} else if( parent instanceof IASTFunctionDefinition )
|
||||
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
|
||||
|
||||
if( declSpec.getStorageClass() == storage ) {
|
||||
if( declSpec != null && declSpec.getStorageClass() == storage ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
|||
} else if( parent instanceof IASTFunctionDefinition )
|
||||
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
|
||||
|
||||
if( declSpec.isInline() )
|
||||
if( declSpec != null && declSpec.isInline() )
|
||||
return true;
|
||||
}
|
||||
if( ds != null && ++i < ds.length )
|
||||
|
|
|
@ -64,16 +64,17 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
|
||||
public IASTDeclaration getPrimaryDeclaration() throws DOMException{
|
||||
//first check if we already know it
|
||||
IASTDeclaration decl= findDeclaration(getDefinition());
|
||||
if (decl != null) {
|
||||
return decl;
|
||||
}
|
||||
|
||||
IASTName [] declarations = (IASTName[]) getDeclarations();
|
||||
if( declarations != null || getDefinition() != null ){
|
||||
int len = ( declarations != null ) ? declarations.length : 0;
|
||||
for( int i = -1; i < len; i++ ){
|
||||
IASTNode node = ( i == -1 ) ? getDefinition() : declarations[i];
|
||||
if( node != null ){
|
||||
while( !(node instanceof IASTDeclaration ) )
|
||||
node = node.getParent();
|
||||
if( node.getParent() instanceof ICPPASTCompositeTypeSpecifier )
|
||||
return (IASTDeclaration) node;
|
||||
if (declarations != null) {
|
||||
for (IASTName name : declarations) {
|
||||
decl= findDeclaration(name);
|
||||
if (decl != null) {
|
||||
return decl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,15 +84,15 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
ICPPClassScope scope = (ICPPClassScope) getScope();
|
||||
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(scope);
|
||||
IASTDeclaration [] members = compSpec.getMembers();
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i] instanceof IASTSimpleDeclaration ){
|
||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
|
||||
for( int j = 0; j < dtors.length; j++ ){
|
||||
IASTName name = dtors[j].getName();
|
||||
for (IASTDeclaration member : members) {
|
||||
if( member instanceof IASTSimpleDeclaration ){
|
||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)member).getDeclarators();
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
IASTName name = dtor.getName();
|
||||
if( CharArrayUtils.equals( name.toCharArray(), myName ) &&
|
||||
name.resolveBinding() == this )
|
||||
{
|
||||
return members[i];
|
||||
return member;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +100,16 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
return null;
|
||||
}
|
||||
|
||||
private IASTDeclaration findDeclaration(IASTNode node) {
|
||||
while(node != null && node instanceof IASTDeclaration == false) {
|
||||
node = node.getParent();
|
||||
}
|
||||
if (node != null && node.getParent() instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
return (IASTDeclaration) node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getVisibility() throws DOMException {
|
||||
ICPPASTVisibilityLabel vis = null;
|
||||
IASTDeclaration decl = getPrimaryDeclaration();
|
||||
|
@ -106,10 +117,10 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent();
|
||||
IASTDeclaration [] members = cls.getMembers();
|
||||
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i] instanceof ICPPASTVisibilityLabel )
|
||||
vis = (ICPPASTVisibilityLabel) members[i];
|
||||
else if( members[i] == decl )
|
||||
for (IASTDeclaration member : members) {
|
||||
if( member instanceof ICPPASTVisibilityLabel )
|
||||
vis = (ICPPASTVisibilityLabel) member;
|
||||
else if( member == decl )
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
*/
|
||||
public class CPPFieldSpecialization extends CPPSpecialization implements ICPPField {
|
||||
private IType type = null;
|
||||
/**
|
||||
* @param orig
|
||||
* @param args
|
||||
* @param args
|
||||
*/
|
||||
|
||||
public CPPFieldSpecialization( IBinding orig, ICPPScope scope, ObjectMap argMap ) {
|
||||
super(orig, scope, argMap);
|
||||
}
|
||||
|
|
|
@ -448,7 +448,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
} else if (parent instanceof IASTFunctionDefinition) {
|
||||
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
|
||||
}
|
||||
if (declSpec.getStorageClass() == storage) {
|
||||
if (declSpec != null && declSpec.getStorageClass() == storage) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
else if (parent instanceof IASTFunctionDefinition)
|
||||
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
|
||||
|
||||
if (declSpec.isInline())
|
||||
if (declSpec != null && declSpec.isInline())
|
||||
return true;
|
||||
}
|
||||
if (ds != null && ++i < ds.length)
|
||||
|
@ -498,8 +498,8 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
}
|
||||
IASTNode[] ds= getDeclarations();
|
||||
if (ds != null) {
|
||||
for (int i = 0; i < ds.length; i++) {
|
||||
if (CPPVisitor.isExternC(ds[i])) {
|
||||
for (IASTNode element : ds) {
|
||||
if (CPPVisitor.isExternC(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
|
|||
declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier();
|
||||
else if( parent instanceof IASTFunctionDefinition )
|
||||
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
|
||||
if( declSpec.getStorageClass() == storage ) {
|
||||
if( declSpec != null && declSpec.getStorageClass() == storage ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
|
|||
else if( parent instanceof IASTFunctionDefinition )
|
||||
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
|
||||
|
||||
if( declSpec.isInline() )
|
||||
if( declSpec != null && declSpec.isInline() )
|
||||
return true;
|
||||
}
|
||||
if( ns != null && ++i < ns.length )
|
||||
|
@ -307,8 +307,8 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
|
|||
}
|
||||
IASTNode[] ds= getDeclarations();
|
||||
if (ds != null) {
|
||||
for (int i = 0; i < ds.length; i++) {
|
||||
if (CPPVisitor.isExternC(ds[i])) {
|
||||
for (IASTNode element : ds) {
|
||||
if (CPPVisitor.isExternC(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent();
|
||||
IASTDeclaration [] members = cls.getMembers();
|
||||
ICPPASTVisibilityLabel vis = null;
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i] instanceof ICPPASTVisibilityLabel )
|
||||
vis = (ICPPASTVisibilityLabel) members[i];
|
||||
else if( members[i] == decl )
|
||||
for (IASTDeclaration member : members) {
|
||||
if( member instanceof ICPPASTVisibilityLabel )
|
||||
vis = (ICPPASTVisibilityLabel) member;
|
||||
else if( member == decl )
|
||||
break;
|
||||
}
|
||||
if( vis != null ){
|
||||
|
@ -78,11 +78,11 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
public IASTDeclaration getPrimaryDeclaration() throws DOMException{
|
||||
//first check if we already know it
|
||||
if( declarations != null ){
|
||||
for( int i = 0; i < declarations.length; i++ ){
|
||||
if (declarations[i] == null) {
|
||||
for (ICPPASTFunctionDeclarator declaration : declarations) {
|
||||
if (declaration == null) {
|
||||
break;
|
||||
}
|
||||
IASTDeclaration decl = (IASTDeclaration) declarations[i].getParent();
|
||||
IASTDeclaration decl = (IASTDeclaration) declaration.getParent();
|
||||
if( decl.getParent() instanceof ICPPASTCompositeTypeSpecifier )
|
||||
return decl;
|
||||
}
|
||||
|
@ -96,12 +96,11 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
return null;
|
||||
}
|
||||
IASTDeclaration [] members = compSpec.getMembers();
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
for (IASTDeclaration member : members) {
|
||||
IASTDeclarator dtor = null;
|
||||
IASTDeclarator [] ds = null;
|
||||
int di = -1;
|
||||
|
||||
IASTDeclaration member = members[i];
|
||||
if( member instanceof ICPPASTTemplateDeclaration )
|
||||
member = ((ICPPASTTemplateDeclaration) member).getDeclaration();
|
||||
if( member instanceof IASTSimpleDeclaration ){
|
||||
|
@ -112,8 +111,6 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
if( ds != null && ds.length > 0 ){
|
||||
di = 0;
|
||||
dtor = ds[0];
|
||||
}
|
||||
|
||||
while( dtor != null ){
|
||||
IASTName name = dtor.getName();
|
||||
if( dtor instanceof ICPPASTFunctionDeclarator &&
|
||||
|
@ -148,12 +145,13 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
addDeclaration( dtor );
|
||||
else if( member instanceof IASTFunctionDefinition )
|
||||
addDefinition( dtor );
|
||||
return members[i];
|
||||
return member;
|
||||
}
|
||||
}
|
||||
dtor = ( di > -1 && ++ di < ds.length ) ? ds[di] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ public interface ICPPInternalDeferredClassInstance {
|
|||
|
||||
/**
|
||||
* instantiate the original template
|
||||
* @return
|
||||
*/
|
||||
public IType instantiate(ObjectMap argMap);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,5 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
public interface ICPPInternalUnknown extends ICPPInternalBinding {
|
||||
public ICPPScope getUnknownScope();
|
||||
|
||||
/**
|
||||
* @param argMap
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException;
|
||||
}
|
||||
|
|
|
@ -398,8 +398,7 @@ public class CPPSemantics {
|
|||
IType[] ps = getSourceParameterTypes(data.functionParameters);
|
||||
ObjectSet<IScope> namespaces = new ObjectSet<IScope>(2);
|
||||
ObjectSet<ICPPClassType> classes = new ObjectSet<ICPPClassType>(2);
|
||||
for (int i = 0; i < ps.length; i++) {
|
||||
IType p = ps[i];
|
||||
for (IType p : ps) {
|
||||
p = getUltimateType(p, true);
|
||||
try {
|
||||
getAssociatedScopes(p, namespaces, classes, data.tu);
|
||||
|
@ -421,10 +420,10 @@ public class CPPSemantics {
|
|||
|
||||
ICPPClassType cls = (ICPPClassType) t;
|
||||
ICPPBase[] bases = cls.getBases();
|
||||
for (int i = 0; i < bases.length; i++) {
|
||||
if (bases[i] instanceof IProblemBinding)
|
||||
for (ICPPBase base : bases) {
|
||||
if (base instanceof IProblemBinding)
|
||||
continue;
|
||||
IBinding b = bases[i].getBaseClass();
|
||||
IBinding b = base.getBaseClass();
|
||||
if (b instanceof IType)
|
||||
getAssociatedScopes((IType) b, namespaces, classes, tu);
|
||||
}
|
||||
|
@ -438,8 +437,8 @@ public class CPPSemantics {
|
|||
|
||||
getAssociatedScopes(getUltimateType(ft.getReturnType(), true), namespaces, classes, tu);
|
||||
IType[] ps = ft.getParameterTypes();
|
||||
for (int i = 0; i < ps.length; i++) {
|
||||
getAssociatedScopes(getUltimateType(ps[i], true), namespaces, classes, tu);
|
||||
for (IType element : ps) {
|
||||
getAssociatedScopes(getUltimateType(element, true), namespaces, classes, tu);
|
||||
}
|
||||
} else if (t instanceof ICPPPointerToMemberType) {
|
||||
IBinding binding = ((ICPPPointerToMemberType)t).getMemberOfClass();
|
||||
|
@ -511,29 +510,36 @@ public class CPPSemantics {
|
|||
|
||||
CharArrayObjectMap map = null;
|
||||
Object[] objs = null;
|
||||
int size;
|
||||
if (source instanceof CharArrayObjectMap) {
|
||||
map = (CharArrayObjectMap) source;
|
||||
size= map.size();
|
||||
} else {
|
||||
if (source instanceof Object[])
|
||||
objs = ArrayUtil.trim(Object.class, (Object[]) source);
|
||||
else
|
||||
objs = new Object[]{ source };
|
||||
size= objs.length;
|
||||
}
|
||||
|
||||
int size = map != null ? map.size() : objs.length;
|
||||
int resultInitialSize = resultMap.size();
|
||||
for (int i = 0; i < size; i ++) {
|
||||
char[] key = (map != null) ?
|
||||
map.keyAt(i) :
|
||||
(objs[i] instanceof IBinding) ?
|
||||
((IBinding) objs[i]).getNameCharArray() :
|
||||
((IASTName) objs[i]).toCharArray();
|
||||
char[] key;
|
||||
Object so;
|
||||
if (map != null) {
|
||||
key= map.keyAt(i);
|
||||
so= map.get(key);
|
||||
} else if (objs != null) {
|
||||
so= objs[i];
|
||||
key= (so instanceof IBinding) ? ((IBinding) so).getNameCharArray() : ((IASTName) so).toCharArray();
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
int idx = resultMap.lookup(key);
|
||||
if (idx == -1) {
|
||||
resultMap.put(key, (map != null) ? map.get(key) : objs[i]);
|
||||
resultMap.put(key, so);
|
||||
} else if (!scoped || idx >= resultInitialSize) {
|
||||
Object obj = resultMap.get(key);
|
||||
Object so = (map != null) ? map.get(key) : objs[i];
|
||||
if (obj instanceof Object[]) {
|
||||
if (so instanceof IBinding || so instanceof IASTName)
|
||||
obj = ArrayUtil.append(Object.class, (Object[]) obj, so);
|
||||
|
@ -621,9 +627,11 @@ public class CPPSemantics {
|
|||
if (inScope != null) {
|
||||
if (data.contentAssist) {
|
||||
Object[] objs = ArrayUtil.addAll(Object.class, null, inScope);
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
if (isFromIndex(b[i]))
|
||||
objs = ArrayUtil.append(Object.class, objs, b[i]);
|
||||
if (b != null) {
|
||||
for (IBinding element : b) {
|
||||
if (isFromIndex(element))
|
||||
objs = ArrayUtil.append(Object.class, objs, element);
|
||||
}
|
||||
}
|
||||
mergeResults(data, objs, true);
|
||||
} else {
|
||||
|
@ -650,8 +658,7 @@ public class CPPSemantics {
|
|||
ICPPUsingDirective[] uds= blockScope.getUsingDirectives();
|
||||
if (uds != null && uds.length > 0) {
|
||||
HashSet<ICPPNamespaceScope> handled= new HashSet<ICPPNamespaceScope>();
|
||||
for (int i = 0; i < uds.length; i++) {
|
||||
final ICPPUsingDirective ud = uds[i];
|
||||
for (final ICPPUsingDirective ud : uds) {
|
||||
if (CPPSemantics.declaredBefore(ud, data.astName, false)) {
|
||||
storeUsingDirective(data, blockScope, ud, handled);
|
||||
}
|
||||
|
@ -851,11 +858,11 @@ public class CPPSemantics {
|
|||
|
||||
ICPPBase[] bases = cls.getBases();
|
||||
|
||||
for (int i = 0; i < bases.length; i++) {
|
||||
IBinding b = bases[i].getBaseClass();
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding b = base.getBaseClass();
|
||||
if (b instanceof ICPPClassType) {
|
||||
IScope bScope = ((ICPPClassType)b).getCompositeScope();
|
||||
if (bases[i].isVirtual()) {
|
||||
if (base.isVirtual()) {
|
||||
if (bScope != null)
|
||||
data.visited.put(bScope);
|
||||
} else if (bScope != null) {
|
||||
|
@ -879,9 +886,16 @@ public class CPPSemantics {
|
|||
}
|
||||
|
||||
IBinding binding= (n instanceof IBinding) ? (IBinding) n : ((IASTName) n).resolveBinding();
|
||||
Object[] objs = (names instanceof Object[]) ? (Object[])names : null;
|
||||
int idx = (objs != null && objs.length > 0) ? 0 : -1;
|
||||
Object o = (idx != -1) ? objs[idx++] : names;
|
||||
|
||||
int idx= 0;
|
||||
Object[] objs= null;
|
||||
Object o= names;
|
||||
if (names instanceof Object[]) {
|
||||
objs= (Object[]) names;
|
||||
o= objs[0];
|
||||
idx= 1;
|
||||
}
|
||||
|
||||
while (o != null) {
|
||||
IBinding b = (o instanceof IBinding) ? (IBinding) o : ((IASTName)o).resolveBinding();
|
||||
|
||||
|
@ -910,7 +924,7 @@ public class CPPSemantics {
|
|||
if (!ok)
|
||||
return true;
|
||||
}
|
||||
if (idx > -1 && idx < objs.length)
|
||||
if (objs != null && idx < objs.length)
|
||||
o = objs[idx++];
|
||||
else
|
||||
o = null;
|
||||
|
@ -955,8 +969,8 @@ public class CPPSemantics {
|
|||
data.tu.handleAdditionalDirectives(nominated);
|
||||
}
|
||||
ICPPUsingDirective[] transitive= nominated.getUsingDirectives();
|
||||
for (int i = 0; i < transitive.length; i++) {
|
||||
storeUsingDirective(data, container, transitive[i], handled);
|
||||
for (ICPPUsingDirective element : transitive) {
|
||||
storeUsingDirective(data, container, element, handled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1033,8 +1047,7 @@ public class CPPSemantics {
|
|||
//need binding because namespaces can be split
|
||||
CPPNamespace namespace = (CPPNamespace) ((ICPPASTNamespaceDefinition)parent).getName().resolveBinding();
|
||||
namespaceDefs = namespace.getNamespaceDefinitions();
|
||||
namespaceIdx= 0;
|
||||
nodes = ((ICPPASTNamespaceDefinition)namespaceDefs[namespaceIdx].getParent()).getDeclarations();
|
||||
nodes = ((ICPPASTNamespaceDefinition)namespaceDefs[++namespaceIdx].getParent()).getDeclarations();
|
||||
while (nodes.length == 0 && ++namespaceIdx < namespaceDefs.length) {
|
||||
nodes= ((ICPPASTNamespaceDefinition)namespaceDefs[namespaceIdx].getParent()).getDeclarations();
|
||||
}
|
||||
|
@ -1108,14 +1121,14 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
|
||||
if (idx > -1 && ++idx < nodes.length) {
|
||||
if (nodes != null && ++idx < nodes.length) {
|
||||
item = nodes[idx];
|
||||
} else {
|
||||
item = null;
|
||||
while (item == null) {
|
||||
if (namespaceIdx > -1) {
|
||||
while (true) {
|
||||
if (namespaceDefs != null) {
|
||||
//check all definitions of this namespace
|
||||
while (namespaceIdx > -1 && namespaceDefs.length > ++namespaceIdx) {
|
||||
while (++namespaceIdx < namespaceDefs.length) {
|
||||
nodes = ((ICPPASTNamespaceDefinition)namespaceDefs[namespaceIdx].getParent()).getDeclarations();
|
||||
if (nodes.length > 0) {
|
||||
idx = 0;
|
||||
|
@ -1136,14 +1149,14 @@ public class CPPSemantics {
|
|||
parent = ((ICPPASTCatchHandler)parent).getCatchBody();
|
||||
if (parent instanceof IASTCompoundStatement) {
|
||||
nodes = ((IASTCompoundStatement)parent).getStatements();
|
||||
}
|
||||
if (nodes.length > 0) {
|
||||
idx = 0;
|
||||
item = nodes[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item == null && nodeStackPos >= 0) {
|
||||
}
|
||||
if (item == null && nodeStack != null && nodeIdxStack != null && nodeStackPos >= 0) {
|
||||
nodes = nodeStack[nodeStackPos];
|
||||
nodeStack[nodeStackPos] = null;
|
||||
idx = nodeIdxStack[nodeStackPos--];
|
||||
|
@ -1200,8 +1213,7 @@ public class CPPSemantics {
|
|||
data.tu.handleAdditionalDirectives(nominated);
|
||||
}
|
||||
ICPPUsingDirective[] usings= nominated.getUsingDirectives();
|
||||
for (int i = 0; i < usings.length; i++) {
|
||||
ICPPUsingDirective using = usings[i];
|
||||
for (ICPPUsingDirective using : usings) {
|
||||
storeUsingDirective(data, scope, using, null);
|
||||
}
|
||||
}
|
||||
|
@ -1273,8 +1285,7 @@ public class CPPSemantics {
|
|||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) simpleDeclaration.getDeclSpecifier();
|
||||
IASTDeclarator[] declarators = simpleDeclaration.getDeclarators();
|
||||
if (!declSpec.isFriend()) {
|
||||
for (int i = 0; i < declarators.length; i++) {
|
||||
IASTDeclarator declarator = declarators[i];
|
||||
for (IASTDeclarator declarator : declarators) {
|
||||
while (declarator.getNestedDeclarator() != null)
|
||||
declarator = declarator.getNestedDeclarator();
|
||||
IASTName declaratorName = declarator.getName();
|
||||
|
@ -1307,8 +1318,8 @@ public class CPPSemantics {
|
|||
{
|
||||
Object o = null;
|
||||
IASTDeclaration[] decls = compSpec.getMembers();
|
||||
for (int i = 0; i < decls.length; i++) {
|
||||
o = collectResult(data, scope, decls[i], checkAux);
|
||||
for (IASTDeclaration decl : decls) {
|
||||
o = collectResult(data, scope, decl, checkAux);
|
||||
if (o instanceof IASTName) {
|
||||
if (resultName == null)
|
||||
resultName = (IASTName) o;
|
||||
|
@ -1338,8 +1349,7 @@ public class CPPSemantics {
|
|||
//check enumerators too
|
||||
IASTEnumerator[] list = enumeration.getEnumerators();
|
||||
IASTName tempName;
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
IASTEnumerator enumerator = list[i];
|
||||
for (IASTEnumerator enumerator : list) {
|
||||
if (enumerator == null) break;
|
||||
tempName = enumerator.getName();
|
||||
ASTInternal.addName(scope, tempName);
|
||||
|
@ -1460,11 +1470,11 @@ public class CPPSemantics {
|
|||
}
|
||||
|
||||
IBinding[] result = null;
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
if (bindings[i] instanceof IASTName)
|
||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, ((IASTName)bindings[i]).resolveBinding());
|
||||
else if (bindings[i] instanceof IBinding)
|
||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, bindings[i]);
|
||||
for (Object binding : bindings) {
|
||||
if (binding instanceof IASTName)
|
||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, ((IASTName)binding).resolveBinding());
|
||||
else if (binding instanceof IBinding)
|
||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
|
||||
}
|
||||
return new CPPCompositeBinding(result);
|
||||
}
|
||||
|
@ -1863,8 +1873,8 @@ public class CPPSemantics {
|
|||
result[0] = implicitType;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < params.length; i++)
|
||||
result = (IType[]) ArrayUtil.append(IType.class, result, params[i].getType());
|
||||
for (IParameter param : params)
|
||||
result = (IType[]) ArrayUtil.append(IType.class, result, param.getType());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1886,9 +1896,9 @@ public class CPPSemantics {
|
|||
reduceToViable(data, fns);
|
||||
|
||||
if (data.forDefinition() || data.forExplicitInstantiation()) {
|
||||
for (int i = 0; i < fns.length; i++) {
|
||||
if (fns[i] != null) {
|
||||
return fns[i];
|
||||
for (IFunction fn : fns) {
|
||||
if (fn != null) {
|
||||
return fn;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -2010,26 +2020,22 @@ public class CPPSemantics {
|
|||
|
||||
if (!hasWorse) {
|
||||
// if they are both template functions, we can order them that way
|
||||
boolean bestIsTemplate = (bestFn instanceof ICPPSpecialization &&
|
||||
((ICPPSpecialization) bestFn).getSpecializedBinding() instanceof ICPPFunctionTemplate);
|
||||
boolean currIsTemplate = (currFn instanceof ICPPSpecialization &&
|
||||
((ICPPSpecialization) currFn).getSpecializedBinding() instanceof ICPPFunctionTemplate);
|
||||
if (bestIsTemplate && currIsTemplate) {
|
||||
ICPPFunctionTemplate t1 = (ICPPFunctionTemplate) ((ICPPSpecialization) bestFn).getSpecializedBinding();
|
||||
ICPPFunctionTemplate t2 = (ICPPFunctionTemplate) ((ICPPSpecialization) currFn).getSpecializedBinding();
|
||||
int order = CPPTemplates.orderTemplateFunctions(t1, t2);
|
||||
ICPPFunctionTemplate bestAsTemplate= asTemplate(bestFn);
|
||||
ICPPFunctionTemplate currAsTemplate= asTemplate(currFn);
|
||||
if (bestAsTemplate != null && currAsTemplate != null) {
|
||||
int order = CPPTemplates.orderTemplateFunctions(bestAsTemplate, currAsTemplate);
|
||||
if (order < 0) {
|
||||
hasBetter = true;
|
||||
} else if (order > 0) {
|
||||
ambiguous = false;
|
||||
}
|
||||
} else if (bestIsTemplate && !currIsTemplate) {
|
||||
} else if (bestAsTemplate != null) {
|
||||
// we prefer normal functions over template functions, unless we specified template arguments
|
||||
if (data.preferTemplateFunctions())
|
||||
ambiguous = false;
|
||||
else
|
||||
hasBetter = true;
|
||||
} else if (!bestIsTemplate && currIsTemplate) {
|
||||
} else if (currAsTemplate != null) {
|
||||
if (data.preferTemplateFunctions())
|
||||
hasBetter = true;
|
||||
else
|
||||
|
@ -2053,6 +2059,16 @@ public class CPPSemantics {
|
|||
return bestFn;
|
||||
}
|
||||
|
||||
private static ICPPFunctionTemplate asTemplate(IFunction function) {
|
||||
if (function instanceof ICPPSpecialization) {
|
||||
IBinding original= ((ICPPSpecialization) function).getSpecializedBinding();
|
||||
if (original instanceof ICPPFunctionTemplate) {
|
||||
return (ICPPFunctionTemplate) original;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 13.4-1 A use of an overloaded function without arguments is resolved in certain contexts to a function
|
||||
* @param data
|
||||
|
@ -2084,8 +2100,8 @@ public class CPPSemantics {
|
|||
if (type == null || !(type instanceof IFunctionType))
|
||||
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name());
|
||||
|
||||
for (int i = 0; i < fns.length; i++) {
|
||||
IFunction fn = (IFunction) fns[i];
|
||||
for (IBinding fn2 : fns) {
|
||||
IFunction fn = (IFunction) fn2;
|
||||
IType ft = null;
|
||||
try {
|
||||
ft = fn.getType();
|
||||
|
@ -2100,7 +2116,7 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
|
||||
if (idx > 0 && ++idx < types.length) {
|
||||
if (types != null && ++idx < types.length) {
|
||||
type = types[idx];
|
||||
} else {
|
||||
type = null;
|
||||
|
@ -2248,8 +2264,7 @@ public class CPPSemantics {
|
|||
if (data.hasResults()) {
|
||||
Object[] items = (Object[]) data.foundItems;
|
||||
IBinding temp = null;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
Object o = items[i];
|
||||
for (Object o : items) {
|
||||
if (o == null) break;
|
||||
if (o instanceof IASTName) {
|
||||
temp = ((IASTName) o).resolveBinding();
|
||||
|
@ -2402,11 +2417,11 @@ public class CPPSemantics {
|
|||
|
||||
ObjectSet<IBinding> set = new ObjectSet<IBinding>(items.length);
|
||||
IBinding binding = null;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] instanceof IASTName) {
|
||||
binding = ((IASTName) items[i]).resolveBinding();
|
||||
} else if (items[i] instanceof IBinding) {
|
||||
binding = (IBinding) items[i];
|
||||
for (Object item : items) {
|
||||
if (item instanceof IASTName) {
|
||||
binding = ((IASTName) item).resolveBinding();
|
||||
} else if (item instanceof IBinding) {
|
||||
binding = (IBinding) item;
|
||||
} else {
|
||||
binding = null;
|
||||
}
|
||||
|
|
|
@ -182,11 +182,11 @@ public class CPPTemplates {
|
|||
int idx = templates.length;
|
||||
int i = 0;
|
||||
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
|
||||
for (int j = 0; j < ns.length; j++) {
|
||||
if (ns[j] instanceof ICPPASTTemplateId) {
|
||||
for (IASTName element : ns) {
|
||||
if (element instanceof ICPPASTTemplateId) {
|
||||
++i;
|
||||
if (i == idx) {
|
||||
binding = ((ICPPASTTemplateId) ns[j]).getTemplateName().resolveBinding();
|
||||
binding = ((ICPPASTTemplateId) element).getTemplateName().resolveBinding();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -253,10 +253,6 @@ public class CPPTemplates {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static IBinding createBinding(ICPPASTTemplateId id) {
|
||||
IASTNode parent = id.getParent();
|
||||
int segment = -1;
|
||||
|
@ -407,9 +403,9 @@ public class CPPTemplates {
|
|||
} catch (DOMException e) {
|
||||
}
|
||||
if (specializations != null) {
|
||||
for (int i = 0; i < specializations.length; i++) {
|
||||
if (isSameTemplate(specializations[i], id)) {
|
||||
spec = specializations[i];
|
||||
for (ICPPClassTemplatePartialSpecialization specialization : specializations) {
|
||||
if (isSameTemplate(specialization, id)) {
|
||||
spec = specialization;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -503,9 +499,7 @@ public class CPPTemplates {
|
|||
return null;
|
||||
ICPPFunctionTemplate[] templates = null;
|
||||
IBinding temp = null;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
Object o = items[i];
|
||||
|
||||
for (Object o : items) {
|
||||
if (o instanceof IASTName) {
|
||||
temp = ((IASTName) o).resolveBinding();
|
||||
if (temp == null)
|
||||
|
@ -565,7 +559,7 @@ public class CPPTemplates {
|
|||
IType arg = null;
|
||||
for (int j = 0; j < numParams; j++) {
|
||||
ICPPTemplateParameter param = params[j];
|
||||
if (j < numArgs) {
|
||||
if (j < numArgs && templateArguments != null) {
|
||||
arg = templateArguments[j];
|
||||
} else {
|
||||
arg = null;
|
||||
|
@ -593,10 +587,6 @@ public class CPPTemplates {
|
|||
|
||||
/**
|
||||
* return Object[] of { ObjectMap, IType[] }
|
||||
* @param primaryTemplate
|
||||
* @param ps
|
||||
* @param specArgs
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
static protected Object[] deduceTemplateFunctionArguments(ICPPFunctionTemplate primaryTemplate,
|
||||
|
@ -642,11 +632,6 @@ public class CPPTemplates {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param decl
|
||||
* @param arguments
|
||||
* @return
|
||||
*/
|
||||
public static IBinding createInstance(ICPPScope scope, IBinding decl, ObjectMap argMap, IType[] args) {
|
||||
ICPPTemplateInstance instance = null;
|
||||
if (decl instanceof ICPPClassType) {
|
||||
|
@ -919,9 +904,9 @@ public class CPPTemplates {
|
|||
boolean clear = bindings.containsKey(name.getBinding());
|
||||
if (!clear && binding instanceof ICPPTemplateInstance) {
|
||||
IType[] args = ((ICPPTemplateInstance) binding).getArguments();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i] instanceof IBinding) {
|
||||
if(bindings.containsKey((IBinding)args[i])) {
|
||||
for (IType arg : args) {
|
||||
if (arg instanceof IBinding) {
|
||||
if(bindings.containsKey((IBinding)arg)) {
|
||||
clear = true;
|
||||
break;
|
||||
}
|
||||
|
@ -941,11 +926,7 @@ public class CPPTemplates {
|
|||
return PROCESS_SKIP;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param definition
|
||||
* @param declarator
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static boolean isSameTemplate(ICPPTemplateDefinition definition, IASTName name) {
|
||||
ICPPTemplateParameter[] defParams = null;
|
||||
try {
|
||||
|
@ -1094,7 +1075,7 @@ public class CPPTemplates {
|
|||
|
||||
IType[] instanceArgs = null;
|
||||
for (int i = 0; i < numTemplateParams; i++) {
|
||||
IType arg = (i < numTemplateArgs) ? CPPVisitor.createType(templateArguments[i]) : null;
|
||||
IType arg = (i < numTemplateArgs && templateArguments != null) ? CPPVisitor.createType(templateArguments[i]) : null;
|
||||
IType mapped = (IType) map.get(templateParams[i]);
|
||||
|
||||
if (arg != null && mapped != null) {
|
||||
|
@ -1118,7 +1099,7 @@ public class CPPTemplates {
|
|||
if (def != null) {
|
||||
if (def instanceof ICPPTemplateParameter) {
|
||||
for (int j = 0; j < i; j++) {
|
||||
if (templateParams[j] == def) {
|
||||
if (templateParams[j] == def && instanceArgs != null) {
|
||||
def = instanceArgs[j];
|
||||
}
|
||||
}
|
||||
|
@ -1410,7 +1391,10 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
ICPPClassTemplatePartialSpecialization[] specializations = template.getPartialSpecializations();
|
||||
int size = (specializations != null) ? specializations.length : 0;
|
||||
if (specializations == null) {
|
||||
return template;
|
||||
}
|
||||
final int size= specializations.length;
|
||||
if (size == 0) {
|
||||
return template;
|
||||
}
|
||||
|
@ -1490,9 +1474,7 @@ public class CPPTemplates {
|
|||
public static final class CPPImplicitFunctionTemplate extends CPPFunctionTemplate {
|
||||
IParameter[] functionParameters = null;
|
||||
ICPPTemplateParameter[] templateParameters = null;
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
|
||||
public CPPImplicitFunctionTemplate(ICPPTemplateParameter[] templateParameters, IParameter[] functionParameters) {
|
||||
super(null);
|
||||
this.functionParameters = functionParameters;
|
||||
|
@ -1656,7 +1638,10 @@ public class CPPTemplates {
|
|||
return e1.getProblem();
|
||||
}
|
||||
|
||||
int numParams = (parameters != null) ? parameters.length : 0;
|
||||
if (parameters == null) {
|
||||
return null;
|
||||
}
|
||||
final int numParams= parameters.length;
|
||||
int numArgs = arguments.length;
|
||||
|
||||
if (numParams == 0) {
|
||||
|
@ -1719,10 +1704,10 @@ public class CPPTemplates {
|
|||
}
|
||||
}
|
||||
|
||||
if (argsContainTemplateParameters) {
|
||||
if (map.isEmpty()) {
|
||||
map = null;
|
||||
}
|
||||
if (argsContainTemplateParameters) {
|
||||
return ((ICPPInternalTemplateInstantiator) template).deferredInstance(map, arguments);
|
||||
}
|
||||
|
||||
|
@ -1754,8 +1739,6 @@ public class CPPTemplates {
|
|||
* Returns an array of specialized bases. The bases will be specialized versions of
|
||||
* the template instances associated specialized bindings bases.
|
||||
* binding.
|
||||
* @param classInstance
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
public static ICPPBase[] getBases(ICPPTemplateInstance classInstance) throws DOMException {
|
||||
|
@ -1765,8 +1748,7 @@ public class CPPTemplates {
|
|||
if (pdomBases != null) {
|
||||
ICPPBase[] result = null;
|
||||
|
||||
for (int i = 0; i < pdomBases.length; i++) {
|
||||
ICPPBase origBase = pdomBases[i];
|
||||
for (ICPPBase origBase : pdomBases) {
|
||||
ICPPBase specBase = (ICPPBase) ((ICPPInternalBase) origBase).clone();
|
||||
IBinding origClass = origBase.getBaseClass();
|
||||
if (origClass instanceof IType) {
|
||||
|
|
|
@ -284,7 +284,6 @@ class LookupData {
|
|||
}
|
||||
/**
|
||||
* an IType[] of function arguments, inluding the implied object argument
|
||||
* @return
|
||||
*/
|
||||
public IType getImpliedObjectArgument() {
|
||||
IType implied = null;
|
||||
|
|
|
@ -13,12 +13,11 @@ package org.eclipse.cdt.internal.core.index.composite.c;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCEnumerator extends CompositeCBinding implements IIndexBinding, IEnumerator {
|
||||
class CompositeCEnumerator extends CompositeCBinding implements IEnumerator {
|
||||
public CompositeCEnumerator(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
|
|
@ -14,11 +14,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCField extends CompositeCVariable implements IIndexBinding, IField {
|
||||
class CompositeCField extends CompositeCVariable implements IField {
|
||||
public CompositeCField(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
|
|
@ -16,13 +16,12 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCFunction extends CompositeCBinding implements IIndexBinding, IFunction {
|
||||
class CompositeCFunction extends CompositeCBinding implements IFunction {
|
||||
|
||||
public CompositeCFunction(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
|
||||
super(cf, rbinding);
|
||||
|
|
|
@ -13,12 +13,11 @@ package org.eclipse.cdt.internal.core.index.composite.c;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCParameter extends CompositeCBinding implements IIndexBinding, IParameter {
|
||||
class CompositeCParameter extends CompositeCBinding implements IParameter {
|
||||
|
||||
public CompositeCParameter(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
|
||||
super(cf, rbinding);
|
||||
|
|
|
@ -13,12 +13,11 @@ package org.eclipse.cdt.internal.core.index.composite.c;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCVariable extends CompositeCBinding implements IIndexBinding, IVariable {
|
||||
class CompositeCVariable extends CompositeCBinding implements IVariable {
|
||||
|
||||
public CompositeCVariable(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
|
||||
super(cf, rbinding);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class BTree {
|
|||
* Constructor.
|
||||
*
|
||||
* @param db the database containing the btree
|
||||
* @param root offset into database of the pointer to the root node
|
||||
* @param rootPointer offset into database of the pointer to the root node
|
||||
*/
|
||||
public BTree(Database db, int rootPointer, int degree, IBTreeComparator cmp) {
|
||||
if(degree<2)
|
||||
|
@ -93,8 +93,7 @@ public class BTree {
|
|||
* key was already there, in which case we return the record
|
||||
* that matched. In other cases, we just return the record back.
|
||||
*
|
||||
* @param offset of the record
|
||||
* @return
|
||||
* @param record offset of the record
|
||||
*/
|
||||
public int insert(int record) throws CoreException {
|
||||
int root = getRoot();
|
||||
|
@ -229,7 +228,6 @@ public class BTree {
|
|||
* The reference to the record in the btree is deleted.
|
||||
*
|
||||
* @param record the record to delete
|
||||
* @param cmp the comparator for locating the record
|
||||
* @throws CoreException
|
||||
*/
|
||||
public void delete(int record) throws CoreException {
|
||||
|
@ -345,8 +343,11 @@ public class BTree {
|
|||
|
||||
/* Case 2c: Merge successor and predecessor */
|
||||
// assert(pred!=null && succ!=null);
|
||||
if (pred != null) {
|
||||
mergeNodes(succ, node, keyIndexInNode, pred);
|
||||
return deleteImp(key, pred.node, mode);
|
||||
}
|
||||
return key;
|
||||
} else {
|
||||
/* Case 3: non-leaf node which does not itself contain the key */
|
||||
|
||||
|
@ -422,7 +423,7 @@ public class BTree {
|
|||
* 'keyProvider' as the source of the median key. Bounds checking is not
|
||||
* performed.
|
||||
* @param src the key to merge into dst
|
||||
* @param mid the node that provides the median key for the new node
|
||||
* @param keyProvider the node that provides the median key for the new node
|
||||
* @param kIndex the index of the key in the node <i>mid</i> which is to become the new node's median key
|
||||
* @param dst the node which is the basis and result of the merge
|
||||
*/
|
||||
|
|
|
@ -125,7 +125,6 @@ public class DBProperties {
|
|||
* it can be re-populated.
|
||||
* @throws CoreException
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
public void clear() throws CoreException {
|
||||
index.accept(new IBTreeVisitor(){
|
||||
public int compare(int record) throws CoreException {
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.db;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -22,11 +20,6 @@ public interface IBTreeComparator {
|
|||
|
||||
/**
|
||||
* Compare two records. Used for insert.
|
||||
*
|
||||
* @param record1
|
||||
* @param record2
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public abstract int compare(int record1, int record2) throws CoreException;
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.db;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +27,7 @@ public interface IBTreeVisitor {
|
|||
*
|
||||
* @param record
|
||||
* @return -1 if record < key, 0 if record == key, 1 if record > key
|
||||
* @throws IOException
|
||||
* @throws CoreException
|
||||
*/
|
||||
public abstract int compare(int record) throws CoreException;
|
||||
|
||||
|
@ -37,7 +35,7 @@ public interface IBTreeVisitor {
|
|||
* Visit a given record and return whether to continue or not.
|
||||
|
||||
* @return <code>true</code> to continue the visit, <code>false</code> to abort it.
|
||||
* @throws IOException
|
||||
* @throws CoreException
|
||||
*/
|
||||
public abstract boolean visit(int record) throws CoreException;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
public interface IString {
|
||||
/**
|
||||
* Get the offset of this IString record in the PDOM
|
||||
* @return
|
||||
*/
|
||||
public int getRecord();
|
||||
|
||||
|
@ -91,7 +90,7 @@ public interface IString {
|
|||
|
||||
/**
|
||||
* Compare this IString record and the specified character array
|
||||
* @param chars
|
||||
* @param name the name to compare to
|
||||
* @param caseSensitive whether to compare in a case-sensitive way
|
||||
* @return <ul><li> -1 if this < chars
|
||||
* <li> 0 if this has a prefix chars
|
||||
|
|
|
@ -54,21 +54,19 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
|
|||
|
||||
try {
|
||||
// type
|
||||
IType targetType= type.getType();
|
||||
int typeRec = 0;
|
||||
byte flags = 0;
|
||||
if (type != null) {
|
||||
IType targetType= type.getType();
|
||||
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
|
||||
if (targetTypeNode != null)
|
||||
typeRec = targetTypeNode.getRecord();
|
||||
}
|
||||
db.putInt(record + TYPE, typeRec);
|
||||
|
||||
// flags
|
||||
byte flags = 0;
|
||||
if (type.isConst())
|
||||
flags |= CONST;
|
||||
if (type.isVolatile())
|
||||
flags |= VOLATILE;
|
||||
}
|
||||
db.putInt(record + TYPE, typeRec);
|
||||
db.putByte(record + FLAGS, flags);
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
|
|
|
@ -57,14 +57,12 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
|
|||
|
||||
// type
|
||||
try {
|
||||
IType targetType = type.getType();
|
||||
if (type != null) {
|
||||
IType targetType = type.getType();
|
||||
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
|
||||
if (targetTypeNode != null) {
|
||||
db.putInt(record + TYPE, targetTypeNode.getRecord());
|
||||
}
|
||||
}
|
||||
|
||||
// flags
|
||||
byte flags = 0;
|
||||
if (type.isConst())
|
||||
|
@ -74,6 +72,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
|
|||
if (type instanceof ICQualifierType && ((ICQualifierType)type).isRestrict())
|
||||
flags |= RESTRICT;
|
||||
db.putByte(record + FLAGS, flags);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
class PDOMCPPEnumeration extends PDOMCPPBinding
|
||||
implements IEnumeration, IIndexType, ICPPBinding {
|
||||
class PDOMCPPEnumeration extends PDOMCPPBinding implements IEnumeration, IIndexType {
|
||||
|
||||
private static final int FIRST_ENUMERATOR = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
|
@ -26,7 +25,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator, ICPPBinding {
|
||||
class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
|
||||
|
||||
private static final int ENUMERATION = PDOMBinding.RECORD_SIZE + 0;
|
||||
private static final int NEXT_ENUMERATOR = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.PointerTypeClone;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
|
@ -25,8 +24,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMPointerType;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
class PDOMCPPPointerToMemberType extends PDOMPointerType
|
||||
implements ICPPPointerToMemberType, IIndexType {
|
||||
class PDOMCPPPointerToMemberType extends PDOMPointerType implements ICPPPointerToMemberType {
|
||||
|
||||
private static final int TYPE = PDOMPointerType.RECORD_SIZE;
|
||||
@SuppressWarnings("hiding")
|
||||
|
|
|
@ -49,9 +49,9 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType,
|
|||
|
||||
try {
|
||||
// type
|
||||
IType targetType = type.getType();
|
||||
int typeRec = 0;
|
||||
if (type != null) {
|
||||
IType targetType = type.getType();
|
||||
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
|
||||
if (targetTypeNode != null)
|
||||
typeRec = targetTypeNode.getRecord();
|
||||
|
|
|
@ -41,7 +41,6 @@ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclara
|
|||
|
||||
private IBinding[] delegates;
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
public PDOMCPPUsingDeclaration(PDOM pdom, PDOMNode parent, ICPPUsingDeclaration using)
|
||||
throws CoreException {
|
||||
super(pdom, parent, using.getNameCharArray());
|
||||
|
|
|
@ -15,12 +15,11 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
class PDOMGPPBasicType extends PDOMCPPBasicType implements IGPPBasicType, IIndexType {
|
||||
class PDOMGPPBasicType extends PDOMCPPBasicType implements IGPPBasicType {
|
||||
|
||||
public PDOMGPPBasicType(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
|
|
|
@ -33,7 +33,6 @@ public class CLIUtil {
|
|||
* @param arguments the arguments map
|
||||
* @param opt the option name to check
|
||||
* @param number the number of parameters
|
||||
* @return
|
||||
* @throws CoreException if the number of parameters is not the specified expected number
|
||||
*/
|
||||
public static List<String> getArg(Map<String, List<String>> arguments, String opt, int number) throws CoreException {
|
||||
|
@ -47,23 +46,20 @@ public class CLIUtil {
|
|||
|
||||
/**
|
||||
* Returns a map of String option to List of String parameters.
|
||||
* <br>
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,List<String>> parseToMap(String[] args) {
|
||||
Map<String,List<String>> result = new HashMap<String,List<String>>();
|
||||
String current = null;
|
||||
for(int i=0; i<args.length; i++) {
|
||||
if(args[i].startsWith("-")) { //$NON-NLS-1$
|
||||
current = args[i];
|
||||
for (String arg : args) {
|
||||
if(arg.startsWith("-")) { //$NON-NLS-1$
|
||||
current = arg;
|
||||
result.put(current, new ArrayList<String>());
|
||||
} else {
|
||||
if(current==null) {
|
||||
current= UNQUALIFIED_PARAMETERS;
|
||||
result.put(current, new ArrayList<String>());
|
||||
}
|
||||
(result.get(current)).add(args[i]);
|
||||
(result.get(current)).add(arg);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -55,6 +55,7 @@ public class GeneratePDOM implements ISafeRunnable {
|
|||
if(cproject==null) {
|
||||
fail(MessageFormat.format(Messages.GeneratePDOM_ProjectProviderReturnedNullCProject,
|
||||
new Object [] {pm.getClass().getName()}));
|
||||
return; // cannot be reached, inform the compiler
|
||||
}
|
||||
|
||||
IIndexLocationConverter converter= pm.getLocationConverter(cproject);
|
||||
|
|
|
@ -115,8 +115,7 @@ public class TodoTaskUpdater implements ITodoTaskUpdater {
|
|||
// first collect all valid file-locations
|
||||
final Map<IPath, TaskList> pathToTaskList= new HashMap<IPath, TaskList>();
|
||||
final Set<IProject> projects= new HashSet<IProject>();
|
||||
for (int i = 0; i < filesToUpdate.length; i++) {
|
||||
final IIndexFileLocation indexFileLocation = filesToUpdate[i];
|
||||
for (final IIndexFileLocation indexFileLocation : filesToUpdate) {
|
||||
final String filepath = indexFileLocation.getFullPath();
|
||||
if (filepath != null) {
|
||||
IFile file = workspaceRoot.getFile(new Path(filepath));
|
||||
|
@ -129,8 +128,7 @@ public class TodoTaskUpdater implements ITodoTaskUpdater {
|
|||
|
||||
if (comments.length > 0) {
|
||||
final Task[] tasks = taskParser.parse(comments);
|
||||
for (int i = 0; i < tasks.length; i++) {
|
||||
final Task task = tasks[i];
|
||||
for (final Task task : tasks) {
|
||||
TaskList list= pathToTaskList.get(new Path(task.getFileLocation()));
|
||||
if (list != null) {
|
||||
list.add(task);
|
||||
|
@ -209,7 +207,7 @@ public class TodoTaskUpdater implements ITodoTaskUpdater {
|
|||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
if (resource == null || !resource.exists()) {
|
||||
if (!resource.exists()) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
resource.deleteMarkers(ICModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
|
||||
|
|
|
@ -47,8 +47,6 @@ public class CdtVariableException extends CoreException {
|
|||
* @param macroName the name of the build macro whose resolution caused this status creation or null if none
|
||||
* @param expression the string whose resolutinon caused caused this status creation or null if none
|
||||
* @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
|
||||
* @param contextType the context type used in the operation
|
||||
* @param contextData the context data used in the operation
|
||||
*/
|
||||
public CdtVariableException(int code,
|
||||
String message,
|
||||
|
@ -66,13 +64,9 @@ public class CdtVariableException extends CoreException {
|
|||
* Creates an exception containing a single IBuildMacroStatus status with the IStatus.ERROR severity and with the default message
|
||||
*
|
||||
* @param code one of the IBuildMacroStatus.TYPE_xxx statusses
|
||||
* @param exception a low-level exception, or <code>null</code> if not
|
||||
* applicable
|
||||
* @param macroName the name of the build macro whose resolution caused this status creation or null if none
|
||||
* @param expression the string whose resolutinon caused caused this status creation or null if none
|
||||
* @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
|
||||
* @param contextType the context type used in the operation
|
||||
* @param contextData the context data used in the operation
|
||||
*/
|
||||
public CdtVariableException(int code,
|
||||
String macroName,
|
||||
|
@ -97,9 +91,9 @@ public class CdtVariableException extends CoreException {
|
|||
IStatus children[] = status.getChildren();
|
||||
ICdtVariableStatus result[] = new ICdtVariableStatus[children.length];
|
||||
int num = 0;
|
||||
for(int i = 0; i < children.length; i++){
|
||||
if(children[i] instanceof ICdtVariableStatus)
|
||||
result[num++]=(ICdtVariableStatus)children[i];
|
||||
for (IStatus element : children) {
|
||||
if(element instanceof ICdtVariableStatus)
|
||||
result[num++]=(ICdtVariableStatus)element;
|
||||
}
|
||||
if(num != children.length){
|
||||
ICdtVariableStatus tmp[] = new ICdtVariableStatus[num];
|
||||
|
|
|
@ -20,18 +20,15 @@ import org.eclipse.core.runtime.Status;
|
|||
* @since 3.0
|
||||
*/
|
||||
public class CdtVariableStatus extends Status implements ICdtVariableStatus {
|
||||
/*
|
||||
* String constants
|
||||
*/
|
||||
private static final String PREFIX = "BuildMacroStatus"; //$NON-NLS-1$
|
||||
private static final String STATUS = PREFIX + ".status"; //$NON-NLS-1$
|
||||
private static final String STATUS_MACRO_UNDEFINED = STATUS + ".macro.undefined"; //$NON-NLS-1$
|
||||
private static final String STATUS_MACROS_REFERENCE_EACHOTHER = STATUS + ".reference.eachother"; //$NON-NLS-1$
|
||||
private static final String STATUS_MACRO_REFERENCE_INCORRECT = STATUS + ".reference.incorrect"; //$NON-NLS-1$
|
||||
private static final String STATUS_MACRO_NOT_STRING = STATUS + ".macro.not.string"; //$NON-NLS-1$
|
||||
private static final String STATUS_MACRO_NOT_STRINGLIST = STATUS + ".macro.not.stringlist"; //$NON-NLS-1$
|
||||
private static final String STATUS_ERROR = STATUS + ".error"; //$NON-NLS-1$
|
||||
private static final String VALUE_UNDEFINED = PREFIX + ".value.undefined"; //$NON-NLS-1$
|
||||
// private static final String PREFIX = "BuildMacroStatus"; //$NON-NLS-1$
|
||||
// private static final String STATUS = PREFIX + ".status"; //$NON-NLS-1$
|
||||
// private static final String STATUS_MACRO_UNDEFINED = STATUS + ".macro.undefined"; //$NON-NLS-1$
|
||||
// private static final String STATUS_MACROS_REFERENCE_EACHOTHER = STATUS + ".reference.eachother"; //$NON-NLS-1$
|
||||
// private static final String STATUS_MACRO_REFERENCE_INCORRECT = STATUS + ".reference.incorrect"; //$NON-NLS-1$
|
||||
// private static final String STATUS_MACRO_NOT_STRING = STATUS + ".macro.not.string"; //$NON-NLS-1$
|
||||
// private static final String STATUS_MACRO_NOT_STRINGLIST = STATUS + ".macro.not.stringlist"; //$NON-NLS-1$
|
||||
// private static final String STATUS_ERROR = STATUS + ".error"; //$NON-NLS-1$
|
||||
// private static final String VALUE_UNDEFINED = PREFIX + ".value.undefined"; //$NON-NLS-1$
|
||||
|
||||
private String fMacroName;
|
||||
private String fExpression;
|
||||
|
@ -42,17 +39,15 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param severity one of the IStatus.xxx severity statuses
|
||||
* @param code one of the IBuildMacroStatus.TYPE_xxx statusses
|
||||
* @param severity as documented in {@link IStatus}
|
||||
* @param code as provided by {@link ICdtVariableStatus}.
|
||||
* @param message message, can be null. In this case the default message will
|
||||
* be generated base upon the other status info
|
||||
* @param exception a low-level exception, or <code>null</code> if not
|
||||
* applicable
|
||||
* @param macroName the name of the build macro whose resolution caused this status creation or null if none
|
||||
* @param expression the string whose resolutinon caused caused this status creation or null if none
|
||||
* @param expression the string whose resolution caused this status creation or null if none
|
||||
* @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
|
||||
* @param contextType the context type used in the operation
|
||||
* @param contextData the context data used in the operation
|
||||
*/
|
||||
public CdtVariableStatus(int severity,
|
||||
int code,
|
||||
|
@ -87,8 +82,6 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus {
|
|||
* @param macroName the name of the build macro whose resolution caused this status creation or null if none
|
||||
* @param expression the string whose resolutinon caused caused this status creation or null if none
|
||||
* @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
|
||||
* @param contextType the context type used in the operation
|
||||
* @param contextData the context data used in the operation
|
||||
*/
|
||||
public CdtVariableStatus(
|
||||
int code,
|
||||
|
@ -108,13 +101,9 @@ public class CdtVariableStatus extends Status implements ICdtVariableStatus {
|
|||
* Creates status with the IStatus.ERROR severity and with the default message
|
||||
*
|
||||
* @param code one of the IBuildMacroStatus.TYPE_xxx statusses
|
||||
* @param exception a low-level exception, or <code>null</code> if not
|
||||
* applicable
|
||||
* @param macroName the name of the build macro whose resolution caused this status creation or null if none
|
||||
* @param expression the string whose resolutinon caused caused this status creation or null if none
|
||||
* @param referencedName the macro name referenced in the resolution string that caused this this status creation or null if none
|
||||
* @param contextType the context type used in the operation
|
||||
* @param contextData the context data used in the operation
|
||||
*/
|
||||
public CdtVariableStatus(
|
||||
int code,
|
||||
|
|
|
@ -58,7 +58,6 @@ public interface ICdtVariable{
|
|||
|
||||
/**
|
||||
* Returns the macro name
|
||||
* @return
|
||||
*/
|
||||
String getName();
|
||||
|
||||
|
|
|
@ -31,29 +31,7 @@ public interface ICdtVariableManager{
|
|||
*
|
||||
* Returns reference to the IBuildMacro interface representing Macro of the
|
||||
* specified name or null if there is there is no such macro
|
||||
* @param macroName macro name
|
||||
* @param contextType represents the context type. Should be set to one of the the
|
||||
* IBuildMacroProvider. CONTEXT_xxx constants
|
||||
* @param contextData represents the additional data needed by the Build Macro Provider
|
||||
* and Macro Suppliers in order to obtain the macro value. The type of the context data
|
||||
* differs depending on the context type and can be one of the following:
|
||||
* 1. IFileContextData interface � used to represent currently selected file context
|
||||
* the IFileContextData interface is defined as follows:
|
||||
* pulic interface IFileContextData{
|
||||
* IFile getFile();
|
||||
* IOption getOption();
|
||||
* }
|
||||
* NOTE: the IFileContextData is passed that represents the current file and the option
|
||||
* for that file because Macro Value Provider needs to know what option should be used
|
||||
* as a context in case macro is not found for �current file� context
|
||||
* 2. IOptionContextData interface used to represent the currently selected option context
|
||||
* 3. IConfiguration � used to represent the currently selected configuration context
|
||||
* 4. IProject � used to represent current project context
|
||||
* 5. IWorkspace � used to represent current workspace context
|
||||
* 6. null � to represent the CDT and Eclipse installation context
|
||||
* 7. null � to represent process environment context
|
||||
* @param includeParentContext specifies whether lower-precedence context macros should
|
||||
* be included
|
||||
* @param name macro name
|
||||
*/
|
||||
public ICdtVariable getVariable(String name, ICConfigurationDescription cfg);
|
||||
|
||||
|
@ -91,8 +69,6 @@ public interface ICdtVariableManager{
|
|||
* �<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>�
|
||||
* otherwise the BuildMacroException is thrown in case the string to be resolved references
|
||||
* string-list macros
|
||||
* @param contextType context from which the macro search should be started
|
||||
* @param contextData context data
|
||||
*/
|
||||
public String resolveValue(String value,
|
||||
String nonexistentMacrosValue,
|
||||
|
@ -103,7 +79,6 @@ public interface ICdtVariableManager{
|
|||
*
|
||||
* if the string contains a value that can be treated as a StringList resolves it to arrays of strings
|
||||
* otherwise throws the BuildMacroException exception
|
||||
* @see isStringListValue
|
||||
*/
|
||||
public String[] resolveStringListValue(String value,
|
||||
String nonexistentMacrosValue,
|
||||
|
@ -114,7 +89,7 @@ public interface ICdtVariableManager{
|
|||
*
|
||||
* resolves macros in the array of string-list values
|
||||
*
|
||||
* @see isStringListValue
|
||||
* @see #isStringListValue
|
||||
*/
|
||||
public String[] resolveStringListValues(String value[],
|
||||
String nonexistentMacrosValue,
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.core.runtime.Preferences;
|
|||
|
||||
public abstract class ACBuilder extends IncrementalProjectBuilder implements IMarkerGenerator {
|
||||
|
||||
private static final String PREF_BUILD_ALL_CONFIGS = "build.all.configs.enabled";
|
||||
private static final String PREF_BUILD_ALL_CONFIGS = "build.all.configs.enabled"; //$NON-NLS-1$
|
||||
private static final Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
|
||||
|
||||
/**
|
||||
|
@ -52,10 +52,10 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa
|
|||
* Try to find matching markers and don't put in duplicates
|
||||
*/
|
||||
if ((cur != null) && (cur.length > 0)) {
|
||||
for (int i = 0; i < cur.length; i++) {
|
||||
int line = ((Integer) cur[i].getAttribute(IMarker.LINE_NUMBER)).intValue();
|
||||
int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue();
|
||||
String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE);
|
||||
for (IMarker element : cur) {
|
||||
int line = ((Integer) element.getAttribute(IMarker.LINE_NUMBER)).intValue();
|
||||
int sev = ((Integer) element.getAttribute(IMarker.SEVERITY)).intValue();
|
||||
String mesg = (String) element.getAttribute(IMarker.MESSAGE);
|
||||
if (line == problemMarkerInfo.lineNumber && sev == mapMarkerSeverity(problemMarkerInfo.severity) && mesg.equals(problemMarkerInfo.description)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ public interface IPathEntryStore extends ICExtension {
|
|||
|
||||
/**
|
||||
* Returns the path entries save on the project.
|
||||
* @param project
|
||||
* @return
|
||||
* @throws CoreException
|
||||
*/
|
||||
IPathEntry[] getRawPathEntries() throws CoreException;
|
||||
|
|
|
@ -33,8 +33,8 @@ public interface IPathEntryVariableChangeListener extends EventListener {
|
|||
*
|
||||
* @param event the path variable change event object describing which variable
|
||||
* changed and how
|
||||
* @see IPathEntryVariableManager#addChangeListener(IPathVariableChangeListener)
|
||||
* @see IPathEntryVariableManager#removeChangeListener(IPathVariableChangeListener)
|
||||
* @see IPathEntryVariableManager#addChangeListener(IPathEntryVariableChangeListener)
|
||||
* @see IPathEntryVariableManager#removeChangeListener(IPathEntryVariableChangeListener)
|
||||
* @see PathEntryVariableChangeEvent
|
||||
*/
|
||||
public void pathVariableChanged(PathEntryVariableChangeEvent event);
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
|||
|
||||
public class ScannerInfo implements IExtendedScannerInfo {
|
||||
|
||||
private final Map fMacroMap;
|
||||
private final Map<String, String> fMacroMap;
|
||||
private final String[] fSystemIncludePaths;
|
||||
private final String[] fMacroFiles;
|
||||
private final String[] fIncludeFiles;
|
||||
|
@ -25,14 +25,20 @@ public class ScannerInfo implements IExtendedScannerInfo {
|
|||
final static String[] EMPTY_ARRAY_STRING = new String[0];
|
||||
|
||||
protected ScannerInfo(String[] systemIncludePaths, String[] localIncludePaths, String[] includeFiles,
|
||||
Map macroMap, String[] macroFiles) {
|
||||
Map<String, String> macroMap, String[] macroFiles) {
|
||||
fSystemIncludePaths = (systemIncludePaths == null) ? EMPTY_ARRAY_STRING : systemIncludePaths;
|
||||
fLocalIncludePaths = (localIncludePaths == null) ? EMPTY_ARRAY_STRING : localIncludePaths;
|
||||
fIncludeFiles = (includeFiles == null) ? EMPTY_ARRAY_STRING : includeFiles;
|
||||
fMacroFiles = (macroFiles == null) ? EMPTY_ARRAY_STRING : macroFiles;
|
||||
fMacroMap = (macroMap == null) ? Collections.EMPTY_MAP : macroMap;
|
||||
fMacroMap= nonNullMap(macroMap);
|
||||
}
|
||||
|
||||
private Map<String, String> nonNullMap(Map<String, String> macroMap) {
|
||||
if (macroMap == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return macroMap;
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -47,7 +53,7 @@ public class ScannerInfo implements IExtendedScannerInfo {
|
|||
*
|
||||
* @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
|
||||
*/
|
||||
public synchronized Map getDefinedSymbols() {
|
||||
public synchronized Map<String, String> getDefinedSymbols() {
|
||||
return fMacroMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.eclipse.core.runtime.IPath;
|
|||
public class ScannerProvider extends AbstractCExtension implements IScannerInfoProvider, IElementChangedListener {
|
||||
|
||||
// Listeners interested in build model changes
|
||||
private static Map listeners;
|
||||
private static Map<IProject, List<IScannerInfoChangeListener>> listeners;
|
||||
|
||||
private static ScannerProvider fProvider;
|
||||
|
||||
|
@ -53,9 +53,9 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP
|
|||
/*
|
||||
* @return
|
||||
*/
|
||||
private static Map getListeners() {
|
||||
private static Map<IProject, List<IScannerInfoChangeListener>> getListeners() {
|
||||
if (listeners == null) {
|
||||
listeners = new HashMap();
|
||||
listeners = new HashMap<IProject, List<IScannerInfoChangeListener>>();
|
||||
}
|
||||
return listeners;
|
||||
}
|
||||
|
@ -66,14 +66,14 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP
|
|||
*/
|
||||
protected static void notifyInfoListeners(IProject project, IScannerInfo info) {
|
||||
// Call in the cavalry
|
||||
List listeners = (List)getListeners().get(project);
|
||||
List<?> listeners = getListeners().get(project);
|
||||
if (listeners == null) {
|
||||
return;
|
||||
}
|
||||
IScannerInfoChangeListener[] observers = new IScannerInfoChangeListener[listeners.size()];
|
||||
listeners.toArray(observers);
|
||||
for (int i = 0; i < observers.length; i++) {
|
||||
observers[i].changeNotification(project, info);
|
||||
for (IScannerInfoChangeListener observer : observers) {
|
||||
observer.changeNotification(project, info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP
|
|||
|
||||
// get the macros
|
||||
IMacroEntry[] macros = CoreModel.getMacroEntries(resPath);
|
||||
Map symbolMap = new HashMap();
|
||||
Map<String, String> symbolMap = new HashMap<String, String>();
|
||||
for (int i = 0; i < macros.length; ++i) {
|
||||
symbolMap.put(macros[i].getMacroName(), macros[i].getMacroValue());
|
||||
}
|
||||
|
@ -145,11 +145,11 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP
|
|||
}
|
||||
IProject project = resource.getProject();
|
||||
// Get listeners for this resource
|
||||
Map map = getListeners();
|
||||
List list = (List)map.get(project);
|
||||
Map<IProject, List<IScannerInfoChangeListener>> map = getListeners();
|
||||
List<IScannerInfoChangeListener> list = map.get(project);
|
||||
if (list == null) {
|
||||
// Create a new list
|
||||
list = new ArrayList();
|
||||
list = new ArrayList<IScannerInfoChangeListener>();
|
||||
map.put(project, list);
|
||||
}
|
||||
if (!list.contains(listener)) {
|
||||
|
@ -170,8 +170,8 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP
|
|||
}
|
||||
IProject project = resource.getProject();
|
||||
// Remove the listener
|
||||
Map map = getListeners();
|
||||
List list = (List)map.get(project);
|
||||
Map<IProject, List<IScannerInfoChangeListener>> map = getListeners();
|
||||
List<IScannerInfoChangeListener> list = map.get(project);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
// The list is not empty so try to remove listener
|
||||
list.remove(listener);
|
||||
|
@ -213,8 +213,8 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP
|
|||
}
|
||||
|
||||
ICElementDelta[] affectedChildren= delta.getAffectedChildren();
|
||||
for (int i= 0; i < affectedChildren.length; i++) {
|
||||
processDelta(affectedChildren[i]);
|
||||
for (ICElementDelta element2 : affectedChildren) {
|
||||
processDelta(element2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.eclipse.core.runtime.SafeRunner;
|
|||
*/
|
||||
public class PathEntryVariableManager implements IPathEntryVariableManager {
|
||||
|
||||
private Set listeners;
|
||||
private Set<IPathEntryVariableChangeListener> listeners;
|
||||
private Preferences preferences;
|
||||
|
||||
static final String VARIABLE_PREFIX = "pathEntryVariable."; //$NON-NLS-1$
|
||||
|
@ -55,7 +55,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager {
|
|||
*
|
||||
*/
|
||||
private PathEntryVariableManager() {
|
||||
this.listeners = Collections.synchronizedSet(new HashSet());
|
||||
this.listeners = Collections.synchronizedSet(new HashSet<IPathEntryVariableChangeListener>());
|
||||
this.preferences = CCorePlugin.getDefault().getPluginPreferences();
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager {
|
|||
* that. But then if they try and call #setValue using the same key it will throw
|
||||
* an exception. We may want to revisit this behaviour in the future.
|
||||
*
|
||||
* @see org.eclipse.core.resources.IPathEntryVariableManager#getValue(String)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryVariableManager#getValue(String)
|
||||
*/
|
||||
public IPath getValue(String varName) {
|
||||
String key = getKeyForName(varName);
|
||||
|
@ -74,7 +74,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.core.resources.IPathEntryVariableManager#setValue(String, IPath)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryVariableManager#setValue(String, IPath)
|
||||
*/
|
||||
public void setValue(String varName, IPath newValue) throws CoreException {
|
||||
//if the location doesn't have a device, see if the OS will assign one
|
||||
|
@ -86,10 +86,11 @@ public class PathEntryVariableManager implements IPathEntryVariableManager {
|
|||
synchronized (this) {
|
||||
IPath currentValue = getValue(varName);
|
||||
boolean variableExists = currentValue != null;
|
||||
if (!variableExists && newValue == null) {
|
||||
if (currentValue == null) {
|
||||
if (newValue == null) {
|
||||
return;
|
||||
}
|
||||
if (variableExists && currentValue.equals(newValue)) {
|
||||
} else if (currentValue.equals(newValue)) {
|
||||
return;
|
||||
}
|
||||
if (newValue == null) {
|
||||
|
@ -112,7 +113,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.core.resources.IPathEntryVariableManager#resolvePath(IPath)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryVariableManager#resolvePath(IPath)
|
||||
*/
|
||||
public IPath resolvePath(IPath path) {
|
||||
if (path == null || path.segmentCount() == 0) {
|
||||
|
@ -167,19 +168,19 @@ public class PathEntryVariableManager implements IPathEntryVariableManager {
|
|||
* @see org.eclipse.core.resources.IPathVariableManager#getPathVariableNames()
|
||||
*/
|
||||
public String[] getVariableNames() {
|
||||
List result = new LinkedList();
|
||||
List<String> result = new LinkedList<String>();
|
||||
String[] names = preferences.propertyNames();
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (names[i].startsWith(VARIABLE_PREFIX)) {
|
||||
String key = names[i].substring(VARIABLE_PREFIX.length());
|
||||
for (String name : names) {
|
||||
if (name.startsWith(VARIABLE_PREFIX)) {
|
||||
String key = name.substring(VARIABLE_PREFIX.length());
|
||||
result.add(key);
|
||||
}
|
||||
}
|
||||
return (String[]) result.toArray(new String[result.size()]);
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.core.resources.
|
||||
* @see org.eclipse.cdt.core.resources.
|
||||
* IPathEntryVariableManager#addChangeListener(IPathEntryVariableChangeListener)
|
||||
*/
|
||||
public void addChangeListener(IPathEntryVariableChangeListener listener) {
|
||||
|
@ -187,7 +188,7 @@ public class PathEntryVariableManager implements IPathEntryVariableManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.core.resources.
|
||||
* @see org.eclipse.cdt.core.resources.
|
||||
* IPathEntryVariableManager#removeChangeListener(IPathEntryVariableChangeListener)
|
||||
*/
|
||||
public void removeChangeListener(IPathEntryVariableChangeListener listener) {
|
||||
|
|
|
@ -131,16 +131,16 @@ public class CdtMacroSupplier extends CoreMacroSupplierBase {
|
|||
private String[] getMacroNames(int contextType, boolean clone){
|
||||
String names[] = null;
|
||||
switch(contextType){
|
||||
case DefaultVariableContextInfo.CONTEXT_CONFIGURATION:
|
||||
case ICoreVariableContextInfo.CONTEXT_CONFIGURATION:
|
||||
names = fConfigurationMacros;
|
||||
break;
|
||||
case DefaultVariableContextInfo.CONTEXT_WORKSPACE:
|
||||
case ICoreVariableContextInfo.CONTEXT_WORKSPACE:
|
||||
names = fWorkspaceMacros;
|
||||
break;
|
||||
case DefaultVariableContextInfo.CONTEXT_INSTALLATIONS:
|
||||
case ICoreVariableContextInfo.CONTEXT_INSTALLATIONS:
|
||||
names = fCDTEclipseMacros;
|
||||
break;
|
||||
case DefaultVariableContextInfo.CONTEXT_ECLIPSEENV:
|
||||
case ICoreVariableContextInfo.CONTEXT_ECLIPSEENV:
|
||||
break;
|
||||
}
|
||||
if(names != null)
|
||||
|
@ -166,22 +166,22 @@ public class CdtMacroSupplier extends CoreMacroSupplierBase {
|
|||
Object contextData) {
|
||||
ICdtVariable macro = null;
|
||||
switch(contextType){
|
||||
case DefaultVariableContextInfo.CONTEXT_CONFIGURATION:
|
||||
case ICoreVariableContextInfo.CONTEXT_CONFIGURATION:
|
||||
if(contextData instanceof ICConfigurationDescription){
|
||||
macro = getMacro(macroName, (ICConfigurationDescription)contextData);
|
||||
}
|
||||
break;
|
||||
case DefaultVariableContextInfo.CONTEXT_WORKSPACE:
|
||||
case ICoreVariableContextInfo.CONTEXT_WORKSPACE:
|
||||
if(contextData == null || contextData instanceof IWorkspace){
|
||||
macro = getMacro(macroName, (IWorkspace)contextData);
|
||||
}
|
||||
break;
|
||||
case DefaultVariableContextInfo.CONTEXT_INSTALLATIONS:
|
||||
case ICoreVariableContextInfo.CONTEXT_INSTALLATIONS:
|
||||
if(contextData == null){
|
||||
macro = getMacro(macroName);
|
||||
}
|
||||
break;
|
||||
case DefaultVariableContextInfo.CONTEXT_ECLIPSEENV:
|
||||
case ICoreVariableContextInfo.CONTEXT_ECLIPSEENV:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -368,23 +368,23 @@ public class CdtMacroSupplier extends CoreMacroSupplierBase {
|
|||
return macro;
|
||||
}
|
||||
|
||||
private String getBaseName(String name){
|
||||
String value = null;
|
||||
int index = name.lastIndexOf('.');
|
||||
if(index == -1)
|
||||
value = name;
|
||||
else
|
||||
value = name.substring(0,index);
|
||||
return value;
|
||||
}
|
||||
|
||||
private String getExtension(String name){
|
||||
String value = null;
|
||||
int index = name.lastIndexOf('.');
|
||||
if(index != -1)
|
||||
value = name.substring(index+1);
|
||||
return value;
|
||||
}
|
||||
// private String getBaseName(String name){
|
||||
// String value = null;
|
||||
// int index = name.lastIndexOf('.');
|
||||
// if(index == -1)
|
||||
// value = name;
|
||||
// else
|
||||
// value = name.substring(0,index);
|
||||
// return value;
|
||||
// }
|
||||
//
|
||||
// private String getExtension(String name){
|
||||
// String value = null;
|
||||
// int index = name.lastIndexOf('.');
|
||||
// if(index != -1)
|
||||
// value = name.substring(index+1);
|
||||
// return value;
|
||||
// }
|
||||
|
||||
/* public IBuildMacro getMacro(String macroName, IManagedProject mngProj){
|
||||
IBuildMacro macro = null;
|
||||
|
@ -474,8 +474,8 @@ public class CdtMacroSupplier extends CoreMacroSupplierBase {
|
|||
if(names != null){
|
||||
ICdtVariable macros[] = new ICdtVariable[names.length];
|
||||
int num = 0;
|
||||
for(int i = 0; i < names.length; i++){
|
||||
ICdtVariable macro = getMacro(names[i],contextType,contextData);
|
||||
for (String name : names) {
|
||||
ICdtVariable macro = getMacro(name,contextType,contextData);
|
||||
if(macro != null)
|
||||
macros[num++] = macro;
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ import org.eclipse.core.variables.VariablesPlugin;
|
|||
* @since 3.0
|
||||
*/
|
||||
public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier {
|
||||
private static final String VAR_PREFIX = "${"; //$NON-NLS-1$
|
||||
private static final char VAR_SUFFIX = '}'; //$NON-NLS-1$
|
||||
private static final char COLON = ':'; //$NON-NLS-1$
|
||||
// private static final String VAR_PREFIX = "${"; //$NON-NLS-1$
|
||||
// private static final char VAR_SUFFIX = '}';
|
||||
private static final char COLON = ':';
|
||||
|
||||
private static EclipseVariablesVariableSupplier fInstance;
|
||||
|
||||
|
@ -155,30 +155,30 @@ public class EclipseVariablesVariableSupplier implements ICdtVariableSupplier {
|
|||
|
||||
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
IDynamicVariable vars[] = mngr.getDynamicVariables();
|
||||
Map map = new HashMap();
|
||||
for(int i = 0; i < vars.length; i++)
|
||||
map.put(vars[i].getName(),vars[i]);
|
||||
Map<String, IStringVariable> map = new HashMap<String, IStringVariable>();
|
||||
for (IDynamicVariable var : vars)
|
||||
map.put(var.getName(),var);
|
||||
|
||||
IValueVariable valVars[] = mngr.getValueVariables();
|
||||
for(int i = 0; i < valVars.length; i++)
|
||||
map.put(valVars[i].getName(),valVars[i]);
|
||||
for (IValueVariable valVar : valVars)
|
||||
map.put(valVar.getName(),valVar);
|
||||
|
||||
Collection collection = map.values();
|
||||
Collection<IStringVariable> collection = map.values();
|
||||
EclipseVarMacro macros[] = new EclipseVarMacro[collection.size()];
|
||||
Iterator iter = collection.iterator();
|
||||
Iterator<IStringVariable> iter = collection.iterator();
|
||||
for(int i = 0; i < macros.length ; i++)
|
||||
macros[i] = new EclipseVarMacro((IStringVariable)iter.next());
|
||||
macros[i] = new EclipseVarMacro(iter.next());
|
||||
|
||||
return macros;
|
||||
}
|
||||
|
||||
private String getMacroValue(String name){
|
||||
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
try{
|
||||
return mngr.performStringSubstitution(VAR_PREFIX + name + VAR_SUFFIX);
|
||||
}catch (CoreException e){
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
// private String getMacroValue(String name){
|
||||
// IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
// try{
|
||||
// return mngr.performStringSubstitution(VAR_PREFIX + name + VAR_SUFFIX);
|
||||
// }catch (CoreException e){
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ public class StorableCdtVariables implements IStorableCdtVariables {
|
|||
|
||||
public StorableCdtVariables(ICdtVariable vars[], boolean readOnly) {
|
||||
fMacros = new HashMap<String, ICdtVariable>(vars.length);
|
||||
for(int i = 0; i < vars.length; i++){
|
||||
addMacro(vars[i]);
|
||||
for (ICdtVariable var : vars) {
|
||||
addMacro(var);
|
||||
}
|
||||
fIsReadOnly = readOnly;
|
||||
}
|
||||
|
@ -199,8 +199,8 @@ public class StorableCdtVariables implements IStorableCdtVariables {
|
|||
public void createMacros(ICdtVariable macros[]){
|
||||
if(fIsReadOnly)
|
||||
throw ExceptionFactory.createIsReadOnlyException();
|
||||
for(int i = 0; i < macros.length; i++){
|
||||
createMacro(macros[i]);
|
||||
for (ICdtVariable macro : macros) {
|
||||
createMacro(macro);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,12 +319,12 @@ public class StorableCdtVariables implements IStorableCdtVariables {
|
|||
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
|
||||
return null;
|
||||
|
||||
ICdtVariable var = (ICdtVariable)getMap().get(name);
|
||||
ICdtVariable var = getMap().get(name);
|
||||
if(var == null){
|
||||
int indx = name.indexOf(':');
|
||||
if(indx != -1){
|
||||
String baseName = name.substring(0, indx);
|
||||
ICdtVariable tmp = (ICdtVariable)getMap().get(baseName);
|
||||
ICdtVariable tmp = getMap().get(baseName);
|
||||
if(tmp != null
|
||||
&& CdtVariableManager.getDefault().toEclipseVariable(tmp, null) != null){
|
||||
var = EclipseVariablesVariableSupplier.getInstance().getVariable(name);
|
||||
|
@ -346,7 +346,7 @@ public class StorableCdtVariables implements IStorableCdtVariables {
|
|||
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
|
||||
return null;
|
||||
|
||||
ICdtVariable macro = (ICdtVariable)getMap().remove(name);
|
||||
ICdtVariable macro = getMap().remove(name);
|
||||
if(macro != null){
|
||||
fIsDirty = true;
|
||||
fIsChanged = true;
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
|
@ -350,8 +349,8 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
try {
|
||||
String[] value = fVar.getStringListValue();
|
||||
if(value != null){
|
||||
for(int i = 0; i < value.length; i++){
|
||||
code += value[i].hashCode();
|
||||
for (String element : value) {
|
||||
code += element.hashCode();
|
||||
}
|
||||
}
|
||||
} catch (CdtVariableException e) {
|
||||
|
@ -395,19 +394,19 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
|
||||
if(oldVars == null || oldVars.length == 0){
|
||||
if(newVars != null && newVars.length != 0)
|
||||
addedVars = (ICdtVariable[])newVars.clone() ;
|
||||
addedVars = newVars.clone() ;
|
||||
} else if(newVars == null || newVars.length == 0){
|
||||
removedVars = (ICdtVariable[])oldVars.clone();
|
||||
removedVars = oldVars.clone();
|
||||
} else {
|
||||
HashSet<VarKey> newSet = new HashSet<VarKey>(newVars.length);
|
||||
HashSet<VarKey> oldSet = new HashSet<VarKey>(oldVars.length);
|
||||
|
||||
for(int i = 0; i < newVars.length; i++){
|
||||
newSet.add(new VarKey(newVars[i], true));
|
||||
for (ICdtVariable newVar : newVars) {
|
||||
newSet.add(new VarKey(newVar, true));
|
||||
}
|
||||
|
||||
for(int i = 0; i < oldVars.length; i++){
|
||||
oldSet.add(new VarKey(oldVars[i], true));
|
||||
for (ICdtVariable oldVar : oldVars) {
|
||||
oldSet.add(new VarKey(oldVar, true));
|
||||
}
|
||||
|
||||
HashSet<VarKey> newSetCopy = (HashSet<VarKey>)newSet.clone();
|
||||
|
@ -426,13 +425,13 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
newSetCopy.removeAll(newSet);
|
||||
|
||||
HashSet modifiedSet = new HashSet(newSetCopy.size());
|
||||
for(Iterator iter = newSetCopy.iterator(); iter.hasNext();){
|
||||
VarKey key = (VarKey)iter.next();
|
||||
for (Object element : newSetCopy) {
|
||||
VarKey key = (VarKey)element;
|
||||
modifiedSet.add(new VarKey(key.getVariable(), false));
|
||||
}
|
||||
|
||||
for(int i = 0; i < oldVars.length; i++){
|
||||
modifiedSet.remove(new VarKey(oldVars[i], false));
|
||||
for (ICdtVariable oldVar : oldVars) {
|
||||
modifiedSet.remove(new VarKey(oldVar, false));
|
||||
}
|
||||
|
||||
if(modifiedSet.size() != 0)
|
||||
|
@ -513,8 +512,7 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
protected void loadPathEntryVariables(StorableCdtVariables vars){
|
||||
org.eclipse.core.runtime.Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
|
||||
String[] names = prefs.propertyNames();
|
||||
for(int i = 0; i < names.length; i++){
|
||||
String name = names[i];
|
||||
for (String name : names) {
|
||||
if (name.startsWith(OLD_VARIABLE_PREFIX)) {
|
||||
String value = prefs.getString(name);
|
||||
prefs.setToDefault(name);
|
||||
|
@ -662,9 +660,9 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
}
|
||||
|
||||
private void notifyListeners(VariableChangeEvent event){
|
||||
ICdtVariableChangeListener[] listeners = (ICdtVariableChangeListener[])fListeners.toArray(new ICdtVariableChangeListener[fListeners.size()]);
|
||||
for(int i = 0; i < listeners.length; i++){
|
||||
listeners[i].variablesChanged(event);
|
||||
ICdtVariableChangeListener[] listeners = fListeners.toArray(new ICdtVariableChangeListener[fListeners.size()]);
|
||||
for (ICdtVariableChangeListener listener : listeners) {
|
||||
listener.variablesChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import org.eclipse.cdt.core.dom.CDOM;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopyProvider;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
@ -19,8 +18,7 @@ import org.eclipse.cdt.core.parser.IScanner;
|
|||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class WorkingCopyCodeReaderFactory extends
|
||||
PartialWorkingCopyCodeReaderFactory implements ICodeReaderFactory {
|
||||
public class WorkingCopyCodeReaderFactory extends PartialWorkingCopyCodeReaderFactory {
|
||||
|
||||
/**
|
||||
* @param provider
|
||||
|
|
|
@ -124,7 +124,7 @@ public class EnvironmentVariableManager implements
|
|||
|
||||
if(contextInfo == null)
|
||||
return null;
|
||||
if((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null) //$NON-NLS-1$
|
||||
if((variableName = EnvVarOperationProcessor.normalizeName(variableName)) == null)
|
||||
return null;
|
||||
|
||||
|
||||
|
@ -133,8 +133,8 @@ public class EnvironmentVariableManager implements
|
|||
if(!includeParentLevels){
|
||||
ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
||||
boolean bVarFound = false;
|
||||
for(int i = 0; i < suppliers.length; i++){
|
||||
if(suppliers[i].getVariable(variableName,infos[0].getContext()) != null){
|
||||
for (ICoreEnvironmentVariableSupplier supplier : suppliers) {
|
||||
if(supplier.getVariable(variableName,infos[0].getContext()) != null){
|
||||
bVarFound = true;
|
||||
break;
|
||||
}
|
||||
|
@ -224,16 +224,16 @@ public class EnvironmentVariableManager implements
|
|||
return null;
|
||||
|
||||
IEnvironmentContextInfo infos[] = getAllContextInfos(contextInfo);
|
||||
HashSet set = null;
|
||||
HashSet<String> set = null;
|
||||
|
||||
if(!includeParentLevels){
|
||||
ICoreEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
||||
set = new HashSet();
|
||||
set = new HashSet<String>();
|
||||
for(int i = 0; i < suppliers.length; i++){
|
||||
IEnvironmentVariable vars[] = suppliers[i].getVariables(infos[0].getContext());
|
||||
if(vars != null){
|
||||
for(int j = 0; j < vars.length; j++){
|
||||
String name = EnvVarOperationProcessor.normalizeName(vars[j].
|
||||
for (IEnvironmentVariable var : vars) {
|
||||
String name = EnvVarOperationProcessor.normalizeName(var.
|
||||
getName());
|
||||
if(name != null)
|
||||
set.add(name);
|
||||
|
@ -260,15 +260,15 @@ public class EnvironmentVariableManager implements
|
|||
|
||||
IEnvironmentVariable vars[] = null;
|
||||
if(set != null){
|
||||
List varList = new ArrayList();
|
||||
Iterator iter = set.iterator();
|
||||
List<IEnvironmentVariable> varList = new ArrayList<IEnvironmentVariable>();
|
||||
Iterator<String> iter = set.iterator();
|
||||
|
||||
while(iter.hasNext()){
|
||||
IEnvironmentVariable var = supplier.getVariable((String)iter.next(),info.getContext());
|
||||
IEnvironmentVariable var = supplier.getVariable(iter.next(),info.getContext());
|
||||
if(var != null)
|
||||
varList.add(var);
|
||||
}
|
||||
vars = (IEnvironmentVariable[])varList.toArray(new IEnvironmentVariable[varList.size()]);
|
||||
vars = varList.toArray(new IEnvironmentVariable[varList.size()]);
|
||||
}
|
||||
else{
|
||||
vars = supplier.getVariables(info.getContext());
|
||||
|
@ -311,14 +311,14 @@ public class EnvironmentVariableManager implements
|
|||
if(contextInfo == null)
|
||||
return null;
|
||||
|
||||
List list = new ArrayList();
|
||||
List<IEnvironmentContextInfo> list = new ArrayList<IEnvironmentContextInfo>();
|
||||
|
||||
list.add(contextInfo);
|
||||
|
||||
while((contextInfo = contextInfo.getNext()) != null)
|
||||
list.add(contextInfo);
|
||||
|
||||
return (IEnvironmentContextInfo[])list.toArray(new IEnvironmentContextInfo[list.size()]);
|
||||
return list.toArray(new IEnvironmentContextInfo[list.size()]);
|
||||
}
|
||||
|
||||
private boolean isWin32(){
|
||||
|
@ -371,7 +371,7 @@ public class EnvironmentVariableManager implements
|
|||
if(des == null || info == null)
|
||||
return null;
|
||||
|
||||
return calculateResolvedVariable(des,getVariableSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
return calculateResolvedVariable(des,getVariableSubstitutor(getMacroContextInfoForContext(info.getContext()),""," ")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
public IEnvironmentVariable calculateResolvedVariable(EnvVarDescriptor des, IVariableSubstitutor sub){
|
||||
|
|
|
@ -185,7 +185,7 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
else if(context == null || context instanceof IWorkspace){
|
||||
final Preferences prefs = getWorkspaceNode();
|
||||
final String name = PREFNAME_WORKSPACE;
|
||||
if(prefs != null && name != null)
|
||||
if (prefs != null)
|
||||
serializeInfo = new ISerializeInfo(){
|
||||
public Preferences getNode(){
|
||||
return prefs;
|
||||
|
@ -237,9 +237,9 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
try{
|
||||
String ids[] = prefNode.keys();
|
||||
boolean found = false;
|
||||
for( int i = 0; i < ids.length; i++){
|
||||
if(projDes.getConfigurationById(ids[i]) == null){
|
||||
prefNode.remove(ids[i]);
|
||||
for (String id : ids) {
|
||||
if(projDes.getConfigurationById(id) == null){
|
||||
prefNode.remove(id);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
@ -285,22 +285,23 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
|
||||
if(oldVars == null || oldVars.length == 0){
|
||||
if(newVars != null && newVars.length != 0)
|
||||
addedVars = (IEnvironmentVariable[])newVars.clone() ;
|
||||
addedVars = newVars.clone();
|
||||
} else if(newVars == null || newVars.length == 0){
|
||||
removedVars = (IEnvironmentVariable[])oldVars.clone();
|
||||
removedVars = oldVars.clone();
|
||||
} else {
|
||||
HashSet newSet = new HashSet(newVars.length);
|
||||
HashSet oldSet = new HashSet(oldVars.length);
|
||||
HashSet<VarKey> newSet = new HashSet<VarKey>(newVars.length);
|
||||
HashSet<VarKey> oldSet = new HashSet<VarKey>(oldVars.length);
|
||||
|
||||
for(int i = 0; i < newVars.length; i++){
|
||||
newSet.add(new VarKey(newVars[i], true));
|
||||
for (IEnvironmentVariable newVar : newVars) {
|
||||
newSet.add(new VarKey(newVar, true));
|
||||
}
|
||||
|
||||
for(int i = 0; i < oldVars.length; i++){
|
||||
oldSet.add(new VarKey(oldVars[i], true));
|
||||
for (IEnvironmentVariable oldVar : oldVars) {
|
||||
oldSet.add(new VarKey(oldVar, true));
|
||||
}
|
||||
|
||||
HashSet newSetCopy = (HashSet)newSet.clone();
|
||||
@SuppressWarnings("unchecked")
|
||||
HashSet<VarKey> newSetCopy = (HashSet<VarKey>)newSet.clone();
|
||||
|
||||
newSet.removeAll(oldSet);
|
||||
oldSet.removeAll(newSetCopy);
|
||||
|
@ -315,14 +316,13 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
|
||||
newSetCopy.removeAll(newSet);
|
||||
|
||||
HashSet modifiedSet = new HashSet(newSetCopy.size());
|
||||
for(Iterator iter = newSetCopy.iterator(); iter.hasNext();){
|
||||
VarKey key = (VarKey)iter.next();
|
||||
HashSet<VarKey> modifiedSet = new HashSet<VarKey>(newSetCopy.size());
|
||||
for (VarKey key : newSetCopy) {
|
||||
modifiedSet.add(new VarKey(key.getVariable(), false));
|
||||
}
|
||||
|
||||
for(int i = 0; i < oldVars.length; i++){
|
||||
modifiedSet.remove(new VarKey(oldVars[i], false));
|
||||
for (IEnvironmentVariable oldVar : oldVars) {
|
||||
modifiedSet.remove(new VarKey(oldVar, false));
|
||||
}
|
||||
|
||||
if(modifiedSet.size() != 0)
|
||||
|
@ -334,11 +334,11 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
return null;
|
||||
}
|
||||
|
||||
static IEnvironmentVariable[] varsFromKeySet(Set set){
|
||||
static IEnvironmentVariable[] varsFromKeySet(Set<VarKey> set){
|
||||
IEnvironmentVariable vars[] = new IEnvironmentVariable[set.size()];
|
||||
int i = 0;
|
||||
for(Iterator iter = set.iterator(); iter.hasNext(); i++){
|
||||
VarKey key = (VarKey)iter.next();
|
||||
for(Iterator<VarKey> iter = set.iterator(); iter.hasNext(); i++){
|
||||
VarKey key = iter.next();
|
||||
vars[i] = key.getVariable();
|
||||
}
|
||||
|
||||
|
@ -348,8 +348,8 @@ public class UserDefinedEnvironmentSupplier extends
|
|||
|
||||
public void storeProjectEnvironment(ICProjectDescription des, boolean force){
|
||||
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
storeEnvironment(cfgs[i], force, false);
|
||||
for (ICConfigurationDescription cfg : cfgs) {
|
||||
storeEnvironment(cfg, force, false);
|
||||
}
|
||||
|
||||
Preferences node = getProjectNode(des);
|
||||
|
|
|
@ -158,7 +158,7 @@ public class ErrorPattern {
|
|||
if (!file.exists()) {
|
||||
CygPath cygpath = null ;
|
||||
try {
|
||||
cygpath = new CygPath("cygpath");
|
||||
cygpath = new CygPath("cygpath"); //$NON-NLS-1$
|
||||
String cygfilename = cygpath.getFileName(filename);
|
||||
path = new Path(cygfilename);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.core.runtime.Path;
|
|||
|
||||
public class MakeErrorParser extends AbstractErrorParser {
|
||||
private static final ErrorPattern[] patterns = {
|
||||
new ErrorPattern("make\\[(.*)\\]: Entering directory `(.*)'", 0, 0) { //$NON-NLS-1
|
||||
new ErrorPattern("make\\[(.*)\\]: Entering directory `(.*)'", 0, 0) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
int level;
|
||||
|
@ -42,14 +42,14 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
return true;
|
||||
}
|
||||
},
|
||||
new ErrorPattern("make\\[.*\\]: Leaving directory", 0, 0) { //$NON-NLS-1
|
||||
new ErrorPattern("make\\[.*\\]: Leaving directory", 0, 0) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
eoParser.popDirectory();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new ErrorPattern("(make: \\*\\*\\* \\[.*\\] Error .*)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make: \\*\\*\\* \\[.*\\] Error .*)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -57,7 +57,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//make [foo] Error NN
|
||||
new ErrorPattern("(make.*\\[.*\\] Error [-]{0,1}\\d*.*)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*\\[.*\\] Error [-]{0,1}\\d*.*)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -68,14 +68,14 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
//[foo] signal description
|
||||
// Turning off for now, bug 203269
|
||||
// This is reporting an error on the line 'make -j8 ...'
|
||||
// new ErrorPattern("(make.*\\d+\\s+\\w+.*)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
// new ErrorPattern("(make.*\\d+\\s+\\w+.*)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
// protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
// super.recordError(matcher, eoParser);
|
||||
// return true;
|
||||
// }
|
||||
// },
|
||||
//missing separator. Stop.
|
||||
new ErrorPattern("(make.*missing separator.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*missing separator.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -83,7 +83,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//missing separator (did you mean TAB instead of 8 spaces?\\). Stop.
|
||||
new ErrorPattern("(make.*missing separator \\(did you mean TAB instead of 8 spaces?\\).\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*missing separator \\(did you mean TAB instead of 8 spaces?\\).\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -91,7 +91,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//commands commence before first target. Stop.
|
||||
new ErrorPattern("(make.*commands commence before first target.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*commands commence before first target.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -99,7 +99,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//commands commence before first target. Stop.
|
||||
new ErrorPattern("(make.*commands commence before first target.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*commands commence before first target.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -107,7 +107,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//missing rule before commands. Stop.
|
||||
new ErrorPattern("(make.*missing rule before commands.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*missing rule before commands.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -115,7 +115,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//missing rule before commands. Stop.
|
||||
new ErrorPattern("(make.*missing rule before commands.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*missing rule before commands.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -123,7 +123,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//No rule to make target `xxx'.
|
||||
new ErrorPattern("(make.*No rule to make target `.*'.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*No rule to make target `.*'.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -131,7 +131,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//No rule to make target `xxx', needed by `yyy'.
|
||||
new ErrorPattern("(make.*No rule to make target `.*', needed by `.*'.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*No rule to make target `.*', needed by `.*'.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -139,7 +139,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//No targets specified and no makefile found. Stop.
|
||||
new ErrorPattern("(make.*No targets specified and no makefile found.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*No targets specified and no makefile found.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -147,7 +147,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//No targets. Stop.
|
||||
new ErrorPattern("(make.*No targets.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*No targets.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -155,7 +155,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//Makefile `xxx' was not found.
|
||||
new ErrorPattern("(make.*Makefile `.*' was not found.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*Makefile `.*' was not found.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -163,7 +163,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//Included makefile `xxx' was not found.
|
||||
new ErrorPattern("(make.*Included makefile `.*' was not found.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*Included makefile `.*' was not found.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -171,7 +171,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//warning: overriding commands for target `xxx'
|
||||
new ErrorPattern("(make.*warning: overriding commands for target `.*')", 1, IMarkerGenerator.SEVERITY_WARNING) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*warning: overriding commands for target `.*')", 1, IMarkerGenerator.SEVERITY_WARNING) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -179,7 +179,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//warning: ignoring old commands for target `xxx'
|
||||
new ErrorPattern("(make.*warning: ignoring old commands for target `.*')", 1, IMarkerGenerator.SEVERITY_WARNING) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*warning: ignoring old commands for target `.*')", 1, IMarkerGenerator.SEVERITY_WARNING) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -187,7 +187,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//Circular .+ <- .+ dependency dropped.
|
||||
new ErrorPattern("(make.*Circular .+ <- .+ dependency dropped.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*Circular .+ <- .+ dependency dropped.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -195,7 +195,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//Recursive variable `xxx' references itself (eventually). Stop.
|
||||
new ErrorPattern("(make.*Recursive variable `.*' references itself \\(eventually\\).\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*Recursive variable `.*' references itself \\(eventually\\).\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -203,7 +203,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//Unterminated variable reference. Stop.
|
||||
new ErrorPattern("(make.*[uU]nterminated variable reference.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*[uU]nterminated variable reference.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -211,7 +211,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//insufficient arguments to function `.*'. Stop.
|
||||
new ErrorPattern("(make.*insufficient arguments to function `.*'.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*insufficient arguments to function `.*'.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -219,7 +219,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//missing target pattern. Stop.
|
||||
new ErrorPattern("(make.*missing target pattern.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*missing target pattern.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -227,7 +227,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//multiple target patterns. Stop.
|
||||
new ErrorPattern("(make.*multiple target patterns.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*multiple target patterns.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -235,7 +235,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//target pattern contains no `%'. Stop.
|
||||
new ErrorPattern("(make.*target pattern contains no `%'.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*target pattern contains no `%'.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -243,7 +243,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//mixed implicit and static pattern rules. Stop.
|
||||
new ErrorPattern("(make.*mixed implicit and static pattern rules.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*mixed implicit and static pattern rules.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -251,7 +251,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//mixed implicit and static pattern rules. Stop.
|
||||
new ErrorPattern("(make.*mixed implicit and static pattern rules.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*mixed implicit and static pattern rules.\\s*Stop.)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -259,7 +259,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//warning: -jN forced in submake: disabling jobserver mode.
|
||||
new ErrorPattern("(make.*warning: -jN forced in submake: disabling jobserver mode.)", 1, IMarkerGenerator.SEVERITY_WARNING) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*warning: -jN forced in submake: disabling jobserver mode.)", 1, IMarkerGenerator.SEVERITY_WARNING) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -267,7 +267,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
|
||||
new ErrorPattern("(make.*warning: jobserver unavailable: using -j1. Add `+' to parent make rule.)", 1, IMarkerGenerator.SEVERITY_WARNING) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*warning: jobserver unavailable: using -j1. Add `+' to parent make rule.)", 1, IMarkerGenerator.SEVERITY_WARNING) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -275,7 +275,7 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
}
|
||||
},
|
||||
//target `abc' doesn't match the target pattern
|
||||
new ErrorPattern("(make.*target `.*' doesn't match the target pattern)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1
|
||||
new ErrorPattern("(make.*target `.*' doesn't match the target pattern)", 1, IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { //$NON-NLS-1$
|
||||
@Override
|
||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||
super.recordError(matcher, eoParser);
|
||||
|
@ -287,4 +287,4 @@ public class MakeErrorParser extends AbstractErrorParser {
|
|||
public MakeErrorParser() {
|
||||
super(patterns);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ import org.eclipse.cdt.core.IMarkerGenerator;
|
|||
public class VCErrorParser extends AbstractErrorParser {
|
||||
|
||||
private static final ErrorPattern[] patterns = {
|
||||
new ErrorPattern("(.+?)(\\(([0-9]+)\\))? : (fatal error|error|warning) (.*)", 1, 3, 5, 0, 0) {
|
||||
new ErrorPattern("(.+?)(\\(([0-9]+)\\))? : (fatal error|error|warning) (.*)", 1, 3, 5, 0, 0) { //$NON-NLS-1$
|
||||
@Override
|
||||
public int getSeverity(Matcher matcher) {
|
||||
return "warning".equals(matcher.group(4))
|
||||
return "warning".equals(matcher.group(4)) //$NON-NLS-1$
|
||||
? IMarkerGenerator.SEVERITY_WARNING
|
||||
: IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
|
||||
}
|
||||
|
|
|
@ -41,14 +41,14 @@ public abstract class BinaryFile extends PlatformObject implements IBinaryFile {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile()
|
||||
* @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getPath()
|
||||
*/
|
||||
public final IPath getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getType()
|
||||
* @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getType()
|
||||
*/
|
||||
public final int getType() {
|
||||
return type;
|
||||
|
@ -56,7 +56,7 @@ public abstract class BinaryFile extends PlatformObject implements IBinaryFile {
|
|||
|
||||
/**
|
||||
* @throws IOException
|
||||
* @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getContents()
|
||||
* @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getContents()
|
||||
*/
|
||||
public InputStream getContents() throws IOException {
|
||||
InputStream stream = null;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class WindowsRegistry {
|
|||
if (registry == null && !failed) {
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
try {
|
||||
System.loadLibrary("winreg");
|
||||
System.loadLibrary("winreg"); //$NON-NLS-1$
|
||||
registry = new WindowsRegistry();
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
failed = true;
|
||||
|
|
|
@ -28,8 +28,8 @@ public class CdtVariableResolver {
|
|||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
|
||||
public static final String VARIABLE_PREFIX = "${"; //$NON-NLS-1$
|
||||
public static final char VARIABLE_SUFFIX = '}'; //$NON-NLS-1$
|
||||
public static final char VARIABLE_ESCAPE_CHAR = '\\'; //$NON-NLS-1$
|
||||
public static final char VARIABLE_SUFFIX = '}';
|
||||
public static final char VARIABLE_ESCAPE_CHAR = '\\';
|
||||
private static final int VARIABLE_PREFIX_LENGTH = VARIABLE_PREFIX.length();
|
||||
|
||||
static public String convertStringListToString(String value[], String listDelimiter) {
|
||||
|
@ -168,10 +168,6 @@ public class CdtVariableResolver {
|
|||
|
||||
/**
|
||||
* resolves macros in the array of string-list values
|
||||
* @param values
|
||||
* @param substitutor
|
||||
* @param ignoreErrors
|
||||
* @return
|
||||
* @throws CdtVariableException
|
||||
*/
|
||||
static public String[] resolveStringListValues(String values[], IVariableSubstitutor substitutor, boolean ignoreErrors)
|
||||
|
@ -187,11 +183,11 @@ public class CdtVariableResolver {
|
|||
throw e;
|
||||
}
|
||||
else {
|
||||
List list = new ArrayList();
|
||||
for(int i = 0; i < values.length; i++){
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String value : values) {
|
||||
String resolved[];
|
||||
try {
|
||||
resolved = CdtVariableResolver.resolveToStringList(values[i], substitutor);
|
||||
resolved = CdtVariableResolver.resolveToStringList(value, substitutor);
|
||||
if(resolved != null && resolved.length > 0)
|
||||
list.addAll(Arrays.asList(resolved));
|
||||
} catch (CdtVariableException e) {
|
||||
|
@ -200,17 +196,13 @@ public class CdtVariableResolver {
|
|||
}
|
||||
}
|
||||
|
||||
result = (String[])list.toArray(new String[list.size()]);
|
||||
result = list.toArray(new String[list.size()]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves macros in the given String to the String-list
|
||||
*
|
||||
* @param string
|
||||
* @param substitutor
|
||||
* @return
|
||||
* @throws CdtVariableException
|
||||
*/
|
||||
static public String[] resolveToStringList(String string, IVariableSubstitutor substitutor)
|
||||
|
@ -220,9 +212,6 @@ public class CdtVariableResolver {
|
|||
|
||||
/**
|
||||
* returns true if the given macro is a String-list macro.
|
||||
*
|
||||
* @param macroType
|
||||
* @return
|
||||
*/
|
||||
public static boolean isStringListVariable(int macroType){
|
||||
switch(macroType){
|
||||
|
@ -238,10 +227,6 @@ public class CdtVariableResolver {
|
|||
|
||||
/**
|
||||
* checks the macros integrity for the given context
|
||||
*
|
||||
* @param provider
|
||||
* @param contextType
|
||||
* @param contextData
|
||||
* @throws CdtVariableException
|
||||
*/
|
||||
public static void checkIntegrity(
|
||||
|
@ -251,8 +236,7 @@ public class CdtVariableResolver {
|
|||
if(info != null){
|
||||
ICdtVariable macros[] = SupplierBasedCdtVariableManager.getVariables(info,true);
|
||||
if(macros != null){
|
||||
for(int i = 0; i < macros.length; i++){
|
||||
ICdtVariable macro = macros[i];
|
||||
for (ICdtVariable macro : macros) {
|
||||
if(isStringListVariable(macro.getValueType()))
|
||||
substitutor.resolveToStringList(macro.getName());
|
||||
else
|
||||
|
|
|
@ -24,13 +24,13 @@ import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
|
|||
import org.eclipse.cdt.core.cdtvariables.ICdtVariableStatus;
|
||||
|
||||
public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor {
|
||||
private static final Object UNDEFINED_MACRO_VALUE = new Object();
|
||||
// private static final Object UNDEFINED_MACRO_VALUE = new Object();
|
||||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
private IVariableContextInfo fContextInfo;
|
||||
private String fInexistentMacroValue;
|
||||
private String fListDelimiter;
|
||||
private String fIncorrectlyReferencedMacroValue;
|
||||
private Map fDelimiterMap;
|
||||
private Map<?, ?> fDelimiterMap;
|
||||
|
||||
protected class ResolvedMacro extends CdtVariable{
|
||||
private boolean fIsDefined;
|
||||
|
@ -99,9 +99,8 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
protected String stringListToString(String values[]) throws CdtVariableException {
|
||||
String result = null;
|
||||
String delimiter;
|
||||
if(values == null)
|
||||
result = null;
|
||||
else if(values.length == 0)
|
||||
if (values != null) {
|
||||
if(values.length == 0)
|
||||
result = EMPTY_STRING;
|
||||
else if(values.length == 1)
|
||||
result = values[0];
|
||||
|
@ -121,9 +120,8 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
fContextInfo);
|
||||
throw new CdtVariableException(eStatus);
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public boolean isList(){
|
||||
|
@ -144,7 +142,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
private ICdtVariable fMacro;
|
||||
private boolean fInitialized;
|
||||
private int fSupplierNum;
|
||||
private int fEnvSupplierNum;
|
||||
// private int fEnvSupplierNum;
|
||||
|
||||
public MacroDescriptor(String name, IVariableContextInfo info){
|
||||
fName = name;
|
||||
|
@ -203,15 +201,15 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
|
||||
}
|
||||
|
||||
private Map fResolvedMacros = new HashMap();
|
||||
private HashSet fMacrosUnderResolution = new HashSet();
|
||||
private Stack fMacroDescriptors = new Stack();
|
||||
private Map<String, ResolvedMacro> fResolvedMacros = new HashMap<String, ResolvedMacro>();
|
||||
private HashSet<String> fMacrosUnderResolution = new HashSet<String>();
|
||||
private Stack<MacroDescriptor> fMacroDescriptors = new Stack<MacroDescriptor>();
|
||||
|
||||
public SupplierBasedCdtVariableSubstitutor(IVariableContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
|
||||
this(contextInfo, inexistentMacroValue, listDelimiter, null ,inexistentMacroValue);
|
||||
}
|
||||
|
||||
public SupplierBasedCdtVariableSubstitutor(IVariableContextInfo contextInfo, String inexistentMacroValue, String listDelimiter, Map delimiterMap, String incorrectlyReferencedMacroValue){
|
||||
public SupplierBasedCdtVariableSubstitutor(IVariableContextInfo contextInfo, String inexistentMacroValue, String listDelimiter, Map<?, ?> delimiterMap, String incorrectlyReferencedMacroValue){
|
||||
fContextInfo = contextInfo;
|
||||
fInexistentMacroValue = inexistentMacroValue;
|
||||
fListDelimiter = listDelimiter;
|
||||
|
@ -344,11 +342,11 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
if(resolvedValues.length == 1)
|
||||
result = resolvedValues[0];
|
||||
else{
|
||||
List list = new ArrayList();
|
||||
for(int i = 0; i < resolvedValues.length; i++)
|
||||
list.addAll(Arrays.asList(resolvedValues[i]));
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String[] resolvedValue : resolvedValues)
|
||||
list.addAll(Arrays.asList(resolvedValue));
|
||||
|
||||
result = (String[])list.toArray(new String[list.size()]);
|
||||
result = list.toArray(new String[list.size()]);
|
||||
}
|
||||
resolvedMacro = new ResolvedMacro(macroName,result);
|
||||
}
|
||||
|
@ -377,7 +375,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
private ResolvedMacro checkResolvingMacro(MacroDescriptor des)
|
||||
throws CdtVariableException{
|
||||
String name = des.fName;
|
||||
ResolvedMacro value = (ResolvedMacro)fResolvedMacros.get(name);
|
||||
ResolvedMacro value = fResolvedMacros.get(name);
|
||||
if(value == null){
|
||||
if(fMacrosUnderResolution.add(name)) {
|
||||
fMacroDescriptors.push(des);
|
||||
|
@ -393,7 +391,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
// ${macro1} = "...${macro1}..."
|
||||
// In the above example the ${macro1} reference will be expanded to the value of the ${macro1} macro of the
|
||||
// parent context or to an empty string if there is no such macro defined in the parent contexts
|
||||
MacroDescriptor last = (MacroDescriptor)fMacroDescriptors.lastElement();
|
||||
MacroDescriptor last = fMacroDescriptors.lastElement();
|
||||
if(last != null && last.fName.equals(name)) {
|
||||
value = resolveParentMacro(last);
|
||||
if(value == null)
|
||||
|
@ -422,7 +420,7 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
}
|
||||
|
||||
protected ResolvedMacro removeResolvedMacro(String name){
|
||||
return (ResolvedMacro)fResolvedMacros.remove(name);
|
||||
return fResolvedMacros.remove(name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -439,11 +437,11 @@ public class SupplierBasedCdtVariableSubstitutor implements IVariableSubstitutor
|
|||
fResolvedMacros.clear();
|
||||
}
|
||||
|
||||
public Map getDelimiterMap() {
|
||||
public Map<?, ?> getDelimiterMap() {
|
||||
return fDelimiterMap;
|
||||
}
|
||||
|
||||
public void setDelimiterMap(Map delimiterMap) throws CdtVariableException {
|
||||
public void setDelimiterMap(Map<?, ?> delimiterMap) throws CdtVariableException {
|
||||
if(checkEqual(fDelimiterMap,delimiterMap))
|
||||
return;
|
||||
reset();
|
||||
|
|
|
@ -65,10 +65,10 @@ public class PEArchive {
|
|||
public class ARHeader {
|
||||
|
||||
private String object_name;
|
||||
private String modification_time;
|
||||
private String uid;
|
||||
private String gid;
|
||||
private String mode;
|
||||
// private String modification_time;
|
||||
// private String uid;
|
||||
// private String gid;
|
||||
// private String mode;
|
||||
private long size;
|
||||
private long elf_offset;
|
||||
|
||||
|
@ -147,10 +147,10 @@ public class PEArchive {
|
|||
// Convert the raw bytes into strings and numbers.
|
||||
//
|
||||
this.object_name = removeBlanks(new String(object_name));
|
||||
this.modification_time = new String(modification_time);
|
||||
this.uid = new String(uid);
|
||||
this.gid = new String(gid);
|
||||
this.mode = new String(mode);
|
||||
// this.modification_time = new String(modification_time);
|
||||
// this.uid = new String(uid);
|
||||
// this.gid = new String(gid);
|
||||
// this.mode = new String(mode);
|
||||
this.size = Long.parseLong(removeBlanks(new String(size)));
|
||||
|
||||
//
|
||||
|
@ -246,7 +246,7 @@ public class PEArchive {
|
|||
if (headers != null)
|
||||
return;
|
||||
|
||||
Vector v = new Vector();
|
||||
Vector<ARHeader> v = new Vector<ARHeader>();
|
||||
try {
|
||||
//
|
||||
// Check for EOF condition
|
||||
|
@ -280,7 +280,7 @@ public class PEArchive {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
headers = (ARHeader[]) v.toArray(new ARHeader[0]);
|
||||
headers = v.toArray(new ARHeader[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -297,30 +297,30 @@ public class PEArchive {
|
|||
}
|
||||
|
||||
private boolean stringInStrings(String str, String[] set) {
|
||||
for (int i = 0; i < set.length; i++)
|
||||
if (str.compareTo(set[i]) == 0)
|
||||
for (String element : set)
|
||||
if (str.compareTo(element) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] extractFiles(String outdir, String[] names)
|
||||
throws IOException {
|
||||
Vector names_used = new Vector();
|
||||
Vector<String> names_used = new Vector<String>();
|
||||
String object_name;
|
||||
int count;
|
||||
|
||||
loadHeaders();
|
||||
|
||||
count = 0;
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
object_name = headers[i].getObjectName();
|
||||
for (ARHeader header : headers) {
|
||||
object_name = header.getObjectName();
|
||||
if (names != null && !stringInStrings(object_name, names))
|
||||
continue;
|
||||
|
||||
object_name = "" + count + "_" + object_name; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
count++;
|
||||
|
||||
byte[] data = headers[i].getObjectData();
|
||||
byte[] data = header.getObjectData();
|
||||
File output = new File(outdir, object_name);
|
||||
names_used.add(object_name);
|
||||
|
||||
|
@ -329,7 +329,7 @@ public class PEArchive {
|
|||
rfile.close();
|
||||
}
|
||||
|
||||
return (String[]) names_used.toArray(new String[0]);
|
||||
return names_used.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String[] extractFiles(String outdir) throws IOException {
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.utils.debug.IDebugEntryRequestor;
|
|||
import org.eclipse.cdt.utils.debug.tools.DebugSym;
|
||||
import org.eclipse.cdt.utils.debug.tools.DebugSymsRequestor;
|
||||
import org.eclipse.cdt.utils.elf.Elf;
|
||||
import org.eclipse.cdt.utils.elf.Elf.Section;
|
||||
|
||||
public class Dwarf {
|
||||
|
||||
|
@ -83,12 +84,12 @@ public class Dwarf {
|
|||
/* unsigned */
|
||||
long tag;
|
||||
byte hasChildren;
|
||||
List attributes;
|
||||
List<Attribute> attributes;
|
||||
AbbreviationEntry(long c, long t, byte h) {
|
||||
code = c;
|
||||
tag = t;
|
||||
hasChildren = h;
|
||||
attributes = new ArrayList();
|
||||
attributes = new ArrayList<Attribute>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +123,7 @@ public class Dwarf {
|
|||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(attribute.toString()).append(' ');
|
||||
if (value != null) {
|
||||
Class clazz = value.getClass();
|
||||
Class<? extends Object> clazz = value.getClass();
|
||||
if (clazz.isArray()) {
|
||||
int len = Array.getLength(value);
|
||||
sb.append(len).append(' ');
|
||||
|
@ -159,8 +160,8 @@ public class Dwarf {
|
|||
int identifierCase;
|
||||
}
|
||||
|
||||
Map dwarfSections = new HashMap();
|
||||
Map abbreviationMaps = new HashMap();
|
||||
Map<String, byte[]> dwarfSections = new HashMap<String, byte[]>();
|
||||
Map<Integer, Map<Long, AbbreviationEntry>> abbreviationMaps = new HashMap<Integer, Map<Long, AbbreviationEntry>>();
|
||||
|
||||
boolean isLE;
|
||||
|
||||
|
@ -183,11 +184,11 @@ public class Dwarf {
|
|||
isLE = header.e_ident[Elf.ELFhdr.EI_DATA] == Elf.ELFhdr.ELFDATA2LSB;
|
||||
|
||||
Elf.Section[] sections = exe.getSections();
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
String name = sections[i].toString();
|
||||
for (int j = 0; j < DWARF_SCNNAMES.length; j++) {
|
||||
if (name.equals(DWARF_SCNNAMES[j])) {
|
||||
dwarfSections.put(DWARF_SCNNAMES[j], sections[i].loadSectionData());
|
||||
for (Section section : sections) {
|
||||
String name = section.toString();
|
||||
for (String element : DWARF_SCNNAMES) {
|
||||
if (name.equals(element)) {
|
||||
dwarfSections.put(element, section.loadSectionData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +335,7 @@ public class Dwarf {
|
|||
}
|
||||
|
||||
void parseDebugInfo(IDebugEntryRequestor requestor) {
|
||||
byte[] data = (byte[]) dwarfSections.get(DWARF_DEBUG_INFO);
|
||||
byte[] data = dwarfSections.get(DWARF_DEBUG_INFO);
|
||||
if (data != null) {
|
||||
try {
|
||||
int length = 0;
|
||||
|
@ -353,7 +354,7 @@ public class Dwarf {
|
|||
// read the abbrev section.
|
||||
// Note "length+4" is the total size in bytes of the CU data.
|
||||
InputStream in = new ByteArrayInputStream(data, offset + 11, length+4-11);
|
||||
Map abbrevs = parseDebugAbbreviation(header);
|
||||
Map<Long, AbbreviationEntry> abbrevs = parseDebugAbbreviation(header);
|
||||
parseDebugInfoEntry(requestor, in, abbrevs, header);
|
||||
|
||||
if (printEnabled)
|
||||
|
@ -365,14 +366,14 @@ public class Dwarf {
|
|||
}
|
||||
}
|
||||
|
||||
Map parseDebugAbbreviation(CompilationUnitHeader header) throws IOException {
|
||||
Map<Long, AbbreviationEntry> parseDebugAbbreviation(CompilationUnitHeader header) throws IOException {
|
||||
int offset = header.abbreviationOffset;
|
||||
Integer key = new Integer(offset);
|
||||
Map abbrevs = (Map) abbreviationMaps.get(key);
|
||||
Map<Long, AbbreviationEntry> abbrevs = abbreviationMaps.get(key);
|
||||
if (abbrevs == null) {
|
||||
abbrevs = new HashMap();
|
||||
abbrevs = new HashMap<Long, AbbreviationEntry>();
|
||||
abbreviationMaps.put(key, abbrevs);
|
||||
byte[] data = (byte[]) dwarfSections.get(DWARF_DEBUG_ABBREV);
|
||||
byte[] data = dwarfSections.get(DWARF_DEBUG_ABBREV);
|
||||
if (data != null) {
|
||||
InputStream in = new ByteArrayInputStream(data);
|
||||
in.skip(offset);
|
||||
|
@ -405,17 +406,17 @@ public class Dwarf {
|
|||
return abbrevs;
|
||||
}
|
||||
|
||||
void parseDebugInfoEntry(IDebugEntryRequestor requestor, InputStream in, Map abbrevs, CompilationUnitHeader header)
|
||||
void parseDebugInfoEntry(IDebugEntryRequestor requestor, InputStream in, Map<Long, AbbreviationEntry> abbrevs, CompilationUnitHeader header)
|
||||
throws IOException {
|
||||
while (in.available() > 0) {
|
||||
long code = read_unsigned_leb128(in);
|
||||
AbbreviationEntry entry = (AbbreviationEntry) abbrevs.get(new Long(code));
|
||||
AbbreviationEntry entry = abbrevs.get(new Long(code));
|
||||
if (entry != null) {
|
||||
int len = entry.attributes.size();
|
||||
List list = new ArrayList(len);
|
||||
List<AttributeValue> list = new ArrayList<AttributeValue>(len);
|
||||
try {
|
||||
for (int i = 0; i < len; i++) {
|
||||
Attribute attr = (Attribute) entry.attributes.get(i);
|
||||
Attribute attr = entry.attributes.get(i);
|
||||
Object obj = readAttribute((int) attr.form, in, header);
|
||||
list.add(new AttributeValue(attr, obj));
|
||||
}
|
||||
|
@ -516,7 +517,7 @@ public class Dwarf {
|
|||
case DwarfConstants.DW_FORM_strp :
|
||||
{
|
||||
int offset = read_4_bytes(in);
|
||||
byte[] data = (byte[]) dwarfSections.get(DWARF_DEBUG_STR);
|
||||
byte[] data = dwarfSections.get(DWARF_DEBUG_STR);
|
||||
if (data == null) {
|
||||
obj = new String();
|
||||
} else if (offset < 0 || offset > data.length) {
|
||||
|
@ -568,14 +569,14 @@ public class Dwarf {
|
|||
return obj;
|
||||
}
|
||||
|
||||
void processDebugInfoEntry(IDebugEntryRequestor requestor, AbbreviationEntry entry, List list) {
|
||||
void processDebugInfoEntry(IDebugEntryRequestor requestor, AbbreviationEntry entry, List<AttributeValue> list) {
|
||||
int len = list.size();
|
||||
int tag = (int) entry.tag;
|
||||
if (printEnabled)
|
||||
System.out.println("Abbrev Number " + entry.code); //$NON-NLS-1$
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
AttributeValue av = (AttributeValue) list.get(i);
|
||||
AttributeValue av = list.get(i);
|
||||
if (printEnabled)
|
||||
System.out.println(av);
|
||||
// We are only interrested in certain tags.
|
||||
|
@ -665,14 +666,14 @@ public class Dwarf {
|
|||
return new Long(value);
|
||||
}
|
||||
|
||||
void processSubProgram(IDebugEntryRequestor requestor, List list) {
|
||||
void processSubProgram(IDebugEntryRequestor requestor, List<AttributeValue> list) {
|
||||
long lowPC = 0;
|
||||
long highPC = 0;
|
||||
String funcName = ""; //$NON-NLS-1$
|
||||
boolean isExtern = false;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
AttributeValue av = (AttributeValue)list.get(i);
|
||||
AttributeValue av = list.get(i);
|
||||
try {
|
||||
int name = (int)av.attribute.name;
|
||||
switch(name) {
|
||||
|
@ -699,13 +700,13 @@ public class Dwarf {
|
|||
requestor.exitFunction(highPC);
|
||||
}
|
||||
|
||||
void processCompileUnit(IDebugEntryRequestor requestor, List list) {
|
||||
void processCompileUnit(IDebugEntryRequestor requestor, List<AttributeValue> list) {
|
||||
if (currentCU != null) {
|
||||
requestor.exitCompilationUnit(currentCU.highPC);
|
||||
}
|
||||
currentCU = new CompileUnit();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
AttributeValue av = (AttributeValue)list.get(i);
|
||||
AttributeValue av = list.get(i);
|
||||
try {
|
||||
int name = (int)av.attribute.name;
|
||||
switch(name) {
|
||||
|
@ -755,8 +756,7 @@ public class Dwarf {
|
|||
Dwarf dwarf = new Dwarf(args[0]);
|
||||
dwarf.parse(symreq);
|
||||
DebugSym[] entries = symreq.getEntries();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
DebugSym entry = entries[i];
|
||||
for (DebugSym entry : entries) {
|
||||
System.out.println(entry);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import org.eclipse.cdt.core.ISymbolReader;
|
||||
import org.eclipse.cdt.utils.debug.IDebugEntryRequestor;
|
||||
import org.eclipse.cdt.utils.elf.Elf;
|
||||
import org.eclipse.cdt.utils.elf.Elf.Section;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
|
@ -39,13 +40,13 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
DWARF_DEBUG_STR // this is optional. Some compilers don't generate it.
|
||||
};
|
||||
|
||||
private Collection m_fileCollection = new ArrayList();
|
||||
private Collection<String> m_fileCollection = new ArrayList<String>();
|
||||
private String[] m_fileNames = null;
|
||||
private String m_exeFileWin32Drive; // Win32 drive of the exe file.
|
||||
private boolean m_onWindows;
|
||||
private boolean m_parsed = false;
|
||||
private int m_leb128Size = 0;
|
||||
private ArrayList m_parsedLineTableOffsets = new ArrayList();
|
||||
private ArrayList<Integer> m_parsedLineTableOffsets = new ArrayList<Integer>();
|
||||
private int m_parsedLineTableSize = 0;
|
||||
|
||||
public DwarfReader(String file) throws IOException {
|
||||
|
@ -67,11 +68,11 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
|
||||
// Read in sections (and only the sections) we care about.
|
||||
//
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
String name = sections[i].toString();
|
||||
for (int j = 0; j < DWARF_SectionsToParse.length; j++) {
|
||||
if (name.equals(DWARF_SectionsToParse[j])) {
|
||||
dwarfSections.put(DWARF_SectionsToParse[j], sections[i].loadSectionData());
|
||||
for (Section section : sections) {
|
||||
String name = section.toString();
|
||||
for (String element : DWARF_SectionsToParse) {
|
||||
if (name.equals(element)) {
|
||||
dwarfSections.put(element, section.loadSectionData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +96,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
String cuCompDir, // compilation directory of the CU
|
||||
int cuStmtList) // offset of the CU line table in .debug_line section
|
||||
{
|
||||
byte[] data = (byte[]) dwarfSections.get(DWARF_DEBUG_LINE);
|
||||
byte[] data = dwarfSections.get(DWARF_DEBUG_LINE);
|
||||
if (data != null) {
|
||||
try {
|
||||
int offset = cuStmtList;
|
||||
|
@ -134,7 +135,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
|
||||
// Read in directories.
|
||||
//
|
||||
ArrayList dirList = new ArrayList();
|
||||
ArrayList<String> dirList = new ArrayList<String>();
|
||||
|
||||
// Put the compilation directory of the CU as the first dir
|
||||
dirList.add(cuCompDir);
|
||||
|
@ -163,7 +164,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
leb128 = read_unsigned_leb128(data, offset);
|
||||
offset += m_leb128Size;
|
||||
|
||||
addSourceFile((String)dirList.get((int)leb128), fileName);
|
||||
addSourceFile(dirList.get((int)leb128), fileName);
|
||||
|
||||
// Skip the followings
|
||||
//
|
||||
|
@ -191,7 +192,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
*/
|
||||
private void getSourceFilesFromDebugLineSection()
|
||||
{
|
||||
byte[] data = (byte[]) dwarfSections.get(DWARF_DEBUG_LINE);
|
||||
byte[] data = dwarfSections.get(DWARF_DEBUG_LINE);
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
|
@ -272,12 +273,12 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
|
||||
// Read in directories.
|
||||
//
|
||||
ArrayList dirList = new ArrayList();
|
||||
ArrayList<String> dirList = new ArrayList<String>();
|
||||
|
||||
String str, fileName;
|
||||
|
||||
// first dir should be TAG_comp_dir from CU, which we don't have here.
|
||||
dirList.add("");
|
||||
dirList.add(""); //$NON-NLS-1$
|
||||
|
||||
while (true) {
|
||||
str = readString(data, offset);
|
||||
|
@ -301,7 +302,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
leb128 = read_unsigned_leb128(data, offset);
|
||||
offset += m_leb128Size;
|
||||
|
||||
addSourceFile((String) dirList.get((int) leb128), fileName);
|
||||
addSourceFile(dirList.get((int) leb128), fileName);
|
||||
|
||||
// Skip the followings
|
||||
//
|
||||
|
@ -422,7 +423,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
|
||||
m_leb128Size = 0;
|
||||
while (true) {
|
||||
b = (short) data[offset++];
|
||||
b = data[offset++];
|
||||
if (data.length == offset)
|
||||
break; //throw new IOException("no more data");
|
||||
m_leb128Size++;
|
||||
|
@ -438,7 +439,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
|
||||
// Override parent: only handle TAG_Compile_Unit.
|
||||
@Override
|
||||
void processDebugInfoEntry(IDebugEntryRequestor requestor, AbbreviationEntry entry, List list) {
|
||||
void processDebugInfoEntry(IDebugEntryRequestor requestor, AbbreviationEntry entry, List<Dwarf.AttributeValue> list) {
|
||||
int tag = (int) entry.tag;
|
||||
switch (tag) {
|
||||
case DwarfConstants.DW_TAG_compile_unit :
|
||||
|
@ -453,15 +454,15 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
|||
// Just get the file name of the CU.
|
||||
// Argument "requestor" is ignored.
|
||||
@Override
|
||||
void processCompileUnit(IDebugEntryRequestor requestor, List list) {
|
||||
void processCompileUnit(IDebugEntryRequestor requestor, List<AttributeValue> list) {
|
||||
|
||||
String cuName, cuCompDir;
|
||||
int stmtList = -1;
|
||||
|
||||
cuName = cuCompDir = "";
|
||||
cuName = cuCompDir = ""; //$NON-NLS-1$
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
AttributeValue av = (AttributeValue)list.get(i);
|
||||
AttributeValue av = list.get(i);
|
||||
try {
|
||||
int name = (int)av.attribute.name;
|
||||
switch(name) {
|
||||
|
|
|
@ -18,6 +18,9 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.utils.coff.PE;
|
||||
import org.eclipse.cdt.utils.coff.Coff.SectionHeader;
|
||||
import org.eclipse.cdt.utils.coff.PE.Attribute;
|
||||
import org.eclipse.cdt.utils.debug.DebugArrayType;
|
||||
import org.eclipse.cdt.utils.debug.DebugBaseType;
|
||||
import org.eclipse.cdt.utils.debug.DebugCrossRefType;
|
||||
|
@ -36,9 +39,7 @@ import org.eclipse.cdt.utils.debug.IDebugEntryRequestor;
|
|||
import org.eclipse.cdt.utils.debug.tools.DebugSym;
|
||||
import org.eclipse.cdt.utils.debug.tools.DebugSymsRequestor;
|
||||
import org.eclipse.cdt.utils.elf.Elf;
|
||||
import org.eclipse.cdt.utils.coff.PE;
|
||||
import org.eclipse.cdt.utils.coff.Coff.SectionHeader;
|
||||
import org.eclipse.cdt.utils.coff.PE.Attribute;
|
||||
import org.eclipse.cdt.utils.elf.Elf.Section;
|
||||
|
||||
public class Stabs {
|
||||
|
||||
|
@ -57,7 +58,7 @@ public class Stabs {
|
|||
int bracket;
|
||||
String currentFile;
|
||||
|
||||
Map mapTypes = new HashMap();
|
||||
Map<TypeNumber, DebugType> mapTypes = new HashMap<TypeNumber, DebugType>();
|
||||
DebugType voidType = new DebugBaseType("void", 0, false); //$NON-NLS-1$
|
||||
|
||||
public Stabs(String file) throws IOException {
|
||||
|
@ -87,12 +88,12 @@ public class Stabs {
|
|||
byte[] data = null;
|
||||
byte[] stabstr = null;
|
||||
Elf.Section[] sections = exe.getSections();
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
String name = sections[i].toString();
|
||||
for (Section section : sections) {
|
||||
String name = section.toString();
|
||||
if (name.equals(".stab")) { //$NON-NLS-1$
|
||||
data = sections[i].loadSectionData();
|
||||
data = section.loadSectionData();
|
||||
} else if (name.equals(".stabstr")) { //$NON-NLS-1$
|
||||
stabstr = sections[i].loadSectionData();
|
||||
stabstr = section.loadSectionData();
|
||||
}
|
||||
}
|
||||
Elf.ELFhdr header = exe.getELFhdr();
|
||||
|
@ -107,12 +108,12 @@ public class Stabs {
|
|||
byte[] stabstr = null;
|
||||
|
||||
SectionHeader[] sections = exe.getSectionHeaders();
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
String name = new String(sections[i].s_name).trim();
|
||||
for (SectionHeader section : sections) {
|
||||
String name = new String(section.s_name).trim();
|
||||
if (name.equals(".stab")) { //$NON-NLS-1$
|
||||
data = sections[i].getRawData();
|
||||
data = section.getRawData();
|
||||
} else if (name.equals(".stabstr")) { //$NON-NLS-1$
|
||||
stabstr = sections[i].getRawData();
|
||||
stabstr = section.getRawData();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,7 +489,7 @@ public class Stabs {
|
|||
// According to the doc 't' can follow the 'T'. If so just
|
||||
// strip the T and go again.
|
||||
if (infoField.length() > 0 && infoField.charAt(0) == 't') {
|
||||
String s = field.replaceFirst(":T", ":");
|
||||
String s = field.replaceFirst(":T", ":"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
parseStabString(requestor, s, value);
|
||||
} else {
|
||||
// Just register the type.
|
||||
|
@ -994,7 +995,7 @@ public class Stabs {
|
|||
* @return
|
||||
*/
|
||||
DebugType parseStabEnumType(String name, Reader reader) throws IOException {
|
||||
List list = new ArrayList();
|
||||
List<DebugEnumField> list = new ArrayList<DebugEnumField>();
|
||||
String fieldName = null;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int c;
|
||||
|
@ -1190,10 +1191,6 @@ public class Stabs {
|
|||
overflowUpperBound = true;
|
||||
}
|
||||
|
||||
if (typeNumber == null) {
|
||||
typeNumber = new TypeNumber(0, 0);
|
||||
}
|
||||
|
||||
boolean self = typeNumber.equals(number);
|
||||
|
||||
// Probably trying 64 bits range like "long long"
|
||||
|
@ -1365,7 +1362,7 @@ public class Stabs {
|
|||
}
|
||||
|
||||
DebugType getDebugType(TypeNumber tn) {
|
||||
return (DebugType) mapTypes.get(tn);
|
||||
return mapTypes.get(tn);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -1374,8 +1371,7 @@ public class Stabs {
|
|||
Stabs stabs = new Stabs(args[0]);
|
||||
stabs.parse(symreq);
|
||||
DebugSym[] entries = symreq.getEntries();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
DebugSym entry = entries[i];
|
||||
for (DebugSym entry : entries) {
|
||||
System.out.println(entry);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
package org.eclipse.cdt.utils.debug.stabs;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.ISymbolReader;
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class StabsReader implements ISymbolReader {
|
|||
byte[] stabData;
|
||||
byte[] stabstrData;
|
||||
boolean isLe;
|
||||
List fileList;
|
||||
List<String> fileList;
|
||||
String[] files = null;
|
||||
boolean parsed = false;
|
||||
String currentFile;
|
||||
|
@ -31,7 +31,7 @@ public class StabsReader implements ISymbolReader {
|
|||
stabstrData = stabstr;
|
||||
isLe = littleEndian;
|
||||
|
||||
fileList = new ArrayList();
|
||||
fileList = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public String[] getSourceFiles() {
|
||||
|
@ -42,7 +42,7 @@ public class StabsReader implements ISymbolReader {
|
|||
|
||||
files = new String[fileList.size()];
|
||||
for (int i = 0; i < fileList.size(); i++) {
|
||||
files[i] = (String)fileList.get(i);
|
||||
files[i] = fileList.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,10 @@ public class StabsReader implements ISymbolReader {
|
|||
|
||||
private String fixUpPath(String path) {
|
||||
// some compilers generate extra back slashes
|
||||
path = path.replaceAll("\\\\\\\\", "\\\\");
|
||||
path = path.replaceAll("\\\\\\\\", "\\\\"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
|
||||
// translate any cygwin drive paths, e.g. //G/System/main.cpp or /cygdrive/c/system/main.c
|
||||
if (path.startsWith("/cygdrive/") && ('/' == path.charAt(11))) {
|
||||
if (path.startsWith("/cygdrive/") && ('/' == path.charAt(11))) { //$NON-NLS-1$
|
||||
char driveLetter = path.charAt(10);
|
||||
driveLetter = (Character.isLowerCase(driveLetter)) ? Character.toUpperCase(driveLetter) : driveLetter;
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class StabsReader implements ISymbolReader {
|
|||
}
|
||||
|
||||
// translate any cygwin drive paths, e.g. //G/System/main.cpp or /cygdrive/c/system/main.c
|
||||
if (path.startsWith("//") && ('/' == path.charAt(3))) {
|
||||
if (path.startsWith("//") && ('/' == path.charAt(3))) { //$NON-NLS-1$
|
||||
char driveLetter = path.charAt(2);
|
||||
driveLetter = (Character.isLowerCase(driveLetter)) ? Character.toUpperCase(driveLetter) : driveLetter;
|
||||
|
||||
|
|
|
@ -63,10 +63,10 @@ public class AR {
|
|||
public class ARHeader {
|
||||
|
||||
private String object_name;
|
||||
private String modification_time;
|
||||
private String uid;
|
||||
private String gid;
|
||||
private String mode;
|
||||
// private String modification_time;
|
||||
// private String uid;
|
||||
// private String gid;
|
||||
// private String mode;
|
||||
private long size;
|
||||
private long elf_offset;
|
||||
|
||||
|
@ -145,10 +145,10 @@ public class AR {
|
|||
// Convert the raw bytes into strings and numbers.
|
||||
//
|
||||
this.object_name = removeBlanks(new String(object_name));
|
||||
this.modification_time = new String(modification_time);
|
||||
this.uid = new String(uid);
|
||||
this.gid = new String(gid);
|
||||
this.mode = new String(mode);
|
||||
// this.modification_time = new String(modification_time);
|
||||
// this.uid = new String(uid);
|
||||
// this.gid = new String(gid);
|
||||
// this.mode = new String(mode);
|
||||
this.size = Long.parseLong(removeBlanks(new String(size)));
|
||||
|
||||
//
|
||||
|
@ -250,7 +250,7 @@ public class AR {
|
|||
if (headers != null)
|
||||
return;
|
||||
|
||||
Vector v = new Vector();
|
||||
Vector<ARHeader> v = new Vector<ARHeader>();
|
||||
try {
|
||||
//
|
||||
// Check for EOF condition
|
||||
|
@ -284,7 +284,7 @@ public class AR {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
headers = (ARHeader[]) v.toArray(new ARHeader[0]);
|
||||
headers = v.toArray(new ARHeader[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -301,29 +301,29 @@ public class AR {
|
|||
}
|
||||
|
||||
private boolean stringInStrings(String str, String[] set) {
|
||||
for (int i = 0; i < set.length; i++)
|
||||
if (str.compareTo(set[i]) == 0)
|
||||
for (String element : set)
|
||||
if (str.compareTo(element) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] extractFiles(String outdir, String[] names) throws IOException {
|
||||
Vector names_used = new Vector();
|
||||
Vector<String> names_used = new Vector<String>();
|
||||
String object_name;
|
||||
int count;
|
||||
|
||||
loadHeaders();
|
||||
|
||||
count = 0;
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
object_name = headers[i].getObjectName();
|
||||
for (ARHeader header : headers) {
|
||||
object_name = header.getObjectName();
|
||||
if (names != null && !stringInStrings(object_name, names))
|
||||
continue;
|
||||
|
||||
object_name = "" + count + "_" + object_name; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
count++;
|
||||
|
||||
byte[] data = headers[i].getObjectData();
|
||||
byte[] data = header.getObjectData();
|
||||
File output = new File(outdir, object_name);
|
||||
names_used.add(object_name);
|
||||
|
||||
|
@ -332,7 +332,7 @@ public class AR {
|
|||
rfile.close();
|
||||
}
|
||||
|
||||
return (String[]) names_used.toArray(new String[0]);
|
||||
return names_used.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String[] extractFiles(String outdir) throws IOException {
|
||||
|
|
|
@ -87,8 +87,8 @@ public class EnvVarOperationProcessor {
|
|||
return prepend ? addValue + initialValue : initialValue + addValue;
|
||||
}
|
||||
|
||||
List value = convertToList(initialValue, delimiter);
|
||||
List added = convertToList(addValue, delimiter);
|
||||
List<String> value = convertToList(initialValue, delimiter);
|
||||
List<String> added = convertToList(addValue, delimiter);
|
||||
|
||||
value = removeDuplicates(value, added);
|
||||
|
||||
|
@ -151,10 +151,9 @@ public class EnvVarOperationProcessor {
|
|||
* Converts a given value to string using a delimiter passed to this method
|
||||
* @param value
|
||||
* @param delimiter
|
||||
* @return
|
||||
*/
|
||||
static public List convertToList(String value, String delimiter){
|
||||
List list = new ArrayList();
|
||||
static public List<String> convertToList(String value, String delimiter){
|
||||
List<String> list = new ArrayList<String>();
|
||||
int delLength = delimiter.length();
|
||||
int valLength = value.length();
|
||||
|
||||
|
@ -180,15 +179,15 @@ public class EnvVarOperationProcessor {
|
|||
/*
|
||||
* removes duplicates
|
||||
*/
|
||||
static public List removeDuplicates(List value, List duplicates){
|
||||
List list = new ArrayList();
|
||||
Iterator valueIter = value.iterator();
|
||||
static public List<String> removeDuplicates(List<String> value, List<String> duplicates){
|
||||
List<String> list = new ArrayList<String>();
|
||||
Iterator<String> valueIter = value.iterator();
|
||||
while(valueIter.hasNext()){
|
||||
String curVal = (String)valueIter.next();
|
||||
String curVal = valueIter.next();
|
||||
boolean duplFound = false;
|
||||
Iterator duplicatesIter = duplicates.iterator();
|
||||
Iterator<String> duplicatesIter = duplicates.iterator();
|
||||
while(duplicatesIter.hasNext()){
|
||||
String curDupl = (String)duplicatesIter.next();
|
||||
String curDupl = duplicatesIter.next();
|
||||
if(curVal.equals(curDupl)){
|
||||
duplFound = true;
|
||||
break;
|
||||
|
@ -207,12 +206,12 @@ public class EnvVarOperationProcessor {
|
|||
* @param delimiter
|
||||
* @return String
|
||||
*/
|
||||
static public String convertToString(List list, String delimiter){
|
||||
Iterator iter = list.iterator();
|
||||
static public String convertToString(List<String> list, String delimiter){
|
||||
Iterator<String> iter = list.iterator();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
while(iter.hasNext()){
|
||||
buffer.append((String)iter.next());
|
||||
buffer.append(iter.next());
|
||||
|
||||
if(iter.hasNext())
|
||||
buffer.append(delimiter);
|
||||
|
@ -221,19 +220,6 @@ public class EnvVarOperationProcessor {
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* concatenetes two Strings
|
||||
* Returns a resulting string
|
||||
*/
|
||||
static private String concatenateStrings(String str1, String str2, String delimiter){
|
||||
if(str1 == null || "".equals(str1)) //$NON-NLS-1$
|
||||
return str2;
|
||||
if(str2 == null || "".equals(str2)) //$NON-NLS-1$
|
||||
return str1;
|
||||
|
||||
return str1 + delimiter + str2;
|
||||
}
|
||||
|
||||
/*
|
||||
* normalizes the variable name. That is: removes prepended and appended spaces
|
||||
* and converts the name to upper-case for Win32 systems
|
||||
|
@ -256,14 +242,13 @@ public class EnvVarOperationProcessor {
|
|||
|
||||
IEnvironmentVariable filtered[] = new IEnvironmentVariable[variables.length];
|
||||
int filteredNum = 0;
|
||||
for(int i = 0; i < variables.length; i++){
|
||||
IEnvironmentVariable var = variables[i];
|
||||
for (IEnvironmentVariable var : variables) {
|
||||
String name = null;
|
||||
if(var != null && (name = normalizeName(var.getName())) != null){
|
||||
boolean skip = false;
|
||||
if(remove != null && remove.length > 0){
|
||||
for(int j = 0; j < remove.length; j++){
|
||||
if(remove[j] != null && remove[j].equals(name)){
|
||||
for (String element : remove) {
|
||||
if(element != null && element.equals(name)){
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -63,9 +63,6 @@ public abstract class StorableEnvironmentLoader {
|
|||
* this method should return the ISerializeInfo representing the information
|
||||
* of where the variable should be stored and loaded
|
||||
* If the given context is not supported this method should return null
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected abstract ISerializeInfo getSerializeInfo(Object context);
|
||||
|
||||
|
@ -198,9 +195,9 @@ public abstract class StorableEnvironmentLoader {
|
|||
CCorePlugin.PLUGIN_ID,
|
||||
-1,
|
||||
//TODO:ManagedMakeMessages.getResourceString(
|
||||
"StorableEnvironmentLoader.storeOutputStream.wrong.arguments"
|
||||
"StorableEnvironmentLoader.storeOutputStream.wrong.arguments" //$NON-NLS-1$
|
||||
//)
|
||||
, //$NON-NLS-1$
|
||||
,
|
||||
null));
|
||||
byte[] bytes= stream.toByteArray();
|
||||
|
||||
|
|
|
@ -60,12 +60,12 @@ public class AR {
|
|||
public class ARHeader {
|
||||
|
||||
private String object_name;
|
||||
private String modification_time;
|
||||
private String uid;
|
||||
private String gid;
|
||||
private String mode;
|
||||
// private String modification_time;
|
||||
// private String uid;
|
||||
// private String gid;
|
||||
// private String mode;
|
||||
private long size;
|
||||
private long file_offset;
|
||||
// private long file_offset;
|
||||
private long macho_offset;
|
||||
|
||||
/**
|
||||
|
@ -88,23 +88,23 @@ public class AR {
|
|||
* @throws IOException
|
||||
* <code>offset</code> not in string table bounds.
|
||||
*/
|
||||
private String nameFromStringTable(long offset) throws IOException {
|
||||
StringBuffer name = new StringBuffer(0);
|
||||
long pos = efile.getFilePointer();
|
||||
|
||||
try {
|
||||
if (strtbl_pos != -1) {
|
||||
byte temp;
|
||||
efile.seek(strtbl_pos + offset);
|
||||
while ((temp = efile.readByte()) != '\n')
|
||||
name.append((char) temp);
|
||||
}
|
||||
} finally {
|
||||
efile.seek(pos);
|
||||
}
|
||||
|
||||
return name.toString();
|
||||
}
|
||||
// private String nameFromStringTable(long offset) throws IOException {
|
||||
// StringBuffer name = new StringBuffer(0);
|
||||
// long pos = efile.getFilePointer();
|
||||
//
|
||||
// try {
|
||||
// if (strtbl_pos != -1) {
|
||||
// byte temp;
|
||||
// efile.seek(strtbl_pos + offset);
|
||||
// while ((temp = efile.readByte()) != '\n')
|
||||
// name.append((char) temp);
|
||||
// }
|
||||
// } finally {
|
||||
// efile.seek(pos);
|
||||
// }
|
||||
//
|
||||
// return name.toString();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Creates a new archive header object.
|
||||
|
@ -143,10 +143,10 @@ public class AR {
|
|||
// Convert the raw bytes into strings and numbers.
|
||||
//
|
||||
this.object_name = removeBlanks(new String(object_name));
|
||||
this.modification_time = new String(modification_time);
|
||||
this.uid = new String(uid);
|
||||
this.gid = new String(gid);
|
||||
this.mode = new String(mode);
|
||||
// this.modification_time = new String(modification_time);
|
||||
// this.uid = new String(uid);
|
||||
// this.gid = new String(gid);
|
||||
// this.mode = new String(mode);
|
||||
this.size = Long.parseLong(removeBlanks(new String(size)));
|
||||
|
||||
//
|
||||
|
@ -256,14 +256,14 @@ public class AR {
|
|||
if (headers != null)
|
||||
return;
|
||||
|
||||
Vector v = new Vector();
|
||||
Vector<ARHeader> v = new Vector<ARHeader>();
|
||||
try {
|
||||
//
|
||||
// Check for EOF condition
|
||||
//
|
||||
while (efile.getFilePointer() < efile.length()) {
|
||||
ARHeader header = new ARHeader();
|
||||
String name = header.getObjectName();
|
||||
header.getObjectName();
|
||||
|
||||
long pos = efile.getFilePointer();
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class AR {
|
|||
} catch (IOException e) {
|
||||
}
|
||||
// strtbl_pos = ???;
|
||||
headers = (ARHeader[]) v.toArray(new ARHeader[0]);
|
||||
headers = v.toArray(new ARHeader[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,29 +298,29 @@ public class AR {
|
|||
}
|
||||
|
||||
private boolean stringInStrings(String str, String[] set) {
|
||||
for (int i = 0; i < set.length; i++)
|
||||
if (str.compareTo(set[i]) == 0)
|
||||
for (String element : set)
|
||||
if (str.compareTo(element) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] extractFiles(String outdir, String[] names) throws IOException {
|
||||
Vector names_used = new Vector();
|
||||
Vector<String> names_used = new Vector<String>();
|
||||
String object_name;
|
||||
int count;
|
||||
|
||||
loadHeaders();
|
||||
|
||||
count = 0;
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
object_name = headers[i].getObjectName();
|
||||
for (ARHeader header : headers) {
|
||||
object_name = header.getObjectName();
|
||||
if (names != null && !stringInStrings(object_name, names))
|
||||
continue;
|
||||
|
||||
object_name = "" + count + "_" + object_name; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
count++;
|
||||
|
||||
byte[] data = headers[i].getObjectData();
|
||||
byte[] data = header.getObjectData();
|
||||
File output = new File(outdir, object_name);
|
||||
names_used.add(object_name);
|
||||
|
||||
|
@ -329,7 +329,7 @@ public class AR {
|
|||
rfile.close();
|
||||
}
|
||||
|
||||
return (String[]) names_used.toArray(new String[0]);
|
||||
return names_used.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String[] extractFiles(String outdir) throws IOException {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class MachO {
|
|||
private Symbol[] local_symbols; /* local symbols from DySymtabCommand */
|
||||
private boolean dynsym = false; /* set if DynSymtabCommand is present */
|
||||
Line[] lines; /* line table */
|
||||
private ArrayList sections = new ArrayList(); /* sections from SegmentCommand */
|
||||
private ArrayList<Section> sections = new ArrayList<Section>(); /* sections from SegmentCommand */
|
||||
SymtabCommand symtab; /* SymtabCommand that contains the symbol table */
|
||||
|
||||
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
|
@ -171,17 +171,17 @@ public class MachO {
|
|||
else
|
||||
if ( magic == MH_UNIVERSAL)
|
||||
{
|
||||
String arch = System.getProperty("os.arch");
|
||||
String arch = System.getProperty("os.arch"); //$NON-NLS-1$
|
||||
int numArchives = efile.readIntE();
|
||||
while (numArchives-- > 0)
|
||||
{
|
||||
int cpuType = efile.readIntE();
|
||||
int cpuSubType = efile.readIntE();
|
||||
int archiveOffset = efile.readIntE();
|
||||
int archiveSize = efile.readIntE();
|
||||
int archiveAlignment = efile.readIntE();
|
||||
if ((cpuType == MachO.MachOhdr.CPU_TYPE_I386 && arch.equalsIgnoreCase("i386")) ||
|
||||
(cpuType == MachO.MachOhdr.CPU_TYPE_POWERPC && arch.equalsIgnoreCase("ppc")))
|
||||
int cpuType = efile.readIntE(); // cpuType
|
||||
efile.readIntE(); // cpuSubType
|
||||
int archiveOffset = efile.readIntE(); // archiveOffset
|
||||
efile.readIntE(); // archiveSize
|
||||
efile.readIntE(); // archiveAlignment
|
||||
if ((cpuType == MachO.MachOhdr.CPU_TYPE_I386 && arch.equalsIgnoreCase("i386")) || //$NON-NLS-1$
|
||||
(cpuType == MachO.MachOhdr.CPU_TYPE_POWERPC && arch.equalsIgnoreCase("ppc"))) //$NON-NLS-1$
|
||||
{
|
||||
efile.seek(archiveOffset);
|
||||
magic = efile.readIntE();
|
||||
|
@ -212,17 +212,17 @@ public class MachO {
|
|||
else
|
||||
if ( magic == MH_UNIVERSAL)
|
||||
{
|
||||
String arch = System.getProperty("os.arch");
|
||||
String arch = System.getProperty("os.arch"); //$NON-NLS-1$
|
||||
int numArchives = makeInt(bytes, offset, isle); offset += 4;
|
||||
while (numArchives-- > 0)
|
||||
{
|
||||
int cpuType = makeInt(bytes, offset, isle); offset += 4;
|
||||
int cpuSubType = makeInt(bytes, offset, isle); offset += 4;
|
||||
offset += 4; // cpuSubType
|
||||
int archiveOffset = makeInt(bytes, offset, isle); offset += 4;
|
||||
int archiveSize = makeInt(bytes, offset, isle); offset += 4;
|
||||
int archiveAlignment = makeInt(bytes, offset, isle); offset += 4;
|
||||
if ((cpuType == MachO.MachOhdr.CPU_TYPE_I386 && arch.equalsIgnoreCase("i386")) ||
|
||||
(cpuType == MachO.MachOhdr.CPU_TYPE_POWERPC && arch.equalsIgnoreCase("ppc")))
|
||||
offset += 4; // archiveSize
|
||||
offset += 4; // archiveAlignment
|
||||
if ((cpuType == MachO.MachOhdr.CPU_TYPE_I386 && arch.equalsIgnoreCase("i386")) || //$NON-NLS-1$
|
||||
(cpuType == MachO.MachOhdr.CPU_TYPE_POWERPC && arch.equalsIgnoreCase("ppc"))) //$NON-NLS-1$
|
||||
{
|
||||
offset = archiveOffset;
|
||||
magic = makeInt(bytes, offset, isle); offset += 4;
|
||||
|
@ -245,15 +245,6 @@ public class MachO {
|
|||
}
|
||||
}
|
||||
|
||||
private static final short makeShort(byte [] val, int offset, boolean isle) throws IOException {
|
||||
if (val.length < offset + 2)
|
||||
throw new IOException();
|
||||
if ( isle ) {
|
||||
return (short)(((val[offset + 1] & 0xff) << 8) + (val[offset + 0] & 0xff));
|
||||
}
|
||||
return (short)(((val[offset + 0] & 0xff) << 8) + (val[offset + 1] & 0xff));
|
||||
}
|
||||
|
||||
private static final int makeInt(byte [] val, int offset, boolean isle) throws IOException
|
||||
{
|
||||
if (val.length < offset + 4)
|
||||
|
@ -644,7 +635,7 @@ public class MachO {
|
|||
return getCStr();
|
||||
}
|
||||
|
||||
public class Symbol implements Comparable {
|
||||
public class Symbol implements Comparable<Object> {
|
||||
/* n_type bit masks */
|
||||
public final static int N_STAB = 0xe0;
|
||||
public final static int N_PEXT = 0x10;
|
||||
|
@ -889,7 +880,7 @@ public class MachO {
|
|||
* and the Long doesn't know how to compare against a Symbol so if
|
||||
* we compare Symbol vs Long it is ok, but not if we do Long vs Symbol.
|
||||
*/
|
||||
public static class SymbolComparator implements Comparator {
|
||||
public static class SymbolComparator implements Comparator<Object> {
|
||||
long val1, val2;
|
||||
public int compare(Object o1, Object o2) {
|
||||
|
||||
|
@ -916,7 +907,7 @@ public class MachO {
|
|||
/**
|
||||
* Simple class to implement a line table
|
||||
*/
|
||||
public static class Line implements Comparable {
|
||||
public static class Line implements Comparable<Object> {
|
||||
public long address;
|
||||
public int lineno;
|
||||
public String file;
|
||||
|
@ -1141,12 +1132,12 @@ public class MachO {
|
|||
return;
|
||||
}
|
||||
DySymtabCommand dysymtab = null;
|
||||
for (int c = 0; c < loadcommands.length; c++) {
|
||||
switch (loadcommands[c].cmd) {
|
||||
for (LoadCommand loadcommand : loadcommands) {
|
||||
switch (loadcommand.cmd) {
|
||||
case LoadCommand.LC_SYMTAB:
|
||||
symtab = (SymtabCommand)loadcommands[c];
|
||||
symtab = (SymtabCommand)loadcommand;
|
||||
efile.seek(symtab.symoff);
|
||||
ArrayList symList = new ArrayList(symtab.nsyms);
|
||||
ArrayList<Symbol> symList = new ArrayList<Symbol>(symtab.nsyms);
|
||||
for (int s = 0; s < symtab.nsyms; s++) {
|
||||
Symbol symbol = new Symbol();
|
||||
symbol.n_strx = efile.readIntE();
|
||||
|
@ -1159,20 +1150,20 @@ public class MachO {
|
|||
debugsym = true;
|
||||
}
|
||||
}
|
||||
symbols = (Symbol[])symList.toArray(new Symbol[0]);
|
||||
symbols = symList.toArray(new Symbol[0]);
|
||||
break;
|
||||
|
||||
case LoadCommand.LC_DYSYMTAB:
|
||||
dysymtab = (DySymtabCommand)loadcommands[c];
|
||||
dysymtab = (DySymtabCommand)loadcommand;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dysymtab != null) {
|
||||
ArrayList symList = new ArrayList(dysymtab.nlocalsym);
|
||||
ArrayList<Symbol> symList = new ArrayList<Symbol>(dysymtab.nlocalsym);
|
||||
for (int s = dysymtab.ilocalsym; s < dysymtab.nlocalsym; s++) {
|
||||
symList.add(symbols[s]);
|
||||
}
|
||||
local_symbols = (Symbol[])symList.toArray(new Symbol[0]);
|
||||
local_symbols = symList.toArray(new Symbol[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1182,8 +1173,8 @@ public class MachO {
|
|||
}
|
||||
/* count number of source line entries */
|
||||
int nlines = 0;
|
||||
for (int s = 0; s < symbols.length; s++) {
|
||||
if (symbols[s].n_type == Symbol.N_SLINE || symbols[s].n_type == Symbol.N_FUN) {
|
||||
for (Symbol symbol : symbols) {
|
||||
if (symbol.n_type == Symbol.N_SLINE || symbol.n_type == Symbol.N_FUN) {
|
||||
nlines++;
|
||||
}
|
||||
}
|
||||
|
@ -1192,15 +1183,14 @@ public class MachO {
|
|||
}
|
||||
|
||||
/* now create line table, sorted on address */
|
||||
Map lineList = new HashMap(nlines);
|
||||
for (int s = 0; s < symbols.length; s++) {
|
||||
Symbol sym = symbols[s];
|
||||
Map<Line, Line> lineList = new HashMap<Line, Line>(nlines);
|
||||
for (Symbol sym : symbols) {
|
||||
if (sym.n_type == Symbol.N_SLINE || sym.n_type == Symbol.N_FUN) {
|
||||
Line lentry = new Line();
|
||||
lentry.address = sym.n_value;
|
||||
lentry.lineno = sym.n_desc;
|
||||
|
||||
Line lookup = (Line)lineList.get(lentry);
|
||||
Line lookup = lineList.get(lentry);
|
||||
if (lookup != null) {
|
||||
lentry = lookup;
|
||||
} else {
|
||||
|
@ -1221,13 +1211,12 @@ public class MachO {
|
|||
}
|
||||
}
|
||||
}
|
||||
Set k = lineList.keySet();
|
||||
lines = (Line[]) k.toArray(new Line[k.size()]);
|
||||
Set<Line> k = lineList.keySet();
|
||||
lines = k.toArray(new Line[k.size()]);
|
||||
Arrays.sort(lines);
|
||||
|
||||
/* now check for file names */
|
||||
for (int s = 0; s < symbols.length; s++) {
|
||||
Symbol sym = symbols[s];
|
||||
for (Symbol sym : symbols) {
|
||||
if (sym.n_type == Symbol.N_SO) {
|
||||
Line line = getLine(sym.n_value);
|
||||
if (line != null) {
|
||||
|
@ -1238,11 +1227,11 @@ public class MachO {
|
|||
|
||||
}
|
||||
|
||||
private ArrayList getSections(SegmentCommand seg) throws IOException {
|
||||
private ArrayList<Section> getSections(SegmentCommand seg) throws IOException {
|
||||
if ( seg.nsects == 0 ) {
|
||||
return new ArrayList();
|
||||
return new ArrayList<Section>();
|
||||
}
|
||||
ArrayList sections = new ArrayList();
|
||||
ArrayList<Section> sections = new ArrayList<Section>();
|
||||
for ( int i = 0; i < seg.nsects; i++ ) {
|
||||
Section section = new Section();
|
||||
byte[] sectname = new byte[16];
|
||||
|
@ -1266,19 +1255,19 @@ public class MachO {
|
|||
return sections;
|
||||
}
|
||||
|
||||
private TwoLevelHint[] getTwoLevelHints(int nhints) throws IOException {
|
||||
if ( nhints == 0 ) {
|
||||
return new TwoLevelHint[0];
|
||||
}
|
||||
TwoLevelHint[] tlhints = new TwoLevelHint[nhints];
|
||||
for ( int i = 0; i < nhints; i++ ) {
|
||||
int field = efile.readIntE();
|
||||
tlhints[i] = new TwoLevelHint();
|
||||
tlhints[i].isub_image = (field & 0xff000000) >> 24;
|
||||
tlhints[i].itoc = field & 0x00ffffff;
|
||||
}
|
||||
return tlhints;
|
||||
}
|
||||
// private TwoLevelHint[] getTwoLevelHints(int nhints) throws IOException {
|
||||
// if ( nhints == 0 ) {
|
||||
// return new TwoLevelHint[0];
|
||||
// }
|
||||
// TwoLevelHint[] tlhints = new TwoLevelHint[nhints];
|
||||
// for ( int i = 0; i < nhints; i++ ) {
|
||||
// int field = efile.readIntE();
|
||||
// tlhints[i] = new TwoLevelHint();
|
||||
// tlhints[i].isub_image = (field & 0xff000000) >> 24;
|
||||
// tlhints[i].itoc = field & 0x00ffffff;
|
||||
// }
|
||||
// return tlhints;
|
||||
// }
|
||||
|
||||
private String getCStr() throws IOException {
|
||||
StringBuffer str = new StringBuffer();
|
||||
|
@ -1597,18 +1586,18 @@ public class MachO {
|
|||
}
|
||||
|
||||
public Section[] getSections() {
|
||||
return (Section[]) sections.toArray(new Section[sections.size()]);
|
||||
return sections.toArray(new Section[sections.size()]);
|
||||
}
|
||||
|
||||
public DyLib[] getDyLibs(int type) {
|
||||
ArrayList v = new ArrayList();
|
||||
for (int i = 0; i < loadcommands.length; i++) {
|
||||
if (loadcommands[i].cmd == type) {
|
||||
DyLibCommand dl = (DyLibCommand)loadcommands[i];
|
||||
ArrayList<DyLib> v = new ArrayList<DyLib>();
|
||||
for (LoadCommand loadcommand : loadcommands) {
|
||||
if (loadcommand.cmd == type) {
|
||||
DyLibCommand dl = (DyLibCommand)loadcommand;
|
||||
v.add(dl.dylib);
|
||||
}
|
||||
}
|
||||
return (DyLib[]) v.toArray(new DyLib[v.size()]);
|
||||
return v.toArray(new DyLib[v.size()]);
|
||||
}
|
||||
|
||||
/* return the address of the function that address is in */
|
||||
|
@ -1663,10 +1652,10 @@ public class MachO {
|
|||
} catch (IOException e) { }
|
||||
|
||||
|
||||
for (int i = 0; i < loadcommands.length; i++) {
|
||||
if (loadcommands[i].cmd == LoadCommand.LC_SYMTAB)
|
||||
for (LoadCommand loadcommand : loadcommands) {
|
||||
if (loadcommand.cmd == LoadCommand.LC_SYMTAB)
|
||||
{
|
||||
symtab = (SymtabCommand)loadcommands[i];
|
||||
symtab = (SymtabCommand)loadcommand;
|
||||
try {
|
||||
int symSize = symtab.nsyms * 12;
|
||||
byte[] data = new byte[symSize];
|
||||
|
|
|
@ -15,6 +15,10 @@ package org.eclipse.cdt.utils.macho;
|
|||
import java.io.IOException;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.cdt.utils.macho.MachO.DyLib;
|
||||
import org.eclipse.cdt.utils.macho.MachO.Section;
|
||||
import org.eclipse.cdt.utils.macho.MachO.Symbol;
|
||||
|
||||
/**
|
||||
* <code>MachOHelper</code> is a wrapper class for the <code>MachO</code> class
|
||||
* to provide higher level API for sorting/searching the MachO data.
|
||||
|
@ -108,12 +112,11 @@ public class MachOHelper {
|
|||
}
|
||||
|
||||
public MachO.Symbol[] getExternalFunctions() throws IOException {
|
||||
Vector v = new Vector();
|
||||
Vector<Symbol> v = new Vector<Symbol>();
|
||||
|
||||
loadBinary();
|
||||
|
||||
for (int i = 0; i < dynsyms.length; i++) {
|
||||
MachO.Symbol sym = dynsyms[i];
|
||||
for (Symbol sym : dynsyms) {
|
||||
if ((sym.n_type_mask(MachO.Symbol.N_PEXT)
|
||||
|| sym.n_type_mask(MachO.Symbol.N_EXT))
|
||||
&& sym.n_desc(MachO.Symbol.REFERENCE_FLAG_UNDEFINED_LAZY)) {
|
||||
|
@ -123,17 +126,16 @@ public class MachOHelper {
|
|||
}
|
||||
}
|
||||
|
||||
MachO.Symbol[] ret = (MachO.Symbol[]) v.toArray(new MachO.Symbol[0]);
|
||||
MachO.Symbol[] ret = v.toArray(new MachO.Symbol[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public MachO.Symbol[] getExternalObjects() throws IOException {
|
||||
Vector v = new Vector();
|
||||
Vector<Symbol> v = new Vector<Symbol>();
|
||||
|
||||
loadBinary();
|
||||
|
||||
for (int i = 0; i < dynsyms.length; i++) {
|
||||
MachO.Symbol sym = dynsyms[i];
|
||||
for (Symbol sym : dynsyms) {
|
||||
if ((sym.n_type_mask(MachO.Symbol.N_PEXT)
|
||||
|| sym.n_type_mask(MachO.Symbol.N_EXT))
|
||||
&& sym.n_desc(MachO.Symbol.REFERENCE_FLAG_UNDEFINED_NON_LAZY)) {
|
||||
|
@ -143,21 +145,21 @@ public class MachOHelper {
|
|||
}
|
||||
}
|
||||
|
||||
MachO.Symbol[] ret = (MachO.Symbol[]) v.toArray(new MachO.Symbol[0]);
|
||||
MachO.Symbol[] ret = v.toArray(new MachO.Symbol[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public MachO.Symbol[] getUndefined() throws IOException {
|
||||
Vector v = new Vector();
|
||||
Vector<Symbol> v = new Vector<Symbol>();
|
||||
|
||||
loadBinary();
|
||||
|
||||
for (int i = 0; i < dynsyms.length; i++) {
|
||||
if (dynsyms[i].n_type(MachO.Symbol.N_UNDF))
|
||||
v.add(dynsyms[i]);
|
||||
for (Symbol dynsym : dynsyms) {
|
||||
if (dynsym.n_type(MachO.Symbol.N_UNDF))
|
||||
v.add(dynsym);
|
||||
}
|
||||
|
||||
MachO.Symbol[] ret = (MachO.Symbol[]) v.toArray(new MachO.Symbol[0]);
|
||||
MachO.Symbol[] ret = v.toArray(new MachO.Symbol[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -165,12 +167,11 @@ public class MachOHelper {
|
|||
* TODO: I'm not sure if this are correct. Need to check
|
||||
*/
|
||||
public MachO.Symbol[] getLocalFunctions() throws IOException {
|
||||
Vector v = new Vector();
|
||||
Vector<Symbol> v = new Vector<Symbol>();
|
||||
|
||||
loadBinary();
|
||||
|
||||
for (int i = 0; i < dynsyms.length; i++) {
|
||||
MachO.Symbol sym = dynsyms[i];
|
||||
for (Symbol sym : dynsyms) {
|
||||
if ((!sym.n_type_mask(MachO.Symbol.N_PEXT)
|
||||
&& !sym.n_type_mask(MachO.Symbol.N_EXT))
|
||||
&& sym.n_desc(MachO.Symbol.REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY)) {
|
||||
|
@ -180,7 +181,7 @@ public class MachOHelper {
|
|||
}
|
||||
}
|
||||
|
||||
MachO.Symbol[] ret = (MachO.Symbol[]) v.toArray(new MachO.Symbol[0]);
|
||||
MachO.Symbol[] ret = v.toArray(new MachO.Symbol[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -188,12 +189,11 @@ public class MachOHelper {
|
|||
* TODO: I'm not sure if this are correct. Need to check
|
||||
*/
|
||||
public MachO.Symbol[] getLocalObjects() throws IOException {
|
||||
Vector v = new Vector();
|
||||
Vector<Symbol> v = new Vector<Symbol>();
|
||||
|
||||
loadBinary();
|
||||
|
||||
for (int i = 0; i < dynsyms.length; i++) {
|
||||
MachO.Symbol sym = dynsyms[i];
|
||||
for (Symbol sym : dynsyms) {
|
||||
if ((!sym.n_type_mask(MachO.Symbol.N_PEXT)
|
||||
&& !sym.n_type_mask(MachO.Symbol.N_EXT))
|
||||
&& sym.n_desc(MachO.Symbol.REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY)) {
|
||||
|
@ -203,12 +203,12 @@ public class MachOHelper {
|
|||
}
|
||||
}
|
||||
|
||||
MachO.Symbol[] ret = (MachO.Symbol[]) v.toArray(new MachO.Symbol[0]);
|
||||
MachO.Symbol[] ret = v.toArray(new MachO.Symbol[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public MachO.Symbol[] getCommonObjects() throws IOException {
|
||||
Vector v = new Vector();
|
||||
Vector<Symbol> v = new Vector<Symbol>();
|
||||
|
||||
loadBinary();
|
||||
|
||||
|
@ -221,19 +221,19 @@ public class MachOHelper {
|
|||
}
|
||||
}
|
||||
|
||||
MachO.Symbol[] ret = (MachO.Symbol[]) v.toArray(new MachO.Symbol[0]);
|
||||
MachO.Symbol[] ret = v.toArray(new MachO.Symbol[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String[] getNeeded() throws IOException {
|
||||
Vector v = new Vector();
|
||||
Vector<String> v = new Vector<String>();
|
||||
|
||||
loadBinary();
|
||||
|
||||
for (int i = 0; i < needed.length; i++) {
|
||||
v.add(needed[i].toString());
|
||||
for (DyLib element : needed) {
|
||||
v.add(element.toString());
|
||||
}
|
||||
return (String[]) v.toArray(new String[0]);
|
||||
return v.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String getSoname() throws IOException {
|
||||
|
@ -241,47 +241,47 @@ public class MachOHelper {
|
|||
|
||||
loadBinary();
|
||||
|
||||
for (int i = 0; i < sonames.length; i++) {
|
||||
soname = sonames[i].toString();
|
||||
for (DyLib soname2 : sonames) {
|
||||
soname = soname2.toString();
|
||||
}
|
||||
return soname;
|
||||
}
|
||||
|
||||
private String getSubUsage(String full, String name) {
|
||||
int start, end;
|
||||
//boolean has_names = false;
|
||||
//boolean has_languages = false;
|
||||
start = 0;
|
||||
end = 0;
|
||||
|
||||
for (int i = 0; i < full.length(); i++) {
|
||||
if (full.charAt(i) == '%') {
|
||||
if (full.charAt(i + 1) == '-') {
|
||||
if (start == 0) {
|
||||
int eol = full.indexOf('\n', i + 2);
|
||||
String temp = full.substring(i + 2, eol);
|
||||
if (temp.compareTo(name) == 0)
|
||||
start = eol;
|
||||
|
||||
//has_names = true;
|
||||
} else if (end == 0) {
|
||||
end = i - 1;
|
||||
}
|
||||
}
|
||||
|
||||
//if( full.charAt( i+1 ) == '=' )
|
||||
//has_languages = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (end == 0)
|
||||
end = full.length();
|
||||
|
||||
if (start == 0)
|
||||
return full;
|
||||
|
||||
return full.substring(start, end);
|
||||
}
|
||||
// private String getSubUsage(String full, String name) {
|
||||
// int start, end;
|
||||
// //boolean has_names = false;
|
||||
// //boolean has_languages = false;
|
||||
// start = 0;
|
||||
// end = 0;
|
||||
//
|
||||
// for (int i = 0; i < full.length(); i++) {
|
||||
// if (full.charAt(i) == '%') {
|
||||
// if (full.charAt(i + 1) == '-') {
|
||||
// if (start == 0) {
|
||||
// int eol = full.indexOf('\n', i + 2);
|
||||
// String temp = full.substring(i + 2, eol);
|
||||
// if (temp.compareTo(name) == 0)
|
||||
// start = eol;
|
||||
//
|
||||
// //has_names = true;
|
||||
// } else if (end == 0) {
|
||||
// end = i - 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //if( full.charAt( i+1 ) == '=' )
|
||||
// //has_languages = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (end == 0)
|
||||
// end = full.length();
|
||||
//
|
||||
// if (start == 0)
|
||||
// return full;
|
||||
//
|
||||
// return full.substring(start, end);
|
||||
// }
|
||||
|
||||
public String getQnxUsage() throws IOException {
|
||||
return new String(""); //$NON-NLS-1$
|
||||
|
@ -298,17 +298,17 @@ public class MachOHelper {
|
|||
// TODO we only need to load the sections, not the whole shebang
|
||||
loadBinary();
|
||||
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
MachO.SegmentCommand seg = sections[i].segment;
|
||||
if (sections[i].flags(MachO.Section.SECTION_TYP) != MachO.Section.S_ZEROFILL) {
|
||||
for (Section section : sections) {
|
||||
MachO.SegmentCommand seg = section.segment;
|
||||
if (section.flags(MachO.Section.SECTION_TYP) != MachO.Section.S_ZEROFILL) {
|
||||
if (seg.prot(MachO.SegmentCommand.VM_PROT_EXECUTE)) {
|
||||
text += sections[i].size;
|
||||
text += section.size;
|
||||
} else if (!seg.prot(MachO.SegmentCommand.VM_PROT_WRITE)) {
|
||||
data += sections[i].size;
|
||||
data += section.size;
|
||||
}
|
||||
} else {
|
||||
if (seg.prot(MachO.SegmentCommand.VM_PROT_WRITE)) {
|
||||
bss += sections[i].size;
|
||||
bss += section.size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ public class MachOBinaryObject extends BinaryObjectAdapter {
|
|||
protected ISymbol[] loadSymbols(MachOHelper helper) throws IOException {
|
||||
CPPFilt cppfilt = null;
|
||||
try {
|
||||
ArrayList list = new ArrayList();
|
||||
ArrayList<Symbol> list = new ArrayList<Symbol>();
|
||||
// Hack should be remove when Elf is clean
|
||||
helper.getMachO().setCppFilter(false);
|
||||
cppfilt = getCPPFilt();
|
||||
|
@ -257,7 +257,7 @@ public class MachOBinaryObject extends BinaryObjectAdapter {
|
|||
addSymbols(helper.getLocalFunctions(), ISymbol.FUNCTION, cppfilt, list);
|
||||
addSymbols(helper.getExternalObjects(), ISymbol.VARIABLE, cppfilt, list);
|
||||
addSymbols(helper.getLocalObjects(), ISymbol.VARIABLE, cppfilt, list);
|
||||
return (ISymbol[]) list.toArray(new ISymbol[list.size()]);
|
||||
return list.toArray(new ISymbol[list.size()]);
|
||||
} finally {
|
||||
if (cppfilt != null) {
|
||||
cppfilt.dispose();
|
||||
|
@ -270,9 +270,9 @@ public class MachOBinaryObject extends BinaryObjectAdapter {
|
|||
return parser.getCPPFilt();
|
||||
}
|
||||
|
||||
private void addSymbols(MachO.Symbol[] array, int type, CPPFilt cppfilt, List list) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
String name = array[i].toString();
|
||||
private void addSymbols(MachO.Symbol[] array, int type, CPPFilt cppfilt, List<Symbol> list) {
|
||||
for (org.eclipse.cdt.utils.macho.MachO.Symbol element : array) {
|
||||
String name = element.toString();
|
||||
if (cppfilt != null) {
|
||||
try {
|
||||
name = cppfilt.getFunction(name);
|
||||
|
@ -280,11 +280,11 @@ public class MachOBinaryObject extends BinaryObjectAdapter {
|
|||
cppfilt = null;
|
||||
}
|
||||
}
|
||||
long addr = array[i].n_value;
|
||||
long addr = element.n_value;
|
||||
int size = 0;
|
||||
String filename = array[i].getFilename();
|
||||
IPath filePath = (filename != null) ? new Path(filename) : null; //$NON-NLS-1$
|
||||
list.add(new Symbol(this, name, type, new Addr32(array[i].n_value), size, filePath, array[i].getLineNumber(addr), array[i].getLineNumber(addr + size - 1)));
|
||||
String filename = element.getFilename();
|
||||
IPath filePath = (filename != null) ? new Path(filename) : null;
|
||||
list.add(new Symbol(this, name, type, new Addr32(element.n_value), size, filePath, element.getLineNumber(addr), element.getLineNumber(addr + size - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,6 +395,7 @@ public class MachOBinaryObject extends BinaryObjectAdapter {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter.equals(MachO.class)) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class AR {
|
|||
|
||||
private long fstmoff = 0;
|
||||
private long lstmoff = 0;
|
||||
private long memoff = 0;
|
||||
// private long memoff = 0;
|
||||
|
||||
public ARHeader() throws IOException {
|
||||
try {
|
||||
|
@ -67,7 +67,7 @@ public class AR {
|
|||
file.read(fl_freeoff);
|
||||
fstmoff = Long.parseLong(removeBlanks(new String(fl_fstmoff)));
|
||||
lstmoff = Long.parseLong(removeBlanks(new String(fl_lstmoff)));
|
||||
memoff = Long.parseLong(removeBlanks(new String(fl_memoff)));
|
||||
// memoff = Long.parseLong(removeBlanks(new String(fl_memoff)));
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -272,7 +272,7 @@ public class AR {
|
|||
if (memberHeaders != null)
|
||||
return;
|
||||
|
||||
Vector v = new Vector();
|
||||
Vector<MemberHeader> v = new Vector<MemberHeader>();
|
||||
try {
|
||||
//
|
||||
// Check for EOF condition
|
||||
|
@ -281,7 +281,6 @@ public class AR {
|
|||
for (long pos = header.fstmoff; pos < file.length(); pos = aHeader.nxtmem) {
|
||||
file.seek(pos);
|
||||
aHeader = new MemberHeader();
|
||||
String name = aHeader.getObjectName();
|
||||
v.add(aHeader);
|
||||
if (pos == 0 || pos == header.lstmoff) { // end of double linked list
|
||||
break;
|
||||
|
@ -289,7 +288,7 @@ public class AR {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
memberHeaders = (MemberHeader[]) v.toArray(new MemberHeader[0]);
|
||||
memberHeaders = v.toArray(new MemberHeader[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,22 +305,22 @@ public class AR {
|
|||
}
|
||||
|
||||
public String[] extractFiles(String outdir, String[] names) throws IOException {
|
||||
Vector names_used = new Vector();
|
||||
Vector<String> names_used = new Vector<String>();
|
||||
String object_name;
|
||||
int count;
|
||||
|
||||
loadHeaders();
|
||||
|
||||
count = 0;
|
||||
for (int i = 0; i < memberHeaders.length; i++) {
|
||||
object_name = memberHeaders[i].getObjectName();
|
||||
for (MemberHeader memberHeader : memberHeaders) {
|
||||
object_name = memberHeader.getObjectName();
|
||||
if (names != null && !stringInStrings(object_name, names))
|
||||
continue;
|
||||
|
||||
object_name = "" + count + "_" + object_name; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
count++;
|
||||
|
||||
byte[] data = memberHeaders[i].getObjectData();
|
||||
byte[] data = memberHeader.getObjectData();
|
||||
File output = new File(outdir, object_name);
|
||||
names_used.add(object_name);
|
||||
|
||||
|
@ -330,12 +329,12 @@ public class AR {
|
|||
rfile.close();
|
||||
}
|
||||
|
||||
return (String[]) names_used.toArray(new String[0]);
|
||||
return names_used.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private boolean stringInStrings(String str, String[] set) {
|
||||
for (int i = 0; i < set.length; i++)
|
||||
if (str.compareTo(set[i]) == 0)
|
||||
for (String element : set)
|
||||
if (str.compareTo(element) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -15,13 +15,8 @@ import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
|
||||
public class XCOFFBinaryExecutable extends XCOFFBinaryObject implements IBinaryFile {
|
||||
public class XCOFFBinaryExecutable extends XCOFFBinaryObject {
|
||||
|
||||
/**
|
||||
* @param parser
|
||||
* @param path
|
||||
* @param type
|
||||
*/
|
||||
public XCOFFBinaryExecutable(IBinaryParser parser, IPath path) {
|
||||
super(parser, path, IBinaryFile.EXECUTABLE);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.utils.IGnuToolFactory;
|
|||
import org.eclipse.cdt.utils.Objdump;
|
||||
import org.eclipse.cdt.utils.xcoff.AR;
|
||||
import org.eclipse.cdt.utils.xcoff.XCoff32;
|
||||
import org.eclipse.cdt.utils.xcoff.XCoff32.Symbol;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
|
@ -113,7 +114,7 @@ public class XCOFFBinaryObject extends BinaryObjectAdapter {
|
|||
|
||||
/**
|
||||
* @throws IOException
|
||||
* @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getContents()
|
||||
* @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getContents()
|
||||
*/
|
||||
@Override
|
||||
public InputStream getContents() throws IOException {
|
||||
|
@ -173,28 +174,28 @@ public class XCOFFBinaryObject extends BinaryObjectAdapter {
|
|||
}
|
||||
|
||||
protected void loadSymbols(XCoff32 xcoff) throws IOException {
|
||||
ArrayList list = new ArrayList();
|
||||
ArrayList<XCoffSymbol> list = new ArrayList<XCoffSymbol>();
|
||||
|
||||
XCoff32.Symbol[] peSyms = xcoff.getSymbols();
|
||||
byte[] table = xcoff.getStringTable();
|
||||
addSymbols(peSyms, table, list);
|
||||
|
||||
symbols = (ISymbol[]) list.toArray(NO_SYMBOLS);
|
||||
symbols = list.toArray(NO_SYMBOLS);
|
||||
Arrays.sort(symbols);
|
||||
list.clear();
|
||||
}
|
||||
|
||||
protected void addSymbols(XCoff32.Symbol[] peSyms, byte[] table, List list) {
|
||||
protected void addSymbols(XCoff32.Symbol[] peSyms, byte[] table, List<XCoffSymbol> list) {
|
||||
CPPFilt cppfilt = getCPPFilt();
|
||||
Addr2line addr2line = getAddr2line(false);
|
||||
for (int i = 0; i < peSyms.length; i++) {
|
||||
if (peSyms[i].isFunction() || peSyms[i].isVariable() ) {
|
||||
String name = peSyms[i].getName(table);
|
||||
for (Symbol peSym : peSyms) {
|
||||
if (peSym.isFunction() || peSym.isVariable() ) {
|
||||
String name = peSym.getName(table);
|
||||
if (name == null || name.trim().length() == 0 || !Character.isJavaIdentifierStart(name.charAt(0))) {
|
||||
continue;
|
||||
}
|
||||
int type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE;
|
||||
IAddress addr = new Addr32(peSyms[i].n_value);
|
||||
int type = peSym.isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE;
|
||||
IAddress addr = new Addr32(peSym.n_value);
|
||||
int size = 4;
|
||||
if (cppfilt != null) {
|
||||
try {
|
||||
|
@ -240,7 +241,6 @@ public class XCOFFBinaryObject extends BinaryObjectAdapter {
|
|||
return getAddr2line();
|
||||
}
|
||||
if (addr2line == null) {
|
||||
XCOFF32Parser parser = (XCOFF32Parser) getBinaryParser();
|
||||
addr2line = getAddr2line();
|
||||
if (addr2line != null) {
|
||||
starttime = System.currentTimeMillis();
|
||||
|
@ -306,6 +306,7 @@ public class XCOFFBinaryObject extends BinaryObjectAdapter {
|
|||
*
|
||||
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == Addr2line.class) {
|
||||
|
|
Loading…
Add table
Reference in a new issue