Bug 526040: Merge Java 9 related changes from JDT
- fix merge errors & remaining compile errors
diff --git a/org.eclipse.jdt.core/.settings/.api_filters b/org.eclipse.jdt.core/.settings/.api_filters
index 330c79a..b2c8ecb 100644
--- a/org.eclipse.jdt.core/.settings/.api_filters
+++ b/org.eclipse.jdt.core/.settings/.api_filters
@@ -478,6 +478,118 @@
         </filter>
     </resource>
     <resource path="dom/org/eclipse/jdt/core/dom/ASTNode.java" type="org.eclipse.jdt.core.dom.ASTNode">
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="BASE_CALL_MESSAGE_SEND"/>
+                <message_argument value="100"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="BASE_CONSTRUCTOR_INVOCATION"/>
+                <message_argument value="98"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="CALLIN_MAPPING_DECLARATION"/>
+                <message_argument value="94"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="CALLOUT_MAPPING_DECLARATION"/>
+                <message_argument value="95"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="FIELD_ACCESS_SPEC"/>
+                <message_argument value="101"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="GUARD_PREDICATE_DECLARATION"/>
+                <message_argument value="107"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="LIFTING_TYPE"/>
+                <message_argument value="96"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="METHOD_BINDING_OPERATOR"/>
+                <message_argument value="108"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="METHOD_SPEC"/>
+                <message_argument value="93"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="PARAMETER_MAPPING"/>
+                <message_argument value="99"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="PRECEDENCE_DECLARATION"/>
+                <message_argument value="106"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="ROLE_TYPE_DECLARATION"/>
+                <message_argument value="102"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="TSUPER_CONSTRUCTOR_INVOCATION"/>
+                <message_argument value="104"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="TSUPER_MESSAGE_SEND"/>
+                <message_argument value="103"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="TYPE_ANCHOR"/>
+                <message_argument value="105"/>
+            </message_arguments>
+        </filter>
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.ASTNode"/>
+                <message_argument value="WITHIN_STATEMENT"/>
+                <message_argument value="97"/>
+            </message_arguments>
+        </filter>
         <filter id="1141899266">
             <message_arguments>
                 <message_argument value="3.14"/>
@@ -657,6 +769,13 @@
         </filter>
     </resource>
     <resource path="dom/org/eclipse/jdt/core/dom/IBinding.java" type="org.eclipse.jdt.core.dom.IBinding">
+        <filter comment="make room for new JDT constants" id="388194388">
+            <message_arguments>
+                <message_argument value="org.eclipse.jdt.core.dom.IBinding"/>
+                <message_argument value="METHOD_MAPPING"/>
+                <message_argument value="7"/>
+            </message_arguments>
+        </filter>
         <filter id="1209008130">
             <message_arguments>
                 <message_argument value="3.14"/>
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
index c2d0b95..e50c370 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
@@ -1429,9 +1429,10 @@
 		if (this.options.checkVisibility) {
 			if((modifiers & ClassFileConstants.AccPublic) == 0) {
 				if((modifiers & ClassFileConstants.AccPrivate) != 0) return;
-
-				char[] currentPackage = CharOperation.concatWith(this.unitScope.fPackage.compoundName, '.');
-				if(!CharOperation.equals(packageName, currentPackage)) return;
+				if (this.moduleDeclaration == null) {
+					char[] currentPackage = CharOperation.concatWith(this.unitScope.fPackage.compoundName, '.');
+					if(!CharOperation.equals(packageName, currentPackage)) return;
+				}
 			}
 		}
 
@@ -2134,57 +2135,66 @@
 							}
 						}
 					}
