diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java index 6360201652a5..431e1488d998 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java @@ -46,6 +46,7 @@ import com.intellij.openapi.projectRoots.JavaSdkType; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.io.FileUtil; @@ -89,6 +90,9 @@ public class BackendCompilerWrapper { private static final FileObject myStopThreadToken = new FileObject(new File(""), new byte[0]); public final Map> myFileNameToSourceMap= new THashMap>(); private final Set myProcessedPackageInfos = new HashSet(); + private final CompileStatistics myStatistics; + private volatile String myModuleName = null; + public BackendCompilerWrapper(Chunk chunk, @NotNull final Project project, @NotNull List filesToCompile, @@ -101,6 +105,12 @@ public class BackendCompilerWrapper { myFilesToCompile = filesToCompile; mySink = sink; myProjectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); + CompileStatistics stat = compileContext.getUserData(CompileStatistics.KEY); + if (stat == null) { + stat = new CompileStatistics(); + compileContext.putUserData(CompileStatistics.KEY, stat); + } + myStatistics = stat; } public void compile() throws CompilerException, CacheCorruptedException { @@ -155,7 +165,6 @@ public class BackendCompilerWrapper { } private void compileModules(final Map> moduleToFilesMap) throws CompilerException { - myProcessedFilesCount = 0; try { compileChunk(new ModuleChunk(myCompileContext, myChunk, moduleToFilesMap)); } @@ -765,12 +774,8 @@ public class BackendCompilerWrapper { return out; } - private volatile int myProcessedFilesCount = 0; - private volatile int myClassesCount = 0; - private volatile String myModuleName = null; - private void sourceFileProcessed() { - myProcessedFilesCount++; + myStatistics.incFilesCount(); updateStatistics(); } @@ -778,10 +783,10 @@ public class BackendCompilerWrapper { final String msg; String moduleName = myModuleName; if (moduleName != null) { - msg = CompilerBundle.message("statistics.files.classes.module", myProcessedFilesCount, myClassesCount, moduleName); + msg = CompilerBundle.message("statistics.files.classes.module", myStatistics.getFilesCount(), myStatistics.getClassesCount(), moduleName); } else { - msg = CompilerBundle.message("statistics.files.classes", myProcessedFilesCount, myClassesCount); + msg = CompilerBundle.message("statistics.files.classes", myStatistics.getFilesCount(), myStatistics.getClassesCount()); } myCompileContext.getProgressIndicator().setText2(msg); //myCompileContext.getProgressIndicator().setFraction(1.0* myProcessedFilesCount /myTotalFilesToCompile); @@ -888,7 +893,7 @@ public class BackendCompilerWrapper { LOG.info(e); } finally { - myClassesCount++; + myStatistics.incClassesCount(); updateStatistics(); } } @@ -923,4 +928,26 @@ public class BackendCompilerWrapper { } return isJDK16; } + + private static final class CompileStatistics { + private static final Key KEY = Key.create("_Compile_Statistics_"); + private int myClassesCount; + private int myFilesCount; + + public int getClassesCount() { + return myClassesCount; + } + + public int incClassesCount() { + return ++myClassesCount; + } + + public int getFilesCount() { + return myFilesCount; + } + + public int incFilesCount() { + return ++myFilesCount; + } + } } diff --git a/java/java-impl/src/com/intellij/lang/java/JavaWordCompletionFilter.java b/java/java-impl/src/com/intellij/lang/java/JavaWordCompletionFilter.java index 9369dcb5d9b5..0c752ae2e23b 100644 --- a/java/java-impl/src/com/intellij/lang/java/JavaWordCompletionFilter.java +++ b/java/java-impl/src/com/intellij/lang/java/JavaWordCompletionFilter.java @@ -19,6 +19,8 @@ */ package com.intellij.lang.java; +import com.intellij.codeInsight.completion.CompletionProcess; +import com.intellij.codeInsight.completion.CompletionService; import com.intellij.lang.WordCompletionElementFilter; import com.intellij.psi.JavaDocTokenType; import com.intellij.psi.JavaTokenType; @@ -30,6 +32,11 @@ public class JavaWordCompletionFilter implements WordCompletionElementFilter { JavaDocTokenType.DOC_COMMENT_DATA, JavaTokenType.STRING_LITERAL); public boolean isWordCompletionEnabledIn(final IElementType element) { + final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion(); + if (process != null && process.isAutopopupCompletion()) { + return false; + } + return ENABLED_TOKENS.contains(element); } } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java b/java/java-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java index 599833736b43..726c59ad1fa4 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java @@ -45,7 +45,7 @@ import com.intellij.util.io.StringRef; import java.io.IOException; public class JavaFileElementType extends IStubFileElementType { - public static final int STUB_VERSION = JavaParserDefinition.USE_NEW_PARSER ? 4 : 3; + public static final int STUB_VERSION = JavaParserDefinition.USE_NEW_PARSER ? 5 : 4; public JavaFileElementType() { super("java.FILE", StdLanguages.JAVA); diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/JavaParsingTestCase.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/JavaParsingTestCase.java index bcd536811c1f..ad44fd557b02 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/JavaParsingTestCase.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/JavaParsingTestCase.java @@ -18,7 +18,6 @@ package com.intellij.lang.java.parser; import com.intellij.lang.ASTNode; import com.intellij.lang.PsiBuilder; import com.intellij.lang.StdLanguages; -import com.intellij.lang.java.JavaParserDefinition; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; @@ -121,9 +120,7 @@ public abstract class JavaParsingTestCase extends ParsingTestCase { @Override protected void doTest(final boolean checkResult) { doTestDefaultParser(checkResult); - if (JavaParserDefinition.USE_NEW_PARSER) { - doTestNewParser(); - } + doTestNewParser(); } protected void doTestDefaultParser(final boolean checkResult) { diff --git a/platform/bootstrap/src/com/intellij/ide/ClassloaderUtil.java b/platform/bootstrap/src/com/intellij/ide/ClassloaderUtil.java index d521547510f4..ac5bce4ff840 100644 --- a/platform/bootstrap/src/com/intellij/ide/ClassloaderUtil.java +++ b/platform/bootstrap/src/com/intellij/ide/ClassloaderUtil.java @@ -223,6 +223,9 @@ public class ClassloaderUtil { final File libFolder = new File(aFolderPath + File.separator + "lib"); addLibraries(classPath, libFolder, selfRootUrl); + final File extLib = new File(new File(libFolder, "ext"), "lib"); + addLibraries(classPath, extLib, selfRootUrl); + final File antLib = new File(new File(libFolder, "ant"), "lib"); addLibraries(classPath, antLib, selfRootUrl); } diff --git a/platform/lang-api/src/com/intellij/lang/DefaultWordCompletionFilter.java b/platform/lang-api/src/com/intellij/lang/DefaultWordCompletionFilter.java index fb1d183ed19e..813c893c80c2 100644 --- a/platform/lang-api/src/com/intellij/lang/DefaultWordCompletionFilter.java +++ b/platform/lang-api/src/com/intellij/lang/DefaultWordCompletionFilter.java @@ -19,10 +19,17 @@ */ package com.intellij.lang; +import com.intellij.codeInsight.completion.CompletionProcess; +import com.intellij.codeInsight.completion.CompletionService; import com.intellij.psi.tree.IElementType; public class DefaultWordCompletionFilter implements WordCompletionElementFilter { public boolean isWordCompletionEnabledIn(final IElementType element) { + final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion(); + if (process != null && process.isAutopopupCompletion()) { + return false; + } + final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(element.getLanguage()); return parserDefinition != null && parserDefinition.getCommentTokens().contains(element); } diff --git a/platform/lang-api/src/com/intellij/openapi/project/ProjectLocatorImpl.java b/platform/lang-api/src/com/intellij/openapi/project/ProjectLocatorImpl.java index 4b4c86e1d670..d4124635bcd9 100644 --- a/platform/lang-api/src/com/intellij/openapi/project/ProjectLocatorImpl.java +++ b/platform/lang-api/src/com/intellij/openapi/project/ProjectLocatorImpl.java @@ -33,14 +33,16 @@ public class ProjectLocatorImpl extends ProjectLocator { @Nullable public Project guessProjectForFile(final VirtualFile file) { ProjectManager projectManager = ProjectManager.getInstance(); - if (projectManager == null || file == null) return null; + if (projectManager == null) return null; final Project[] projects = projectManager.getOpenProjects(); if (projects.length == 0) return null; if (projects.length == 1 && !projects[0].isDisposed()) return projects[0]; - for (Project project : projects) { - if (project.isInitialized() && !project.isDisposed() && ProjectRootManager.getInstance(project).getFileIndex().isInContent(file)) { - return project; + if (file != null) { + for (Project project : projects) { + if (project.isInitialized() && !project.isDisposed() && ProjectRootManager.getInstance(project).getFileIndex().isInContent(file)) { + return project; + } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java index 63ebad0b2689..e71ffedc4128 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java @@ -60,6 +60,10 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate { finishAutopopupCompletion(); return Result.CONTINUE; } + } else { + if (LookupManager.getActiveLookup(editor) != null) { + return Result.CONTINUE; + } } myEditor = editor; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java new file mode 100644 index 000000000000..5ce313359b04 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.template.macro; + +import com.intellij.codeInsight.CodeInsightBundle; +import com.intellij.codeInsight.template.Expression; +import com.intellij.codeInsight.template.ExpressionContext; +import com.intellij.codeInsight.template.Result; +import com.intellij.codeInsight.template.TextResult; +import com.intellij.psi.codeStyle.NameUtil; +import org.jetbrains.annotations.NotNull; + +/** + * @author Konstantin Bulenkov + */ +public class CapitalizeAndUnderscoreMacro extends MacroBase { + public CapitalizeAndUnderscoreMacro() { + super("capitalizeAndUnderscore", CodeInsightBundle.message("macro.capitalizeAndUnderscore.string")); + } + + @Override + protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) { + String text = getTextResult(params, context, true); + if (text != null && text.length() > 0) { + final String[] words = NameUtil.nameToWords(text); + boolean insertUnderscore = false; + final StringBuffer buf = new StringBuffer(); + for (String word : words) { + if (insertUnderscore) { + buf.append("_"); + } else { + insertUnderscore = true; + } + buf.append(word.toUpperCase()); + } + return new TextResult(buf.toString()); + } + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeMacro.java index eab6938819f5..aca630eb3862 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeMacro.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeMacro.java @@ -17,47 +17,29 @@ package com.intellij.codeInsight.template.macro; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.template.*; +import com.intellij.codeInsight.template.Expression; +import com.intellij.codeInsight.template.ExpressionContext; +import com.intellij.codeInsight.template.Result; +import com.intellij.codeInsight.template.TextResult; import org.jetbrains.annotations.NotNull; -public class CapitalizeMacro implements Macro { - - public String getName() { - return "capitalize"; +/** + * @author Konstantin Bulenkov + */ +public class CapitalizeMacro extends MacroBase { + public CapitalizeMacro() { + super("capitalize", CodeInsightBundle.message("macro.capitalize.string")); } - public String getDescription() { - return CodeInsightBundle.message("macro.capitalize.string"); - } - - public String getDefaultValue() { - return "A"; - } - - public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) { - if (params.length != 1) return null; - Result result = params[0].calculateResult(context); - return execute(result); - } - - public Result calculateQuickResult(@NotNull Expression[] params, ExpressionContext context) { - if (params.length != 1) return null; - Result result = params[0].calculateQuickResult(context); - return execute(result); - } - - private Result execute(Result result) { - if (result == null) return null; - String text = result.toString(); - if (text == null) return null; - if (text.length() > 0) { - text = text.substring(0, 1).toUpperCase() + text.substring(1, text.length()); + @Override + protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) { + String text = getTextResult(params, context); + if (text != null) { + if (text.length() > 0) { + text = text.substring(0, 1).toUpperCase() + text.substring(1, text.length()); + } + return new TextResult(text); } - return new TextResult(text); - } - - public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) { return null; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/DecapitalizeMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/DecapitalizeMacro.java index d46637790f4b..1af1508fdcc6 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/DecapitalizeMacro.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/DecapitalizeMacro.java @@ -17,46 +17,27 @@ package com.intellij.codeInsight.template.macro; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.template.*; +import com.intellij.codeInsight.template.Expression; +import com.intellij.codeInsight.template.ExpressionContext; +import com.intellij.codeInsight.template.Result; +import com.intellij.codeInsight.template.TextResult; import org.jetbrains.annotations.NotNull; -public class DecapitalizeMacro implements Macro { - - public String getName() { - return "decapitalize"; +/** + * @author Konstantin Bulenkov + */ +public class DecapitalizeMacro extends MacroBase { + public DecapitalizeMacro() { + super("decapitalize", CodeInsightBundle.message("macro.decapitalize.string")); } - public String getDescription() { - return CodeInsightBundle.message("macro.decapitalize.string"); - } - - public String getDefaultValue() { - return "a"; - } - - public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) { - if (params.length != 1) return null; - Result result = params[0].calculateResult(context); - return execute(result); - } - - public Result calculateQuickResult(@NotNull Expression[] params, ExpressionContext context) { - if (params.length != 1) return null; - Result result = params[0].calculateQuickResult(context); - return execute(result); - } - - private Result execute(Result result) { - if (result == null) return null; - String text = result.toString(); - if (text.length() > 0) { + @Override + protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) { + String text = getTextResult(params, context); + if (text != null && text.length() > 0) { text = text.substring(0, 1).toLowerCase() + text.substring(1, text.length()); + return new TextResult(text); } - return new TextResult(text); - } - - public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) { return null; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/FirstWordMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/FirstWordMacro.java index 2927fea1aec9..223649c865c3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/FirstWordMacro.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/FirstWordMacro.java @@ -17,53 +17,28 @@ package com.intellij.codeInsight.template.macro; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.template.*; -import org.jetbrains.annotations.NonNls; +import com.intellij.codeInsight.template.Expression; +import com.intellij.codeInsight.template.ExpressionContext; +import com.intellij.codeInsight.template.Result; +import com.intellij.codeInsight.template.TextResult; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * @author ven + * @author Konstantin Bulenkov */ -public class FirstWordMacro implements Macro { - @NonNls - public String getName() { - return "firstWord"; +public class FirstWordMacro extends MacroBase { + public FirstWordMacro() { + super("firstWord", CodeInsightBundle.message("macro.firstWord.string")); } - public String getDescription() { - return CodeInsightBundle.message("macro.firstWord.string"); - } - - @NonNls - public String getDefaultValue() { - return "a"; - } - - public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) { - if (params.length != 1) return null; - Result result = params[0].calculateResult(context); - return execute(result); - } - - @Nullable - private static Result execute(final Result result) { - if (result == null) { - return null; + @Override + protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) { + final String text = getTextResult(params, context); + if (text != null) { + final int index = text.indexOf(' '); + return index >= 0 ? new TextResult(text.substring(0, index)) : new TextResult(text); } - final String resultString = result.toString(); - final int index = resultString.indexOf(' '); - return index >= 0 ? new TextResult(resultString.substring(0, index)) : result; - } - - public Result calculateQuickResult(@NotNull Expression[] params, ExpressionContext context) { - if (params.length != 1) return null; - Result result = params[0].calculateResult(context); - return execute(result); - } - - public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) { - return LookupElement.EMPTY_ARRAY; + return null; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/MacroBase.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/MacroBase.java new file mode 100644 index 000000000000..b6de49c93fa4 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/MacroBase.java @@ -0,0 +1,86 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.template.macro; + +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.codeInsight.template.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Konstantin Bulenkov + */ +public abstract class MacroBase implements Macro { + private final String myName; + private final String myDescription; + + public MacroBase(String name, String description) { + myName = name; + myDescription = description; + } + + @Nullable + protected abstract Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick); + + @Override + public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) { + return calculateResult(params, context, false); + } + + @Override + public Result calculateQuickResult(@NotNull Expression[] params, ExpressionContext context) { + return calculateResult(params, context, true); + } + + @Override + public String getName() { + return myName; + } + + @Override + public String getDescription() { + return myDescription; + } + + @Override + public String getDefaultValue() { + return "a"; + } + + public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) { + return LookupElement.EMPTY_ARRAY; + } + + @Nullable + public static String getTextResult(@NotNull Expression[] params, final ExpressionContext context) { + return getTextResult(params, context, false); + } + + @Nullable + public static String getTextResult(@NotNull Expression[] params, final ExpressionContext context, boolean useSelection) { + if (params.length == 1) { + Result result = params[0].calculateResult(context); + if (result == null && useSelection) { + final String property = context.getProperty(ExpressionContext.SELECTION); + if (property != null) { + result = new TextResult(property); + } + } + return result == null ? null : result.toString(); + } + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/ReplaceUnderscoresToCamelCaseMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/ReplaceUnderscoresToCamelCaseMacro.java new file mode 100644 index 000000000000..55481b812b3c --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/ReplaceUnderscoresToCamelCaseMacro.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.template.macro; + +import com.intellij.codeInsight.CodeInsightBundle; +import com.intellij.codeInsight.template.Expression; +import com.intellij.codeInsight.template.ExpressionContext; +import com.intellij.codeInsight.template.Result; +import com.intellij.codeInsight.template.TextResult; +import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author Konstantin Bulenkov + */ +public class ReplaceUnderscoresToCamelCaseMacro extends MacroBase { + public ReplaceUnderscoresToCamelCaseMacro() { + super("underscoresToCamelCase", CodeInsightBundle.message("macro.undescoresToCamelCase.string")); + } + + @Nullable + @Override + protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) { + final String text = getTextResult(params, context, true); + if (text != null) { + final StringBuffer buf = new StringBuffer(); + final List strings = StringUtil.split(text, "_"); + buf.append(strings.get(0).toLowerCase()); + for (int i = 1; i < strings.size(); i++) { + buf.append(StringUtil.capitalize(strings.get(i).toLowerCase())); + } + return new TextResult(buf.toString()); + } + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/ReplaceUnderscoresWithSpacesMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/ReplaceUnderscoresWithSpacesMacro.java index 26041eb068ad..c1af8a56c221 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/ReplaceUnderscoresWithSpacesMacro.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/ReplaceUnderscoresWithSpacesMacro.java @@ -17,50 +17,27 @@ package com.intellij.codeInsight.template.macro; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.template.*; -import org.jetbrains.annotations.NonNls; +import com.intellij.codeInsight.template.Expression; +import com.intellij.codeInsight.template.ExpressionContext; +import com.intellij.codeInsight.template.Result; +import com.intellij.codeInsight.template.TextResult; import org.jetbrains.annotations.NotNull; /** * @author Roman.Chernyatchik + * @author Konstantin Bulenkov */ -public class ReplaceUnderscoresWithSpacesMacro implements Macro { - @NonNls - public String getName() { - return "underscoresToSpaces"; +public class ReplaceUnderscoresWithSpacesMacro extends MacroBase { + public ReplaceUnderscoresWithSpacesMacro() { + super("undescoresToSpaces", CodeInsightBundle.message("macro.undescoresToSpaces.string")); } - public String getDescription() { - return CodeInsightBundle.message("macro.undescoresToSpaces.string"); - } - - @NonNls - public String getDefaultValue() { - return "a"; - } - - public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) { - if (params.length != 1) { - return null; + @Override + protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) { + final String text = getTextResult(params, context); + if (text != null) { + return new TextResult(text.replace('_', ' ')); } - Result param_result = params[0].calculateResult(context); - if (param_result == null) { - return null; - } - return execute(param_result); - } - - public Result calculateQuickResult(@NotNull Expression[] params, ExpressionContext context) { - return calculateResult(params, context); - } - - public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) { - return LookupElement.EMPTY_ARRAY; - } - - private Result execute(final Result param_result) { - final String param_string_value = param_result.toString(); - return new TextResult(param_string_value.replace('_', ' ')); + return null; } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index 17973e199084..af4a400d304c 100644 --- a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -924,7 +924,6 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } else if (item instanceof DoneMarker) { curNode = nodes.pop(); - item.next = i < myProduction.size() - 1 ? myProduction.get(i + 1) : null; } else if (item instanceof ErrorItem) { int curToken = item.myLexemeIndex; @@ -987,79 +986,43 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { CompositeElement curNode = rootNode; int lexIndex = rootMarker.myLexemeIndex; - int lastErrorIndex = -1; - for (int i = myProduction.indexOf(rootMarker) + 1; i <= myProduction.indexOf(rootMarker.myDoneMarker); i++) { - final ProductionMarker item = myProduction.get(i); - - lexIndex = insertLeaves(lexIndex, item.myLexemeIndex, curNode); - - if (item instanceof StartMarker) { - final StartMarker marker = (StartMarker)item; - if (!marker.myDoneMarker.myCollapse) { - markers.push(curMarker); - curMarker = marker; - - final CompositeElement childNode = createComposite(curMarker); - curNode.rawAddChildren(childNode); - nodes.push(curNode); - curNode = childNode; - } - else { - lexIndex = collapseLeaves(curNode, marker); - //noinspection AssignmentToForLoopParameter - i = myProduction.indexOf(marker.myDoneMarker); - } - } - else if (item instanceof DoneMarker) { - curMarker = markers.pop(); - curNode = nodes.pop(); - } - else if (item instanceof ErrorItem) { - int curToken = item.myLexemeIndex; - if (curToken == lastErrorIndex) continue; - lastErrorIndex = curToken; - - final PsiErrorElementImpl errorElement = new PsiErrorElementImpl(); - errorElement.setErrorDescription(((ErrorItem)item).myMessage); - curNode.rawAddChildren(errorElement); - } - } - /* ProductionMarker item = rootMarker.firstChild != null ? rootMarker.firstChild : rootMarker.myDoneMarker; - while (item != null) { + while (true) { lexIndex = insertLeaves(lexIndex, item.myLexemeIndex, curNode); + if (item == rootMarker.myDoneMarker) break; + if (item instanceof StartMarker) { final StartMarker marker = (StartMarker)item; if (!marker.myDoneMarker.myCollapse) { markers.push(curMarker); curMarker = marker; - final CompositeElement childNode = createComposite(curMarker); + final CompositeElement childNode = createComposite(marker); curNode.rawAddChildren(childNode); nodes.push(curNode); curNode = childNode; item = marker.firstChild != null ? marker.firstChild : marker.myDoneMarker; + continue; } else { lexIndex = collapseLeaves(curNode, marker); - item = marker.myDoneMarker.next; } } else if (item instanceof ErrorItem) { final PsiErrorElementImpl errorElement = new PsiErrorElementImpl(); errorElement.setErrorDescription(((ErrorItem)item).myMessage); curNode.rawAddChildren(errorElement); - item = item.next != null ? item.next : curMarker.myDoneMarker; } else if (item instanceof DoneMarker) { curMarker = markers.pop(); curNode = nodes.pop(); - item = item.next; + item = ((DoneMarker)item).myStart; } + + item = item.next != null ? item.next : curMarker.myDoneMarker; } - */ } private int insertLeaves(int curToken, int lastIdx, final CompositeElement curNode) { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java index 0e04b594e9f1..a7cc039825cc 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java @@ -16,6 +16,8 @@ package com.intellij.psi.impl.source.resolve.reference.impl.providers; +import com.intellij.codeInsight.completion.CompletionProcess; +import com.intellij.codeInsight.completion.CompletionService; import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; import com.intellij.codeInsight.daemon.QuickFixProvider; import com.intellij.codeInsight.daemon.impl.HighlightInfo; @@ -201,6 +203,12 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc @NotNull public Object[] getVariants() { + final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion(); + if (process != null && process.isAutopopupCompletion() && isSoft()) { + return ArrayUtil.EMPTY_OBJECT_ARRAY; + } + + final String s = getText(); if (s != null && s.equals("/")) { return ArrayUtil.EMPTY_OBJECT_ARRAY; diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java index 4bf22990fac7..a783606dd7cf 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java @@ -219,7 +219,7 @@ public class VariableInplaceRenamer { //move to old offset final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor); - final boolean lookupShown = lookup != null && lookup.getLookupStart() < offset; + final boolean lookupShown = lookup != null && lookup.getLookupStart() <= offset; if (lookupShown) { lookup.setAdditionalPrefix(myEditor.getDocument().getCharsSequence().subSequence(lookup.getLookupStart(), offset).toString()); lookup.setFocused(false); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java index b36dfc1d749a..07d877736a7b 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java @@ -535,34 +535,37 @@ public class FileBasedIndex implements ApplicationComponent { if (!myShutdownPerformed.compareAndSet(false, true)) { return; // already shut down } - if (myFlushingFuture != null) { - myFlushingFuture.cancel(false); - myFlushingFuture = null; - } - - myFileDocumentManager.saveAllDocuments(); - - LOG.info("START INDEX SHUTDOWN"); try { - myChangedFilesCollector.forceUpdate(null, null, true); - - for (ID indexId : myIndices.keySet()) { - final UpdatableIndex index = getIndex(indexId); - assert index != null; - checkRebuild(indexId, true); // if the index was scheduled for rebuild, only clean it - //LOG.info("DISPOSING " + indexId); - index.dispose(); + if (myFlushingFuture != null) { + myFlushingFuture.cancel(false); + myFlushingFuture = null; } - myVfManager.removeVirtualFileListener(myChangedFilesCollector); + myFileDocumentManager.saveAllDocuments(); + } + finally { + LOG.info("START INDEX SHUTDOWN"); + try { + myChangedFilesCollector.forceUpdate(null, null, true); - //FileUtil.delete(getMarkerFile()); + for (ID indexId : myIndices.keySet()) { + final UpdatableIndex index = getIndex(indexId); + assert index != null; + checkRebuild(indexId, true); // if the index was scheduled for rebuild, only clean it + //LOG.info("DISPOSING " + indexId); + index.dispose(); + } + + myVfManager.removeVirtualFileListener(myChangedFilesCollector); + + //FileUtil.delete(getMarkerFile()); + } + catch (Throwable e) { + LOG.info("Problems during index shutdown", e); + throw new RuntimeException(e); + } + LOG.info("END INDEX SHUTDOWN"); } - catch (Throwable e) { - LOG.info("Problems during index shutdown", e); - throw new RuntimeException(e); - } - LOG.info("END INDEX SHUTDOWN"); } private void flushAllIndices() { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index b88b73c2606a..157ef9a1c3d6 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -628,30 +628,7 @@ public class Messages { panel.add(container, BorderLayout.WEST); } if (myMessage != null) { - JLabel label = new JLabel(); - final JTextPane messageComponent = new JTextPane(); - messageComponent.setFont(label.getFont()); - if (BasicHTML.isHTMLString(myMessage)) { - final HTMLEditorKit editorKit = new HTMLEditorKit(); - editorKit.getStyleSheet().addRule(UIUtil.displayPropertiesToCSS(label.getFont(), label.getForeground())); - messageComponent.setEditorKit(editorKit); - messageComponent.setContentType("text/html"); - messageComponent.addHyperlinkListener(new BrowserHyperlinkListener()); - } - messageComponent.setText(myMessage); - messageComponent.setEditable(false); - if (messageComponent.getCaret() != null) { - messageComponent.setCaretPosition(0); - } - - if (UIUtil.isUnderNimbusLookAndFeel()) { - messageComponent.setOpaque(false); - messageComponent.setBackground(new Color(0, 0, 0, 0)); - } else { - messageComponent.setBackground(UIUtil.getOptionPaneBackground()); - } - - messageComponent.setForeground(label.getForeground()); + final JTextPane messageComponent = createMessageComponent(myMessage); final Dimension screenSize = messageComponent.getToolkit().getScreenSize(); final Dimension textSize = messageComponent.getPreferredSize(); @@ -682,6 +659,34 @@ public class Messages { return panel; } + protected static JTextPane createMessageComponent(final String message) { + JLabel label = new JLabel(); + final JTextPane messageComponent = new JTextPane(); + messageComponent.setFont(label.getFont()); + if (BasicHTML.isHTMLString(message)) { + final HTMLEditorKit editorKit = new HTMLEditorKit(); + editorKit.getStyleSheet().addRule(UIUtil.displayPropertiesToCSS(label.getFont(), label.getForeground())); + messageComponent.setEditorKit(editorKit); + messageComponent.setContentType("text/html"); + messageComponent.addHyperlinkListener(new BrowserHyperlinkListener()); + } + messageComponent.setText(message); + messageComponent.setEditable(false); + if (messageComponent.getCaret() != null) { + messageComponent.setCaretPosition(0); + } + + if (UIUtil.isUnderNimbusLookAndFeel()) { + messageComponent.setOpaque(false); + messageComponent.setBackground(new Color(0, 0, 0, 0)); + } else { + messageComponent.setBackground(UIUtil.getOptionPaneBackground()); + } + + messageComponent.setForeground(label.getForeground()); + return messageComponent; + } + @Override protected void doHelpAction() { // do nothing @@ -833,10 +838,17 @@ public class Messages { JPanel messagePanel = new JPanel(new BorderLayout()); if (myMessage != null) { - JLabel textLabel = new JLabel(myMessage); - textLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); - textLabel.setUI(new MultiLineLabelUI()); - messagePanel.add(textLabel, BorderLayout.NORTH); + JComponent textComponent; + if (BasicHTML.isHTMLString(myMessage)) { + textComponent = createMessageComponent(myMessage); + } + else { + JLabel textLabel = new JLabel(myMessage); + textLabel.setUI(new MultiLineLabelUI()); + textComponent = textLabel; + } + textComponent.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); + messagePanel.add(textComponent, BorderLayout.NORTH); } myField = createTextFieldComponent(); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index acca41f03a40..86aacf3c133d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -709,19 +709,22 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt } private void scheduleReloadApplicationAndProject() { - IdeEventQueue.getInstance().addIdleListener(new Runnable() { - @Override + ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { - IdeEventQueue.getInstance().removeIdleListener(this); - ApplicationManager.getApplication().invokeLater(new Runnable() { + IdeEventQueue.getInstance().addIdleListener(new Runnable() { + @Override public void run() { - if (!tryToReloadApplication()) return; - askToReloadProjectIfConfigFilesChangedExternally(); + IdeEventQueue.getInstance().removeIdleListener(this); + ApplicationManager.getApplication().invokeLater(new Runnable() { + public void run() { + if (!tryToReloadApplication()) return; + askToReloadProjectIfConfigFilesChangedExternally(); + } + }, ModalityState.NON_MODAL); } - - }, ModalityState.NON_MODAL); + }, 2000); } - }, 2000); + }, ModalityState.NON_MODAL); } public void setCurrentTestProject(@Nullable final Project project) { diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index 38548b3bfdf5..dc026cf605cf 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -310,6 +310,8 @@ macro.current.package=currentPackage() macro.decapitalize.string=decapitalize(String) macro.firstWord.string=firstWord(String) macro.undescoresToSpaces.string=underscoresToSpaces(String) +macro.undescoresToCamelCase.string=underscoresToCamelCase(String) +macro.capitalizeAndUnderscore.string=capitalizeAndUnderscore(String) macro.descendant.classes.enum=descendantClassesEnum(String) macro.enum=enum(...) macro.expected.type=expectedType() diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 61ea7b0d7af7..5431d3b1cc4b 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -316,6 +316,8 @@ + + diff --git a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java index cb88ef1d7aaa..36ed9dbcec22 100644 --- a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java +++ b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java @@ -18,6 +18,7 @@ package com.intellij.openapi.util; import com.intellij.openapi.diagnostic.Logger; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; public class ShutDownTracker implements Runnable { @@ -25,7 +26,7 @@ public class ShutDownTracker implements Runnable { private static ShutDownTracker ourInstance; private final List myThreads = new ArrayList(); private final List myShutdownThreads = new ArrayList(); - private final List myShutdownTasks = new ArrayList(); + private final LinkedList myShutdownTasks = new LinkedList(); private volatile boolean myIsShutdownHookRunning = false; private ShutDownTracker() { @@ -46,6 +47,18 @@ public class ShutDownTracker implements Runnable { public void run() { myIsShutdownHookRunning = true; + + while (!myShutdownTasks.isEmpty()) { + // task can change myShutdownTasks + final Runnable task = myShutdownTasks.removeLast(); + try { + task.run(); + } + catch (Throwable e) { + LOG.error(e); + } + } + Thread[] threads = getStopperThreads(); while (threads.length > 0) { Thread thread = threads[0]; @@ -65,17 +78,6 @@ public class ShutDownTracker implements Runnable { threads = getStopperThreads(); } - while (!myShutdownTasks.isEmpty()) { - // task can change myShutdownTasks - final Runnable task = myShutdownTasks.remove(myShutdownTasks.size()-1); - try { - task.run(); - } - catch (Throwable e) { - LOG.error(e); - } - } - for (int idx = myShutdownThreads.size() - 1; idx >= 0; idx--) { final Thread thread = myShutdownThreads.remove(idx); thread.start(); @@ -111,7 +113,7 @@ public class ShutDownTracker implements Runnable { } public void registerShutdownTask(Runnable task) { - myShutdownTasks.add(task); + myShutdownTasks.addLast(task); } public void unregisterShutdownTask(Runnable task) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java index 4888bd2e1474..51c7eb203e16 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java @@ -16,6 +16,7 @@ package com.intellij.xdebugger.impl.breakpoints; import com.intellij.ide.startup.StartupManagerEx; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; @@ -26,11 +27,13 @@ import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory; import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.fileEditor.FileEditor; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.Disposable; import com.intellij.psi.PsiDocumentManager; import com.intellij.util.containers.BidirectionalMap; import com.intellij.util.ui.update.MergingUpdateQueue; @@ -185,10 +188,11 @@ public class XLineBreakpointManager { public void mouseClicked(final EditorMouseEvent e) { final Editor editor = e.getEditor(); final MouseEvent mouseEvent = e.getMouseEvent(); - if (mouseEvent.isPopupTrigger() || - mouseEvent.getButton() != MouseEvent.BUTTON1 || - MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(editor) || - e.getArea() != EditorMouseEventArea.LINE_MARKERS_AREA) { + if (mouseEvent.isPopupTrigger() + || mouseEvent.getButton() != MouseEvent.BUTTON1 + || MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(editor) + || e.getArea() != EditorMouseEventArea.LINE_MARKERS_AREA + ||!isFromMyProject(editor)) { return; } @@ -211,6 +215,15 @@ public class XLineBreakpointManager { } } + private boolean isFromMyProject(Editor editor) { + for (FileEditor fileEditor : FileEditorManager.getInstance(myProject).getAllEditors()) { + if (fileEditor instanceof TextEditor && ((TextEditor)fileEditor).getEditor().equals(editor)) { + return true; + } + } + return false; + } + private class MyDependentBreakpointListener implements XDependentBreakpointListener { public void dependencySet(final XBreakpoint slave, final XBreakpoint master) { queueBreakpointUpdate(slave); diff --git a/plugins/properties/src/com/intellij/lang/properties/PropertiesWordCompletionFilter.java b/plugins/properties/src/com/intellij/lang/properties/PropertiesWordCompletionFilter.java index ea728f02504d..f9b71b8e5b9f 100644 --- a/plugins/properties/src/com/intellij/lang/properties/PropertiesWordCompletionFilter.java +++ b/plugins/properties/src/com/intellij/lang/properties/PropertiesWordCompletionFilter.java @@ -19,12 +19,19 @@ */ package com.intellij.lang.properties; +import com.intellij.codeInsight.completion.CompletionProcess; +import com.intellij.codeInsight.completion.CompletionService; import com.intellij.lang.DefaultWordCompletionFilter; import com.intellij.lang.properties.parsing.PropertiesElementTypes; import com.intellij.psi.tree.IElementType; public class PropertiesWordCompletionFilter extends DefaultWordCompletionFilter { public boolean isWordCompletionEnabledIn(final IElementType element) { + final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion(); + if (process != null && process.isAutopopupCompletion()) { + return false; + } + return super.isWordCompletionEnabledIn(element) || element == PropertiesElementTypes.PROPERTY; } } \ No newline at end of file diff --git a/plugins/properties/src/com/intellij/lang/properties/references/PropertyReferenceBase.java b/plugins/properties/src/com/intellij/lang/properties/references/PropertyReferenceBase.java index 8b1715d0051d..b81b57931a3c 100644 --- a/plugins/properties/src/com/intellij/lang/properties/references/PropertyReferenceBase.java +++ b/plugins/properties/src/com/intellij/lang/properties/references/PropertyReferenceBase.java @@ -15,6 +15,8 @@ */ package com.intellij.lang.properties.references; +import com.intellij.codeInsight.completion.CompletionProcess; +import com.intellij.codeInsight.completion.CompletionService; import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.lang.properties.psi.Property; @@ -180,6 +182,11 @@ public abstract class PropertyReferenceBase implements PsiPolyVariantReference, @NotNull public Object[] getVariants() { + final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion(); + if (process != null && process.isAutopopupCompletion() && isSoft()) { + return ArrayUtil.EMPTY_OBJECT_ARRAY; + } + final Set variants = new THashSet(new TObjectHashingStrategy() { public int computeHashCode(final Object object) { if (object instanceof Property) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildInvocationHandler.java index 97315b8a8279..e3c289a1ed9e 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildInvocationHandler.java @@ -16,8 +16,7 @@ import com.intellij.util.xml.DomElement; import com.intellij.util.xml.DomElementVisitor; import com.intellij.util.xml.EvaluatedXmlName; import com.intellij.util.xml.GenericAttributeValue; -import com.intellij.util.xml.events.ElementChangedEvent; -import com.intellij.util.xml.events.ElementDefinedEvent; +import com.intellij.util.xml.events.DomEvent; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -77,7 +76,8 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler 0; } - final DomEvent[] recomputeFileElement(final XmlFile file) { + static DomEvent[] recomputeFileElement(final XmlFile file) { final DomFileElementImpl oldElement = getCachedFileElement(file); - final DomFileElementImpl newElement = getFileElement(file); - if (newElement == null) { - return oldElement == null ? DomEvent.EMPTY_ARRAY : new DomEvent[]{new ElementUndefinedEvent(oldElement)}; - } - - if (oldElement == null) return new DomEvent[]{new ElementDefinedEvent(newElement)}; - if (oldElement.equals(newElement)) return new DomEvent[]{new ElementChangedEvent(newElement)}; - return new DomEvent[]{new ElementUndefinedEvent(oldElement), new ElementDefinedEvent(newElement)}; + return oldElement == null ? DomEvent.EMPTY_ARRAY : new DomEvent[]{new DomEvent(oldElement, false)}; } private void processDirectoryChange(final VirtualFile directory) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/ExternalChangeProcessor.java b/xml/dom-impl/src/com/intellij/util/xml/impl/ExternalChangeProcessor.java index 9232fc6bb34f..8d780d8d731d 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/ExternalChangeProcessor.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/ExternalChangeProcessor.java @@ -13,7 +13,6 @@ import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.util.xml.events.DomEvent; -import com.intellij.util.xml.events.ElementChangedEvent; import com.intellij.util.xml.DomElement; import java.lang.reflect.Type; @@ -40,7 +39,7 @@ public class ExternalChangeProcessor implements XmlChangeVisitor { public void processChanges() { if (myDocumentChanged) return; for (DomInvocationHandler handler : myChangeSets.values()) { - myDomManager.fireEvent(new ElementChangedEvent(handler.getProxy())); + myDomManager.fireEvent(new DomEvent(handler.getProxy(), false)); } } @@ -105,7 +104,7 @@ public class ExternalChangeProcessor implements XmlChangeVisitor { LOG.assertTrue(rootTag.isValid()); rootHandler.setXmlElement(rootTag); } - myDomManager.fireEvent(new ElementChangedEvent(oldElement.getRootElement())); + myDomManager.fireEvent(new DomEvent(oldElement.getRootElement(), false)); } } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java index 99e867a092ee..09564bc23fce 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java @@ -29,8 +29,6 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import com.intellij.util.xml.*; import com.intellij.util.xml.events.DomEvent; -import com.intellij.util.xml.events.ElementDefinedEvent; -import com.intellij.util.xml.events.ElementUndefinedEvent; import org.jetbrains.annotations.Nullable; import java.util.Collections; @@ -97,7 +95,7 @@ class FileDescriptionCachedValueProvider implements SemEle final List events = fireEvents ? new SmartList() : Collections.emptyList(); if (oldValue != null) { if (fireEvents) { - events.add(new ElementUndefinedEvent(oldValue)); + events.add(new DomEvent(oldValue, false)); } } @@ -116,7 +114,8 @@ class FileDescriptionCachedValueProvider implements SemEle } if (fireEvents) { - events.add(new ElementDefinedEvent(myLastResult)); + final DomElement element = myLastResult; + events.add(new DomEvent(element, true)); } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomChangeAdapter.java b/xml/dom-openapi/src/com/intellij/util/xml/DomChangeAdapter.java index 591f71e78847..bd2fb5755ef5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomChangeAdapter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomChangeAdapter.java @@ -20,19 +20,12 @@ import com.intellij.util.xml.events.*; /** * @author peter */ -public abstract class DomChangeAdapter extends DomEventAdapter { +public abstract class DomChangeAdapter implements DomEventListener { protected abstract void elementChanged(DomElement element); - public void elementChanged(ElementChangedEvent event) { - elementChanged(event.getElement()); - } - - public void elementDefined(ElementDefinedEvent event) { - elementChanged(event.getElement()); - } - - public void elementUndefined(ElementUndefinedEvent event) { + @Override + public void eventOccured(DomEvent event) { elementChanged(event.getElement()); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomEventAdapter.java b/xml/dom-openapi/src/com/intellij/util/xml/DomEventAdapter.java index 7f1cea34d30a..4935964aca34 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomEventAdapter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomEventAdapter.java @@ -15,36 +15,9 @@ */ package com.intellij.util.xml; -import com.intellij.util.xml.events.*; - /** * @author peter */ -public abstract class DomEventAdapter implements DomEventVisitor, DomEventListener { - - public void elementDefined(ElementDefinedEvent event) { - } - - public void elementUndefined(ElementUndefinedEvent event) { - } - - public void elementChanged(ElementChangedEvent event) { - } - - public void eventOccured(DomEvent event) { - event.accept(this); - } - - public final void visitElementDefined(final ElementDefinedEvent event) { - elementDefined(event); - } - - public final void visitElementUndefined(final ElementUndefinedEvent event) { - elementUndefined(event); - } - - public final void visitElementChangedEvent(final ElementChangedEvent event) { - elementChanged(event); - } - +@Deprecated +public abstract class DomEventAdapter implements DomEventListener { } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomEventVisitor.java b/xml/dom-openapi/src/com/intellij/util/xml/DomEventVisitor.java index 486eba0c5567..ac0970f795ed 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomEventVisitor.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomEventVisitor.java @@ -22,10 +22,8 @@ import com.intellij.util.xml.events.*; */ public interface DomEventVisitor { - void visitElementDefined(final ElementDefinedEvent event); + void visitElementDefined(final DomEvent event); - void visitElementUndefined(final ElementUndefinedEvent event); - - void visitElementChangedEvent(final ElementChangedEvent event); + void visitElementChangedEvent(final DomEvent event); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/events/DomEvent.java b/xml/dom-openapi/src/com/intellij/util/xml/events/DomEvent.java index ab1a27d25fc8..ac1e62158dfe 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/events/DomEvent.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/events/DomEvent.java @@ -15,13 +15,34 @@ */ package com.intellij.util.xml.events; +import com.intellij.util.xml.DomElement; import com.intellij.util.xml.DomEventVisitor; +import org.jetbrains.annotations.NotNull; /** * @author peter */ -public interface DomEvent { - DomEvent[] EMPTY_ARRAY = new DomEvent[0]; +public class DomEvent { + public static final DomEvent[] EMPTY_ARRAY = new DomEvent[0]; + + private final DomElement myElement; + private final boolean myDefined; + + public DomEvent(@NotNull final DomElement element, boolean defined) { + myDefined = defined; + myElement = element; + } + + public final DomElement getElement() { + return myElement; + } + + public boolean isDefined() { + return myDefined; + } + + public String toString() { + return (myDefined ? "Defined " : "Changed ") + myElement; + } - void accept(DomEventVisitor visitor); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/events/ElementChangedEvent.java b/xml/dom-openapi/src/com/intellij/util/xml/events/ElementChangedEvent.java deleted file mode 100644 index 9cdd86c32b17..000000000000 --- a/xml/dom-openapi/src/com/intellij/util/xml/events/ElementChangedEvent.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2000-2009 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.xml.events; - -import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.DomEventVisitor; - -/** - * @author peter - */ -public class ElementChangedEvent implements DomEvent { - private final DomElement myElement; - - public ElementChangedEvent(final DomElement element) { - assert element != null; - myElement = element; - } - - public final DomElement getElement() { - return myElement; - } - - public String toString() { - return "Changed " + myElement; - } - - public void accept(DomEventVisitor visitor) { - visitor.visitElementChangedEvent(this); - } -} diff --git a/xml/dom-openapi/src/com/intellij/util/xml/events/ElementDefinedEvent.java b/xml/dom-openapi/src/com/intellij/util/xml/events/ElementDefinedEvent.java deleted file mode 100644 index e89a1f8e9f83..000000000000 --- a/xml/dom-openapi/src/com/intellij/util/xml/events/ElementDefinedEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2009 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.xml.events; - -import com.intellij.util.xml.events.ElementChangedEvent; -import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.DomEventVisitor; - -/** - * @author peter - */ -public class ElementDefinedEvent extends ElementChangedEvent { - public ElementDefinedEvent(final DomElement element) { - super(element); - } - - public String toString() { - return "Defined " + getElement(); - } - - public void accept(DomEventVisitor visitor) { - visitor.visitElementDefined(this); - } -} diff --git a/xml/dom-openapi/src/com/intellij/util/xml/events/ElementUndefinedEvent.java b/xml/dom-openapi/src/com/intellij/util/xml/events/ElementUndefinedEvent.java deleted file mode 100644 index bedf358eb6fc..000000000000 --- a/xml/dom-openapi/src/com/intellij/util/xml/events/ElementUndefinedEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2009 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.xml.events; - -import com.intellij.util.xml.events.ElementChangedEvent; -import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.DomEventVisitor; - -/** - * @author peter - */ -public class ElementUndefinedEvent extends ElementChangedEvent { - - public ElementUndefinedEvent(final DomElement element) { - super(element); - } - - public String toString() { - return "Undefined " + getElement(); - } - - public void accept(DomEventVisitor visitor) { - visitor.visitElementUndefined(this); - } -} diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java index 4c82a84b16d5..99fdbbb9babf 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java @@ -99,7 +99,7 @@ public class DomFileEditor extends Perspecti new MnemonicHelper().register(getComponent()); myComponent = myComponentFactory.create(); DomUIFactory.getDomUIFactory().setupErrorOutdatingUserActivityWatcher(this, getDomElement()); - DomManager.getDomManager(getProject()).addDomEventListener(new DomEventAdapter() { + DomManager.getDomManager(getProject()).addDomEventListener(new DomEventListener() { public void eventOccured(DomEvent event) { checkIsValid(); }