introduce JavaCompletionHints class to decouple PsiJavaFileBaseImpl from JavaCompletionProcessor

This commit is contained in:
Dmitry Jemerov
2011-09-23 14:27:00 +02:00
parent aaf71fd080
commit 8787887fb5
4 changed files with 36 additions and 8 deletions
@@ -0,0 +1,30 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.completion.scope;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Key;
/**
* @author yole
*/
public class JavaCompletionHints {
public static final Key<Boolean> JAVA_COMPLETION = Key.create("JAVA_COMPLETION");
public static final Key<Condition<String>> NAME_FILTER = Key.create("NAME_FILTER");
private JavaCompletionHints() {
}
}
@@ -45,8 +45,6 @@ import java.util.*;
* To change this template use Options | File Templates.
*/
public class JavaCompletionProcessor extends BaseScopeProcessor implements ElementClassHint {
public static final Key<Condition<String>> NAME_FILTER = Key.create("NAME_FILTER");
public static final Key<Boolean> JAVA_COMPLETION = Key.create("JAVA_COMPLETION");
private boolean myStatic = false;
private PsiElement myDeclarationHolder = null;
@@ -294,10 +292,10 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
if (hintKey == ElementClassHint.KEY) {
return (T)this;
}
if (hintKey == NAME_FILTER) {
if (hintKey == JavaCompletionHints.NAME_FILTER) {
return (T)myMatcher;
}
if (hintKey == JAVA_COMPLETION) {
if (hintKey == JavaCompletionHints.JAVA_COMPLETION) {
return (T)Boolean.TRUE;
}
@@ -15,7 +15,7 @@
*/
package com.intellij.psi.impl.file;
import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
import com.intellij.codeInsight.completion.scope.JavaCompletionHints;
import com.intellij.ide.projectView.ProjectView;
import com.intellij.ide.projectView.impl.PackageViewPane;
import com.intellij.ide.projectView.impl.ProjectRootsUtil;
@@ -276,7 +276,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
final JavaPsiFacadeImpl facade = getFacade();
final PsiMigrationImpl migration = facade.getCurrentMigration();
final Condition<String> prefixMatcher = processor.getHint(JavaCompletionProcessor.NAME_FILTER);
final Condition<String> prefixMatcher = processor.getHint(JavaCompletionHints.NAME_FILTER);
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) {
NameHint nameHint = processor.getHint(NameHint.KEY);
@@ -15,7 +15,7 @@
*/
package com.intellij.psi.impl.source;
import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
import com.intellij.codeInsight.completion.scope.JavaCompletionHints;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.lang.java.JavaLanguage;
@@ -312,7 +312,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
final PsiImportStaticStatement[] importStaticStatements = importList.getImportStaticStatements();
if (importStaticStatements.length > 0) {
final StaticImportFilteringProcessor staticImportProcessor = new StaticImportFilteringProcessor(processor);
final boolean forCompletion = Boolean.TRUE == processor.getHint(JavaCompletionProcessor.JAVA_COMPLETION);
final boolean forCompletion = Boolean.TRUE == processor.getHint(JavaCompletionHints.JAVA_COMPLETION);
// single member processing
for (PsiImportStaticStatement importStaticStatement : importStaticStatements) {