diff options
author | Jay Arthanareeswaran | 2018-02-22 12:26:38 +0000 |
---|---|---|
committer | Jay Arthanareeswaran | 2018-02-22 14:16:42 +0000 |
commit | 3b1eade6257846b964d26359bdcfbc40d6c4bec4 (patch) | |
tree | 029218f7e10ccc707e04afa7fc1a68d01708103b /org.eclipse.jdt.core/codeassist | |
parent | 4972ceda4bf841162712401d9d7a17bc60e10887 (diff) | |
download | eclipse.jdt.core-3b1eade6257846b964d26359bdcfbc40d6c4bec4.tar.gz eclipse.jdt.core-3b1eade6257846b964d26359bdcfbc40d6c4bec4.tar.xz eclipse.jdt.core-3b1eade6257846b964d26359bdcfbc40d6c4bec4.zip |
Change-Id: I877ad296fcdd10c039e66314848bd0fa512e5fe6
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.core/codeassist')
-rw-r--r-- | org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java index 03e8737abd..64c38a0d35 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -61,6 +65,7 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.parser.JavadocParser; import org.eclipse.jdt.internal.compiler.parser.RecoveredType; import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; @@ -601,11 +606,16 @@ protected void consumeExitVariableWithInitialization() { // does not keep the initialization if selection is not inside AbstractVariableDeclaration variable = (AbstractVariableDeclaration) this.astStack[this.astPtr]; - int start = variable.initialization.sourceStart; - int end = variable.initialization.sourceEnd; - if ((this.selectionStart < start) && (this.selectionEnd < start) || - (this.selectionStart > end) && (this.selectionEnd > end)) { + int start = variable.declarationSourceStart; + int end = variable.declarationSourceEnd; + char[][] typeName = variable.type == null ? null : variable.type.getTypeName(); + // Keep the initialization intact, because that's the only way we are going to know the type + // TODO: Figure out a way to get the scope and hence the compliance + if (typeName == null || !(typeName.length == 1 && CharOperation.equals(typeName[0], TypeConstants.VAR))) { + if ((this.selectionStart < start) && (this.selectionEnd < start) || + (this.selectionStart > end) && (this.selectionEnd > end)) { variable.initialization = null; + } } triggerRecoveryUponLambdaClosure(variable, false); } |