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:
@@ -799,6 +799,7 @@ public class DeclarationParser {
|
||||
|
||||
parseAnnotationValue(builder);
|
||||
|
||||
boolean unclosed = false;
|
||||
while (true) {
|
||||
if (expect(builder, JavaTokenType.RBRACE)) {
|
||||
break;
|
||||
@@ -808,11 +809,15 @@ public class DeclarationParser {
|
||||
}
|
||||
else {
|
||||
error(builder, JavaErrorMessages.message("expected.rbrace"));
|
||||
unclosed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
annoArray.done(JavaElementType.ANNOTATION_ARRAY_INITIALIZER);
|
||||
if (unclosed) {
|
||||
annoArray.setCustomEdgeProcessors(null, GREEDY_RIGHT_EDGE_PROCESSOR);
|
||||
}
|
||||
return annoArray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,18 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class JavaParserUtil {
|
||||
private static final Key<LanguageLevel> LANG_LEVEL_KEY = Key.create("JavaParserUtil.LanguageLevel");
|
||||
|
||||
public static final WhitespacesAndCommentsProcessor GREEDY_RIGHT_EDGE_PROCESSOR = new WhitespacesAndCommentsProcessor() {
|
||||
public int process(final List<IElementType> tokens) {
|
||||
return tokens.size();
|
||||
}
|
||||
};
|
||||
|
||||
private JavaParserUtil() { }
|
||||
|
||||
public static void setLanguageLevel(final PsiBuilder builder, final LanguageLevel level) {
|
||||
@@ -124,7 +132,7 @@ public class JavaParserUtil {
|
||||
|
||||
@Override
|
||||
public boolean eof() {
|
||||
return getCurrentOffset() < stopAt || super.eof();
|
||||
return getCurrentOffset() >= stopAt || super.eof();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.intellij.lang.java.parser;
|
||||
|
||||
import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.WhitespacesAndCommentsProcessor;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
@@ -43,12 +42,6 @@ public class StatementParser {
|
||||
|
||||
private static final TokenSet TRY_CLOSERS_SET = TokenSet.create(JavaTokenType.CATCH_KEYWORD, JavaTokenType.FINALLY_KEYWORD);
|
||||
|
||||
private static final WhitespacesAndCommentsProcessor GREEDY_CODE_BLOCK_PROCESSOR = new WhitespacesAndCommentsProcessor() {
|
||||
public int process(final List<IElementType> tokens) {
|
||||
return tokens.size();
|
||||
}
|
||||
};
|
||||
|
||||
private StatementParser() { }
|
||||
|
||||
@Nullable
|
||||
@@ -109,7 +102,7 @@ public class StatementParser {
|
||||
|
||||
codeBlock.collapse(JavaElementType.CODE_BLOCK);
|
||||
if (greedyBlock) {
|
||||
codeBlock.setCustomEdgeProcessors(null, GREEDY_CODE_BLOCK_PROCESSOR);
|
||||
codeBlock.setCustomEdgeProcessors(null, GREEDY_RIGHT_EDGE_PROCESSOR);
|
||||
}
|
||||
return codeBlock;
|
||||
}
|
||||
@@ -127,7 +120,7 @@ public class StatementParser {
|
||||
|
||||
codeBlock.done(JavaElementType.CODE_BLOCK);
|
||||
if (greedyBlock) {
|
||||
codeBlock.setCustomEdgeProcessors(null, GREEDY_CODE_BLOCK_PROCESSOR);
|
||||
codeBlock.setCustomEdgeProcessors(null, GREEDY_RIGHT_EDGE_PROCESSOR);
|
||||
}
|
||||
return codeBlock;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public interface JavaElementType {
|
||||
IElementType CATCH_SECTION = new IJavaElementType("CATCH_SECTION");
|
||||
|
||||
IElementType ANNOTATION_ARRAY_INITIALIZER = new IJavaElementType("ANNOTATION_ARRAY_INITIALIZER");
|
||||
IElementType NAME_VALUE_PAIR = new IJavaElementType("NAME_VALUE_PAIR");
|
||||
IElementType NAME_VALUE_PAIR = new IJavaElementType("NAME_VALUE_PAIR", true);
|
||||
IElementType ANNOTATION_PARAMETER_LIST = new IJavaElementType("ANNOTATION_PARAMETER_LIST", true);
|
||||
IElementType METHOD_RECEIVER = new IJavaElementType("METHOD_RECEIVER");
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
PsiJavaFile:MultiLineUnclosed.java
|
||||
PsiJavaFile:MultiLineUnclosed0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:Test
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
String uiTest1 = new String("Test1"),
|
||||
uiTest2<caret> = new String("Test2");
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
PsiJavaFile:MultiLineUnclosed1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:C
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:class('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:C('C')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiField:uiTest1
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:String
|
||||
PsiJavaCodeReferenceElement:String
|
||||
PsiIdentifier:String('String')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:uiTest1('uiTest1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:EQ('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiNewExpression:new String("Test1")
|
||||
PsiKeyword:new('new')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:String
|
||||
PsiIdentifier:String('String')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiExpressionList
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiLiteralExpression:"Test1"
|
||||
PsiJavaToken:STRING_LITERAL('"Test1"')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:uiTest2<caret>
|
||||
PsiJavaCodeReferenceElement:uiTest2<caret>
|
||||
PsiIdentifier:uiTest2('uiTest2')
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:caret
|
||||
PsiJavaCodeReferenceElement:caret
|
||||
PsiIdentifier:caret('caret')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiJavaToken:EQ('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:new('new')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiMethod:String
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:String('String')
|
||||
PsiParameterList:("Test2")
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiErrorElement:Parameter expected
|
||||
PsiJavaToken:STRING_LITERAL('"Test2"')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
+2
-1
@@ -18,7 +18,8 @@ public class FieldParsingTest extends JavaParsingTestCase {
|
||||
public void testUnclosedSemicolon() { doTest(true); }
|
||||
public void testMissingInitializerExpression() { doTest(true); }
|
||||
|
||||
public void testMultiLineUnclosed() { doTest(true); }
|
||||
public void testMultiLineUnclosed0() { doTest(true); }
|
||||
public void testMultiLineUnclosed1() { doTest(true); }
|
||||
|
||||
public void testComplexInitializer() { doTest(true); }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.openapi.vcs.changes;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ChangesRenameContext {
|
||||
private File myCurrentPath;
|
||||
|
||||
public ChangesRenameContext(File currentPath) {
|
||||
myCurrentPath = currentPath;
|
||||
}
|
||||
|
||||
public void checkForRename(final Collection<Change> list) {
|
||||
for (Change change : list) {
|
||||
if (change.getAfterRevision() != null && change.getBeforeRevision() != null) {
|
||||
if (change.getAfterRevision().getFile().getIOFile().equals(myCurrentPath) &&
|
||||
(! change.getBeforeRevision().getFile().getIOFile().equals(myCurrentPath))) {
|
||||
myCurrentPath = change.getBeforeRevision().getFile().getIOFile();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public File getCurrentPath() {
|
||||
return myCurrentPath;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ChangesRenameContext;
|
||||
import com.intellij.openapi.vcs.changes.committed.DecoratorManager;
|
||||
import com.intellij.openapi.vcs.changes.committed.VcsCommittedListsZipper;
|
||||
import com.intellij.openapi.vcs.changes.committed.VcsCommittedViewAuxiliary;
|
||||
@@ -227,7 +229,6 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider<
|
||||
|
||||
@Override
|
||||
public Pair<CommittedChangeList, FilePath> getOneList(VirtualFile file, final VcsRevisionNumber number) throws VcsException {
|
||||
// todo implement in proper way
|
||||
final FilePathImpl filePath = new FilePathImpl(file);
|
||||
final GitRepositoryLocation l = (GitRepositoryLocation) getLocationFor(filePath);
|
||||
VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(l.getRoot());
|
||||
@@ -239,6 +240,7 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider<
|
||||
GitUtil.getLocalCommittedChanges(myProject, root, new Consumer<GitSimpleHandler>() {
|
||||
public void consume(GitSimpleHandler h) {
|
||||
h.addParameters("-n1");
|
||||
h.addParameters("-M");
|
||||
h.addParameters(number.asString());
|
||||
}
|
||||
}, new Consumer<CommittedChangeList>() {
|
||||
@@ -247,7 +249,32 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider<
|
||||
result[0] = committedChangeList;
|
||||
}
|
||||
}, false);
|
||||
return new Pair<CommittedChangeList, FilePath>(result[0], filePath);
|
||||
|
||||
final Collection<Change> changes = result[0].getChanges();
|
||||
if (changes.size() == 1) {
|
||||
return new Pair<CommittedChangeList, FilePath>(result[0], changes.iterator().next().getAfterRevision().getFile());
|
||||
}
|
||||
for (Change change : changes) {
|
||||
if (change.getAfterRevision() != null && filePath.getIOFile().equals(change.getAfterRevision().getFile().getIOFile())) {
|
||||
return new Pair<CommittedChangeList, FilePath>(result[0], filePath);
|
||||
}
|
||||
}
|
||||
// go for history
|
||||
final ChangesRenameContext renameContext = new ChangesRenameContext(filePath.getIOFile());
|
||||
GitUtil.getLocalCommittedChanges(myProject, root, new Consumer<GitSimpleHandler>() {
|
||||
public void consume(GitSimpleHandler h) {
|
||||
h.addParameters("-M");
|
||||
h.addParameters(number.asString() + "..");
|
||||
}
|
||||
}, new Consumer<CommittedChangeList>() {
|
||||
@Override
|
||||
public void consume(CommittedChangeList committedChangeList) {
|
||||
final Collection<Change> list = committedChangeList.getChanges();
|
||||
renameContext.checkForRename(list);
|
||||
}
|
||||
}, false);
|
||||
renameContext.checkForRename(result[0].getChanges());
|
||||
return new Pair<CommittedChangeList, FilePath>(result[0], new FilePathImpl(renameContext.getCurrentPath(), false));
|
||||
}
|
||||
|
||||
public int getFormatVersion() {
|
||||
|
||||
Reference in New Issue
Block a user