Merge remote branch 'origin/master'

This commit is contained in:
irengrig
2012-05-14 18:37:44 +04:00
500 changed files with 38046 additions and 2429 deletions
+1
View File
@@ -91,6 +91,7 @@
<module fileurl="file://$PROJECT_DIR$/platform/platform-resources-en/platform-resources-en.iml" filepath="$PROJECT_DIR$/platform/platform-resources-en/platform-resources-en.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/platform-tests/platform-tests.iml" filepath="$PROJECT_DIR$/platform/platform-tests/platform-tests.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/properties/properties.iml" filepath="$PROJECT_DIR$/plugins/properties/properties.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/rearranger/rearranger.iml" filepath="$PROJECT_DIR$/plugins/rearranger/rearranger.iml" />
<module fileurl="file://$PROJECT_DIR$/xml/relaxng/relaxng.iml" filepath="$PROJECT_DIR$/xml/relaxng/relaxng.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/resources/resources.iml" filepath="$PROJECT_DIR$/resources/resources.iml" />
<module fileurl="file://$PROJECT_DIR$/resources-en/resources-en.iml" filepath="$PROJECT_DIR$/resources-en/resources-en.iml" />
+6
View File
@@ -226,6 +226,12 @@ public def layoutCommunityPlugins(String home) {
module("gradle")
}
}
layoutPlugin("rearranger") {
jar("rearranger.jar") {
module("rearranger")
}
}
layoutPlugin("git4idea") {
jar("git4idea-rt.jar") {
+1
View File
@@ -237,6 +237,7 @@ binding.setVariable("platformApiModules", [
binding.setVariable("platformImplementationModules", [
"core-impl",
"indexing-impl",
"platform-impl",
"vcs-impl",
"lang-impl",
+1
View File
@@ -89,6 +89,7 @@
<orderEntry type="module" module-name="android" />
<orderEntry type="module" module-name="relaxng" />
<orderEntry type="module" module-name="gradle" />
<orderEntry type="module" module-name="rearranger" />
</component>
</module>
@@ -36,7 +36,7 @@ import java.io.IOException;
public class ImageInfoIndex extends SingleEntryFileBasedIndexExtension<ImageInfoIndex.ImageInfo> {
public static final ID<Integer, ImageInfo> INDEX_ID = ID.create("ImageFileInfoIndex");
private final InputFilter myInputFilter = new InputFilter() {
private final FileBasedIndex.InputFilter myInputFilter = new FileBasedIndex.InputFilter() {
@Override
public boolean acceptInput(final VirtualFile file) {
return (file.getFileSystem() == LocalFileSystem.getInstance() || file.getFileSystem() instanceof TempFileSystem) &&
@@ -89,7 +89,7 @@ public class ImageInfoIndex extends SingleEntryFileBasedIndexExtension<ImageInfo
}
@Override
public InputFilter getInputFilter() {
public FileBasedIndex.InputFilter getInputFilter() {
return myInputFilter;
}
@@ -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;
@@ -109,7 +109,7 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider<B
@Override
public String getDescription(BuildArtifactsBeforeRunTask task) {
final List<ArtifactPointer> pointers = task.getArtifactPointers();
if (!task.isEnabled() || pointers.isEmpty()) {
if (pointers.isEmpty()) {
return CompilerBundle.message("build.artifacts.before.run.description.empty");
}
if (pointers.size() == 1) {
@@ -16,7 +16,6 @@
package com.intellij.execution.application;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.RunConfigurationExtension;
import com.intellij.execution.configuration.ConfigurationFactoryEx;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationType;
@@ -48,11 +47,6 @@ public class ApplicationConfigurationType implements ConfigurationType {
return new ApplicationConfiguration("", project, ApplicationConfigurationType.this);
}
@Override
public Icon getIcon(@NotNull final RunConfiguration configuration) {
return getIcon();
}
@Override
public void onNewConfigurationCreated(@NotNull RunConfiguration configuration) {
((ModuleBasedConfiguration)configuration).onNewConfigurationCreated();
@@ -120,7 +120,7 @@ public class CodeStyleImportsPanel extends JPanel {
}
private JPanel createGeneralOptionsPanel() {
OptionGroup group = new OptionGroup(ApplicationBundle.message("title.general"), true);
OptionGroup group = new OptionGroup(ApplicationBundle.message("title.general"));
myCbUseSingleClassImports = new JCheckBox(ApplicationBundle.message("checkbox.use.single.class.import"));
group.add(myCbUseSingleClassImports);
@@ -32,7 +32,6 @@ import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.AllOverridingMethodsSearch;
import com.intellij.psi.search.searches.ClassInheritorsSearch;
@@ -61,8 +60,6 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
private static final Icon IMPLEMENTED_INTERFACE_MARKER_RENDERER = IMPLEMENTED_METHOD_MARKER_RENDERER;
private static final Icon SUBCLASSED_CLASS_MARKER_RENDERER = OVERRIDEN_METHOD_MARKER_RENDERER;
private static final Icon RECURSIVE_METHOD_ICON = IconLoader.getIcon("/gutter/recursiveMethod.png");
protected final DaemonCodeAnalyzerSettings myDaemonSettings;
protected final EditorColorsManager myColorsManager;
@@ -167,11 +164,6 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
}
else if (element instanceof PsiClass && !(element instanceof PsiTypeParameter)) {
collectInheritingClasses((PsiClass)element, result);
} else if(element instanceof PsiMethodCallExpression){
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element;
if (isRecursiveMethodCall(methodCall)){
result.add(new RecursiveMethodCallMarkerInfo(methodCall));
}
}
}
if (!methods.isEmpty()) {
@@ -179,14 +171,6 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
}
}
private static boolean isRecursiveMethodCall(@NotNull PsiMethodCallExpression methodCall){
PsiMethod referencedMethod = methodCall.resolveMethod();
TextRange rmRange = referencedMethod == null ? null : referencedMethod.getTextRange();
int mcOffset = methodCall.getTextRange().getStartOffset();
return rmRange != null && rmRange.contains(mcOffset);
}
private static void collectInheritingClasses(PsiClass aClass, Collection<LineMarkerInfo> result) {
if (aClass.hasModifierProperty(PsiModifier.FINAL)) {
return;
@@ -292,36 +276,4 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
};
}
}
private static class RecursiveMethodCallMarkerInfo extends MergeableLineMarkerInfo<PsiMethodCallExpression> {
private RecursiveMethodCallMarkerInfo(@NotNull PsiMethodCallExpression methodCall) {
super(methodCall,
methodCall.getTextRange(),
RECURSIVE_METHOD_ICON,
Pass.UPDATE_OVERRIDEN_MARKERS,
FunctionUtil.<PsiMethodCallExpression, String>constant("Recursive call"),
null,
GutterIconRenderer.Alignment.RIGHT
);
}
@Override
public boolean canMergeWith(@NotNull MergeableLineMarkerInfo<?> info) {
if (!(info instanceof RecursiveMethodCallMarkerInfo)) return false;
PsiElement otherElement = info.getElement();
PsiElement myElement = getElement();
return otherElement != null && myElement != null;
}
@Override
public Icon getCommonIcon(@NotNull List<MergeableLineMarkerInfo> infos) {
return myIcon;
}
@Override
public Function<? super PsiElement, String> getCommonTooltip(@NotNull List<MergeableLineMarkerInfo> infos) {
return FunctionUtil.<PsiElement, String>constant("Multiple recursive calls");
}
}
}
@@ -19,18 +19,22 @@ import com.intellij.analysis.AnalysisScope;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.reference.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.OverridingMethodsSearch;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
import com.intellij.util.IncorrectOperationException;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
@@ -40,6 +44,8 @@ import java.util.List;
public class UnusedReturnValue extends GlobalJavaInspectionTool{
private MakeVoidQuickFix myQuickFix;
public boolean IGNORE_BUILDER_PATTERN = false;
@Nullable
public CommonProblemDescriptor[] checkElement(RefEntity refEntity,
AnalysisScope scope,
@@ -54,8 +60,11 @@ public class UnusedReturnValue extends GlobalJavaInspectionTool{
if (refMethod.getInReferences().size() == 0) return null;
if (!refMethod.isReturnValueUsed()) {
return new ProblemDescriptor[]{manager.createProblemDescriptor(refMethod.getElement().getNavigationElement(),
InspectionsBundle.message("inspection.unused.return.value.problem.descriptor"),
final PsiMethod psiMethod = (PsiMethod)refMethod.getElement();
if (IGNORE_BUILDER_PATTERN && PropertyUtil.isSimplePropertySetter(psiMethod)) return null;
return new ProblemDescriptor[]{manager.createProblemDescriptor(psiMethod.getNavigationElement(),
InspectionsBundle
.message("inspection.unused.return.value.problem.descriptor"),
getFix(processor), ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
false)};
}
@@ -64,6 +73,17 @@ public class UnusedReturnValue extends GlobalJavaInspectionTool{
return null;
}
@Override
public void writeSettings(Element node) throws WriteExternalException {
if (IGNORE_BUILDER_PATTERN) {
super.writeSettings(node);
}
}
@Override
public JComponent createOptionsPanel() {
return new SingleCheckboxOptionsPanel("Ignore simple setters", this, "IGNORE_BUILDER_PATTERN");
}
protected boolean queryExternalUsagesRequests(final RefManager manager, final GlobalJavaInspectionContext globalContext,
final ProblemDescriptionsProcessor processor) {
@@ -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.
@@ -25,6 +25,8 @@ import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.JavaDocTokenType;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.StringEscapesTokenTypes;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.ElementType;
import com.intellij.psi.impl.source.tree.JavaDocElementType;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.xml.XmlTokenType;
@@ -51,9 +53,8 @@ public class JavaFileHighlighter extends SyntaxHighlighterBase {
ourMap1 = new HashMap<IElementType, TextAttributesKey>();
ourMap2 = new HashMap<IElementType, TextAttributesKey>();
fillMap(ourMap1, JavaTokenType.KEYWORD_BIT_SET, SyntaxHighlighterColors.KEYWORD);
fillMap(ourMap1, JavaTokenType.OPERATION_BIT_SET, SyntaxHighlighterColors.OPERATION_SIGN);
fillMap(ourMap1, JavaTokenType.OPERATION_BIT_SET, SyntaxHighlighterColors.OPERATION_SIGN);
fillMap(ourMap1, ElementType.KEYWORD_BIT_SET, SyntaxHighlighterColors.KEYWORD);
fillMap(ourMap1, ElementType.OPERATION_BIT_SET, SyntaxHighlighterColors.OPERATION_SIGN);
for (IElementType type : JavaDocTokenType.ALL_JAVADOC_TOKENS.getTypes()) {
ourMap1.put(type, SyntaxHighlighterColors.DOC_COMMENT);
@@ -86,12 +87,10 @@ public class JavaFileHighlighter extends SyntaxHighlighterBase {
ourMap1.put(JavaTokenType.DOT, SyntaxHighlighterColors.DOT);
ourMap1.put(JavaTokenType.SEMICOLON, SyntaxHighlighterColors.JAVA_SEMICOLON);
//ourMap1[JavaTokenType.BOOLEAN_LITERAL] = HighlighterColors.JAVA_KEYWORD;
//ourMap1[JavaTokenType.NULL_LITERAL] = HighlighterColors.JAVA_KEYWORD;
ourMap1.put(JavaTokenType.C_STYLE_COMMENT, SyntaxHighlighterColors.JAVA_BLOCK_COMMENT);
ourMap1.put(JavaDocElementType.DOC_COMMENT, SyntaxHighlighterColors.DOC_COMMENT);
ourMap1.put(JavaTokenType.END_OF_LINE_COMMENT, SyntaxHighlighterColors.LINE_COMMENT);
ourMap1.put(JavaTokenType.BAD_CHARACTER, HighlighterColors.BAD_CHARACTER);
ourMap1.put(TokenType.BAD_CHARACTER, HighlighterColors.BAD_CHARACTER);
ourMap1.put(JavaDocTokenType.DOC_TAG_NAME, SyntaxHighlighterColors.DOC_COMMENT);
ourMap2.put(JavaDocTokenType.DOC_TAG_NAME, SyntaxHighlighterColors.DOC_COMMENT_TAG);
@@ -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.
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.cache.impl.idCache;
import com.intellij.lexer.Lexer;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.cache.impl.BaseFilterLexer;
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
import com.intellij.psi.impl.source.tree.ElementType;
@@ -30,7 +31,7 @@ import com.intellij.psi.tree.TokenSet;
public class JavaFilterLexer extends BaseFilterLexer {
private static final TokenSet ourSkipWordsScanSet = TokenSet.orSet(
TokenSet.create(
JavaTokenType.WHITE_SPACE,
TokenType.WHITE_SPACE,
JavaTokenType.LPARENTH,
JavaTokenType.RPARENTH,
JavaTokenType.LBRACE,
@@ -43,7 +44,7 @@ public class JavaFilterLexer extends BaseFilterLexer {
JavaTokenType.ELLIPSIS,
JavaTokenType.AT
),
JavaTokenType.OPERATION_BIT_SET
ElementType.OPERATION_BIT_SET
);
public JavaFilterLexer(final Lexer originalLexer, final OccurrenceConsumer table) {
@@ -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;
}
File diff suppressed because it is too large Load Diff
@@ -121,7 +121,7 @@ public class MoveMembersDialog extends RefactoringDialog implements MoveMembersO
}
myMemberInfos = memberList;
String fqName = initialTargetClass != null && !sourceClass.equals(initialTargetClass) ? initialTargetClass.getQualifiedName() : "";
myTfTargetClassName = new ReferenceEditorComboWithBrowseButton(new ChooseClassAction(), fqName, myProject, true, RECENTS_KEY);
myTfTargetClassName = new ReferenceEditorComboWithBrowseButton(new ChooseClassAction(), fqName, myProject, true, JavaCodeFragment.VisibilityChecker.PROJECT_SCOPE_VISIBLE, RECENTS_KEY);
init();
}
@@ -60,7 +60,9 @@ public class ConstructorParameterOnFieldRenameRenamer extends AutomaticRenamer {
if (constructor instanceof LightElement) continue;
final PsiParameter[] parameters = constructor.getParameterList().getParameters();
for (final PsiParameter parameter : parameters) {
if (paramName.equals(parameter.getName())) {
final String parameterName = parameter.getName();
if (paramName.equals(parameterName) ||
propertyName.equals(styleManager.variableNameToPropertyName(parameterName, VariableKind.PARAMETER))) {
toRename.add(parameter);
}
}
@@ -34,7 +34,16 @@ public class ReferenceEditorComboWithBrowseButton extends ComponentWithBrowseBut
final String text,
@NotNull final Project project,
boolean toAcceptClasses, final String recentsKey) {
super(new EditorComboBox(createDocument(text, project, toAcceptClasses), project, StdFileTypes.JAVA), browseActionListener);
this(browseActionListener, text, project, toAcceptClasses, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, recentsKey);
}
public ReferenceEditorComboWithBrowseButton(final ActionListener browseActionListener,
final String text,
@NotNull final Project project,
boolean toAcceptClasses,
final JavaCodeFragment.VisibilityChecker visibilityChecker, final String recentsKey) {
super(new EditorComboBox(createDocument(text, project, toAcceptClasses, visibilityChecker), project, StdFileTypes.JAVA),
browseActionListener);
final List<String> recentEntries = RecentsManager.getInstance(project).getRecentEntries(recentsKey);
if (recentEntries != null) {
setHistory(ArrayUtil.toStringArray(recentEntries));
@@ -44,10 +53,13 @@ public class ReferenceEditorComboWithBrowseButton extends ComponentWithBrowseBut
}
}
private static Document createDocument(final String text, Project project, boolean isClassesAccepted) {
private static Document createDocument(final String text,
Project project,
boolean isClassesAccepted,
final JavaCodeFragment.VisibilityChecker visibilityChecker) {
PsiPackage defaultPackage = JavaPsiFacade.getInstance(project).findPackage("");
final JavaCodeFragment fragment = JavaCodeFragmentFactory.getInstance(project).createReferenceCodeFragment(text, defaultPackage, true, isClassesAccepted);
fragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
fragment.setVisibilityChecker(visibilityChecker);
return PsiDocumentManager.getInstance(project).getDocument(fragment);
}
@@ -139,6 +139,13 @@ public interface JavaCodeFragment extends PsiImportHolder, PsiCodeFragment {
return Visibility.VISIBLE;
}
};
VisibilityChecker PROJECT_SCOPE_VISIBLE = new VisibilityChecker() {
@Override
public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
return declaration.getManager().isInProject(declaration) ? Visibility.VISIBLE : Visibility.NOT_VISIBLE;
}
};
}
/**
@@ -20,8 +20,7 @@ import com.intellij.psi.tree.TokenSet;
import com.intellij.psi.tree.java.IJavaElementType;
import com.intellij.psi.tree.java.IKeywordElementType;
public interface JavaTokenType extends TokenType{
public interface JavaTokenType extends TokenType {
IElementType IDENTIFIER = new IJavaElementType("IDENTIFIER");
IElementType C_STYLE_COMMENT = new IJavaElementType("C_STYLE_COMMENT");
IElementType END_OF_LINE_COMMENT = new IJavaElementType("END_OF_LINE_COMMENT");
@@ -87,7 +86,6 @@ public interface JavaTokenType extends TokenType{
IElementType TRY_KEYWORD = new IKeywordElementType("TRY_KEYWORD");
IElementType VOLATILE_KEYWORD = new IKeywordElementType("VOLATILE_KEYWORD");
IElementType THROWS_KEYWORD = new IKeywordElementType("THROWS_KEYWORD");
IElementType NONE_KEYWORD = new IKeywordElementType("NONE_KEYWORD");
IElementType LPARENTH = new IJavaElementType("LPARENTH");
IElementType RPARENTH = new IJavaElementType("RPARENTH");
@@ -143,13 +141,15 @@ public interface JavaTokenType extends TokenType{
IElementType DOUBLE_COLON = new IJavaElementType("DOUBLE_COLON");
IElementType ARROW = new IJavaElementType("ARROW");
TokenSet OPERATION_BIT_SET = TokenSet.create(
/** @deprecated use {@linkplain com.intellij.psi.impl.source.tree.ElementType#OPERATION_BIT_SET} (to remove in IDEA 13) */
@SuppressWarnings("UnusedDeclaration") TokenSet OPERATION_BIT_SET = TokenSet.create(
EQ, GT, LT, EXCL, TILDE, QUEST, COLON, PLUS, MINUS, ASTERISK, DIV, AND, OR, XOR,
PERC, EQEQ, LE, GE, NE, ANDAND, OROR, PLUSPLUS, MINUSMINUS, LTLT, GTGT, GTGTGT,
PLUSEQ, MINUSEQ, ASTERISKEQ, DIVEQ, ANDEQ, OREQ, XOREQ, PERCEQ, LTLTEQ, GTGTEQ, GTGTGTEQ
);
TokenSet KEYWORD_BIT_SET = TokenSet.create(
/** @deprecated use {@linkplain com.intellij.psi.impl.source.tree.ElementType#KEYWORD_BIT_SET} (to remove in IDEA 13) */
@SuppressWarnings("UnusedDeclaration") TokenSet KEYWORD_BIT_SET = TokenSet.create(
ABSTRACT_KEYWORD, ASSERT_KEYWORD, BOOLEAN_KEYWORD, BREAK_KEYWORD, BYTE_KEYWORD, CASE_KEYWORD,
CATCH_KEYWORD, CHAR_KEYWORD, CLASS_KEYWORD, CONST_KEYWORD, CONTINUE_KEYWORD,
DEFAULT_KEYWORD, DO_KEYWORD, DOUBLE_KEYWORD, ELSE_KEYWORD, ENUM_KEYWORD, EXTENDS_KEYWORD,
@@ -162,7 +162,8 @@ public interface JavaTokenType extends TokenType{
VOID_KEYWORD, VOLATILE_KEYWORD, WHILE_KEYWORD, TRUE_KEYWORD, FALSE_KEYWORD, NULL_KEYWORD
);
TokenSet MODIFIER_BIT_SET = TokenSet.create(
/** @deprecated use {@linkplain com.intellij.psi.impl.source.tree.ElementType#MODIFIER_BIT_SET} (to remove in IDEA 13) */
@SuppressWarnings("UnusedDeclaration") TokenSet MODIFIER_BIT_SET = TokenSet.create(
PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_KEYWORD, STATIC_KEYWORD,
ABSTRACT_KEYWORD, FINAL_KEYWORD, NATIVE_KEYWORD, STRICTFP_KEYWORD,
SYNCHRONIZED_KEYWORD, TRANSIENT_KEYWORD, VOLATILE_KEYWORD
@@ -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);
}
@@ -25,6 +25,9 @@ import com.intellij.openapi.roots.PackageIndex;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClassOwner;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiPackage;
import org.jetbrains.annotations.NotNull;
@@ -35,6 +38,9 @@ public class PackageScope extends GlobalSearchScope {
private final PsiPackage myPackage;
private final boolean myIncludeSubpackages;
private final boolean myIncludeLibraries;
protected final boolean myPartOfPackagePrefix;
protected final String myPackageQualifiedName;
protected final String myPackageQNamePrefix;
public PackageScope(@NotNull PsiPackage aPackage, boolean includeSubpackages, final boolean includeLibraries) {
super(aPackage.getProject());
@@ -42,8 +48,12 @@ public class PackageScope extends GlobalSearchScope {
myIncludeSubpackages = includeSubpackages;
Project project = myPackage.getProject();
myDirs = PackageIndex.getInstance(project).getDirsByPackageName(myPackage.getQualifiedName(), true).findAll();
myPackageQualifiedName = myPackage.getQualifiedName();
myDirs = PackageIndex.getInstance(project).getDirsByPackageName(myPackageQualifiedName, true).findAll();
myIncludeLibraries = includeLibraries;
myPartOfPackagePrefix = JavaPsiFacade.getInstance(getProject()).isPartOfPackagePrefix(myPackageQualifiedName);
myPackageQNamePrefix = myPackageQualifiedName + ".";
}
@Override
@@ -54,6 +64,14 @@ public class PackageScope extends GlobalSearchScope {
: Comparing.equal(file.getParent(), scopeDir);
if (inDir) return true;
}
if (myPartOfPackagePrefix && myIncludeSubpackages) {
final PsiFile psiFile = myPackage.getManager().findFile(file);
if (psiFile instanceof PsiClassOwner) {
final String packageName = ((PsiClassOwner)psiFile).getPackageName();
if (myPackageQualifiedName.equals(packageName) ||
packageName.startsWith(myPackageQNamePrefix)) return true;
}
}
return false;
}
@@ -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);
@@ -30,7 +30,6 @@ import java.util.Set;
public class JavaLexer extends LexerBase {
private static final HashTable[] TABLES = new HashTable[]{
new HashTable(LanguageLevel.JDK_1_8),
new HashTable(LanguageLevel.JDK_1_5),
new HashTable(LanguageLevel.JDK_1_4),
new HashTable(LanguageLevel.JDK_1_3)
@@ -118,9 +117,6 @@ public class JavaLexer extends LexerBase {
add("assert", JavaTokenType.ASSERT_KEYWORD);
if (level.isAtLeast(LanguageLevel.JDK_1_5)) {
add("enum", JavaTokenType.ENUM_KEYWORD);
if (level.isAtLeast(LanguageLevel.JDK_1_8)) {
add("none", JavaTokenType.NONE_KEYWORD);
}
}
}
add("abstract", JavaTokenType.ABSTRACT_KEYWORD);
@@ -12,13 +12,11 @@ import com.intellij.psi.tree.IElementType;
%{
private boolean myAssertKeyword;
private boolean myEnumKeyword;
private boolean myNoneKeyword;
public _JavaLexer(LanguageLevel level) {
this((java.io.Reader)null);
myAssertKeyword = level.isAtLeast(LanguageLevel.JDK_1_4);
myEnumKeyword = level.isAtLeast(LanguageLevel.JDK_1_5);
myNoneKeyword = level.isAtLeast(LanguageLevel.JDK_1_8);
}
public void goTo(int offset) {
@@ -154,7 +152,6 @@ ESCAPE_SEQUENCE=\\[^\r\n]
<YYINITIAL> "try" { return JavaTokenType.TRY_KEYWORD; }
<YYINITIAL> "volatile" { return JavaTokenType.VOLATILE_KEYWORD; }
<YYINITIAL> "throws" { return JavaTokenType.THROWS_KEYWORD; }
<YYINITIAL> "none" { return myNoneKeyword ? JavaTokenType.NONE_KEYWORD : JavaTokenType.IDENTIFIER; }
<YYINITIAL> {IDENTIFIER} { return JavaTokenType.IDENTIFIER; }
File diff suppressed because it is too large Load Diff
@@ -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.
@@ -40,6 +40,11 @@ public interface ElementType extends JavaTokenType, JavaDocTokenType,
TRANSIENT_KEYWORD, RETURN_KEYWORD, VOID_KEYWORD, STATIC_KEYWORD, WHILE_KEYWORD, TRY_KEYWORD, VOLATILE_KEYWORD, THROWS_KEYWORD,
ENUM_KEYWORD);
TokenSet OPERATION_BIT_SET = TokenSet.create(
EQ, GT, LT, EXCL, TILDE, QUEST, COLON, PLUS, MINUS, ASTERISK, DIV, AND, OR, XOR,
PERC, EQEQ, LE, GE, NE, ANDAND, OROR, PLUSPLUS, MINUSMINUS, LTLT, GTGT, GTGTGT,
PLUSEQ, MINUSEQ, ASTERISKEQ, DIVEQ, ANDEQ, OREQ, XOREQ, PERCEQ, LTLTEQ, GTGTEQ, GTGTGTEQ);
TokenSet MODIFIER_BIT_SET = TokenSet.create(
PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_KEYWORD, STATIC_KEYWORD, ABSTRACT_KEYWORD, FINAL_KEYWORD, NATIVE_KEYWORD, SYNCHRONIZED_KEYWORD,
STRICTFP_KEYWORD, TRANSIENT_KEYWORD, VOLATILE_KEYWORD);
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
@@ -0,0 +1,13 @@
class Test {
private String myStr;
public Test setStr(String str) {
myStr = str;
return this;
}
public static void main(String[] args) {
final Test test = new Test();
test.setStr("");
}
}
@@ -0,0 +1,7 @@
class Test {
private boolean is<caret>Flag = false;
public Test(boolean isFlag) {
this.isFlag = isFlag;
}
}
@@ -0,0 +1,7 @@
class Test {
private boolean pp = false;
public Test(boolean pp) {
this.pp = pp;
}
}
@@ -0,0 +1,79 @@
/*
* 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.codeInspection;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
import com.intellij.testFramework.LightIdeaTestCase;
/**
* @author Dmitry Avdeev
* Date: 5/10/12
*/
public class SingleInspectionProfilePanelTest extends LightIdeaTestCase {
// see IDEA-85700
public void testSettingsModification() throws Exception {
Project project = ProjectManager.getInstance().getDefaultProject();
InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE);
profile.initInspectionTools(project);
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model);
panel.setVisible(true);
panel.reset();
LocalInspectionToolWrapper wrapper = (LocalInspectionToolWrapper)model.getInspectionTool(myInspection.getShortName());
assert wrapper != null;
JavaDocLocalInspection tool = (JavaDocLocalInspection)wrapper.getTool();
assertEquals("", tool.myAdditionalJavadocTags);
tool.myAdditionalJavadocTags = "foo";
model.setModified(true);
panel.apply();
wrapper = (LocalInspectionToolWrapper)profile.getInspectionTool(myInspection.getShortName());
assert wrapper != null;
tool = (JavaDocLocalInspection)wrapper.getTool();
assertEquals("foo", tool.myAdditionalJavadocTags);
}
@Override
public void setUp() throws Exception {
InspectionProfileImpl.INIT_INSPECTIONS = true;
super.setUp();
}
@Override
public void tearDown() throws Exception {
InspectionProfileImpl.INIT_INSPECTIONS = false;
super.tearDown();
}
private final JavaDocLocalInspection myInspection = new JavaDocLocalInspection();
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
return new LocalInspectionTool[] {myInspection};
}
}
@@ -35,4 +35,14 @@ public class UnusedReturnValueTest extends InspectionTestCase {
doTest();
}
public void testSimpleSetter() throws Exception {
try {
myTool.IGNORE_BUILDER_PATTERN = true;
doTest();
}
finally {
myTool.IGNORE_BUILDER_PATTERN = false;
}
}
}
@@ -136,7 +136,7 @@ public class JavaLexerTest extends LexerTestCase {
public void testJava8Tokens() {
doTest("none :: ->",
"NONE_KEYWORD ('none')\nWHITE_SPACE (' ')\nDOUBLE_COLON ('::')\nWHITE_SPACE (' ')\nARROW ('->')");
"IDENTIFIER ('none')\nWHITE_SPACE (' ')\nDOUBLE_COLON ('::')\nWHITE_SPACE (' ')\nARROW ('->')");
}
@Override
@@ -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
@@ -78,6 +78,10 @@ public class RenameLocalTest extends LightRefactoringTestCase {
public void testRenameInPlaceParamInOverriderAutomaticRenamer() throws Exception {
doTestInplaceRename("pp");
}
public void testRenameFieldWithConstructorParamAutomatic() throws Exception {
doTest("pp");
}
public void testRenameInPlaceParamInOverriderAutomaticRenamerConflict() throws Exception {
doTestInplaceRename("pp");
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.jetbrains.ether.StorageDumper
@@ -0,0 +1,145 @@
package org.jetbrains.ether;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.ether.dependencyView.Mappings;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.Sdk;
import org.jetbrains.jps.idea.IdeaProjectLoader;
import org.jetbrains.jps.incremental.Utils;
import org.jetbrains.jps.server.ClasspathBootstrap;
import java.io.File;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
/**
* Created with IntelliJ IDEA.
* User: db
* Date: 14.05.12
* Time: 13:02
* To change this template use File | Settings | File Templates.
*/
public class StorageDumper {
private static class Env {
final String myProjectPath;
final String myOutputPath;
final String myErrors;
final boolean myHelp;
Env(final String[] args) {
int s = 0;
String projectPath = null;
String outputPath = null;
boolean help = false;
final StringBuilder errors = new StringBuilder();
for (final String arg : args) {
switch (s) {
case 0: // Initial state
if (arg.equals("-o")) {
s = 1;
}
else if (arg.equals("-h")) {
help = true;
}
else if (arg.startsWith("-")) {
errors.append("Unrecognized option: ");
errors.append(arg);
errors.append("\n");
}
else {
if (projectPath != null) {
errors.append("Multiple storage paths specified, skipping ");
errors.append(arg);
errors.append("\n");
}
else {
projectPath = arg;
}
}
break;
case 1: // -o
if (arg.startsWith("-")) {
errors.append("Output path expected after \"-o\", but found: ");
errors.append(arg);
errors.append("\n");
}
else {
if (outputPath != null) {
errors.append("Multiple output paths specified, skipping ");
errors.append(arg);
errors.append("\n");
}
else {
outputPath = arg;
}
}
s = 0;
}
}
myOutputPath = outputPath;
myProjectPath = projectPath;
myHelp = help;
myErrors = errors.toString();
}
String getProjectPath() {
return myProjectPath;
}
String getOutputPath() {
return myOutputPath;
}
String getErrors() {
return myErrors;
}
void report() {
if (myHelp) {
System.out.println("Usage: <executable> [-o <output-path> | -h ] <storage-path>");
System.out.println();
}
System.err.println(myErrors);
}
}
public static void main(final String[] args) {
final Env env = new Env(args);
env.report();
final String path = env.getProjectPath();
final String oath = env.getOutputPath();
if (path == null) {
System.err.println("No project path specified.");
}
else {
try {
final String outputPath = (oath == null ? "" : oath) + File.separator + "snapshot-" + new SimpleDateFormat("dd-MM-yy(hh:mm:ss)").format(new Date()) + ".log";
final File dataStorageRoot = new File(path + File.separator + "mappings");
final Mappings mappings = new Mappings(dataStorageRoot, true);
final PrintStream p = new PrintStream(outputPath);
mappings.toStream(p);
p.close();
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
@@ -155,7 +155,7 @@ class ClassfileAnalyzer {
final int methodName = context.get(name);
if (value instanceof Type) {
final String className = ((Type)value).getClassName();
final String className = ((Type)value).getClassName().replace('.', '/');
if (className != null) {
usages.addUsage(residence, UsageRepr.createClassUsage(context, context.get(className)));
@@ -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,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,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,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,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,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,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,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,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.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);
}
/**
* Author: dmitrylomov
*/
public static interface InputFilter {
boolean acceptInput(VirtualFile file);
}
}
@@ -44,7 +44,7 @@ public abstract class FileBasedIndexExtension<K, V> {
public abstract DataExternalizer<V> getValueExternalizer();
public abstract InputFilter getInputFilter();
public abstract FileBasedIndex.InputFilter getInputFilter();
public abstract boolean dependsOnFileContent();
+1
View File
@@ -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>
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.util.indexing;
package com.intellij.openapi.fileTypes.impl;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ide.highlighter.custom.SyntaxTable;
import com.intellij.openapi.fileTypes.FileType;
/**
* Author: dmitrylomov
*/
public interface InputFilter {
boolean acceptInput(VirtualFile file);
* Author: dmitrylomov
*/
public interface CustomSyntaxTableFileType extends FileType {
SyntaxTable getSyntaxTable();
}
@@ -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,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,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.
@@ -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,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;
/**
@@ -55,6 +55,8 @@ public abstract class BeforeRunTask<T extends BeforeRunTask> implements Cloneabl
if (attribValue == null) {
attribValue = element.getAttributeValue("value"); // maintain compatibility with old format
}
if (attribValue == null)
attribValue = "true";
myIsEnabled = Boolean.valueOf(attribValue).booleanValue();
}
@@ -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
View File
@@ -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>
@@ -112,7 +112,6 @@ public class ExportToHTMLDialog extends DialogWrapper {
CodeEditorBundle.message("export.to.html.select.output.directory.description"),
project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
labeledComponent.setComponent(targetDirectoryField);
labeledComponent.setBorder(BorderFactory.createEmptyBorder(5, 4, 0, 0));
return labeledComponent;
}
@@ -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();
}
@@ -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() {
@@ -53,7 +53,10 @@ public abstract class RunManagerEx extends RunManager {
@NotNull
public abstract RunnerAndConfigurationSettings createConfiguration(String name, ConfigurationFactory type);
public abstract void addConfiguration(RunnerAndConfigurationSettings settings, boolean isShared, List<BeforeRunTask> tasks);
public abstract void addConfiguration(RunnerAndConfigurationSettings settings,
boolean isShared,
List<BeforeRunTask> tasks,
boolean addTemplateTasksIfAbsent);
public abstract void addConfiguration(final RunnerAndConfigurationSettings settings, final boolean isShared);
@@ -62,14 +65,11 @@ public abstract class RunManagerEx extends RunManager {
@NotNull
public abstract List<BeforeRunTask> getBeforeRunTasks(RunConfiguration settings);
@NotNull
public abstract List<BeforeRunTask> getBeforeRunTasks(RunConfiguration settings, boolean includeOnlyActiveTasks);
@NotNull
public abstract <T extends BeforeRunTask> List<T> getBeforeRunTasks(RunConfiguration settings, Key<T> taskProviderID);
@NotNull
public abstract <T extends BeforeRunTask> List<T> getBeforeRunTasks(Key<T> taskProviderID, boolean includeOnlyActiveTasks);
public abstract <T extends BeforeRunTask> List<T> getBeforeRunTasks(Key<T> taskProviderID);
public abstract RunnerAndConfigurationSettings findConfigurationByName(@Nullable final String name);
@@ -122,7 +122,8 @@ public class CreateAction extends BaseRunConfigurationAction {
final RunnerAndConfigurationSettings configuration = context.getConfiguration();
final RunnerAndConfigurationSettings template = runManager.getConfigurationTemplate(configuration.getFactory());
final RunConfiguration templateConfiguration = template.getConfiguration();
runManager.addConfiguration(configuration, runManager.isConfigurationShared(template), runManager.getBeforeRunTasks( templateConfiguration));
runManager.addConfiguration(configuration, runManager.isConfigurationShared(template), runManager.getBeforeRunTasks( templateConfiguration),
false);
runManager.setActiveConfiguration(configuration);
}
}
@@ -139,7 +140,7 @@ public class CreateAction extends BaseRunConfigurationAction {
final RunManagerImpl runManager = (RunManagerImpl)context.getRunManager();
runManager.addConfiguration(configuration,
runManager.isConfigurationShared(configuration),
runManager.getBeforeRunTasks(configuration.getConfiguration()));
runManager.getBeforeRunTasks(configuration.getConfiguration()), false);
runManager.setActiveConfiguration(configuration);
}
}
@@ -235,7 +235,7 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
tasks.remove(task);
}
}
runManager.setBeforeRunTasks(config, tasks);
runManager.setBeforeRunTasks(config, tasks, false);
}
protected abstract void update(T task);
@@ -120,7 +120,7 @@ class BeforeRunStepsPanel extends JPanel {
myRunConfiguration = settings.getConfiguration();
originalTasks.clear();
originalTasks.addAll(RunManagerImpl.getInstanceImpl(myRunConfiguration.getProject()).getBeforeRunTasks(myRunConfiguration, true));
originalTasks.addAll(RunManagerImpl.getInstanceImpl(myRunConfiguration.getProject()).getBeforeRunTasks(myRunConfiguration));
myModel.replaceAll(originalTasks);
myShowSettingsBeforeRunCheckBox.setSelected(settings.isEditBeforeRun());
myShowSettingsBeforeRunCheckBox.setEnabled(!(myRunConfiguration instanceof UnknownRunConfiguration));
@@ -205,11 +205,11 @@ class BeforeRunStepsPanel extends JPanel {
= (RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask)task;
RunConfiguration configuration = runTask.getSettings().getConfiguration();
List<BeforeRunTask> tasks = RunManagerImpl.getInstanceImpl(configuration.getProject()).getBeforeRunTasks(configuration, true);
List<BeforeRunTask> tasks = RunManagerImpl.getInstanceImpl(configuration.getProject()).getBeforeRunTasks(configuration);
for (BeforeRunTask beforeRunTask : tasks) {
if (beforeRunTask instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
configurationSet.add(((RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask)beforeRunTask).getSettings().getConfiguration());
getAllRunBeforeRuns(beforeRunTask, configurationSet);
if (configurationSet.add(((RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask)beforeRunTask).getSettings().getConfiguration()))
getAllRunBeforeRuns(beforeRunTask, configurationSet);
}
}
}
@@ -114,7 +114,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
private void doApply(final RunnerAndConfigurationSettings settings) {
final RunConfiguration runConfiguration = settings.getConfiguration();
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(runConfiguration.getProject());
runManager.setBeforeRunTasks(runConfiguration, myBeforeRunStepsPanel.getTasks(true));
runManager.setBeforeRunTasks(runConfiguration, myBeforeRunStepsPanel.getTasks(true), false);
runManager.shareConfiguration(runConfiguration, myStoreProjectConfiguration);
RunnerAndConfigurationSettings runManagerSettings = runManager.getSettings(runConfiguration);
if (runManagerSettings != null) {
@@ -125,7 +125,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
}
public List<BeforeRunTask> getStepsBeforeLaunch() {
return Collections.unmodifiableList(myBeforeRunStepsPanel.getTasks(false));
return Collections.unmodifiableList(myBeforeRunStepsPanel.getTasks(true));
}
public boolean isStoreProjectConfiguration() {
@@ -97,12 +97,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
final List<BeforeRunTask> activeTasks = new ArrayList<BeforeRunTask>();
final List<BeforeRunTask> tasks = runManager.getBeforeRunTasks(runConfiguration);
for (BeforeRunTask task : tasks) {
if (task != null && task.isEnabled()) {
activeTasks.add(task);
}
}
activeTasks.addAll(runManager.getBeforeRunTasks(runConfiguration));
ConfigurationPerRunnerSettings configurationSettings = state != null ? state.getConfigurationSettings() : null;
final DataContext projectContext = SimpleDataContext.getProjectContext(myProject);
@@ -164,12 +164,7 @@ class RunConfigurable extends BaseConfigurable {
if (userObject instanceof SingleConfigurationConfigurable) {
final SingleConfigurationConfigurable<?> settings = (SingleConfigurationConfigurable)userObject;
RunnerAndConfigurationSettings snapshot;
try {
snapshot = settings.getSnapshot();
}
catch (ConfigurationException e) {
snapshot = settings.getSettings();
}
snapshot = settings.getSettings();
configuration = settings.getConfiguration();
name = settings.getNameText();
setIcon(ProgramRunnerUtil.getConfigurationIcon(snapshot, !settings.isValid(), runManager.isTemporary(configuration)));
@@ -645,7 +640,7 @@ class RunConfigurable extends BaseConfigurable {
for (RunConfigurationBean each : stableConfigurations) {
toDeleteSettings.remove(each.getSettings());
manager.addConfiguration(each.getSettings(), each.isShared(), each.getStepsBeforeLaunch());
manager.addConfiguration(each.getSettings(), each.isShared(), each.getStepsBeforeLaunch(), false);
}
RunnerAndConfigurationSettings selected = manager.getSelectedConfiguration();

Some files were not shown because too many files have changed in this diff Show More