-					UsesStatement[] uses = this.moduleDeclaration.uses;
-					if (uses != null) {
-						for (int i = 0, l = uses.length; i < l; ++i) {
-							TypeReference usesReference = uses[i].serviceInterface;
-							if (usesReference instanceof CompletionOnUsesSingleTypeReference ||
-									usesReference instanceof CompletionOnUsesQualifiedTypeReference) {
-								this.lookupEnvironment.buildTypeBindings(parsedUnit, null);
-								if ((this.unitScope = parsedUnit.scope) != null) {
-									contextAccepted = true;
-									buildContext(usesReference, null, parsedUnit, null, null);
-									findTypeReferences(usesReference, true);
-									debugPrintf();
+					try {
+						UsesStatement[] uses = this.moduleDeclaration.uses;
+						if (uses != null) {
+							for (int i = 0, l = uses.length; i < l; ++i) {
+								UsesStatement usesStatement = uses[i];
+								this.parser.enclosingNode = usesStatement;
+								TypeReference usesReference = usesStatement.serviceInterface;
+								if (usesReference instanceof CompletionOnUsesSingleTypeReference ||
+										usesReference instanceof CompletionOnUsesQualifiedTypeReference) {
+									contextAccepted = checkForCNF(usesReference, parsedUnit, true);
 									return;
 								}
 							}
 						}
-					}
-					ProvidesStatement[] providesStmts = this.moduleDeclaration.services;
-					for (int i = 0, l = providesStmts != null ? providesStmts.length : 0; i < l; ++i) {
-						ProvidesStatement providesStmt = providesStmts[i];
-						TypeReference pInterface = providesStmt.serviceInterface;
-						if (pInterface instanceof CompletionOnProvidesInterfacesSingleTypeReference ||
-								pInterface instanceof CompletionOnProvidesInterfacesQualifiedTypeReference) {
-							this.lookupEnvironment.buildTypeBindings(parsedUnit, null);
-							if ((this.unitScope = parsedUnit.scope) != null) {
-								contextAccepted = true;
-								buildContext(pInterface, null, parsedUnit, null, null);
-								findTypeReferences(pInterface, true);
-								debugPrintf();
+						ProvidesStatement[] providesStmts = this.moduleDeclaration.services;
+						for (int i = 0, l = providesStmts != null ? providesStmts.length : 0; i < l; ++i) {
+							ProvidesStatement providesStmt = providesStmts[i];
+							this.parser.enclosingNode = providesStmt;
+							TypeReference pInterface = providesStmt.serviceInterface;
+							if (pInterface instanceof CompletionOnProvidesInterfacesSingleTypeReference ||
+									pInterface instanceof CompletionOnProvidesInterfacesQualifiedTypeReference) {
+								contextAccepted = checkForCNF(pInterface, parsedUnit, true);
 								return;
 							}
-						}
-						TypeReference[] implementations = providesStmt.implementations;
-						for (int j = 0, k = implementations.length; j < k; ++j) {
-							TypeReference implementation = implementations[i];
-							
-							if (implementation instanceof CompletionOnProvidesImplementationsSingleTypeReference ||
-									implementation instanceof CompletionOnProvidesImplementationsQualifiedTypeReference) {
-								this.lookupEnvironment.buildTypeBindings(parsedUnit, null);
-								if ((this.unitScope = parsedUnit.scope) != null) {
-									contextAccepted = true;
-									buildContext(implementation, null, parsedUnit, null, null);
-									findImplementations(providesStmt, i/* stmtIndex */, j/* implIndex */);
-									debugPrintf();
+							TypeReference[] implementations = providesStmt.implementations;
+							for (int j = 0, k = implementations.length; j < k; ++j) {
+								TypeReference implementation = implementations[j];
+								if (implementation instanceof CompletionOnProvidesImplementationsSingleTypeReference ||
+										implementation instanceof CompletionOnProvidesImplementationsQualifiedTypeReference) {
+									contextAccepted = checkForCNF(implementation, parsedUnit, false);
 									return;
+								} else if (implementation instanceof CompletionOnKeyword) {
+									contextAccepted = true;
+									processModuleKeywordCompletion(parsedUnit, implementation, (CompletionOnKeyword) implementation);
 								}
-							} else if (implementation instanceof CompletionOnKeyword) {
-								contextAccepted = true;
-								processModuleKeywordCompletion(parsedUnit, implementation, (CompletionOnKeyword) implementation);
 							}
 						}
+					} catch (CompletionNodeFound e) {
+						//					completionNodeFound = true;
+						if (e.astNode != null) {
+							// if null then we found a problem in the completion node
+							if(DEBUG) {
+								System.out.print("COMPLETION - Completion node : "); //$NON-NLS-1$
+								System.out.println(e.astNode.toString());
+								if(this.parser.assistNodeParent != null) {
+									System.out.print("COMPLETION - Parent Node : ");  //$NON-NLS-1$
+									System.out.println(this.parser.assistNodeParent);
+								}
+							}
+							this.lookupEnvironment.unitBeingCompleted = parsedUnit; // better resilient to further error reporting
+							contextAccepted =
+									complete(
+											e.astNode,
+											this.parser.assistNodeParent,
+											this.parser.enclosingNode,
+											parsedUnit,
+											e.qualifiedBinding,
+											e.scope,
+											e.insideTypeAnnotation);
+						}
 					}
 				}
 				// scan the package & import statements first
@@ -2395,6 +2405,26 @@
 		}
 	}
 
+	private boolean checkForCNF(TypeReference ref, CompilationUnitDeclaration parsedUnit, boolean showAll) {
+		this.lookupEnvironment.buildTypeBindings(parsedUnit, null);
+		this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
+		parsedUnit.resolve();
+		if ((this.unitScope = parsedUnit.scope) != null) {
+			if (showAll) {
+				char[][] tokens = ref.getTypeName();
+				char[] typeName = CharOperation.concatWithAll(tokens, '.');
+				if (typeName.length == 0) {
+					buildContext(ref, null, parsedUnit, null, null);
+					this.completionToken = new char[] {'*'};
+					findTypesAndPackages(this.completionToken, this.unitScope, true, true, new ObjectVector());
+					return true;
+				}
+			}
+			parsedUnit.scope.faultInTypes();
+		}
+		return false; // should not come here - will throw exception
+	}
+
 	private boolean completeOnPackageVisibilityStatements(boolean contextAccepted,
 			CompilationUnitDeclaration parsedUnit, PackageVisibilityStatement[] pvsStmts) {
 		for (int i = 0, l = pvsStmts.length; i < l; ++i) {
@@ -3727,8 +3757,7 @@
 	}
 
 	private void completionOnProvidesImplementationsQualifiedTypeReference(ASTNode astNode, ASTNode astNodeParent, Binding qualifiedBinding, Scope scope) {
-		// TODO: Filter the results wrt accessibility and add relevance to the results.
-		completionOnQualifiedTypeReference(astNode, astNodeParent, qualifiedBinding, scope);
+		findImplementations((ProvidesStatement) this.parser.enclosingNode, (TypeReference) astNode);
 	}
 
 	private void completionOnSingleNameReference(ASTNode astNode, ASTNode astNodeParent, Scope scope,
@@ -3873,12 +3902,11 @@
 	}
 
 	private void completionOnProvidesInterfacesSingleTypeReference(ASTNode astNode, ASTNode astNodeParent, Binding qualifiedBinding, Scope scope) {
-		// TODO : filter the results.
 		completionOnSingleTypeReference(astNode, astNodeParent, qualifiedBinding, scope);
 	}
 	private void completionOnProvidesImplementationsSingleTypeReference(ASTNode astNode, ASTNode astNodeParent, Binding qualifiedBinding, Scope scope) {
-		// TODO : filter the results.
-		completionOnSingleTypeReference(astNode, astNodeParent, qualifiedBinding, scope);
+		findImplementations((ProvidesStatement) this.parser.enclosingNode, (TypeReference) astNode);
+		// TODO : filter the results - remove packs without a type in impl.
 	}
 
 	private char[][] computeAlreadyDefinedName(
@@ -4456,7 +4484,7 @@
 			for (int j = 0; j < length; j++) {
 				Expression argument = arguments[j];
 				TypeBinding argType = argument.resolvedType;
-				if(argType != null && !argType.isCompatibleWith(parameters[j]))
+				if(argType != null && !argType.erasure().isCompatibleWith(parameters[j].erasure()))
 					continue nextMethod;
 			}
 
@@ -11394,7 +11422,80 @@
 		createOverrideRoleProposal(superTeam, superRoleName, roleTypeSignature, superRole.getFlags());
 	}
 // SH}
+	private void findModuleName(CompilationUnitDeclaration parsedUnit) {
+		char[] fileName1 = parsedUnit.getFileName();
+		if (fileName1 == null || !CharOperation.endsWith(fileName1, MODULE_INFO_FILE_NAME)) return;
+		int lastFileSeparatorIndex = fileName1.length - (MODULE_INFO_FILE_NAME.length + 1);
+		if (lastFileSeparatorIndex  <= 0) return;
+		int prevFileSeparatorIndex = CharOperation.lastIndexOf(fileName1[lastFileSeparatorIndex], fileName1, 0, lastFileSeparatorIndex - 1);
+		prevFileSeparatorIndex = prevFileSeparatorIndex < 0 ? 0 : prevFileSeparatorIndex + 1;
+		char[] moduleName = CharOperation.subarray(fileName1, prevFileSeparatorIndex, lastFileSeparatorIndex);
+		if (moduleName == null || moduleName.length == 0) return;
+		this.completionToken = CharOperation.concatWith(this.moduleDeclaration.tokens, '.');
+		if (this.completionToken.length > 0 && !CharOperation.prefixEquals(this.completionToken, moduleName)) return;
 
+		InternalCompletionProposal proposal =  createProposal(CompletionProposal.MODULE_DECLARATION, this.actualCompletionPosition);
+		proposal.setName(moduleName);
+		proposal.setCompletion(moduleName);
+		proposal.setReplaceRange((this.startPosition < 0) ? 0 : this.startPosition - this.offset, this.endPosition - this.offset);
+		proposal.setTokenRange((this.tokenStart < 0) ? 0 : this.tokenStart - this.offset, this.tokenEnd - this.offset);
+		proposal.setRelevance(R_MODULE_DECLARATION);
+		this.requestor.accept(proposal);
+		if(DEBUG) {
+			this.printDebug(proposal);
+		}
+	}
+
+	private void findTargettedModules(char[] prefix, HashSet<String> skipSet) {
+		ModuleSourcePathManager mManager = JavaModelManager.getModulePathManager();
+		JavaElementRequestor javaElementRequestor = new JavaElementRequestor();
+		try {
+			mManager.seekModule(this.completionToken, true, javaElementRequestor);
+			IModuleDescription[] modules = javaElementRequestor.getModules();
+			for (IModuleDescription module : modules) {
+				String name = module.getElementName();
+				if (name == null || name.equals("") || skipSet.contains(name)) //$NON-NLS-1$
+					continue;
+				this.acceptModule(name.toCharArray());
+			}
+		} catch (JavaModelException e) {
+			// TODO ignore for now
+		}
+	}
+	private void findTargettedModules(CompletionOnModuleReference moduleReference, HashSet<String> skipSet) {
+		setCompletionToken(moduleReference.tokens, moduleReference.sourceStart, moduleReference.sourceEnd, moduleReference.sourcePositions);
+		findTargettedModules(CharOperation.toLowerCase(this.completionToken), skipSet);
+	}
+
+	private void setCompletionToken(char[][] tokens, int sourceStart, int sourceEnd, long[] sourcePositions, boolean without) {
+		this.completionToken = without ? CharOperation.concatWith(tokens, '.') : CharOperation.concatWithAll(tokens, '.');
+		if (this.completionToken.length == 0)
+			this.completionToken = CharOperation.ALL_PREFIX;
+		setSourceRange(sourceStart, sourceEnd);
+		long completionPosition = sourcePositions[sourcePositions.length - 1];
+		setTokenRange((int) (completionPosition >>> 32), (int) completionPosition);
+	}
+	private void setCompletionToken(char[][] tokens, int sourceStart, int sourceEnd, long[] sourcePositions) {
+		setCompletionToken(tokens, sourceStart, sourceEnd, sourcePositions, tokens.length > 0 && tokens[tokens.length - 1].length > 0);
+	}
+	private void findModules(CompletionOnModuleReference moduleReference, boolean targetted) {
+		setCompletionToken(moduleReference.tokens, moduleReference.sourceStart, moduleReference.sourceEnd, moduleReference.sourcePositions);
+		findTargettedModules(moduleReference, new HashSet<>()); // empty skipSet passed
+		this.nameEnvironment.findModules(CharOperation.toLowerCase(this.completionToken), this, targetted ? this.javaProject : null);
+	}
+	private void findPackages(CompletionOnPackageVisibilityReference reference) {
+		setCompletionToken(reference.tokens, reference.sourceStart, reference.sourceEnd, reference.sourcePositions, false);
+		findPackagesInCurrentModule();
+	}
+
+	private void findPackagesInCurrentModule() {
+		try {
+			IPackageFragmentRoot[] moduleRoots = SearchableEnvironment.getOwnedPackageFragmentRoots(this.javaProject);
+			this.nameEnvironment.findPackages(CharOperation.toLowerCase(this.completionToken), this, moduleRoots);
+		} catch (JavaModelException e) {
+			// silent
+		}
+	}
 	private void findPackages(CompletionOnPackageReference packageStatement) {
 		this.completionToken = CharOperation.concatWithAll(packageStatement.tokens, '.');
 		if (this.completionToken.length == 0)
@@ -12561,30 +12662,7 @@
 		return null;
 	}
 
-	private void findTypeReferences(TypeReference reference, boolean findMembers) {
-		char[][] tokens = reference.getTypeName();
-
-		char[] typeName = CharOperation.concatWithAll(tokens, '.');
-
-		if (typeName.length == 0) {
-			this.completionToken = new char[] {'*'};
-		} else if (reference instanceof CompletionOnUsesQualifiedTypeReference ||
-				reference instanceof CompletionOnProvidesInterfacesQualifiedTypeReference) {
-			CompletionOnQualifiedTypeReference qReference = (CompletionOnQualifiedTypeReference) reference;
-			if (qReference.completionIdentifier != null) {
-				this.completionToken = CharOperation.concatAll(typeName, qReference.completionIdentifier, '.');
-			}
-		} else {
-			 char[] lastToken = tokens[tokens.length - 1];
-			 this.completionToken = lastToken != null && lastToken.length == 0 ?
-					 CharOperation.concat(typeName, new char[]{'.'}) :lastToken;
-		}
-		setSourceRange(reference.sourceStart, reference.sourceEnd);
-		findTypesAndPackages(this.completionToken, this.unitScope, true, true, new ObjectVector());
-	}
-
-	private void findImplementations(ProvidesStatement providesStmt, int stmtIndex, int implIndex) {
-		TypeReference reference = providesStmt.implementations[implIndex];
+	private void findImplementations(ProvidesStatement providesStmt, TypeReference reference ) {
 		char[][] tokens = reference.getTypeName();
 		char[] typeName = CharOperation.concatWithAll(tokens, '.');
 
@@ -12601,15 +12679,19 @@
 					 CharOperation.concat(typeName, new char[]{'.'}) :lastToken;
 		}
 		setSourceRange(reference.sourceStart, reference.sourceEnd);
-		findImplementations(this.completionToken, this.unitScope, providesStmt, stmtIndex);
+		findImplementations(this.completionToken, this.unitScope, providesStmt, -1);
 	}
 
 	private void findImplementations(char[] token, Scope scope, ProvidesStatement providesStmt, int stmtIndex) {
-
 		TypeReference theInterface = providesStmt.serviceInterface;
-
 		if (token == null) return;
-		char[][] theInterfaceType = theInterface.getTypeName();
+		char[][] theInterfaceType = null;
+		if (theInterface.resolvedType != null && theInterface.resolvedType.isValidBinding()) {
+			char[] readableName = theInterface.resolvedType.readableName();
+			if (readableName != null)
+				theInterfaceType = CharOperation.splitOn('.', readableName);
+		}
+		theInterfaceType = theInterfaceType == null ? theInterface.getTypeName() : theInterfaceType;
 		if (theInterfaceType == null) return;
 		SearchPattern pattern  = null;
 		NameEnvironmentAnswer answer =  this.nameEnvironment.findTypeInModules(theInterfaceType, scope.module());
@@ -12636,7 +12718,7 @@
 			}
 			@Override
 			public void acceptSearchMatch(SearchMatch match) throws CoreException {
-				checkCancel();
+			//	checkCancel();
 				IJavaElement element = ((IJavaElement) match.getElement());
 				if (element.getElementType() == IJavaElement.TYPE) {
 					IType type = (IType) element;
@@ -12647,7 +12729,9 @@
 						} else {
 							fullTypeName = type.getElementName();
 						}
-						if (!fullTypeName.startsWith(this.prefix) || this.filter.contains(fullTypeName)) return;
+						if (this.filter.contains(fullTypeName)) return;
+						if (!(fullTypeName.startsWith(this.prefix) || type.getElementName().startsWith(this.prefix)))
+							return;
 					}
 					this.types.add(type);
 				}
@@ -13634,6 +13718,7 @@
 		this.offset = prefix.length();
 
 		String encoding = this.compilerOptions.defaultEncoding;
+		@SuppressWarnings("deprecation")
 		BasicCompilationUnit fakeUnit = new BasicCompilationUnit(
 			fakeSource,
 			null,
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
index 7bfcf01..f90d826 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
@@ -1153,21 +1153,17 @@
 						selectFrom(e.binding, parsedUnit, sourceUnit, e.isDeclaration);
 					}
 //{ObjectTeams :
-				} catch(SelectionNodesFound exc)
-					{
-					    if(exc._bindings != null)
-					    {
-							if(DEBUG) {
-								System.out.println("SELECTION - Selection binding:"); //$NON-NLS-1$
-								System.out.println(exc._bindings.toString());
-							}
-							// if null then we found a problem in the selection node
-						    for(int idx = 0; idx < exc._bindings.length; idx++)
-						    {
-						        selectFrom(exc._bindings[idx], parsedUnit, exc._isDeclaration);
-						    }
+				} catch(SelectionNodesFound exc) {
+				    if(exc._bindings != null) {
+						if(DEBUG) {
+							System.out.println("SELECTION - Selection binding:"); //$NON-NLS-1$
+							System.out.println(exc._bindings.toString());
+						}
+						// if null then we found a problem in the selection node
+					    for(int idx = 0; idx < exc._bindings.length; idx++) {
+					        selectFrom(exc._bindings[idx], parsedUnit, exc._isDeclaration);
 					    }
-					}
+				    }
 //haebor}
 				}
 			}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
index bce04d4..e1c1b18 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
@@ -15,7 +15,7 @@
 
 public interface Keywords {
 //{ObjectTeams: adapted count
-	int COUNT = 63;
+	int COUNT = 62;
 //carp}
 
 	char[] ABSTRACT = "abstract".toCharArray(); //$NON-NLS-1$
@@ -76,7 +76,6 @@
 	char[] BEFORE = "before".toCharArray(); //$NON-NLS-1$
 	char[] AFTER = "after".toCharArray(); //$NON-NLS-1$
 	char[] REPLACE = "replace".toCharArray(); //$NON-NLS-1$
-	char[] WITH = "with".toCharArray(); //$NON-NLS-1$
 	char[] WITHIN = "within".toCharArray(); //$NON-NLS-1$
 	char[] BASE = "base".toCharArray(); //$NON-NLS-1$
 	char[] TSUPER = "tsuper".toCharArray(); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index c9e63a1..b05b29b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -231,8 +231,9 @@
     	case TokenNameprecedence:
     	case TokenNametsuper:
     	case TokenNamewhen:
-    	case TokenNamewith:
     		return this._isOTSource;
+    	case TokenNamewith:
+    		return this._isOTSource || this.insideModuleInfo;
     	}
     	return true;
     }