|
Link Here
|
| 26 |
import org.eclipse.cdt.core.dom.ast.IASTNode; |
26 |
import org.eclipse.cdt.core.dom.ast.IASTNode; |
| 27 |
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; |
27 |
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; |
| 28 |
import org.eclipse.cdt.core.dom.ast.IBasicType; |
28 |
import org.eclipse.cdt.core.dom.ast.IBasicType; |
|
|
29 |
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; |
| 29 |
import org.eclipse.cdt.core.dom.ast.IBinding; |
30 |
import org.eclipse.cdt.core.dom.ast.IBinding; |
| 30 |
import org.eclipse.cdt.core.dom.ast.IType; |
31 |
import org.eclipse.cdt.core.dom.ast.IType; |
| 31 |
import org.eclipse.cdt.core.dom.ast.ITypedef; |
32 |
import org.eclipse.cdt.core.dom.ast.ITypedef; |
| 32 |
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; |
33 |
import org.eclipse.cdt.core.dom.ast.IVariable; |
| 33 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression; |
34 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression; |
| 34 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; |
35 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; |
| 35 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; |
36 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; |
|
Link Here
|
| 188 |
if(ret != null) return ret; |
189 |
if(ret != null) return ret; |
| 189 |
}else { |
190 |
}else { |
| 190 |
if(node.getOperand1() instanceof CPPASTIdExpression) { |
191 |
if(node.getOperand1() instanceof CPPASTIdExpression) { |
| 191 |
return getBinaryExpressionType(((CPPASTIdExpression) node.getOperand1()).getExpressionType()); |
192 |
return getBinaryExpressionType((CPPASTIdExpression) node.getOperand1()); |
| 192 |
} |
193 |
} |
| 193 |
} |
194 |
} |
| 194 |
|
195 |
|
|
Link Here
|
| 197 |
if(ret != null) return ret; |
198 |
if(ret != null) return ret; |
| 198 |
}else { |
199 |
}else { |
| 199 |
if(node.getOperand2() instanceof CPPASTIdExpression) { |
200 |
if(node.getOperand2() instanceof CPPASTIdExpression) { |
| 200 |
return getBinaryExpressionType(((CPPASTIdExpression) node.getOperand2()).getExpressionType()); |
201 |
return getBinaryExpressionType((CPPASTIdExpression) node.getOperand2()); |
| 201 |
} |
202 |
} |
| 202 |
} |
203 |
} |
| 203 |
return null; |
204 |
return null; |
| 204 |
} |
205 |
} |
| 205 |
|
206 |
|
| 206 |
private IASTDeclSpecifier getBinaryExpressionType(IType expressionType) { |
207 |
private IASTDeclSpecifier getBinaryExpressionType(CPPASTIdExpression expression) { |
|
|
208 |
IType expressionType = ((IVariable) expression.getName().resolveBinding()).getType(); |
| 209 |
if (expressionType instanceof ITypedef) { |
| 210 |
ITypedef typdef = (ITypedef) expressionType; |
| 211 |
IType expandedType = expression.getExpressionType(); |
| 212 |
if(typdef.getType().isSameType(expandedType)) { |
| 213 |
return getDeclSpecifierForType(typdef); |
| 214 |
}else{ |
| 215 |
return getDeclSpecifierForType(expandedType); |
| 216 |
} |
| 217 |
|
| 218 |
} |
| 219 |
return getDeclSpecifierForType(expressionType); |
| 220 |
|
| 221 |
} |
| 222 |
|
| 223 |
private IASTDeclSpecifier getDeclSpecifierForType(IType expressionType) { |
| 224 |
|
| 207 |
if (expressionType instanceof CPPBasicType) { |
225 |
if (expressionType instanceof CPPBasicType) { |
| 208 |
|
226 |
|
| 209 |
CPPBasicType basicType = (CPPBasicType) expressionType; |
227 |
CPPBasicType basicType = (CPPBasicType) expressionType; |
| 210 |
return createSimpleDeclSpecifier(basicType.getKind()); |
228 |
return createSimpleDeclSpecifier(basicType.getKind()); |
| 211 |
|
229 |
|
| 212 |
} else if (expressionType instanceof ITypedef) { |
230 |
} else if (expressionType instanceof ITypedef) { |
| 213 |
|
231 |
return getDeclSpecForType((ITypedef) expressionType); |
| 214 |
return getDeclSpecForType(((ITypedef)expressionType)); |
|
|
| 215 |
|
| 216 |
} else if (expressionType instanceof ICPPClassType) { |
232 |
} else if (expressionType instanceof ICPPClassType) { |
| 217 |
|
|
|
| 218 |
return getDeclSpecForType((ICPPClassType)expressionType); |
233 |
return getDeclSpecForType((ICPPClassType)expressionType); |
| 219 |
} |
234 |
} |
| 220 |
return null; |
235 |
return null; |