diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java index dbb380ae54e4..357c934f8f2d 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java @@ -318,7 +318,7 @@ public class HighlightControlFlowUtil { return null; } final PsiField anotherField = PsiTreeUtil.getTopmostParentOfType(expression, PsiField.class); - if (anotherField != null && anotherField.getContainingClass() == aClass) { + if (anotherField != null && anotherField.getContainingClass() == aClass && !field.hasModifierProperty(PsiModifier.STATIC)) { startOffset = 0; } block = null; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java index a86c0b310882..8f09a701701a 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java @@ -239,4 +239,14 @@ class IDEA100237 { final int qux = bar.hashCode() + 1; }; } +} + +class StaticInitializerUsedInAnotherStaticField { + private static final int ENUMERATION_CACHE_SIZE; + + static { + ENUMERATION_CACHE_SIZE = 0; + } + + private static final int ourEnumerationCacheConstant = ENUMERATION_CACHE_SIZE; } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy index 8d03d1fa5ddf..5deabbd30fd8 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy +++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy @@ -172,6 +172,8 @@ class Intf { assert getPopupElements(new GotoClassModel2(project), 'Bar') == [c] assert getPopupElements(new GotoClassModel2(project), 'Bar:2') == [c] assert getPopupElements(new GotoClassModel2(project), 'Bar:2:3') == [c] + assert getPopupElements(new GotoClassModel2(project), 'Bar:[2:3]') == [c] + assert getPopupElements(new GotoClassModel2(project), 'Bar:[2,3]') == [c] } private List getPopupElements(ChooseByNameModel model, String text) { diff --git a/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java b/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java index 278ccd4541cc..3c7a8d3f4041 100644 --- a/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java +++ b/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java @@ -89,6 +89,7 @@ public interface DetailView extends UserDataHolder { return myFile; } + @Nullable public LogicalPosition getNavigate() { return myNavigate; } @@ -101,7 +102,7 @@ public interface DetailView extends UserDataHolder { private final LogicalPosition myNavigate; private final TextAttributes myAttributes; - public PreviewEditorState(VirtualFile file, LogicalPosition navigate, TextAttributes attributes) { + public PreviewEditorState(VirtualFile file, @Nullable LogicalPosition navigate, TextAttributes attributes) { myFile = file; myNavigate = navigate; diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java index 465482ca76c4..4f6959da84f6 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java @@ -332,7 +332,7 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP return newPopup; } - private static final Pattern patternToDetectLinesAndColumns = Pattern.compile("([^:]+)(?::|@|,)(\\d+)?(?:(?:\\D)(\\d+)?)?"); + private static final Pattern patternToDetectLinesAndColumns = Pattern.compile("([^:]+)(?::|@|,|)\\[?(\\d+)?(?:(?:\\D)(\\d+)?)?\\]?"); private static final Pattern patternToDetectAnonymousClasses = Pattern.compile("([\\.\\w]+)((\\$[\\d]+)*(\\$)?)"); private static final Pattern patternToDetectMembers = Pattern.compile("(.+)(#)(.*)"); diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java b/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java index c66212e0ffc1..76939d421741 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java @@ -156,14 +156,16 @@ public class DetailViewImpl extends JPanel implements DetailView, UserDataHolder add(getEditor().getComponent(), BorderLayout.CENTER); } - getEditor().getCaretModel().moveToLogicalPosition(positionToNavigate); - validate(); - getEditor().getScrollingModel().scrollToCaret(ScrollType.CENTER); + if (positionToNavigate != null) { + getEditor().getCaretModel().moveToLogicalPosition(positionToNavigate); + validate(); + getEditor().getScrollingModel().scrollToCaret(ScrollType.CENTER); + } getEditor().setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); clearHightlighting(); - if (lineAttributes != null) { + if (lineAttributes != null && positionToNavigate != null) { myHighlighter = getEditor().getMarkupModel().addLineHighlighter(positionToNavigate.line, HighlighterLayer.SELECTION - 1, lineAttributes); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java index cc26a84aef29..22346edecdcd 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java @@ -70,13 +70,14 @@ class DetailsPanel extends JPanel implements ListSelectionListener { add(myMessagePanel, MESSAGE_LAYER); setBackground(UIUtil.getTableBackground()); + showMessage("No commits selected"); } @Override public void valueChanged(@Nullable ListSelectionEvent notUsed) { int[] rows = myGraphTable.getSelectedRows(); if (rows.length < 1) { - showMessage("Nothing selected"); + showMessage("No commits selected"); } else if (rows.length > 1) { showMessage("Several commits selected"); @@ -85,7 +86,7 @@ class DetailsPanel extends JPanel implements ListSelectionListener { ((CardLayout)getLayout()).show(this, STANDARD_LAYER); Hash hash = ((AbstractVcsLogTableModel)myGraphTable.getModel()).getHashAtRow(rows[0]); if (hash == null) { - showMessage("Nothing selected"); + showMessage("No commits selected"); return; } @@ -206,6 +207,8 @@ class DetailsPanel extends JPanel implements ListSelectionListener { super(new BorderLayout()); myLabel = new JLabel(); myLabel.setForeground(UIUtil.getInactiveTextColor()); + myLabel.setHorizontalAlignment(SwingConstants.CENTER); + myLabel.setVerticalAlignment(SwingConstants.CENTER); add(myLabel); } diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java index 27947217d265..69f6efb14a50 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java @@ -46,8 +46,8 @@ public class GithubApiUtil { private static final String PER_PAGE = "per_page=100"; private static final Logger LOG = GithubUtil.LOG; - private static final Header ACCEPT_HTML_BODY_MARKUP = new Header("Accept", "application/vnd.github.v3.html+json"); - private static final Header ACCEPT_NEW_SEARCH_API = new Header("Accept", "application/vnd.github.preview"); + private static final Header ACCEPT_V3_JSON_HTML_MARKUP = new Header("Accept", "application/vnd.github.v3.html+json"); + private static final Header ACCEPT_V3_JSON = new Header("Accept", "application/vnd.github.v3+json"); @NotNull private static final Gson gson = initGson(); @@ -433,7 +433,7 @@ public class GithubApiUtil { @NotNull public static GithubUser getCurrentUser(@NotNull GithubAuthData auth) throws IOException { try { - JsonElement result = getRequest(auth, "/user"); + JsonElement result = getRequest(auth, "/user", ACCEPT_V3_JSON); return createDataFromRaw(fromJson(result, GithubUserRaw.class), GithubUser.class); } catch (GithubConfusingException e) { @@ -445,7 +445,7 @@ public class GithubApiUtil { @NotNull public static GithubUserDetailed getCurrentUserDetailed(@NotNull GithubAuthData auth) throws IOException { try { - JsonElement result = getRequest(auth, "/user"); + JsonElement result = getRequest(auth, "/user", ACCEPT_V3_JSON); return createDataFromRaw(fromJson(result, GithubUserRaw.class), GithubUserDetailed.class); } catch (GithubConfusingException e) { @@ -459,7 +459,7 @@ public class GithubApiUtil { try { String path = "/user/repos?" + PER_PAGE; - PagedRequest request = new PagedRequest(path, GithubRepo.class, GithubRepoRaw[].class); + PagedRequest request = new PagedRequest(path, GithubRepo.class, GithubRepoRaw[].class, ACCEPT_V3_JSON); return request.getAll(auth); } @@ -474,7 +474,7 @@ public class GithubApiUtil { try { String path = "/users/" + user + "/repos?" + PER_PAGE; - PagedRequest request = new PagedRequest(path, GithubRepo.class, GithubRepoRaw[].class); + PagedRequest request = new PagedRequest(path, GithubRepo.class, GithubRepoRaw[].class, ACCEPT_V3_JSON); return request.getAll(auth); } @@ -509,7 +509,8 @@ public class GithubApiUtil { List repos = new ArrayList(); for (GithubOrg org : orgsRequest.getAll(auth)) { String path = "/orgs/" + org.getLogin() + "/repos?type=member&" + PER_PAGE; - PagedRequest request = new PagedRequest(path, GithubRepoOrg.class, GithubRepoRaw[].class); + PagedRequest request = + new PagedRequest(path, GithubRepoOrg.class, GithubRepoRaw[].class, ACCEPT_V3_JSON); repos.addAll(request.getAll(auth)); } @@ -519,7 +520,8 @@ public class GithubApiUtil { @NotNull public static List getWatchedRepos(@NotNull GithubAuthData auth) throws IOException { String pathWatched = "/user/subscriptions?" + PER_PAGE; - PagedRequest requestWatched = new PagedRequest(pathWatched, GithubRepo.class, GithubRepoRaw[].class); + PagedRequest requestWatched = + new PagedRequest(pathWatched, GithubRepo.class, GithubRepoRaw[].class, ACCEPT_V3_JSON); return requestWatched.getAll(auth); } @@ -529,7 +531,7 @@ public class GithubApiUtil { try { final String request = "/repos/" + owner + "/" + name; - JsonElement jsonObject = getRequest(auth, request); + JsonElement jsonObject = getRequest(auth, request, ACCEPT_V3_JSON); return createDataFromRaw(fromJson(jsonObject, GithubRepoRaw.class), GithubRepoDetailed.class); } @@ -566,7 +568,7 @@ public class GithubApiUtil { public static GithubGist getGist(@NotNull GithubAuthData auth, @NotNull String id) throws IOException { try { String path = "/gists/" + id; - JsonElement result = getRequest(auth, path); + JsonElement result = getRequest(auth, path, ACCEPT_V3_JSON); return createDataFromRaw(fromJson(result, GithubGistRaw.class), GithubGist.class); } @@ -583,7 +585,7 @@ public class GithubApiUtil { boolean isPrivate) throws IOException { try { String request = gson.toJson(new GithubGistRequest(contents, description, !isPrivate)); - return createDataFromRaw(fromJson(postRequest(auth, "/gists", request), GithubGistRaw.class), GithubGist.class); + return createDataFromRaw(fromJson(postRequest(auth, "/gists", request, ACCEPT_V3_JSON), GithubGistRaw.class), GithubGist.class); } catch (GithubConfusingException e) { e.setDetails("Can't create gist"); @@ -601,8 +603,9 @@ public class GithubApiUtil { @NotNull String base) throws IOException { try { String request = gson.toJson(new GithubPullRequestRequest(title, description, head, base)); - return createDataFromRaw(fromJson(postRequest(auth, "/repos/" + user + "/" + repo + "/pulls", request), GithubPullRequestRaw.class), - GithubPullRequest.class); + return createDataFromRaw( + fromJson(postRequest(auth, "/repos/" + user + "/" + repo + "/pulls", request, ACCEPT_V3_JSON), GithubPullRequestRaw.class), + GithubPullRequest.class); } catch (GithubConfusingException e) { e.setDetails("Can't create pull request"); @@ -618,7 +621,8 @@ public class GithubApiUtil { GithubRepoRequest request = new GithubRepoRequest(name, description, isPrivate); - return createDataFromRaw(fromJson(postRequest(auth, path, gson.toJson(request)), GithubRepoRaw.class), GithubRepo.class); + return createDataFromRaw(fromJson(postRequest(auth, path, gson.toJson(request), ACCEPT_V3_JSON), GithubRepoRaw.class), + GithubRepo.class); } catch (GithubConfusingException e) { e.setDetails("Can't create repository: " + name); @@ -644,7 +648,7 @@ public class GithubApiUtil { path = "/repos/" + user + "/" + repo + "/issues?assignee=" + assigned + "&" + PER_PAGE; } - PagedRequest request = new PagedRequest(path, GithubIssue.class, GithubIssueRaw[].class); + PagedRequest request = new PagedRequest(path, GithubIssue.class, GithubIssueRaw[].class, ACCEPT_V3_JSON); List result = new ArrayList(); while (request.hasNext() && max > result.size()) { @@ -670,9 +674,8 @@ public class GithubApiUtil { query = URLEncoder.encode("@" + user + "/" + repo + " " + query, "UTF-8"); String path = "/search/issues?q=" + query; - //TODO: remove header after end of preview period. ~ october 2013 - //TODO: Use bodyHtml for issues - preview does not support this feature - JsonElement result = getRequest(auth, path, ACCEPT_NEW_SEARCH_API); + //TODO: Use bodyHtml for issues - GitHub does not support this feature for SearchApi yet + JsonElement result = getRequest(auth, path, ACCEPT_V3_JSON); return createDataFromRaw(fromJson(result, GithubIssuesSearchResultRaw.class), GithubIssuesSearchResult.class).getIssues(); } @@ -688,7 +691,7 @@ public class GithubApiUtil { try { String path = "/repos/" + user + "/" + repo + "/issues/" + id; - JsonElement result = getRequest(auth, path); + JsonElement result = getRequest(auth, path, ACCEPT_V3_JSON); return createDataFromRaw(fromJson(result, GithubIssueRaw.class), GithubIssue.class); } @@ -705,7 +708,7 @@ public class GithubApiUtil { String path = "/repos/" + user + "/" + repo + "/issues/" + id + "/comments?" + PER_PAGE; PagedRequest request = - new PagedRequest(path, GithubIssueComment.class, GithubIssueCommentRaw[].class, ACCEPT_HTML_BODY_MARKUP); + new PagedRequest(path, GithubIssueComment.class, GithubIssueCommentRaw[].class, ACCEPT_V3_JSON_HTML_MARKUP); return request.getAll(auth); } @@ -723,7 +726,7 @@ public class GithubApiUtil { try { String path = "/repos/" + user + "/" + repo + "/commits/" + sha; - JsonElement result = getRequest(auth, path); + JsonElement result = getRequest(auth, path, ACCEPT_V3_JSON); return createDataFromRaw(fromJson(result, GithubCommitRaw.class), GithubCommitDetailed.class); } catch (GithubConfusingException e) { @@ -741,7 +744,7 @@ public class GithubApiUtil { String path = "/repos/" + user + "/" + repo + "/commits/" + sha + "/comments"; PagedRequest request = - new PagedRequest(path, GithubCommitComment.class, GithubCommitCommentRaw[].class, ACCEPT_HTML_BODY_MARKUP); + new PagedRequest(path, GithubCommitComment.class, GithubCommitCommentRaw[].class, ACCEPT_V3_JSON_HTML_MARKUP); return request.getAll(auth); } @@ -760,7 +763,7 @@ public class GithubApiUtil { String path = "/repos/" + user + "/" + repo + "/pulls/" + id + "/comments"; PagedRequest request = - new PagedRequest(path, GithubCommitComment.class, GithubCommitCommentRaw[].class, ACCEPT_HTML_BODY_MARKUP); + new PagedRequest(path, GithubCommitComment.class, GithubCommitCommentRaw[].class, ACCEPT_V3_JSON_HTML_MARKUP); return request.getAll(auth); } @@ -775,7 +778,7 @@ public class GithubApiUtil { throws IOException { try { String path = "/repos/" + user + "/" + repo + "/pulls/" + id; - return createDataFromRaw(fromJson(getRequest(auth, path, ACCEPT_HTML_BODY_MARKUP), GithubPullRequestRaw.class), + return createDataFromRaw(fromJson(getRequest(auth, path, ACCEPT_V3_JSON_HTML_MARKUP), GithubPullRequestRaw.class), GithubPullRequest.class); } catch (GithubConfusingException e) { @@ -791,7 +794,7 @@ public class GithubApiUtil { String path = "/repos/" + user + "/" + repo + "/pulls?" + PER_PAGE; PagedRequest request = - new PagedRequest(path, GithubPullRequest.class, GithubPullRequestRaw[].class, ACCEPT_HTML_BODY_MARKUP); + new PagedRequest(path, GithubPullRequest.class, GithubPullRequestRaw[].class, ACCEPT_V3_JSON_HTML_MARKUP); return request.getAll(auth); } @@ -805,7 +808,7 @@ public class GithubApiUtil { public static PagedRequest getPullRequests(@NotNull String user, @NotNull String repo) { String path = "/repos/" + user + "/" + repo + "/pulls?" + PER_PAGE; - return new PagedRequest(path, GithubPullRequest.class, GithubPullRequestRaw[].class, ACCEPT_HTML_BODY_MARKUP); + return new PagedRequest(path, GithubPullRequest.class, GithubPullRequestRaw[].class, ACCEPT_V3_JSON_HTML_MARKUP); } @NotNull @@ -814,7 +817,8 @@ public class GithubApiUtil { try { String path = "/repos/" + user + "/" + repo + "/pulls/" + id + "/commits?" + PER_PAGE; - PagedRequest request = new PagedRequest(path, GithubCommit.class, GithubCommitRaw[].class); + PagedRequest request = + new PagedRequest(path, GithubCommit.class, GithubCommitRaw[].class, ACCEPT_V3_JSON); return request.getAll(auth); } @@ -830,7 +834,7 @@ public class GithubApiUtil { try { String path = "/repos/" + user + "/" + repo + "/pulls/" + id + "/files?" + PER_PAGE; - PagedRequest request = new PagedRequest(path, GithubFile.class, GithubFileRaw[].class); + PagedRequest request = new PagedRequest(path, GithubFile.class, GithubFileRaw[].class, ACCEPT_V3_JSON); return request.getAll(auth); } @@ -846,7 +850,8 @@ public class GithubApiUtil { try { String path = "/repos/" + user + "/" + repo + "/branches?" + PER_PAGE; - PagedRequest request = new PagedRequest(path, GithubBranch.class, GithubBranchRaw[].class); + PagedRequest request = + new PagedRequest(path, GithubBranch.class, GithubBranchRaw[].class, ACCEPT_V3_JSON); return request.getAll(auth); } @@ -864,7 +869,7 @@ public class GithubApiUtil { try { String path = "/repos/" + user + "/" + repo + "/forks?" + PER_PAGE; - PagedRequest request = new PagedRequest(path, GithubRepo.class, GithubRepoRaw[].class); + PagedRequest request = new PagedRequest(path, GithubRepo.class, GithubRepoRaw[].class, ACCEPT_V3_JSON); while (request.hasNext()) { for (GithubRepo fork : request.next(auth)) { diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/GithubGistRaw.java b/plugins/github/src/org/jetbrains/plugins/github/api/GithubGistRaw.java index 17919fe99846..2ff77971fe9e 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/GithubGistRaw.java +++ b/plugins/github/src/org/jetbrains/plugins/github/api/GithubGistRaw.java @@ -42,7 +42,7 @@ class GithubGistRaw implements DataConstructor { @Nullable public Map files; - @Nullable public GithubUserRaw user; + @Nullable public GithubUserRaw owner; @Nullable public Date createdAt; @@ -66,7 +66,7 @@ class GithubGistRaw implements DataConstructor { @SuppressWarnings("ConstantConditions") @NotNull public GithubGist createGist() { - GithubUser user = this.user == null ? null : this.user.createUser(); + GithubUser user = this.owner == null ? null : this.owner.createUser(); List files = new ArrayList(); for (Map.Entry entry : this.files.entrySet()) { diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubIssuesTest.java b/plugins/github/test/org/jetbrains/plugins/github/GithubIssuesTest.java index e1f6a9291920..80220e0385b7 100644 --- a/plugins/github/test/org/jetbrains/plugins/github/GithubIssuesTest.java +++ b/plugins/github/test/org/jetbrains/plugins/github/GithubIssuesTest.java @@ -68,7 +68,7 @@ public class GithubIssuesTest extends GithubTest { } }); - List expected = Arrays.asList(1L, 2L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L); + List expected = Arrays.asList(1L, 2L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 14L); assertTrue(Comparing.haveEqualElements(issues, expected)); }