mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'upsource-master'
This commit is contained in:
@@ -237,6 +237,7 @@ binding.setVariable("platformApiModules", [
|
||||
|
||||
binding.setVariable("platformImplementationModules", [
|
||||
"core-impl",
|
||||
"indexing-impl",
|
||||
"platform-impl",
|
||||
"vcs-impl",
|
||||
"lang-impl",
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.roots.ContentIterator;
|
||||
import com.intellij.openapi.roots.FileIndex;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.JspPsiUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.cache.impl.id.IdTableBuilding;
|
||||
import com.intellij.psi.impl.cache.impl.id.PlatformIdTableBuilding;
|
||||
import com.intellij.psi.impl.source.tree.StdTokenSets;
|
||||
import com.intellij.psi.jsp.JspFile;
|
||||
import com.intellij.psi.jsp.JspTokenType;
|
||||
@@ -47,7 +47,7 @@ public class JspIndexPatternBuilder implements IndexPatternBuilder {
|
||||
boolean alreadyInitializedHighlighter = false;
|
||||
|
||||
if ((cachedEditorHighlighter = EditorHighlighterCache.getEditorHighlighterForCachesBuilding(document)) != null &&
|
||||
IdTableBuilding.checkCanUseCachedEditorHighlighter(file.getText(), cachedEditorHighlighter)) {
|
||||
PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(file.getText(), cachedEditorHighlighter)) {
|
||||
highlighter = cachedEditorHighlighter;
|
||||
alreadyInitializedHighlighter = true;
|
||||
}
|
||||
|
||||
+1039
-1061
File diff suppressed because it is too large
Load Diff
@@ -1,194 +1,213 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi.codeStyle;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class JavaCodeStyleManager {
|
||||
public static JavaCodeStyleManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, JavaCodeStyleManager.class);
|
||||
}
|
||||
|
||||
public static final int DO_NOT_ADD_IMPORTS = 0x1000;
|
||||
public static final int UNCOMPLETE_CODE = 0x2000;
|
||||
|
||||
public abstract boolean addImport(@NotNull PsiJavaFile file, @NotNull PsiClass refClass);
|
||||
public abstract PsiElement shortenClassReferences(@NotNull PsiElement element, @MagicConstant(flags = {DO_NOT_ADD_IMPORTS, UNCOMPLETE_CODE}) int flags) throws IncorrectOperationException;
|
||||
|
||||
@NotNull public abstract String getPrefixByVariableKind(VariableKind variableKind);
|
||||
@NotNull public abstract String getSuffixByVariableKind(VariableKind variableKind);
|
||||
|
||||
public abstract int findEntryIndex(@NotNull PsiImportStatementBase statement);
|
||||
|
||||
/**
|
||||
* Replaces fully-qualified class names in the contents of the specified element with
|
||||
* non-qualified names and adds import statements as necessary.
|
||||
*
|
||||
* @param element the element to shorten references in.
|
||||
* @return the element in the PSI tree after the shorten references operation corresponding
|
||||
* to the original element.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the file to shorten references in is read-only.
|
||||
*/
|
||||
public abstract PsiElement shortenClassReferences(@NotNull PsiElement element) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Replaces fully-qualified class names in a part of contents of the specified element with
|
||||
* non-qualified names and adds import statements as necessary.
|
||||
*
|
||||
* @param element the element to shorten references in.
|
||||
* @param startOffset the start offset in the <b>element</b> of the part where class references are
|
||||
* shortened.
|
||||
* @param endOffset the end offset in the <b>element</b> of the part where class references are
|
||||
* shortened.
|
||||
* @throws IncorrectOperationException if the file to shorten references in is read-only.
|
||||
*/
|
||||
public abstract void shortenClassReferences(@NotNull PsiElement element, int startOffset, int endOffset) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Optimizes imports in the specified Java or JSP file.
|
||||
*
|
||||
* @param file the file to optimize the imports in.
|
||||
* @throws IncorrectOperationException if the file is read-only.
|
||||
*/
|
||||
public abstract void optimizeImports(@NotNull PsiFile file) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Calculates the import list that would be substituted in the specified Java or JSP
|
||||
* file if an Optimize Imports operation was performed on it.
|
||||
*
|
||||
* @param file the file to calculate the import list for.
|
||||
* @return the calculated import list.
|
||||
*/
|
||||
public abstract PsiImportList prepareOptimizeImportsResult(@NotNull PsiJavaFile file);
|
||||
|
||||
/**
|
||||
* Returns the kind of the specified variable (local, parameter, field, static field or static
|
||||
* final field).
|
||||
*
|
||||
* @param variable the variable to get the kind for.
|
||||
* @return the variable kind.
|
||||
*/
|
||||
public abstract VariableKind getVariableKind(@NotNull PsiVariable variable);
|
||||
|
||||
public SuggestedNameInfo suggestVariableName(@NotNull final VariableKind kind,
|
||||
@Nullable final String propertyName,
|
||||
@Nullable final PsiExpression expr,
|
||||
@Nullable PsiType type) {
|
||||
return suggestVariableName(kind, propertyName, expr, type, true);
|
||||
}
|
||||
|
||||
|
||||
public abstract SuggestedNameInfo suggestVariableName(@NotNull VariableKind kind,
|
||||
@Nullable String propertyName,
|
||||
@Nullable PsiExpression expr,
|
||||
@Nullable PsiType type,
|
||||
boolean correctKeywords);
|
||||
/**
|
||||
* Generates a stripped-down name (with no code style defined prefixes or suffixes, usable as
|
||||
* a property name) from the specified name of a variable of the specified kind.
|
||||
*
|
||||
* @param name the name of the variable.
|
||||
* @param variableKind the kind of the variable.
|
||||
* @return the stripped-down name.
|
||||
*/
|
||||
public abstract String variableNameToPropertyName(@NonNls String name, VariableKind variableKind);
|
||||
|
||||
/**
|
||||
* Appends code style defined prefixes and/or suffixes for the specified variable kind
|
||||
* to the specified variable name.
|
||||
*
|
||||
* @param propertyName the base name of the variable.
|
||||
* @param variableKind the kind of the variable.
|
||||
* @return the variable name.
|
||||
*/
|
||||
public abstract String propertyNameToVariableName(@NonNls String propertyName, VariableKind variableKind);
|
||||
|
||||
/**
|
||||
* Suggests a unique name for the variable used at the specified location.
|
||||
*
|
||||
* @param baseName the base name for the variable.
|
||||
* @param place the location where the variable will be used.
|
||||
* @param lookForward if true, the existing variables are searched in both directions; if false - only backward
|
||||
* @return the generated unique name,
|
||||
*/
|
||||
public abstract String suggestUniqueVariableName(@NonNls String baseName, PsiElement place, boolean lookForward);
|
||||
|
||||
/**
|
||||
* Suggests a unique name for the variable used at the specified location.
|
||||
*
|
||||
* @param baseNameInfo the base name info for the variable.
|
||||
* @param place the location where the variable will be used.
|
||||
* @param lookForward if true, the existing variables are searched in both directions; if false - only backward
|
||||
* @return the generated unique name
|
||||
*/
|
||||
@NotNull
|
||||
public SuggestedNameInfo suggestUniqueVariableName(@NotNull SuggestedNameInfo baseNameInfo,
|
||||
PsiElement place,
|
||||
boolean lookForward) {
|
||||
return suggestUniqueVariableName(baseNameInfo, place, false, lookForward);
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggests a unique name for the variable used at the specified location.
|
||||
*
|
||||
*
|
||||
* @param baseNameInfo the base name info for the variable.
|
||||
* @param place the location where the variable will be used.
|
||||
* @param ignorePlaceName if true and place is PsiNamedElement, place.getName() would be still treated as unique name
|
||||
* @param lookForward if true, the existing variables are searched in both directions; if false - only backward @return the generated unique name,
|
||||
* @return the generated unique name
|
||||
*/
|
||||
@NotNull public abstract SuggestedNameInfo suggestUniqueVariableName(@NotNull SuggestedNameInfo baseNameInfo,
|
||||
PsiElement place,
|
||||
boolean ignorePlaceName,
|
||||
boolean lookForward);
|
||||
|
||||
/**
|
||||
* Replaces all references to Java classes in the contents of the specified element,
|
||||
* except for references to classes in the same package or in implicitly imported packages,
|
||||
* with full-qualified references.
|
||||
*
|
||||
* @param element the element to replace the references in.
|
||||
* @return the element in the PSI tree after the qualify operation corresponding to the
|
||||
* original element.
|
||||
*/
|
||||
public abstract PsiElement qualifyClassReferences(@NotNull PsiElement element);
|
||||
|
||||
/**
|
||||
* Removes unused import statements from the specified Java file.
|
||||
*
|
||||
* @param file the file to remove the import statements from.
|
||||
* @throws IncorrectOperationException if the operation fails for some reason (for example,
|
||||
* the file is read-only).
|
||||
*/
|
||||
public abstract void removeRedundantImports(@NotNull PsiJavaFile file) throws IncorrectOperationException;
|
||||
|
||||
@Nullable
|
||||
public abstract Collection<PsiImportStatementBase> findRedundantImports(PsiJavaFile file);
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi.codeStyle;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class JavaCodeStyleManager {
|
||||
public static JavaCodeStyleManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, JavaCodeStyleManager.class);
|
||||
}
|
||||
|
||||
public static final int DO_NOT_ADD_IMPORTS = 0x1000;
|
||||
public static final int UNCOMPLETE_CODE = 0x2000;
|
||||
|
||||
public abstract boolean addImport(@NotNull PsiJavaFile file, @NotNull PsiClass refClass);
|
||||
public abstract PsiElement shortenClassReferences(@NotNull PsiElement element, @MagicConstant(flags = {DO_NOT_ADD_IMPORTS, UNCOMPLETE_CODE}) int flags) throws IncorrectOperationException;
|
||||
|
||||
@NotNull public abstract String getPrefixByVariableKind(VariableKind variableKind);
|
||||
@NotNull public abstract String getSuffixByVariableKind(VariableKind variableKind);
|
||||
|
||||
public abstract int findEntryIndex(@NotNull PsiImportStatementBase statement);
|
||||
|
||||
/**
|
||||
* Replaces fully-qualified class names in the contents of the specified element with
|
||||
* non-qualified names and adds import statements as necessary.
|
||||
*
|
||||
* @param element the element to shorten references in.
|
||||
* @return the element in the PSI tree after the shorten references operation corresponding
|
||||
* to the original element.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the file to shorten references in is read-only.
|
||||
*/
|
||||
public abstract PsiElement shortenClassReferences(@NotNull PsiElement element) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Replaces fully-qualified class names in a part of contents of the specified element with
|
||||
* non-qualified names and adds import statements as necessary.
|
||||
*
|
||||
* @param element the element to shorten references in.
|
||||
* @param startOffset the start offset in the <b>element</b> of the part where class references are
|
||||
* shortened.
|
||||
* @param endOffset the end offset in the <b>element</b> of the part where class references are
|
||||
* shortened.
|
||||
* @throws IncorrectOperationException if the file to shorten references in is read-only.
|
||||
*/
|
||||
public abstract void shortenClassReferences(@NotNull PsiElement element, int startOffset, int endOffset) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Optimizes imports in the specified Java or JSP file.
|
||||
*
|
||||
* @param file the file to optimize the imports in.
|
||||
* @throws IncorrectOperationException if the file is read-only.
|
||||
*/
|
||||
public abstract void optimizeImports(@NotNull PsiFile file) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Calculates the import list that would be substituted in the specified Java or JSP
|
||||
* file if an Optimize Imports operation was performed on it.
|
||||
*
|
||||
* @param file the file to calculate the import list for.
|
||||
* @return the calculated import list.
|
||||
*/
|
||||
public abstract PsiImportList prepareOptimizeImportsResult(@NotNull PsiJavaFile file);
|
||||
|
||||
/**
|
||||
* Returns the kind of the specified variable (local, parameter, field, static field or static
|
||||
* final field).
|
||||
*
|
||||
* @param variable the variable to get the kind for.
|
||||
* @return the variable kind.
|
||||
*/
|
||||
public VariableKind getVariableKind(@NotNull PsiVariable variable){
|
||||
if (variable instanceof PsiField) {
|
||||
if (variable.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (variable.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
return VariableKind.STATIC_FINAL_FIELD;
|
||||
}
|
||||
return VariableKind.STATIC_FIELD;
|
||||
}
|
||||
return VariableKind.FIELD;
|
||||
}
|
||||
else {
|
||||
if (variable instanceof PsiParameter) {
|
||||
if (((PsiParameter)variable).getDeclarationScope() instanceof PsiForeachStatement) {
|
||||
return VariableKind.LOCAL_VARIABLE;
|
||||
}
|
||||
return VariableKind.PARAMETER;
|
||||
}
|
||||
return VariableKind.LOCAL_VARIABLE;
|
||||
}
|
||||
}
|
||||
|
||||
public SuggestedNameInfo suggestVariableName(@NotNull final VariableKind kind,
|
||||
@Nullable final String propertyName,
|
||||
@Nullable final PsiExpression expr,
|
||||
@Nullable PsiType type) {
|
||||
return suggestVariableName(kind, propertyName, expr, type, true);
|
||||
}
|
||||
|
||||
|
||||
public abstract SuggestedNameInfo suggestVariableName(@NotNull VariableKind kind,
|
||||
@Nullable String propertyName,
|
||||
@Nullable PsiExpression expr,
|
||||
@Nullable PsiType type,
|
||||
boolean correctKeywords);
|
||||
/**
|
||||
* Generates a stripped-down name (with no code style defined prefixes or suffixes, usable as
|
||||
* a property name) from the specified name of a variable of the specified kind.
|
||||
*
|
||||
* @param name the name of the variable.
|
||||
* @param variableKind the kind of the variable.
|
||||
* @return the stripped-down name.
|
||||
*/
|
||||
public abstract String variableNameToPropertyName(@NonNls String name, VariableKind variableKind);
|
||||
|
||||
/**
|
||||
* Appends code style defined prefixes and/or suffixes for the specified variable kind
|
||||
* to the specified variable name.
|
||||
*
|
||||
* @param propertyName the base name of the variable.
|
||||
* @param variableKind the kind of the variable.
|
||||
* @return the variable name.
|
||||
*/
|
||||
public abstract String propertyNameToVariableName(@NonNls String propertyName, VariableKind variableKind);
|
||||
|
||||
/**
|
||||
* Suggests a unique name for the variable used at the specified location.
|
||||
*
|
||||
* @param baseName the base name for the variable.
|
||||
* @param place the location where the variable will be used.
|
||||
* @param lookForward if true, the existing variables are searched in both directions; if false - only backward
|
||||
* @return the generated unique name,
|
||||
*/
|
||||
public abstract String suggestUniqueVariableName(@NonNls String baseName, PsiElement place, boolean lookForward);
|
||||
|
||||
/**
|
||||
* Suggests a unique name for the variable used at the specified location.
|
||||
*
|
||||
* @param baseNameInfo the base name info for the variable.
|
||||
* @param place the location where the variable will be used.
|
||||
* @param lookForward if true, the existing variables are searched in both directions; if false - only backward
|
||||
* @return the generated unique name
|
||||
*/
|
||||
@NotNull
|
||||
public SuggestedNameInfo suggestUniqueVariableName(@NotNull SuggestedNameInfo baseNameInfo,
|
||||
PsiElement place,
|
||||
boolean lookForward) {
|
||||
return suggestUniqueVariableName(baseNameInfo, place, false, lookForward);
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggests a unique name for the variable used at the specified location.
|
||||
*
|
||||
*
|
||||
* @param baseNameInfo the base name info for the variable.
|
||||
* @param place the location where the variable will be used.
|
||||
* @param ignorePlaceName if true and place is PsiNamedElement, place.getName() would be still treated as unique name
|
||||
* @param lookForward if true, the existing variables are searched in both directions; if false - only backward @return the generated unique name,
|
||||
* @return the generated unique name
|
||||
*/
|
||||
@NotNull public abstract SuggestedNameInfo suggestUniqueVariableName(@NotNull SuggestedNameInfo baseNameInfo,
|
||||
PsiElement place,
|
||||
boolean ignorePlaceName,
|
||||
boolean lookForward);
|
||||
|
||||
/**
|
||||
* Replaces all references to Java classes in the contents of the specified element,
|
||||
* except for references to classes in the same package or in implicitly imported packages,
|
||||
* with full-qualified references.
|
||||
*
|
||||
* @param element the element to replace the references in.
|
||||
* @return the element in the PSI tree after the qualify operation corresponding to the
|
||||
* original element.
|
||||
*/
|
||||
public abstract PsiElement qualifyClassReferences(@NotNull PsiElement element);
|
||||
|
||||
/**
|
||||
* Removes unused import statements from the specified Java file.
|
||||
*
|
||||
* @param file the file to remove the import statements from.
|
||||
* @throws IncorrectOperationException if the operation fails for some reason (for example,
|
||||
* the file is read-only).
|
||||
*/
|
||||
public abstract void removeRedundantImports(@NotNull PsiJavaFile file) throws IncorrectOperationException;
|
||||
|
||||
@Nullable
|
||||
public abstract Collection<PsiImportStatementBase> findRedundantImports(PsiJavaFile file);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.core;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.SuggestedNameInfo;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class CoreJavaCodeStyleManager extends JavaCodeStyleManager {
|
||||
@Override
|
||||
public boolean addImport(@NotNull PsiJavaFile file, @NotNull PsiClass refClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement shortenClassReferences(@NotNull PsiElement element,
|
||||
@MagicConstant(flags = {DO_NOT_ADD_IMPORTS, UNCOMPLETE_CODE}) int flags)
|
||||
throws IncorrectOperationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPrefixByVariableKind(VariableKind variableKind) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getSuffixByVariableKind(VariableKind variableKind) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findEntryIndex(@NotNull PsiImportStatementBase statement) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement shortenClassReferences(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shortenClassReferences(@NotNull PsiElement element, int startOffset, int endOffset) throws IncorrectOperationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void optimizeImports(@NotNull PsiFile file) throws IncorrectOperationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiImportList prepareOptimizeImportsResult(@NotNull PsiJavaFile file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestedNameInfo suggestVariableName(@NotNull VariableKind kind,
|
||||
@Nullable String propertyName,
|
||||
@Nullable PsiExpression expr,
|
||||
@Nullable PsiType type,
|
||||
boolean correctKeywords) {
|
||||
return SuggestedNameInfo.NULL_INFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String variableNameToPropertyName(@NonNls String name, VariableKind variableKind) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String propertyNameToVariableName(@NonNls String propertyName, VariableKind variableKind) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String suggestUniqueVariableName(@NonNls String baseName, PsiElement place, boolean lookForward) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SuggestedNameInfo suggestUniqueVariableName(@NotNull SuggestedNameInfo baseNameInfo,
|
||||
PsiElement place,
|
||||
boolean ignorePlaceName,
|
||||
boolean lookForward) {
|
||||
return SuggestedNameInfo.NULL_INFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement qualifyClassReferences(@NotNull PsiElement element) {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRedundantImports(@NotNull PsiJavaFile file) throws IncorrectOperationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PsiImportStatementBase> findRedundantImports(PsiJavaFile file) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -30,11 +30,9 @@ import com.intellij.openapi.roots.PackageIndex;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.augment.PsiAugmentProvider;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettingsFacade;
|
||||
import com.intellij.psi.impl.EmptySubstitutorImpl;
|
||||
import com.intellij.psi.impl.JavaPsiFacadeImpl;
|
||||
import com.intellij.psi.impl.JavaPsiImplementationHelper;
|
||||
import com.intellij.psi.impl.PsiElementFactoryImpl;
|
||||
import com.intellij.psi.impl.*;
|
||||
import com.intellij.psi.impl.compiled.ClassFileStubBuilder;
|
||||
import com.intellij.psi.impl.compiled.ClsStubBuilderFactory;
|
||||
import com.intellij.psi.impl.compiled.DefaultClsStubBuilderFactory;
|
||||
@@ -62,6 +60,7 @@ public class JavaCoreEnvironment extends CoreEnvironment {
|
||||
registerFileType(JavaFileType.INSTANCE, "java");
|
||||
addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new CoreJavaASTFactory());
|
||||
addExplicitExtension(LanguageParserDefinitions.INSTANCE, JavaLanguage.INSTANCE, new JavaParserDefinition());
|
||||
addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator());
|
||||
|
||||
registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);
|
||||
registerExtensionPoint(Extensions.getRootArea(), ClsStubBuilderFactory.EP_NAME, ClsStubBuilderFactory.class);
|
||||
@@ -79,6 +78,7 @@ public class JavaCoreEnvironment extends CoreEnvironment {
|
||||
myProject.registerService(PackageIndex.class, myFileManager);
|
||||
myProject.registerService(JavaResolveCache.class, new JavaResolveCache(null));
|
||||
myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
|
||||
myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
|
||||
|
||||
JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, null);
|
||||
myProject.registerService(CoreJavaFileManager.class, myFileManager);
|
||||
|
||||
@@ -35,9 +35,8 @@ public class IdCacheTest extends CodeInsightTestCase{
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
|
||||
fileBasedIndex.requestRebuild(IdIndex.NAME);
|
||||
fileBasedIndex.requestRebuild(TodoIndex.NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(IdIndex.NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(TodoIndex.NAME);
|
||||
|
||||
String root = JavaTestUtil.getJavaTestDataPath()+ "/psi/impl/cache/";
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ public class UpdateCacheTest extends PsiTestCase{
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
FileBasedIndex.requestRebuild(IdIndex.NAME);
|
||||
FileBasedIndex.requestRebuild(TodoIndex.NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(IdIndex.NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(TodoIndex.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-9
@@ -95,15 +95,6 @@ public class EmptyProgressIndicator implements ProgressIndicator {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void finish(final Task task) {
|
||||
myFinished = true;
|
||||
}
|
||||
|
||||
public boolean isFinished(final Task task) {
|
||||
return myFinished;
|
||||
}
|
||||
|
||||
public void setIndeterminate(boolean indeterminate) {
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.ExtensionsArea;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.*;
|
||||
import com.intellij.openapi.progress.*;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.FileIndexFacade;
|
||||
@@ -151,6 +152,26 @@ public class CoreEnvironment {
|
||||
myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
|
||||
myProject.registerService(ProjectScopeBuilder.class, new CoreProjectScopeBuilder(myProject, myFileIndexFacade));
|
||||
myProject.registerService(DumbService.class, new MockDumbService(myProject));
|
||||
|
||||
ProgressIndicatorProvider.ourInstance = new ProgressIndicatorProvider() {
|
||||
@Override
|
||||
public ProgressIndicator getProgressIndicator() {
|
||||
return new EmptyProgressIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doCheckCanceled() throws ProcessCanceledException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
return new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.util.indexing;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ContentIterator;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWithId;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Author: dmitrylomov
|
||||
*/
|
||||
public abstract class FileBasedIndex implements BaseComponent {
|
||||
public abstract void iterateIndexableFiles(@NotNull ContentIterator processor, @NotNull Project project, ProgressIndicator indicator);
|
||||
|
||||
public abstract void registerIndexableSet(@NotNull IndexableFileSet set, @Nullable Project project);
|
||||
|
||||
public abstract void removeIndexableSet(@NotNull IndexableFileSet set);
|
||||
|
||||
public static FileBasedIndex getInstance() {
|
||||
return ApplicationManager.getApplication().getComponent(FileBasedIndex.class);
|
||||
}
|
||||
|
||||
public static int getFileId(@NotNull final VirtualFile file) {
|
||||
if (file instanceof VirtualFileWithId) {
|
||||
return ((VirtualFileWithId)file).getId();
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Virtual file doesn't support id: " + file + ", implementation class: " + file.getClass().getName());
|
||||
}
|
||||
|
||||
public void requestRebuild(ID<?, ?> indexId) {
|
||||
requestRebuild(indexId, new Throwable());
|
||||
}
|
||||
|
||||
|
||||
@NonNls
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "FileBasedIndex";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract <K, V> List<V> getValues(@NotNull ID<K, V> indexId, @NotNull K dataKey, @NotNull GlobalSearchScope filter);
|
||||
|
||||
@NotNull
|
||||
public abstract <K, V> Collection<VirtualFile> getContainingFiles(@NotNull ID<K, V> indexId,
|
||||
@NotNull K dataKey,
|
||||
@NotNull GlobalSearchScope filter);
|
||||
|
||||
public abstract <K, V> boolean processValues(@NotNull ID<K, V> indexId,
|
||||
@NotNull K dataKey,
|
||||
@Nullable VirtualFile inFile,
|
||||
@NotNull FileBasedIndex.ValueProcessor<V> processor,
|
||||
@NotNull GlobalSearchScope filter);
|
||||
|
||||
public abstract <K, V> boolean processFilesContainingAllKeys(@NotNull ID<K, V> indexId,
|
||||
@NotNull Collection<K> dataKeys,
|
||||
@NotNull GlobalSearchScope filter,
|
||||
@Nullable Condition<V> valueChecker,
|
||||
@NotNull Processor<VirtualFile> processor);
|
||||
|
||||
@NotNull
|
||||
public abstract <K> Collection<K> getAllKeys(@NotNull ID<K, ?> indexId, @NotNull Project project);
|
||||
|
||||
public abstract <K> void ensureUpToDate(@NotNull ID<K, ?> indexId, @Nullable Project project, @Nullable GlobalSearchScope filter);
|
||||
|
||||
public abstract void requestRebuild(ID<?, ?> indexId, Throwable throwable);
|
||||
|
||||
public abstract <K> void scheduleRebuild(@NotNull ID<K, ?> indexId, @NotNull Throwable e);
|
||||
|
||||
public abstract void requestReindex(@NotNull VirtualFile file);
|
||||
|
||||
public abstract void requestReindexExcluded(@NotNull VirtualFile file);
|
||||
|
||||
public abstract <K, V> boolean getFilesWithKey(@NotNull ID<K, V> indexId,
|
||||
@NotNull Set<K> dataKeys,
|
||||
@NotNull Processor<VirtualFile> processor,
|
||||
@NotNull GlobalSearchScope filter);
|
||||
|
||||
public abstract <K> boolean processAllKeys(@NotNull ID<K, ?> indexId, Processor<K> processor, @Nullable Project project);
|
||||
|
||||
public interface ValueProcessor<V> {
|
||||
/**
|
||||
* @param value a value to process
|
||||
* @param file the file the value came from
|
||||
* @return false if no further processing is needed, true otherwise
|
||||
*/
|
||||
boolean process(VirtualFile file, V value);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="core-impl" />
|
||||
<orderEntry type="module" module-name="indexing-api" exported="" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.openapi.fileTypes.impl;
|
||||
|
||||
import com.intellij.ide.highlighter.custom.SyntaxTable;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
|
||||
/**
|
||||
* Author: dmitrylomov
|
||||
*/
|
||||
public interface CustomSyntaxTableFileType extends FileType {
|
||||
SyntaxTable getSyntaxTable();
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
+8
-175
@@ -16,39 +16,26 @@
|
||||
|
||||
package com.intellij.psi.impl.cache.impl.id;
|
||||
|
||||
import com.intellij.ide.highlighter.HighlighterFactory;
|
||||
import com.intellij.ide.highlighter.custom.CustomFileTypeLexer;
|
||||
import com.intellij.idea.LoggerFactory;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.lang.cacheBuilder.*;
|
||||
import com.intellij.lang.findUsages.FindUsagesProvider;
|
||||
import com.intellij.lang.findUsages.LanguageFindUsages;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.psi.CustomHighlighterTokenType;
|
||||
import com.intellij.psi.impl.cache.impl.BaseFilterLexer;
|
||||
import com.intellij.psi.impl.cache.impl.CacheUtil;
|
||||
import com.intellij.psi.impl.cache.impl.IndexPatternUtil;
|
||||
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
|
||||
import com.intellij.psi.impl.cache.impl.todo.TodoIndexEntry;
|
||||
import com.intellij.psi.impl.cache.impl.todo.TodoIndexers;
|
||||
import com.intellij.psi.search.IndexPattern;
|
||||
import com.intellij.psi.search.UsageSearchContext;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.indexing.DataIndexer;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
import com.intellij.util.indexing.IdDataConsumer;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -123,19 +110,12 @@ public class IdTableBuilding {
|
||||
}
|
||||
|
||||
private static final HashMap<FileType, FileTypeIdIndexer> ourIdIndexers = new HashMap<FileType, FileTypeIdIndexer>();
|
||||
private static final HashMap<FileType, DataIndexer<TodoIndexEntry, Integer, FileContent>> ourTodoIndexers =
|
||||
new HashMap<FileType, DataIndexer<TodoIndexEntry, Integer, FileContent>>();
|
||||
|
||||
@Deprecated
|
||||
public static void registerIdIndexer(FileType fileType, FileTypeIdIndexer indexer) {
|
||||
ourIdIndexers.put(fileType, indexer);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void registerTodoIndexer(FileType fileType, DataIndexer<TodoIndexEntry, Integer, FileContent> indexer) {
|
||||
ourTodoIndexers.put(fileType, indexer);
|
||||
}
|
||||
|
||||
public static boolean isIdIndexerRegistered(FileType fileType) {
|
||||
return ourIdIndexers.containsKey(fileType) || IdIndexers.INSTANCE.forFileType(fileType) != null;
|
||||
}
|
||||
@@ -144,18 +124,7 @@ public class IdTableBuilding {
|
||||
return ourIdIndexers.containsKey(fileType) || TodoIndexers.INSTANCE.forFileType(fileType) != null;
|
||||
}
|
||||
|
||||
static {
|
||||
registerIdIndexer(FileTypes.PLAIN_TEXT, new PlainTextIndexer());
|
||||
registerTodoIndexer(FileTypes.PLAIN_TEXT, new PlainTextTodoIndexer());
|
||||
|
||||
registerIdIndexer(StdFileTypes.IDEA_MODULE, null);
|
||||
registerIdIndexer(StdFileTypes.IDEA_WORKSPACE, null);
|
||||
registerIdIndexer(StdFileTypes.IDEA_PROJECT, null);
|
||||
|
||||
registerTodoIndexer(StdFileTypes.IDEA_MODULE, null);
|
||||
registerTodoIndexer(StdFileTypes.IDEA_WORKSPACE, null);
|
||||
registerTodoIndexer(StdFileTypes.IDEA_PROJECT, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static FileTypeIdIndexer getFileTypeIndexer(FileType fileType) {
|
||||
@@ -185,15 +154,15 @@ public class IdTableBuilding {
|
||||
return new WordsScannerFileTypeIdIndexerAdapter(scanner);
|
||||
}
|
||||
|
||||
if (fileType instanceof AbstractFileType) {
|
||||
return new WordsScannerFileTypeIdIndexerAdapter(createWordScanner((AbstractFileType)fileType));
|
||||
if (fileType instanceof CustomSyntaxTableFileType) {
|
||||
return new WordsScannerFileTypeIdIndexerAdapter(createWordScanner((CustomSyntaxTableFileType)fileType));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static WordsScanner createWordScanner(final AbstractFileType abstractFileType) {
|
||||
return new DefaultWordsScanner(new CustomFileTypeLexer(abstractFileType.getSyntaxTable(), true),
|
||||
private static WordsScanner createWordScanner(final CustomSyntaxTableFileType customSyntaxTableFileType) {
|
||||
return new DefaultWordsScanner(new CustomFileTypeLexer(customSyntaxTableFileType.getSyntaxTable(), true),
|
||||
TokenSet.create(CustomHighlighterTokenType.IDENTIFIER),
|
||||
TokenSet.create(CustomHighlighterTokenType.LINE_COMMENT,
|
||||
CustomHighlighterTokenType.MULTI_LINE_COMMENT),
|
||||
@@ -201,46 +170,6 @@ public class IdTableBuilding {
|
||||
|
||||
}
|
||||
|
||||
private static final TokenSet ABSTRACT_FILE_COMMENT_TOKENS =
|
||||
TokenSet.create(CustomHighlighterTokenType.LINE_COMMENT, CustomHighlighterTokenType.MULTI_LINE_COMMENT);
|
||||
|
||||
@Nullable
|
||||
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, final VirtualFile virtualFile) {
|
||||
final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = ourTodoIndexers.get(fileType);
|
||||
|
||||
if (indexer != null) {
|
||||
return indexer;
|
||||
}
|
||||
|
||||
final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
|
||||
if (fileType instanceof SubstitutedFileType) {
|
||||
SubstitutedFileType sft = (SubstitutedFileType)fileType;
|
||||
extIndexer =
|
||||
new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), virtualFile), getTodoIndexer(sft.getFileType(), virtualFile));
|
||||
}
|
||||
else {
|
||||
extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
|
||||
}
|
||||
if (extIndexer != null) {
|
||||
return extIndexer;
|
||||
}
|
||||
|
||||
if (fileType instanceof LanguageFileType) {
|
||||
final Language lang = ((LanguageFileType)fileType).getLanguage();
|
||||
final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
|
||||
final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
|
||||
if (commentTokens != null) {
|
||||
return new TokenSetTodoIndexer(commentTokens, virtualFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileType instanceof AbstractFileType) {
|
||||
return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, virtualFile);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class WordsScannerFileTypeIdIndexerAdapter extends FileTypeIdIndexer {
|
||||
private final WordsScanner myScanner;
|
||||
|
||||
@@ -279,102 +208,6 @@ public class IdTableBuilding {
|
||||
}
|
||||
}
|
||||
|
||||
private static class CompositeTodoIndexer implements DataIndexer<TodoIndexEntry, Integer, FileContent> {
|
||||
|
||||
private final DataIndexer<TodoIndexEntry, Integer, FileContent>[] indexers;
|
||||
|
||||
public CompositeTodoIndexer(DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) {
|
||||
this.indexers = indexers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<TodoIndexEntry, Integer> map(FileContent inputData) {
|
||||
Map<TodoIndexEntry, Integer> result = CollectionFactory.newTroveMap();
|
||||
for (DataIndexer<TodoIndexEntry, Integer, FileContent> indexer : indexers) {
|
||||
for (Map.Entry<TodoIndexEntry, Integer> entry : indexer.map(inputData).entrySet()) {
|
||||
TodoIndexEntry key = entry.getKey();
|
||||
if (result.containsKey(key)) {
|
||||
result.put(key, result.get(key) + entry.getValue());
|
||||
} else {
|
||||
result.put(key, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TokenSetTodoIndexer implements DataIndexer<TodoIndexEntry, Integer, FileContent> {
|
||||
@NotNull private final TokenSet myCommentTokens;
|
||||
private final VirtualFile myFile;
|
||||
|
||||
public TokenSetTodoIndexer(@NotNull final TokenSet commentTokens, @NotNull final VirtualFile file) {
|
||||
myCommentTokens = commentTokens;
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<TodoIndexEntry, Integer> map(final FileContent inputData) {
|
||||
if (IndexPatternUtil.getIndexPatternCount() > 0) {
|
||||
final CharSequence chars = inputData.getContentAsText();
|
||||
final OccurrenceConsumer occurrenceConsumer = new OccurrenceConsumer(null, true);
|
||||
EditorHighlighter highlighter;
|
||||
|
||||
final EditorHighlighter editorHighlighter = inputData.getUserData(FileBasedIndex.EDITOR_HIGHLIGHTER);
|
||||
if (editorHighlighter != null && checkCanUseCachedEditorHighlighter(chars, editorHighlighter)) {
|
||||
highlighter = editorHighlighter;
|
||||
}
|
||||
else {
|
||||
highlighter = HighlighterFactory.createHighlighter(null, myFile);
|
||||
highlighter.setText(chars);
|
||||
}
|
||||
|
||||
final int documentLength = chars.length();
|
||||
BaseFilterLexer.TodoScanningData[] todoScanningDatas = null;
|
||||
final HighlighterIterator iterator = highlighter.createIterator(0);
|
||||
|
||||
while (!iterator.atEnd()) {
|
||||
final IElementType token = iterator.getTokenType();
|
||||
|
||||
if (myCommentTokens.contains(token) || CacheUtil.isInComments(token)) {
|
||||
int start = iterator.getStart();
|
||||
if (start >= documentLength) break;
|
||||
int end = iterator.getEnd();
|
||||
|
||||
todoScanningDatas = BaseFilterLexer.advanceTodoItemsCount(
|
||||
chars.subSequence(start, Math.min(end, documentLength)),
|
||||
occurrenceConsumer,
|
||||
todoScanningDatas
|
||||
);
|
||||
if (end > documentLength) break;
|
||||
}
|
||||
iterator.advance();
|
||||
}
|
||||
final Map<TodoIndexEntry, Integer> map = new HashMap<TodoIndexEntry, Integer>();
|
||||
for (IndexPattern pattern : IndexPatternUtil.getIndexPatterns()) {
|
||||
final int count = occurrenceConsumer.getOccurrenceCount(pattern);
|
||||
if (count > 0) {
|
||||
map.put(new TodoIndexEntry(pattern.getPatternString(), pattern.isCaseSensitive()), count);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkCanUseCachedEditorHighlighter(final CharSequence chars, final EditorHighlighter editorHighlighter) {
|
||||
assert editorHighlighter instanceof LexerEditorHighlighter;
|
||||
final boolean b = ((LexerEditorHighlighter)editorHighlighter).checkContentIsEqualTo(chars);
|
||||
if (!b) {
|
||||
final Logger logger = LoggerFactory.getInstance().getLoggerInstance(IdTableBuilding.class.getName());
|
||||
logger.warn("Unexpected mismatch of editor highlighter content with indexing content");
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static void scanWords(final ScanWordProcessor processor, final CharSequence chars, final int startOffset, final int endOffset) {
|
||||
scanWords(processor, chars, CharArrayUtil.fromSequenceWithoutCopying(chars), startOffset, endOffset, false);
|
||||
}
|
||||
+1
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -22,7 +22,6 @@ import gnu.trove.THashMap;
|
||||
import gnu.trove.TIntIntHashMap;
|
||||
import gnu.trove.TIntIntProcedure;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<orderEntry type="library" exported="" name="cli-parser" level="project" />
|
||||
<orderEntry type="library" name="http-client-3.1" level="project" />
|
||||
<orderEntry type="module" module-name="indexing-api" />
|
||||
<orderEntry type="module" module-name="indexing-impl" />
|
||||
<orderEntry type="module" module-name="indexing-impl" exported="" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+4
-3
@@ -29,6 +29,7 @@ import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -223,8 +224,8 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler {
|
||||
private TextRange findCommentedRange(final Commenter commenter) {
|
||||
final CharSequence text = myDocument.getCharsSequence();
|
||||
final FileType fileType = myFile.getFileType();
|
||||
if (fileType instanceof AbstractFileType) {
|
||||
Lexer lexer = new CustomFileTypeLexer(((AbstractFileType)fileType).getSyntaxTable());
|
||||
if (fileType instanceof CustomSyntaxTableFileType) {
|
||||
Lexer lexer = new CustomFileTypeLexer(((CustomSyntaxTableFileType)fileType).getSyntaxTable());
|
||||
final int caretOffset = myEditor.getCaretModel().getOffset();
|
||||
int commentStart = CharArrayUtil.lastIndexOf(text, commenter.getBlockCommentPrefix(), caretOffset);
|
||||
if (commentStart == -1) return null;
|
||||
@@ -312,7 +313,7 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler {
|
||||
@Nullable
|
||||
private static Commenter findCommenter(PsiFile file, Editor editor) {
|
||||
final FileType fileType = file.getFileType();
|
||||
if (fileType instanceof AbstractFileType) {
|
||||
if (fileType instanceof CustomSyntaxTableFileType) {
|
||||
return ((AbstractFileType)fileType).getCommenter();
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -31,6 +31,7 @@ import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -210,9 +211,9 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
|
||||
|
||||
Commenter blockSuitableCommenter =
|
||||
languageSuitableForCompleteFragment == null ? LanguageCommenters.INSTANCE.forLanguage(myFile.getLanguage()) : null;
|
||||
if (blockSuitableCommenter == null && myFile.getFileType() instanceof AbstractFileType) {
|
||||
if (blockSuitableCommenter == null && myFile.getFileType() instanceof CustomSyntaxTableFileType) {
|
||||
blockSuitableCommenter = new Commenter() {
|
||||
final SyntaxTable mySyntaxTable = ((AbstractFileType)myFile.getFileType()).getSyntaxTable();
|
||||
final SyntaxTable mySyntaxTable = ((CustomSyntaxTableFileType)myFile.getFileType()).getSyntaxTable();
|
||||
|
||||
@Nullable
|
||||
public String getLineCommentPrefix() {
|
||||
|
||||
-1
@@ -16,7 +16,6 @@
|
||||
package com.intellij.find.findUsages;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.lang.findUsages.LanguageFindUsages;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -502,8 +502,7 @@ public class FindInProjectUtil {
|
||||
if (!keys.isEmpty()) {
|
||||
fast = true;
|
||||
List<VirtualFile> hits = new ArrayList<VirtualFile>();
|
||||
FileBasedIndex.getInstance()
|
||||
.getFilesWithKey(TrigramIndex.INDEX_ID, keys, new CommonProcessors.CollectProcessor<VirtualFile>(hits), scope);
|
||||
FileBasedIndex.getInstance().getFilesWithKey(TrigramIndex.INDEX_ID, keys, new CommonProcessors.CollectProcessor<VirtualFile>(hits), scope);
|
||||
|
||||
for (VirtualFile hit : hits) {
|
||||
resultFiles.add(pm.findFile(hit));
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighterProvider;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ide.highlighter.custom.CustomFileHighlighter;
|
||||
@@ -32,7 +33,7 @@ public class CustomFileTypeHighlighterProvider implements SyntaxHighlighterProvi
|
||||
@Nullable
|
||||
public SyntaxHighlighter create(final FileType fileType, @Nullable final Project project, @Nullable final VirtualFile file) {
|
||||
if (fileType instanceof AbstractFileType) {
|
||||
return new CustomFileHighlighter(((AbstractFileType) fileType).getSyntaxTable());
|
||||
return new CustomFileHighlighter(((CustomSyntaxTableFileType) fileType).getSyntaxTable());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ import com.intellij.ide.highlighter.custom.SyntaxTable;
|
||||
import com.intellij.lang.Commenter;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
|
||||
public class StandardFileTypeRegistrator implements FileTypeRegistrator {
|
||||
public void initFileType(final FileType fileType) {
|
||||
@@ -51,9 +52,9 @@ public class StandardFileTypeRegistrator implements FileTypeRegistrator {
|
||||
}
|
||||
|
||||
private static class MyCommenter implements Commenter {
|
||||
private final AbstractFileType myAbstractFileType;
|
||||
private final CustomSyntaxTableFileType myAbstractFileType;
|
||||
|
||||
public MyCommenter(final AbstractFileType abstractFileType) {
|
||||
public MyCommenter(final CustomSyntaxTableFileType abstractFileType) {
|
||||
|
||||
myAbstractFileType = abstractFileType;
|
||||
}
|
||||
|
||||
-2
@@ -20,13 +20,11 @@
|
||||
package com.intellij.openapi.fileTypes;
|
||||
|
||||
import com.intellij.ide.highlighter.custom.AbstractCustomLexer;
|
||||
import com.intellij.ide.highlighter.custom.CustomHighlighterColors;
|
||||
import com.intellij.ide.highlighter.custom.tokens.*;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.CustomHighlighterTokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
-2
@@ -21,7 +21,6 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.psi.impl.cache.impl.id.IdIndexEntry;
|
||||
import com.intellij.psi.impl.cache.impl.id.IdTableBuilding;
|
||||
import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer;
|
||||
import com.intellij.psi.impl.cache.impl.todo.LexerBasedTodoIndexer;
|
||||
import com.intellij.psi.impl.cache.impl.todo.TodoIndexEntry;
|
||||
import com.intellij.psi.search.IndexPattern;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
@@ -29,7 +28,6 @@ import com.intellij.util.indexing.IdDataConsumer;
|
||||
import gnu.trove.THashMap;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BaseFilterLexerUtil {
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.intellij.psi.impl.cache.impl.id;
|
||||
import com.intellij.lang.cacheBuilder.CacheBuilderRegistry;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.indexing.*;
|
||||
@@ -126,7 +126,7 @@ public class IdIndex extends FileBasedIndexExtension<IdIndexEntry, Integer> {
|
||||
|
||||
private static boolean isIndexable(FileType fileType) {
|
||||
return fileType instanceof LanguageFileType ||
|
||||
fileType instanceof AbstractFileType ||
|
||||
fileType instanceof CustomSyntaxTableFileType ||
|
||||
IdTableBuilding.isIdIndexerRegistered(fileType) ||
|
||||
CacheBuilderRegistry.getInstance().getCacheBuilder(fileType) != null;
|
||||
}
|
||||
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.psi.impl.cache.impl.id;
|
||||
|
||||
import com.intellij.ide.highlighter.HighlighterFactory;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.CustomHighlighterTokenType;
|
||||
import com.intellij.psi.impl.cache.impl.BaseFilterLexer;
|
||||
import com.intellij.psi.impl.cache.impl.CacheUtil;
|
||||
import com.intellij.psi.impl.cache.impl.IndexPatternUtil;
|
||||
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
|
||||
import com.intellij.psi.impl.cache.impl.todo.TodoIndexEntry;
|
||||
import com.intellij.psi.impl.cache.impl.todo.TodoIndexers;
|
||||
import com.intellij.psi.search.IndexPattern;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.indexing.DataIndexer;
|
||||
import com.intellij.util.indexing.FileBasedIndexImpl;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
import com.intellij.util.indexing.SubstitutedFileType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Author: dmitrylomov
|
||||
*/
|
||||
public abstract class PlatformIdTableBuilding {
|
||||
static final HashMap<FileType, DataIndexer<TodoIndexEntry, Integer, FileContent>> ourTodoIndexers =
|
||||
new HashMap<FileType, DataIndexer<TodoIndexEntry, Integer, FileContent>>();
|
||||
private static final TokenSet ABSTRACT_FILE_COMMENT_TOKENS =
|
||||
TokenSet.create(CustomHighlighterTokenType.LINE_COMMENT, CustomHighlighterTokenType.MULTI_LINE_COMMENT);
|
||||
|
||||
private PlatformIdTableBuilding() {}
|
||||
|
||||
@Nullable
|
||||
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, final VirtualFile virtualFile) {
|
||||
final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = ourTodoIndexers.get(fileType);
|
||||
|
||||
if (indexer != null) {
|
||||
return indexer;
|
||||
}
|
||||
|
||||
final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
|
||||
if (fileType instanceof SubstitutedFileType) {
|
||||
SubstitutedFileType sft = (SubstitutedFileType)fileType;
|
||||
extIndexer =
|
||||
new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), virtualFile), getTodoIndexer(sft.getFileType(), virtualFile));
|
||||
}
|
||||
else {
|
||||
extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
|
||||
}
|
||||
if (extIndexer != null) {
|
||||
return extIndexer;
|
||||
}
|
||||
|
||||
if (fileType instanceof LanguageFileType) {
|
||||
final Language lang = ((LanguageFileType)fileType).getLanguage();
|
||||
final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
|
||||
final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
|
||||
if (commentTokens != null) {
|
||||
return new TokenSetTodoIndexer(commentTokens, virtualFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileType instanceof CustomSyntaxTableFileType) {
|
||||
return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, virtualFile);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean checkCanUseCachedEditorHighlighter(final CharSequence chars, final EditorHighlighter editorHighlighter) {
|
||||
assert editorHighlighter instanceof LexerEditorHighlighter;
|
||||
final boolean b = ((LexerEditorHighlighter)editorHighlighter).checkContentIsEqualTo(chars);
|
||||
if (!b) {
|
||||
final Logger logger = Logger.getInstance(IdTableBuilding.class.getName());
|
||||
logger.warn("Unexpected mismatch of editor highlighter content with indexing content");
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void registerTodoIndexer(FileType fileType, DataIndexer<TodoIndexEntry, Integer, FileContent> indexer) {
|
||||
ourTodoIndexers.put(fileType, indexer);
|
||||
}
|
||||
|
||||
|
||||
private static class CompositeTodoIndexer implements DataIndexer<TodoIndexEntry, Integer, FileContent> {
|
||||
|
||||
private final DataIndexer<TodoIndexEntry, Integer, FileContent>[] indexers;
|
||||
|
||||
public CompositeTodoIndexer(DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) {
|
||||
this.indexers = indexers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<TodoIndexEntry, Integer> map(FileContent inputData) {
|
||||
Map<TodoIndexEntry, Integer> result = CollectionFactory.newTroveMap();
|
||||
for (DataIndexer<TodoIndexEntry, Integer, FileContent> indexer : indexers) {
|
||||
for (Map.Entry<TodoIndexEntry, Integer> entry : indexer.map(inputData).entrySet()) {
|
||||
TodoIndexEntry key = entry.getKey();
|
||||
if (result.containsKey(key)) {
|
||||
result.put(key, result.get(key) + entry.getValue());
|
||||
} else {
|
||||
result.put(key, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TokenSetTodoIndexer implements DataIndexer<TodoIndexEntry, Integer, FileContent> {
|
||||
@NotNull private final TokenSet myCommentTokens;
|
||||
private final VirtualFile myFile;
|
||||
|
||||
public TokenSetTodoIndexer(@NotNull final TokenSet commentTokens, @NotNull final VirtualFile file) {
|
||||
myCommentTokens = commentTokens;
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<TodoIndexEntry, Integer> map(final FileContent inputData) {
|
||||
if (IndexPatternUtil.getIndexPatternCount() > 0) {
|
||||
final CharSequence chars = inputData.getContentAsText();
|
||||
final OccurrenceConsumer occurrenceConsumer = new OccurrenceConsumer(null, true);
|
||||
EditorHighlighter highlighter;
|
||||
|
||||
final EditorHighlighter editorHighlighter = inputData.getUserData(FileBasedIndexImpl.EDITOR_HIGHLIGHTER);
|
||||
if (editorHighlighter != null && checkCanUseCachedEditorHighlighter(chars, editorHighlighter)) {
|
||||
highlighter = editorHighlighter;
|
||||
}
|
||||
else {
|
||||
highlighter = HighlighterFactory.createHighlighter(null, myFile);
|
||||
highlighter.setText(chars);
|
||||
}
|
||||
|
||||
final int documentLength = chars.length();
|
||||
BaseFilterLexer.TodoScanningData[] todoScanningDatas = null;
|
||||
final HighlighterIterator iterator = highlighter.createIterator(0);
|
||||
|
||||
while (!iterator.atEnd()) {
|
||||
final IElementType token = iterator.getTokenType();
|
||||
|
||||
if (myCommentTokens.contains(token) || CacheUtil.isInComments(token)) {
|
||||
int start = iterator.getStart();
|
||||
if (start >= documentLength) break;
|
||||
int end = iterator.getEnd();
|
||||
|
||||
todoScanningDatas = BaseFilterLexer.advanceTodoItemsCount(
|
||||
chars.subSequence(start, Math.min(end, documentLength)),
|
||||
occurrenceConsumer,
|
||||
todoScanningDatas
|
||||
);
|
||||
if (end > documentLength) break;
|
||||
}
|
||||
iterator.advance();
|
||||
}
|
||||
final Map<TodoIndexEntry, Integer> map = new HashMap<TodoIndexEntry, Integer>();
|
||||
for (IndexPattern pattern : IndexPatternUtil.getIndexPatterns()) {
|
||||
final int count = occurrenceConsumer.getOccurrenceCount(pattern);
|
||||
if (count > 0) {
|
||||
map.put(new TodoIndexEntry(pattern.getPatternString(), pattern.isCaseSensitive()), count);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
IdTableBuilding.registerIdIndexer(FileTypes.PLAIN_TEXT, new IdTableBuilding.PlainTextIndexer());
|
||||
registerTodoIndexer(FileTypes.PLAIN_TEXT, new IdTableBuilding.PlainTextTodoIndexer());
|
||||
|
||||
IdTableBuilding.registerIdIndexer(StdFileTypes.IDEA_MODULE, null);
|
||||
IdTableBuilding.registerIdIndexer(StdFileTypes.IDEA_WORKSPACE, null);
|
||||
IdTableBuilding.registerIdIndexer(StdFileTypes.IDEA_PROJECT, null);
|
||||
|
||||
registerTodoIndexer(StdFileTypes.IDEA_MODULE, null);
|
||||
registerTodoIndexer(StdFileTypes.IDEA_WORKSPACE, null);
|
||||
registerTodoIndexer(StdFileTypes.IDEA_PROJECT, null);
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -21,11 +21,12 @@ import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.impl.cache.impl.id.IdTableBuilding;
|
||||
import com.intellij.psi.impl.cache.impl.id.PlatformIdTableBuilding;
|
||||
import com.intellij.psi.search.IndexPatternProvider;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.indexing.*;
|
||||
@@ -54,7 +55,7 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
|
||||
messageBus.connect().subscribe(IndexPatternProvider.INDEX_PATTERNS_CHANGED, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
FileBasedIndex.requestRebuild(NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(NAME);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -101,7 +102,8 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
|
||||
@NotNull
|
||||
public Map<TodoIndexEntry,Integer> map(final FileContent inputData) {
|
||||
final VirtualFile file = inputData.getFile();
|
||||
final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = IdTableBuilding.getTodoIndexer(inputData.getFileType(), file);
|
||||
final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = PlatformIdTableBuilding
|
||||
.getTodoIndexer(inputData.getFileType(), file);
|
||||
if (indexer != null) {
|
||||
return indexer.map(inputData);
|
||||
}
|
||||
@@ -129,7 +131,7 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
|
||||
}
|
||||
|
||||
return IdTableBuilding.isTodoIndexerRegistered(fileType) ||
|
||||
fileType instanceof AbstractFileType;
|
||||
fileType instanceof CustomSyntaxTableFileType;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -111,7 +111,7 @@ public class IndexPatternSearcher implements QueryExecutor<IndexPatternOccurrenc
|
||||
final TIntArrayList commentEnds) {
|
||||
if (file instanceof PsiPlainTextFile) {
|
||||
FileType fType = file.getFileType();
|
||||
if (fType instanceof AbstractFileType) {
|
||||
if (fType instanceof CustomSyntaxTableFileType) {
|
||||
Lexer lexer = SyntaxHighlighter.PROVIDER.create(fType, file.getProject(), file.getVirtualFile()).getHighlightingLexer();
|
||||
findComments(lexer, chars, range, COMMENT_TOKENS, commentStarts, commentEnds, null);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
|
||||
@@ -200,7 +200,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
@NotNull final Project project,
|
||||
@Nullable final GlobalSearchScope scope,
|
||||
@NotNull final Processor<? super Psi> processor) {
|
||||
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
|
||||
final FileBasedIndexImpl fileBasedIndex = (FileBasedIndexImpl)FileBasedIndex.getInstance();
|
||||
fileBasedIndex.ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, scope);
|
||||
|
||||
final PersistentFS fs = (PersistentFS)ManagingFS.getInstance();
|
||||
@@ -211,11 +211,11 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
try {
|
||||
try {
|
||||
// disable up-to-date check to avoid locks on attempt to acquire index write lock while holding at the same time the readLock for this index
|
||||
FileBasedIndex.disableUpToDateCheckForCurrentThread();
|
||||
FileBasedIndexImpl.disableUpToDateCheckForCurrentThread();
|
||||
index.getReadLock().lock();
|
||||
final ValueContainer<TIntArrayList> container = index.getData(key);
|
||||
|
||||
final FileBasedIndex.ProjectIndexableFilesFilter projectFilesFilter = fileBasedIndex.projectIndexableFiles(project);
|
||||
final FileBasedIndexImpl.ProjectIndexableFilesFilter projectFilesFilter = fileBasedIndex.projectIndexableFiles(project);
|
||||
|
||||
return container.forEach(new ValueContainer.ContainerAction<TIntArrayList>() {
|
||||
@Override
|
||||
@@ -320,14 +320,14 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
}
|
||||
finally {
|
||||
index.getReadLock().unlock();
|
||||
FileBasedIndex.enableUpToDateCheckForCurrentThread();
|
||||
FileBasedIndexImpl.enableUpToDateCheckForCurrentThread();
|
||||
}
|
||||
}
|
||||
catch (StorageException e) {
|
||||
forceRebuild(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
final Throwable cause = FileBasedIndex.getCauseToRebuildIndex(e);
|
||||
final Throwable cause = FileBasedIndexImpl.getCauseToRebuildIndex(e);
|
||||
if (cause != null) {
|
||||
forceRebuild(cause);
|
||||
}
|
||||
@@ -354,7 +354,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
}
|
||||
|
||||
private static void requestRebuild() {
|
||||
FileBasedIndex.requestRebuild(StubUpdatingIndex.INDEX_ID);
|
||||
FileBasedIndex.getInstance().requestRebuild(StubUpdatingIndex.INDEX_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -232,7 +232,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
}
|
||||
catch (StorageException e) {
|
||||
LOG.info(e);
|
||||
FileBasedIndex.requestRebuild(INDEX_ID);
|
||||
FileBasedIndex.getInstance().requestRebuild(INDEX_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-45
@@ -26,7 +26,6 @@ import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.application.ApplicationAdapter;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
@@ -87,8 +86,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
* Date: Dec 20, 2007
|
||||
*/
|
||||
|
||||
public class FileBasedIndex implements ApplicationComponent {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.FileBasedIndex");
|
||||
public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.FileBasedIndexImpl");
|
||||
@NonNls
|
||||
private static final String CORRUPTION_MARKER_NAME = "corruption.marker";
|
||||
private final Map<ID<?, ?>, Pair<UpdatableIndex<?, ?, FileContent>, InputFilter>> myIndices = new THashMap<ID<?, ?>, Pair<UpdatableIndex<?, ?, FileContent>, InputFilter>>();
|
||||
@@ -124,16 +123,22 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
private volatile int myLocalModCount;
|
||||
private volatile int myFilesModCount;
|
||||
|
||||
@Override
|
||||
public void requestReindex(@NotNull final VirtualFile file) {
|
||||
myChangedFilesCollector.invalidateIndices(file, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestReindexExcluded(@NotNull final VirtualFile file) {
|
||||
myChangedFilesCollector.invalidateIndices(file, false);
|
||||
}
|
||||
|
||||
public FileBasedIndex(final VirtualFileManagerEx vfManager, FileDocumentManager fdm,
|
||||
FileTypeManager fileTypeManager, @NotNull MessageBus bus, SerializationManager sm /*need this parameter to ensure component dependency*/) throws IOException {
|
||||
public FileBasedIndexImpl(final VirtualFileManagerEx vfManager,
|
||||
FileDocumentManager fdm,
|
||||
FileTypeManager fileTypeManager,
|
||||
@NotNull MessageBus bus,
|
||||
SerializationManager sm
|
||||
/*need this parameter to ensure component dependency*/) throws IOException {
|
||||
myVfManager = vfManager;
|
||||
myFileDocumentManager = fdm;
|
||||
myFileTypeManager = fileTypeManager;
|
||||
@@ -352,14 +357,6 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private static class FileBasedIndexHolder {
|
||||
private static final FileBasedIndex ourInstance = ApplicationManager.getApplication().getComponent(FileBasedIndex.class);
|
||||
}
|
||||
|
||||
public static FileBasedIndex getInstance() {
|
||||
return FileBasedIndexHolder.ourInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if registered index requires full rebuild for some reason, e.g. is just created or corrupted
|
||||
*
|
||||
@@ -586,13 +583,6 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "FileBasedIndex";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
performShutdown();
|
||||
@@ -667,6 +657,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
* @param project it is guaranteed to return data which is up-to-date withing the project
|
||||
* Keys obtained from the files which do not belong to the project specified may not be up-to-date or even exist
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public <K> Collection<K> getAllKeys(@NotNull final ID<K, ?> indexId, @NotNull Project project) {
|
||||
Set<K> allKeys = new THashSet<K>();
|
||||
@@ -678,6 +669,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
* @param project it is guaranteed to return data which is up-to-date withing the project
|
||||
* Keys obtained from the files which do not belong to the project specified may not be up-to-date or even exist
|
||||
*/
|
||||
@Override
|
||||
public <K> boolean processAllKeys(@NotNull final ID<K, ?> indexId, Processor<K> processor, @Nullable Project project) {
|
||||
try {
|
||||
final UpdatableIndex<K, ?, FileContent> index = getIndex(indexId);
|
||||
@@ -740,12 +732,15 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
* DO NOT CALL DIRECTLY IN CLIENT CODE
|
||||
* The method is internal to indexing engine end is called internally. The method is public due to implementation details
|
||||
*/
|
||||
@Override
|
||||
public <K> void ensureUpToDate(@NotNull final ID<K, ?> indexId, @Nullable Project project, @Nullable GlobalSearchScope filter) {
|
||||
ensureUpToDate(indexId, project, filter, null);
|
||||
}
|
||||
|
||||
private <K> void ensureUpToDate(@NotNull final ID<K, ?> indexId, @Nullable Project project, @Nullable GlobalSearchScope filter,
|
||||
@Nullable VirtualFile restrictedFile) {
|
||||
protected <K> void ensureUpToDate(@NotNull final ID<K, ?> indexId,
|
||||
@Nullable Project project,
|
||||
@Nullable GlobalSearchScope filter,
|
||||
@Nullable VirtualFile restrictedFile) {
|
||||
if (!needsFileContentLoading(indexId)) {
|
||||
return; //indexed eagerly in foreground while building unindexed file list
|
||||
}
|
||||
@@ -816,6 +811,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public <K, V> List<V> getValues(@NotNull final ID<K, V> indexId, @NotNull K dataKey, @NotNull final GlobalSearchScope filter) {
|
||||
final List<V> values = new SmartList<V>();
|
||||
@@ -829,6 +825,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public <K, V> Collection<VirtualFile> getContainingFiles(@NotNull final ID<K, V> indexId, @NotNull K dataKey, @NotNull final GlobalSearchScope filter) {
|
||||
final Set<VirtualFile> files = new THashSet<VirtualFile>();
|
||||
@@ -843,18 +840,10 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
|
||||
|
||||
public interface ValueProcessor<V> {
|
||||
/**
|
||||
* @param value a value to process
|
||||
* @param file the file the value came from
|
||||
* @return false if no further processing is needed, true otherwise
|
||||
*/
|
||||
boolean process(VirtualFile file, V value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false if ValueProcessor.process() returned false; true otherwise or if ValueProcessor was not called at all
|
||||
*/
|
||||
@Override
|
||||
public <K, V> boolean processValues(@NotNull final ID<K, V> indexId, @NotNull final K dataKey, @Nullable final VirtualFile inFile,
|
||||
@NotNull ValueProcessor<V> processor, @NotNull final GlobalSearchScope filter) {
|
||||
return processValuesImpl(indexId, dataKey, false, inFile, processor, filter);
|
||||
@@ -952,6 +941,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return result == null || result.booleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> boolean processFilesContainingAllKeys(@NotNull final ID<K, V> indexId,
|
||||
@NotNull final Collection<K> dataKeys,
|
||||
@NotNull final GlobalSearchScope filter,
|
||||
@@ -1114,6 +1104,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> boolean getFilesWithKey(@NotNull final ID<K, V> indexId,
|
||||
@NotNull final Set<K> dataKeys,
|
||||
@NotNull Processor<VirtualFile> processor,
|
||||
@@ -1208,6 +1199,7 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K> void scheduleRebuild(@NotNull final ID<K, ?> indexId, @NotNull final Throwable e) {
|
||||
LOG.info(e);
|
||||
requestRebuild(indexId);
|
||||
@@ -1524,11 +1516,8 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public static void requestRebuild(ID<?, ?> indexId) {
|
||||
requestRebuild(indexId, new Throwable());
|
||||
}
|
||||
|
||||
public static void requestRebuild(ID<?, ?> indexId, Throwable throwable) {
|
||||
@Override
|
||||
public void requestRebuild(ID<?, ?> indexId, Throwable throwable) {
|
||||
cleanupProcessedFlag();
|
||||
LOG.info("Rebuild requested for index " + indexId, throwable);
|
||||
ourRebuildStatus.get(indexId).set(REQUIRES_REBUILD);
|
||||
@@ -1685,14 +1674,6 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getFileId(@NotNull final VirtualFile file) {
|
||||
if (file instanceof VirtualFileWithId) {
|
||||
return ((VirtualFileWithId)file).getId();
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Virtual file doesn't support id: " + file + ", implementation class: " + file.getClass().getName());
|
||||
}
|
||||
|
||||
private boolean needsFileContentLoading(ID<?, ?> indexId) {
|
||||
return !myNotRequiringContentIndices.contains(indexId);
|
||||
}
|
||||
@@ -2157,11 +2138,13 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return new UnindexedFilesFinder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIndexableSet(@NotNull IndexableFileSet set, @Nullable Project project) {
|
||||
myIndexableSets.add(set);
|
||||
myIndexableSetToProjectMap.put(set, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeIndexableSet(@NotNull IndexableFileSet set) {
|
||||
myChangedFilesCollector.forceUpdate(null, null, null, true);
|
||||
myIndexableSets.remove(set);
|
||||
@@ -2207,7 +2190,8 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public static void iterateIndexableFiles(@NotNull final ContentIterator processor, @NotNull Project project, ProgressIndicator indicator) {
|
||||
@Override
|
||||
public void iterateIndexableFiles(@NotNull final ContentIterator processor, @NotNull Project project, ProgressIndicator indicator) {
|
||||
if (project.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
@@ -42,12 +42,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collection;
|
||||
|
||||
public class FileBasedIndexProjectHandler extends AbstractProjectComponent implements IndexableFileSet {
|
||||
private final FileBasedIndex myIndex;
|
||||
private final FileBasedIndexImpl myIndex;
|
||||
private final ProjectRootManagerEx myRootManager;
|
||||
private final FileTypeManager myFileTypeManager;
|
||||
private final ProjectFileExclusionManagerImpl myExclusionManager;
|
||||
|
||||
public FileBasedIndexProjectHandler(final FileBasedIndex index, final Project project, final ProjectRootManagerEx rootManager, FileTypeManager ftManager, final ProjectManager projectManager) {
|
||||
public FileBasedIndexProjectHandler(final FileBasedIndexImpl index, final Project project, final ProjectRootManagerEx rootManager, FileTypeManager ftManager, final ProjectManager projectManager) {
|
||||
super(project);
|
||||
myIndex = index;
|
||||
myRootManager = rootManager;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -33,11 +33,11 @@ import java.util.List;
|
||||
*/
|
||||
public class UnindexedFilesUpdater implements CacheUpdater {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.UnindexedFilesUpdater");
|
||||
private final FileBasedIndex myIndex;
|
||||
private final FileBasedIndexImpl myIndex;
|
||||
private final Project myProject;
|
||||
private long myStarted;
|
||||
|
||||
public UnindexedFilesUpdater(final Project project, FileBasedIndex index) {
|
||||
public UnindexedFilesUpdater(final Project project, FileBasedIndexImpl index) {
|
||||
myIndex = index;
|
||||
myProject = project;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class UnindexedFilesUpdater implements CacheUpdater {
|
||||
public VirtualFile[] queryNeededFiles(ProgressIndicator indicator) {
|
||||
CollectingContentIterator finder = myIndex.createContentIterator();
|
||||
long l = System.currentTimeMillis();
|
||||
FileBasedIndex.iterateIndexableFiles(finder, myProject, indicator);
|
||||
FileBasedIndex.getInstance().iterateIndexableFiles(finder, myProject, indicator);
|
||||
LOG.info("Indexable files iterated in " + (System.currentTimeMillis() - l) + " ms");
|
||||
List<VirtualFile> files = finder.getFiles();
|
||||
LOG.info("Unindexed files update started: " + files.size() + " files to update");
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
<orderEntry type="library" name="swingx" level="project" />
|
||||
<orderEntry type="module" module-name="core-impl" exported="" />
|
||||
<orderEntry type="library" exported="" name="miglayout-swing" level="project" />
|
||||
<orderEntry type="module" module-name="indexing-api" />
|
||||
<orderEntry type="module" module-name="indexing-impl" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.intellij.ide.highlighter.custom.impl;
|
||||
|
||||
import com.intellij.ide.highlighter.custom.SyntaxTable;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import org.jdom.Element;
|
||||
|
||||
public class ReadFileType extends AbstractFileType {
|
||||
|
||||
+4
-2
@@ -38,7 +38,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class AbstractFileType extends UserFileType<AbstractFileType> implements ExternalizableFileType, ExternalizableScheme {
|
||||
public class AbstractFileType extends UserFileType<AbstractFileType> implements ExternalizableFileType, ExternalizableScheme,
|
||||
CustomSyntaxTableFileType {
|
||||
protected SyntaxTable mySyntaxTable;
|
||||
private SyntaxTable myDefaultSyntaxTable;
|
||||
protected Commenter myCommenter = null;
|
||||
@@ -76,6 +77,7 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyntaxTable getSyntaxTable() {
|
||||
return mySyntaxTable;
|
||||
}
|
||||
@@ -95,7 +97,7 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
|
||||
public void copyFrom(UserFileType newType) {
|
||||
super.copyFrom(newType);
|
||||
if (newType instanceof AbstractFileType) {
|
||||
mySyntaxTable = ((AbstractFileType)newType).getSyntaxTable();
|
||||
mySyntaxTable = ((CustomSyntaxTableFileType)newType).getSyntaxTable();
|
||||
myExternalInfo.copy(((AbstractFileType)newType).myExternalInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<implementation-class>com.intellij.util.indexing.FileBasedIndex</implementation-class>
|
||||
<interface-class>com.intellij.util.indexing.FileBasedIndex</interface-class>
|
||||
<implementation-class>com.intellij.util.indexing.FileBasedIndexImpl</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<interface-class>com.intellij.psi.stubs.StubIndex</interface-class>
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.util.graph;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.util.graph.impl.KShortestPathsFinder;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.ModuleAdapter;
|
||||
import com.intellij.openapi.project.ModuleListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
@@ -93,6 +92,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.LocalTimeCounter;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FileBasedIndexImpl;
|
||||
import com.intellij.util.indexing.IndexableFileSet;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -234,7 +234,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
FileBasedIndex.getInstance().registerIndexableSet(new IndexableFileSet() {
|
||||
((FileBasedIndexImpl)FileBasedIndex.getInstance()).registerIndexableSet(new IndexableFileSet() {
|
||||
@Override
|
||||
public boolean isInSet(@NotNull final VirtualFile file) {
|
||||
return ourSourceRoot != null && file.getFileSystem() == ourSourceRoot.getFileSystem() && ourProject.isOpen();
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
package com.intellij.util.continuation;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
|
||||
import com.intellij.openapi.progress.impl.ProgressManagerImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.CalledInAny;
|
||||
import com.intellij.openapi.vcs.CalledInAwt;
|
||||
@@ -28,7 +24,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* @author irengrig
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.TestDialog;
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="core-api" />
|
||||
<orderEntry type="module" module-name="java-psi-api" />
|
||||
<orderEntry type="library" name="JUnit4" level="project" />
|
||||
|
||||
Reference in New Issue
Block a user