1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 511871 - CContentAssistProcessor.createContext may leak index lock

Change-Id: I828c94484c7b1594ba72551b80cd5ed6e6a8576c
This commit is contained in:
Sergey Prigogin 2017-02-07 14:48:32 -08:00
parent d06db08a30
commit c6955df2e2

View file

@ -266,29 +266,35 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
char activationChar = getActivationChar(viewer, offset);
CContentAssistInvocationContext context =
new CContentAssistInvocationContext(viewer, offset, fEditor, isCompletion, isAutoActivated());
if (isCompletion && activationChar == '.' && fReplacementAutoActivationCharacters != null &&
fReplacementAutoActivationCharacters.contains('.')) {
IASTCompletionNode node = context.getCompletionNode();
if (node != null) {
IASTName[] names = node.getNames();
if (names.length > 0 && names[0].getParent() instanceof IASTFieldReference) {
IASTFieldReference ref = (IASTFieldReference) names[0].getParent();
IASTExpression ownerExpr = ref.getFieldOwner();
IType ownerExprType = SemanticUtil.getNestedType(ownerExpr.getExpressionType(), SemanticUtil.TDEF);
if (ownerExprType instanceof ICPPUnknownType) {
ownerExprType = HeuristicResolver.resolveUnknownType((ICPPUnknownType) ownerExprType,
names[0]);
}
if (ownerExprType instanceof IPointerType) {
context = replaceDotWithArrow(viewer, offset, isCompletion, context, activationChar);
try {
if (isCompletion && activationChar == '.' && fReplacementAutoActivationCharacters != null &&
fReplacementAutoActivationCharacters.contains('.')) {
IASTCompletionNode node = context.getCompletionNode();
if (node != null) {
IASTName[] names = node.getNames();
if (names.length > 0 && names[0].getParent() instanceof IASTFieldReference) {
IASTFieldReference ref = (IASTFieldReference) names[0].getParent();
IASTExpression ownerExpr = ref.getFieldOwner();
IType ownerExprType = SemanticUtil.getNestedType(ownerExpr.getExpressionType(), SemanticUtil.TDEF);
if (ownerExprType instanceof ICPPUnknownType) {
ownerExprType = HeuristicResolver.resolveUnknownType((ICPPUnknownType) ownerExprType,
names[0]);
}
if (ownerExprType instanceof IPointerType) {
context = replaceDotWithArrow(viewer, offset, isCompletion, context, activationChar);
}
}
}
if (context != null && isAutoActivated() && !fCContentAutoActivationCharacters.contains(activationChar)) {
// Auto-replace, but not auto-content-assist - bug 344387.
context.dispose();
context = null;
}
}
if (context != null && isAutoActivated() && !fCContentAutoActivationCharacters.contains(activationChar)) {
// Auto-replace, but not auto-content-assist - bug 344387.
} catch (RuntimeException | Error e) {
if (context != null)
context.dispose();
context = null;
}
throw e;
}
return context;