mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -107,14 +107,6 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
|
||||
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
|
||||
}
|
||||
|
||||
if (completionChar == '#') {
|
||||
context.setLaterRunnable(new Runnable() {
|
||||
public void run() {
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC).invoke(project, editor, file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (annotation) {
|
||||
// Check if someone inserts annotation class that require @
|
||||
PsiElement elementAt = file.findElementAt(context.getStartOffset());
|
||||
@@ -324,7 +316,6 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
|
||||
case ':': return TailType.CASE_COLON; //?
|
||||
case '<':
|
||||
case '>':
|
||||
case '#':
|
||||
case '\"':
|
||||
case '[': return TailType.createSimpleTailType(completionChar);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.completion;
|
||||
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class FocusInJavadoc extends CompletionConfidence {
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) {
|
||||
if (PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiDocTag.class) != null) {
|
||||
return ThreeState.YES;
|
||||
}
|
||||
return ThreeState.UNSURE;
|
||||
}
|
||||
}
|
||||
+25
-2
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.ExpectedTypeInfo;
|
||||
import com.intellij.codeInsight.ExpectedTypesProvider;
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.lang.LangBundle;
|
||||
import com.intellij.lang.StdLanguages;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
@@ -32,6 +33,7 @@ import com.intellij.psi.filters.TrueFilter;
|
||||
import com.intellij.psi.filters.classes.ThisOrAnyInnerFilter;
|
||||
import com.intellij.psi.filters.element.ExcludeDeclaredFilter;
|
||||
import com.intellij.psi.filters.types.AssignableFromFilter;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -66,8 +68,29 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (completingRawConstructor(context, item) && !JavaCompletionUtil.hasAccessibleInnerClass(item.getObject(), file)) {
|
||||
ConstructorInsertHandler.insertParentheses(context, item, item.getObject());
|
||||
PsiElement position = file.findElementAt(offset);
|
||||
PsiClass psiClass = item.getObject();
|
||||
|
||||
if (context.getCompletionChar() == '#') {
|
||||
context.setLaterRunnable(new Runnable() {
|
||||
public void run() {
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC).invoke(context.getProject(), context.getEditor(), file);
|
||||
}
|
||||
});
|
||||
TailType.insertChar(context.getEditor(), context.getTailOffset(), '#');
|
||||
}
|
||||
|
||||
if (position != null) {
|
||||
PsiElement parent = position.getParent();
|
||||
if (parent instanceof PsiJavaCodeReferenceElement && PsiTreeUtil.getParentOfType(position, PsiDocTag.class) != null) {
|
||||
if (((PsiJavaCodeReferenceElement)parent).isReferenceTo(psiClass)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (completingRawConstructor(context, item) && !JavaCompletionUtil.hasAccessibleInnerClass(psiClass, file)) {
|
||||
ConstructorInsertHandler.insertParentheses(context, item, psiClass);
|
||||
DefaultInsertHandler.addImportForItem(context.getFile(), context.getStartOffset(), item);
|
||||
} else {
|
||||
new DefaultInsertHandler().handleInsert(context, item);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class A{
|
||||
{
|
||||
String str;
|
||||
str.toCharArray();
|
||||
str.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
class A{
|
||||
{
|
||||
final String path = BASE_PATH;
|
||||
path.toCharArray()<caret>;
|
||||
path.toString()<caret>;
|
||||
sdkfjsdkhjfh();
|
||||
}
|
||||
}
|
||||
@@ -217,4 +217,28 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
assert lookup
|
||||
}
|
||||
|
||||
public void testFocusInJavadoc() {
|
||||
myFixture.configureByText("a.java", """
|
||||
/**
|
||||
* {@link ArrLi<caret>}
|
||||
*/
|
||||
class Foo {}
|
||||
""")
|
||||
type 's'
|
||||
assert lookup.focused
|
||||
|
||||
}
|
||||
|
||||
public void testPrefixLengthDependentSorting() {
|
||||
myFixture.addClass("package foo; public class PsiJavaCodeReferenceElement {}")
|
||||
myFixture.configureByText("a.java", """
|
||||
class PsiJavaCodeReferenceElementImpl {
|
||||
{ <caret> }
|
||||
}
|
||||
""")
|
||||
type 'PJCR'
|
||||
assertOrderedEquals myFixture.lookupElementStrings, 'PsiJavaCodeReferenceElement', 'PsiJavaCodeReferenceElementImpl'
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-2
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.testFramework.fixtures.impl;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.ProjectScope;
|
||||
@@ -49,12 +51,17 @@ public class JavaCodeInsightTestFixtureImpl extends CodeInsightTestFixtureImpl i
|
||||
return psiClass;
|
||||
}
|
||||
|
||||
private PsiClass addClass(@NonNls String rootPath, @NotNull @NonNls final String classText) throws IOException {
|
||||
private PsiClass addClass(@NonNls final String rootPath, @NotNull @NonNls final String classText) throws IOException {
|
||||
final PsiClass aClass = ((PsiJavaFile)PsiFileFactory.getInstance(getProject()).createFileFromText("a.java", classText)).getClasses()[0];
|
||||
final String qName = aClass.getQualifiedName();
|
||||
assert qName != null;
|
||||
|
||||
final PsiFile psiFile = addFileToProject(rootPath, qName.replace('.', '/') + ".java", classText);
|
||||
final PsiFile psiFile = new WriteCommandAction<PsiFile>(getProject()) {
|
||||
@Override
|
||||
protected void run(Result<PsiFile> result) throws Throwable {
|
||||
result.setResult(addFileToProject(rootPath, qName.replace('.', '/') + ".java", classText));
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
return ((PsiJavaFile)psiFile).getClasses()[0];
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -35,8 +35,7 @@ public class PrefixMatchingWeigher extends CompletionWeigher {
|
||||
final String prefixHumps = StringUtil.capitalsOnly(prefix);
|
||||
final String itemHumps = StringUtil.capitalsOnly(lookupString);
|
||||
|
||||
if (itemHumps.equals(prefixHumps)) return 20;
|
||||
if (itemHumps.startsWith(prefixHumps)) return 10;
|
||||
if (itemHumps.startsWith(prefixHumps)) return 100 - itemHumps.length();
|
||||
|
||||
if (lookupString.startsWith(prefix)) return 5;
|
||||
if (StringUtil.startsWithIgnoreCase(lookupString, prefix)) return 1;
|
||||
|
||||
+1
-1
@@ -452,7 +452,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
|
||||
@Nullable
|
||||
private static TextRange insertNewLineIndentMarker(@NotNull Document document, final int offset) {
|
||||
CharSequence text = document.getCharsSequence();
|
||||
if (!isWhiteSpaceSymbol(text.charAt(offset))) {
|
||||
if (offset < 0 || offset >= text.length() || !isWhiteSpaceSymbol(text.charAt(offset))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -356,8 +356,9 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
}
|
||||
myIndexIdToVersionMap.put(name, version);
|
||||
final File versionFile = IndexInfrastructure.getVersionFile(name);
|
||||
final boolean versionFileExisted = versionFile.exists();
|
||||
if (isCurrentVersionCorrupted || IndexInfrastructure.versionDiffers(versionFile, version)) {
|
||||
if (!isCurrentVersionCorrupted) {
|
||||
if (!isCurrentVersionCorrupted && versionFileExisted) {
|
||||
versionChanged = true;
|
||||
LOG.info("Version has changed for index " + extension.getName() + ". The index will be rebuilt.");
|
||||
}
|
||||
|
||||
@@ -264,11 +264,11 @@ public abstract class HistoryDialog<T extends HistoryDialogModel> extends FrameW
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) return;
|
||||
if (isDisposed() || myProject.isDisposed()) return;
|
||||
|
||||
invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) return;
|
||||
if (isDisposed() || myProject.isDisposed()) return;
|
||||
|
||||
isUpdating = true;
|
||||
updateActions();
|
||||
@@ -287,7 +287,7 @@ public abstract class HistoryDialog<T extends HistoryDialogModel> extends FrameW
|
||||
final Runnable finalApply = apply;
|
||||
invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) return;
|
||||
if (isDisposed() || myProject.isDisposed()) return;
|
||||
|
||||
isUpdating = false;
|
||||
if (finalApply != null) {
|
||||
|
||||
@@ -238,14 +238,14 @@ public class SegmentArray {
|
||||
|
||||
public int getSegmentStart(int index) {
|
||||
if (index < 0 || index >= mySegmentCount) {
|
||||
throw new IndexOutOfBoundsException("Wrong line: " + index);
|
||||
throw new IndexOutOfBoundsException("Wrong line: " + index + ". Available lines count: " + mySegmentCount);
|
||||
}
|
||||
return myStarts[index];
|
||||
}
|
||||
|
||||
public int getSegmentEnd(int index) {
|
||||
if (index < 0 || index >= mySegmentCount) {
|
||||
throw new IndexOutOfBoundsException("Wrong line: " + index);
|
||||
throw new IndexOutOfBoundsException("Wrong line: " + index + ". Available lines count: " + mySegmentCount);
|
||||
}
|
||||
return myEnds[index];
|
||||
}
|
||||
|
||||
@@ -1603,6 +1603,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
if (!getFoldingModel().isOffsetCollapsed(startOffset)) {
|
||||
if (visibleStartLine >= startLineNumber && visibleStartLine <= endLineNumber) {
|
||||
int logStartLine = offsetToLogicalPosition(startOffset).line;
|
||||
if (logStartLine >= myDocument.getLineCount()) {
|
||||
return;
|
||||
}
|
||||
LogicalPosition logPosition = offsetToLogicalPosition(myDocument.getLineEndOffset(logStartLine));
|
||||
Point end = logicalPositionToXY(logPosition);
|
||||
int charWidth = EditorUtil.getSpaceWidth(Font.PLAIN, this);
|
||||
|
||||
+9
-1
@@ -247,7 +247,15 @@ public class FSRecords implements Forceable {
|
||||
|
||||
private static void invalidateIndex() {
|
||||
LOG.info("Marking VFS as corrupted");
|
||||
FileUtil.createIfDoesntExist(new File(PathManager.getIndexRoot(), "corruption.marker"));
|
||||
final File indexRoot = PathManager.getIndexRoot();
|
||||
if (indexRoot.exists()) {
|
||||
final String[] children = indexRoot.list();
|
||||
if (children != null && children.length > 0) {
|
||||
// create index corruption marker only if index directory exists and is non-empty
|
||||
// It is incorrect to consider non-existing indices "corrupted"
|
||||
FileUtil.createIfDoesntExist(new File(PathManager.getIndexRoot(), "corruption.marker"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static File basePath() {
|
||||
|
||||
+1
-1
@@ -391,7 +391,7 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler {
|
||||
outputFile.getParentFile().mkdirs();
|
||||
|
||||
boolean shouldFilter = eachItem.isFiltered();
|
||||
if (sourceFile.length() > 10 * 1024 * 1024) {
|
||||
if (shouldFilter && sourceFile.length() > 10 * 1024 * 1024) {
|
||||
context.addMessage(CompilerMessageCategory.WARNING,
|
||||
"Maven: File is too big to be filtered. Most likely it is a binary file and should be excluded from filtering.",
|
||||
sourceVirtualFile.getUrl(), -1, -1);
|
||||
|
||||
+3
-3
@@ -31,13 +31,13 @@ public class MavenArtifactCoordinatesVersionConverter extends MavenArtifactCoord
|
||||
|| StringUtil.isEmpty(id.getVersion())) {
|
||||
return false;
|
||||
}
|
||||
if (isVersionRange(id)) return true; // todo handle ranges more sensibly
|
||||
if (isMagicVersion(id)) return true; // todo handle ranges more sensibly
|
||||
return manager.hasVersion(id.getGroupId(), id.getArtifactId(), id.getVersion());
|
||||
}
|
||||
|
||||
private boolean isVersionRange(MavenId id) {
|
||||
private boolean isMagicVersion(MavenId id) {
|
||||
String version = id.getVersion().trim();
|
||||
return version.startsWith("(") || version.startsWith("[");
|
||||
return version.equals("LATEST") || version.equals("RELEASE") || version.startsWith("(") || version.startsWith("[");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+52
@@ -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 org.jetbrains.idea.maven.utils;
|
||||
|
||||
import com.intellij.navigation.ChooseByNameContributor;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MavenGotoFileContributor implements ChooseByNameContributor {
|
||||
public String[] getNames(Project project, boolean includeNonProjectItems) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
|
||||
for (MavenProject each : MavenProjectsManager.getInstance(project).getProjects()) {
|
||||
result.add(each.getMavenId().getArtifactId());
|
||||
}
|
||||
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
|
||||
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
|
||||
List<NavigationItem> result = new ArrayList<NavigationItem>();
|
||||
|
||||
for (final MavenProject each : MavenProjectsManager.getInstance(project).getProjects()) {
|
||||
if (name.equals(each.getMavenId().getArtifactId())) {
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(each.getFile());
|
||||
if (psiFile != null) result.add(psiFile);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toArray(new NavigationItem[result.size()]);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -30,7 +30,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MavenGotoSettingsFileContibutor implements ChooseByNameContributor, DumbAware {
|
||||
public class MavenGotoSettingsFileContributor implements ChooseByNameContributor, DumbAware {
|
||||
public String[] getNames(Project project, boolean includeNonProjectItems) {
|
||||
if (!includeNonProjectItems) return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
public class MavenGotoPropertyFileContibutor implements ChooseByNameContributor {
|
||||
public class MavenGotoPropertyFileContributor implements ChooseByNameContributor {
|
||||
public String[] getNames(Project project, boolean includeNonProjectItems) {
|
||||
if (!includeNonProjectItems) return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
return MavenPropertiesVirtualFileSystem.PROPERTIES_FILES;
|
||||
@@ -95,8 +95,9 @@
|
||||
<codeInsight.unresolvedReferenceQuickFixProvider
|
||||
implementation="org.jetbrains.idea.maven.dom.intentions.ResolveReferenceQuickFixProvider"/>
|
||||
|
||||
<gotoFileContributor implementation="org.jetbrains.idea.maven.vfs.MavenGotoPropertyFileContibutor"/>
|
||||
<gotoFileContributor implementation="org.jetbrains.idea.maven.utils.MavenGotoSettingsFileContibutor"/>
|
||||
<gotoFileContributor implementation="org.jetbrains.idea.maven.utils.MavenGotoFileContributor"/>
|
||||
<gotoFileContributor implementation="org.jetbrains.idea.maven.utils.MavenGotoSettingsFileContributor"/>
|
||||
<gotoFileContributor implementation="org.jetbrains.idea.maven.vfs.MavenGotoPropertyFileContributor"/>
|
||||
<fileTemplateGroup implementation="org.jetbrains.idea.maven.utils.MavenFileTemplateGroupFactory"/>
|
||||
|
||||
<annotator language="XML" implementationClass="org.jetbrains.idea.maven.dom.annotator.MavenDomGutterAnnotator"/>
|
||||
|
||||
+21
@@ -57,4 +57,25 @@ public class MavenDependencySpecialVersionsCompletionAndResolutionTest extends M
|
||||
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
public void testDoNotHighlightLatestAndReleaseDependencies() throws Throwable {
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<dependencies>" +
|
||||
" <dependency>" +
|
||||
" <groupId>jmock</groupId>" +
|
||||
" <artifactId>jmock</artifactId>" +
|
||||
" <version>LATEST</version>" +
|
||||
" </dependency>" +
|
||||
" <dependency>" +
|
||||
" <groupId>jmock</groupId>" +
|
||||
" <artifactId>jmock</artifactId>" +
|
||||
" <version>RELEASE</version>" +
|
||||
" </dependency>" +
|
||||
"</dependencies>");
|
||||
|
||||
checkHighlighting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,6 +231,7 @@
|
||||
id="excludeFromCompletion" order="last"/>
|
||||
|
||||
<completion.confidence language="JAVA" implementationClass="com.intellij.codeInsight.completion.UnfocusedNameIdentifier" id="javaNameIdentifier"/>
|
||||
<completion.confidence language="JAVA" implementationClass="com.intellij.codeInsight.completion.FocusInJavadoc" id="javadoc" order="before javaComments"/>
|
||||
<completion.confidence language="JAVA" implementationClass="com.intellij.codeInsight.completion.UnfocusedComments" id="javaComments"/>
|
||||
<completion.confidence language="JAVA" implementationClass="com.intellij.codeInsight.completion.AlwaysFocusLookup" id="javaTrue" order="last"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user