From aa4d4718570b392652ecf3ed2f63ffba474e8c9b Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Sat, 8 Apr 2017 10:50:04 +0100
Subject: [PATCH 001/463] Cleanup & NotNulls
Remove trivial javadocs, reformat, lambdify, add @NotNulls
---
.../src/git4idea/GitContentRevision.java | 102 +++++++++---------
1 file changed, 52 insertions(+), 50 deletions(-)
diff --git a/plugins/git4idea/src/git4idea/GitContentRevision.java b/plugins/git4idea/src/git4idea/GitContentRevision.java
index 411d3bc82e66..8ab1fbf6cb9d 100644
--- a/plugins/git4idea/src/git4idea/GitContentRevision.java
+++ b/plugins/git4idea/src/git4idea/GitContentRevision.java
@@ -17,7 +17,6 @@ package git4idea;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
-import com.intellij.openapi.util.Throwable2Computable;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.ByteBackedContentRevision;
@@ -38,28 +37,17 @@ import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
-/**
- * Git content revision
- */
-public class GitContentRevision implements ByteBackedContentRevision {
- /**
- * the file path
- */
- @NotNull protected final FilePath myFile;
- /**
- * the revision number
- */
- @NotNull protected final GitRevisionNumber myRevision;
- /**
- * the context project
- */
- @NotNull protected final Project myProject;
- /**
- * The charset for the file
- */
- @Nullable private Charset myCharset;
+import static com.intellij.openapi.vcs.impl.ContentRevisionCache.UniqueType.REPOSITORY_CONTENT;
- protected GitContentRevision(@NotNull FilePath file, @NotNull GitRevisionNumber revision, @NotNull Project project,
+public class GitContentRevision implements ByteBackedContentRevision {
+ @NotNull protected final FilePath myFile;
+ @NotNull private final GitRevisionNumber myRevision;
+ @NotNull private final Project myProject;
+ @Nullable private final Charset myCharset;
+
+ protected GitContentRevision(@NotNull FilePath file,
+ @NotNull GitRevisionNumber revision,
+ @NotNull Project project,
@Nullable Charset charset) {
myProject = project;
myFile = file;
@@ -81,14 +69,7 @@ public class GitContentRevision implements ByteBackedContentRevision {
return null;
}
try {
- return ContentRevisionCache
- .getOrLoadAsBytes(myProject, myFile, myRevision, GitVcs.getKey(), ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
- new Throwable2Computable() {
- @Override
- public byte[] compute() throws VcsException, IOException {
- return loadContent();
- }
- });
+ return ContentRevisionCache.getOrLoadAsBytes(myProject, myFile, myRevision, GitVcs.getKey(), REPOSITORY_CONTENT, this::loadContent);
}
catch (IOException e) {
throw new VcsException(e);
@@ -133,19 +114,24 @@ public class GitContentRevision implements ByteBackedContentRevision {
* @param isDeleted if true, the file is deleted
* @param unescapePath
* @return a created revision
- * @throws com.intellij.openapi.vcs.VcsException
- * if there is a problem with creating revision
+ * @throws VcsException if there is a problem with creating revision
*/
- public static ContentRevision createRevision(VirtualFile vcsRoot,
- String path,
+ @NotNull
+ public static ContentRevision createRevision(@NotNull VirtualFile vcsRoot,
+ @NotNull String path,
@Nullable VcsRevisionNumber revisionNumber,
Project project,
- boolean isDeleted, final boolean canBeDeleted, boolean unescapePath) throws VcsException {
+ boolean isDeleted,
+ boolean canBeDeleted,
+ boolean unescapePath) throws VcsException {
FilePath file = createPath(vcsRoot, path, isDeleted, canBeDeleted, unescapePath);
return createRevision(file, revisionNumber, project);
}
-
- private static ContentRevision createRevision(@NotNull FilePath filePath, @Nullable VcsRevisionNumber revisionNumber, @NotNull Project project) {
+
+ @NotNull
+ private static ContentRevision createRevision(@NotNull FilePath filePath,
+ @Nullable VcsRevisionNumber revisionNumber,
+ @NotNull Project project) {
if (revisionNumber != null && revisionNumber != VcsRevisionNumber.NULL) {
return createRevisionImpl(filePath, (GitRevisionNumber)revisionNumber, project, null);
}
@@ -154,10 +140,13 @@ public class GitContentRevision implements ByteBackedContentRevision {
}
}
- public static ContentRevision createRevisionForTypeChange(@NotNull Project project, @NotNull VirtualFile vcsRoot,
- @NotNull String path, @Nullable VcsRevisionNumber revisionNumber,
+ @NotNull
+ public static ContentRevision createRevisionForTypeChange(@NotNull Project project,
+ @NotNull VirtualFile vcsRoot,
+ @NotNull String path,
+ @Nullable VcsRevisionNumber revisionNumber,
boolean unescapePath) throws VcsException {
- final FilePath filePath;
+ FilePath filePath;
if (revisionNumber == null) {
File file = new File(makeAbsolutePath(vcsRoot, path, unescapePath));
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
@@ -168,9 +157,13 @@ public class GitContentRevision implements ByteBackedContentRevision {
return createRevision(filePath, revisionNumber, project);
}
- public static FilePath createPath(@NotNull VirtualFile vcsRoot, @NotNull String path,
- boolean isDeleted, boolean canBeDeleted, boolean unescapePath) throws VcsException {
- final String absolutePath = makeAbsolutePath(vcsRoot, path, unescapePath);
+ @NotNull
+ public static FilePath createPath(@NotNull VirtualFile vcsRoot,
+ @NotNull String path,
+ boolean isDeleted,
+ boolean canBeDeleted,
+ boolean unescapePath) throws VcsException {
+ String absolutePath = makeAbsolutePath(vcsRoot, path, unescapePath);
FilePath file = isDeleted ? VcsUtil.getFilePathForDeletedFile(absolutePath, false) : VcsUtil.getFilePath(absolutePath, false);
if (canBeDeleted && (! SystemInfo.isFileSystemCaseSensitive) && VcsFilePathUtil.caseDiffers(file.getPath(), absolutePath)) {
// as for deleted file
@@ -179,19 +172,25 @@ public class GitContentRevision implements ByteBackedContentRevision {
return file;
}
+ @NotNull
private static String makeAbsolutePath(@NotNull VirtualFile vcsRoot, @NotNull String path, boolean unescapePath) throws VcsException {
- final String unescapedPath = unescapePath ? GitUtil.unescapePath(path) : path;
+ String unescapedPath = unescapePath ? GitUtil.unescapePath(path) : path;
return vcsRoot.getPath() + "/" + unescapedPath;
}
- public static ContentRevision createRevision(@NotNull final VirtualFile file, @Nullable final VcsRevisionNumber revisionNumber,
- @NotNull final Project project) {
+ @NotNull
+ public static ContentRevision createRevision(@NotNull VirtualFile file,
+ @Nullable VcsRevisionNumber revisionNumber,
+ @NotNull Project project) {
FilePath filePath = VcsUtil.getFilePath(file);
return createRevision(filePath, revisionNumber, project, null);
}
- public static ContentRevision createRevision(@NotNull final FilePath filePath, @Nullable final VcsRevisionNumber revisionNumber,
- @NotNull final Project project, @Nullable final Charset charset) {
+ @NotNull
+ public static ContentRevision createRevision(@NotNull FilePath filePath,
+ @Nullable VcsRevisionNumber revisionNumber,
+ @NotNull Project project,
+ @Nullable Charset charset) {
if (revisionNumber != null && revisionNumber != VcsRevisionNumber.NULL) {
return createRevisionImpl(filePath, (GitRevisionNumber)revisionNumber, project, charset);
}
@@ -200,8 +199,11 @@ public class GitContentRevision implements ByteBackedContentRevision {
}
}
- private static GitContentRevision createRevisionImpl(@NotNull FilePath path, @NotNull GitRevisionNumber revisionNumber,
- @NotNull Project project, @Nullable final Charset charset) {
+ @NotNull
+ private static GitContentRevision createRevisionImpl(@NotNull FilePath path,
+ @NotNull GitRevisionNumber revisionNumber,
+ @NotNull Project project,
+ @Nullable Charset charset) {
if (path.getFileType().isBinary()) {
return new GitBinaryContentRevision(path, revisionNumber, project);
} else {
From eab4a2488eca969179fda9c0888f00ef11781003 Mon Sep 17 00:00:00 2001
From: Julia Beliaeva
Date: Fri, 31 Mar 2017 16:03:39 +0300
Subject: [PATCH 002/463] [git] remove deprecated classes: GitHeavyCommit,
SymbolicRefs, SymbolicRefsI
---
.../src/git4idea/history/GitHistoryUtils.java | 72 ------
.../history/browser/GitHeavyCommit.java | 235 ------------------
.../history/browser/SymbolicRefs.java | 74 ------
.../history/browser/SymbolicRefsI.java | 29 ---
4 files changed, 410 deletions(-)
delete mode 100644 plugins/git4idea/src/git4idea/history/browser/GitHeavyCommit.java
delete mode 100644 plugins/git4idea/src/git4idea/history/browser/SymbolicRefs.java
delete mode 100644 plugins/git4idea/src/git4idea/history/browser/SymbolicRefsI.java
diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
index 178675830bec..ff981006948d 100644
--- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
+++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
@@ -51,11 +51,7 @@ import git4idea.branch.GitBranchUtil;
import git4idea.commands.*;
import git4idea.config.GitVersion;
import git4idea.config.GitVersionSpecialty;
-import git4idea.history.browser.GitHeavyCommit;
import git4idea.history.browser.SHAHash;
-import git4idea.history.browser.SymbolicRefs;
-import git4idea.history.browser.SymbolicRefsI;
-import git4idea.history.wholeTree.AbstractHash;
import git4idea.i18n.GitBundle;
import git4idea.log.GitLogProvider;
import git4idea.log.GitRefManager;
@@ -909,74 +905,6 @@ public class GitHistoryUtils {
return ContainerUtil.map(record.getParentsHashes(), factory::createHash);
}
- @NotNull
- private static GitHeavyCommit createCommit(@NotNull Project project, @Nullable SymbolicRefsI refs, @NotNull VirtualFile root,
- @NotNull GitLogRecord record) throws VcsException {
- final Collection currentRefs = record.getRefs();
- List locals = new ArrayList<>();
- List remotes = new ArrayList<>();
- List tags = new ArrayList<>();
- final String s = parseRefs(refs, currentRefs, locals, remotes, tags);
-
- GitHeavyCommit
- gitCommit = new GitHeavyCommit(root, AbstractHash.create(record.getHash()), new SHAHash(record.getHash()), record.getAuthorName(),
- record.getCommitterName(),
- record.getDate(), record.getSubject(), record.getFullMessage(),
- new HashSet<>(Arrays.asList(record.getParentsHashes())), record.getFilePaths(root),
- record.getAuthorEmail(),
- record.getCommitterEmail(), tags, locals, remotes,
- record.parseChanges(project, root), record.getAuthorTimeStamp());
- gitCommit.setCurrentBranch(s);
- return gitCommit;
- }
-
- @Nullable
- private static String parseRefs(@Nullable SymbolicRefsI refs, @NotNull Collection currentRefs, @NotNull List locals,
- @NotNull List remotes, @NotNull List tags) {
- if (refs == null) {
- return null;
- }
- for (String ref : currentRefs) {
- final SymbolicRefs.Kind kind = refs.getKind(ref);
- if (SymbolicRefs.Kind.LOCAL.equals(kind)) {
- locals.add(ref);
- }
- else if (SymbolicRefs.Kind.REMOTE.equals(kind)) {
- remotes.add(ref);
- }
- else {
- tags.add(ref);
- }
- }
- if (refs.getCurrent() != null && currentRefs.contains(refs.getCurrent().getName())) {
- return refs.getCurrent().getName();
- }
- return null;
- }
-
- @Deprecated
- @NotNull
- public static List commitsDetails(@NotNull Project project, @NotNull FilePath path, @Nullable SymbolicRefsI refs,
- @NotNull Collection commitsIds) throws VcsException {
- path = getLastCommitName(project, path); // adjust path using change manager
- VirtualFile root = GitUtil.getGitRoot(path);
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
- GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS,
- HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME,
- COMMITTER_EMAIL, PARENTS, REF_NAMES, SUBJECT, BODY, RAW_BODY);
- h.setSilent(true);
- h.addParameters("--name-status", "-M", parser.getPretty(), "--encoding=UTF-8");
- h.addParameters(new ArrayList<>(commitsIds));
-
- String output = h.run();
- final List rc = new ArrayList<>();
- for (GitLogRecord record : parser.parse(output)) {
- final GitHeavyCommit gitCommit = createCommit(project, refs, root, record);
- rc.add(gitCommit);
- }
- return rc;
- }
-
public static long getAuthorTime(@NotNull Project project, @NotNull FilePath path, @NotNull String commitsId) throws VcsException {
// adjust path using change manager
path = getLastCommitName(project, path);
diff --git a/plugins/git4idea/src/git4idea/history/browser/GitHeavyCommit.java b/plugins/git4idea/src/git4idea/history/browser/GitHeavyCommit.java
deleted file mode 100644
index 3bad1c2d43d6..000000000000
--- a/plugins/git4idea/src/git4idea/history/browser/GitHeavyCommit.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * 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 git4idea.history.browser;
-
-import com.intellij.openapi.vcs.FilePath;
-import com.intellij.openapi.vcs.changes.Change;
-import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.GitCommit;
-import git4idea.history.wholeTree.AbstractHash;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.*;
-
-/**
- * This class is cluttered with a lot of fields which sometimes are populated, sometimes not, and some of which are completely
- * unrelated to the commit object (like tags, branches, root or current branch).
- * It will be removed.
- * {@link GitCommit} should be used instead.
- */
-@Deprecated
-public class GitHeavyCommit {
- @NotNull private final VirtualFile myRoot;
- @NotNull private final AbstractHash myShortHash;
- @NotNull private final SHAHash myHash;
- private final String myAuthor;
- private final String myCommitter;
- private final String mySubject;
- private final String myDescription;
- private final Date myDate;
-
- private final String myAuthorEmail;
- private final String myComitterEmail;
-
- private final List myTags;
- private final List myLocalBranches;
- private final List myRemoteBranches;
-
- private final Set myParentsHashes;
- private final Set myParentsLinks;
-
- // todo concern having
- private final List myPathsList;
- private final List myChanges;
- private String myCurrentBranch;
-
- private final long myAuthorTime;
- //private final List myBranches;
- private boolean myOnLocal;
- // very expensive to calculate it massively, seems it wouldnt be shown
- private boolean myOnTracked;
-
- public GitHeavyCommit(@NotNull VirtualFile root, @NotNull final AbstractHash shortHash,
- @NotNull final SHAHash hash,
- final String author,
- final String committer,
- final Date date,
- final String subject,
- final String description,
- final Set parentsHashes,
- final List pathsList,
- final String authorEmail,
- final String comitterEmail,
- List tags,
- final List localBranches,
- final List remoteBranches,
- List changes,
- long authorTime) {
- myRoot = root;
- myShortHash = shortHash;
- myAuthor = author;
- myCommitter = committer;
- myDate = date;
- mySubject = subject;
- myDescription = description;
- myHash = hash;
- myParentsHashes = parentsHashes;
- myPathsList = pathsList;
- myAuthorEmail = authorEmail;
- myComitterEmail = comitterEmail;
- myTags = tags;
- myChanges = changes;
- myLocalBranches = localBranches;
- myRemoteBranches = remoteBranches;
- myAuthorTime = authorTime;
- //myBranches = branches;
- myParentsLinks = new HashSet<>();
- }
-
- public void addParentLink(final GitHeavyCommit commit) {
- myParentsLinks.add(commit);
- }
-
- public String getAuthor() {
- return myAuthor;
- }
-
- public String getCommitter() {
- return myCommitter;
- }
-
- public Date getDate() {
- return myDate;
- }
-
- public String getDescription() {
- return myDescription;
- }
-
- @NotNull
- public SHAHash getHash() {
- return myHash;
- }
-
- // todo think of interface
- public Set getParentsHashes() {
- return myParentsHashes;
- }
-
- // todo think of interface
- public Set getParentsLinks() {
- return myParentsLinks;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- GitHeavyCommit gitCommit = (GitHeavyCommit)o;
-
- if (!myHash.equals(gitCommit.myHash)) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return myHash.hashCode();
- }
-
- public List getTags() {
- return myTags;
- }
-
- public void orderTags(final Comparator comparator) {
- Collections.sort(myTags, comparator);
- }
-
- public List getLocalBranches() {
- return myLocalBranches;
- }
-
- public List getRemoteBranches() {
- return myRemoteBranches;
- }
-
- public String getAuthorEmail() {
- return myAuthorEmail;
- }
-
- public String getCommitterEmail() {
- return myComitterEmail;
- }
-
- public List getPathsList() {
- return myPathsList;
- }
-
- @Override
- public String toString() {
- return myHash.getValue();
- }
-
- @NotNull
- public AbstractHash getShortHash() {
- return myShortHash;
- }
-
- public List getChanges() {
- return myChanges;
- }
-
- public void setCurrentBranch(String s) {
- myCurrentBranch = s;
- }
-
- public String getCurrentBranch() {
- return myCurrentBranch;
- }
-
- public long getAuthorTime() {
- return myAuthorTime;
- }
-
- public String getComitterEmail() {
- return myComitterEmail;
- }
-
- public boolean isOnLocal() {
- return myOnLocal;
- }
-
- public void setOnLocal(boolean onLocal) {
- myOnLocal = onLocal;
- }
-
- public boolean isOnTracked() {
- return myOnTracked;
- }
-
- public void setOnTracked(boolean onTracked) {
- myOnTracked = onTracked;
- }
-
- public String getSubject() {
- return mySubject;
- }
-
- public VirtualFile getRoot() {
- return myRoot;
- }
-}
diff --git a/plugins/git4idea/src/git4idea/history/browser/SymbolicRefs.java b/plugins/git4idea/src/git4idea/history/browser/SymbolicRefs.java
deleted file mode 100644
index fbee7b3a3f11..000000000000
--- a/plugins/git4idea/src/git4idea/history/browser/SymbolicRefs.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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 git4idea.history.browser;
-
-import git4idea.GitBranch;
-
-import java.util.TreeSet;
-
-@Deprecated
-public class SymbolicRefs implements SymbolicRefsI {
- private GitBranch myCurrent;
- private final TreeSet myLocalBranches;
- private final TreeSet myRemoteBranches;
- private String myUsername;
-
- public SymbolicRefs() {
- myLocalBranches = new TreeSet<>();
- myRemoteBranches = new TreeSet<>();
- }
-
- public TreeSet getLocalBranches() {
- return myLocalBranches;
- }
-
- public TreeSet getRemoteBranches() {
- return myRemoteBranches;
- }
-
- @Override
- public GitBranch getCurrent() {
- return myCurrent;
- }
-
- public void setCurrent(GitBranch current) {
- myCurrent = current;
- }
-
- @Override
- public Kind getKind(final String s) {
- if (myLocalBranches.contains(s)) return Kind.LOCAL;
- if (myRemoteBranches.contains(s)) return Kind.REMOTE;
- return Kind.TAG;
- }
-
- public void clear() {
- myLocalBranches.clear();
- myRemoteBranches.clear();
- }
-
- @Override
- public String getUsername() {
- return myUsername;
- }
-
- public void setUsername(String username) {
- myUsername = username;
- }
-
- public enum Kind {
- TAG,
- LOCAL,
- REMOTE
- }
-}
diff --git a/plugins/git4idea/src/git4idea/history/browser/SymbolicRefsI.java b/plugins/git4idea/src/git4idea/history/browser/SymbolicRefsI.java
deleted file mode 100644
index c899f040df67..000000000000
--- a/plugins/git4idea/src/git4idea/history/browser/SymbolicRefsI.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2000-2011 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package git4idea.history.browser;
-
-import git4idea.GitBranch;
-
-@Deprecated
-public interface SymbolicRefsI {
-
- GitBranch getCurrent();
-
- SymbolicRefs.Kind getKind(String s);
-
- String getUsername();
-
-}
From 130978173ba4270f28dba6672beab2518f6a0b66 Mon Sep 17 00:00:00 2001
From: Julia Beliaeva
Date: Sat, 8 Apr 2017 21:12:57 +0300
Subject: [PATCH 003/463] [vcs] remove VcsFileRevisionDvcsSpecific that has
only one usage
Instead, introduce getAuthorDate method into VcsFileRevisionEx and use it instead.
---
.../history/VcsFileRevisionDvcsSpecific.java | 31 -------------------
.../vcs/history/VcsFileRevisionEx.java | 5 +++
.../DefaultPatchBaseVersionProvider.java | 4 +--
.../vcs/log/history/VcsLogFileRevision.java | 17 ++++++++--
.../src/git4idea/GitFileRevision.java | 7 ++---
5 files changed, 23 insertions(+), 41 deletions(-)
delete mode 100644 platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionDvcsSpecific.java
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionDvcsSpecific.java b/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionDvcsSpecific.java
deleted file mode 100644
index 09ca51a446cb..000000000000
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionDvcsSpecific.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2000-2011 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.openapi.vcs.history;
-
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Date;
-
-/**
- * Created by IntelliJ IDEA.
- * User: Irina.Chernushina
- * Date: 9/14/11
- * Time: 5:57 PM
- */
-public interface VcsFileRevisionDvcsSpecific {
- @Nullable
- Date getDateForRevisionsOrdering();
-}
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionEx.java b/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionEx.java
index 18d6988ff130..4958340e6293 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionEx.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionEx.java
@@ -19,6 +19,8 @@ import com.intellij.openapi.vcs.FilePath;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Date;
+
/**
* User: spLeaner
*/
@@ -38,4 +40,7 @@ public abstract class VcsFileRevisionEx implements VcsFileRevision {
*/
@NotNull
public abstract FilePath getPath();
+
+ @Nullable
+ public abstract Date getAuthorDate();
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java
index 3d250f102a9f..0ab6cc0cfc04 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java
@@ -145,8 +145,8 @@ public class DefaultPatchBaseVersionProvider {
found = fileRevision.getRevisionNumber().compareTo(revision) <= 0;
}
else {
- final Date date = fileRevision instanceof VcsFileRevisionDvcsSpecific ?
- ((VcsFileRevisionDvcsSpecific) fileRevision).getDateForRevisionsOrdering() : fileRevision.getRevisionDate();
+ final Date date = fileRevision instanceof VcsFileRevisionEx ?
+ ((VcsFileRevisionEx) fileRevision).getAuthorDate() : fileRevision.getRevisionDate();
found = (date != null) && (date.before(versionDate) || date.equals(versionDate));
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/history/VcsLogFileRevision.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/history/VcsLogFileRevision.java
index 3684d879d439..0a578fd6db39 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/history/VcsLogFileRevision.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/history/VcsLogFileRevision.java
@@ -33,11 +33,13 @@ import java.util.Date;
public class VcsLogFileRevision extends VcsFileRevisionEx {
@NotNull private final ContentRevision myRevision;
@NotNull private final FilePath myPath;
- private final long myAuthorTime;
- @NotNull private final String myFullMessage;
- @Nullable private byte[] myContent = null;
@NotNull private final VcsUser myAuthor;
@NotNull private final VcsUser myCommitter;
+ private final long myAuthorTime;
+ private final long myCommitTime;
+ @NotNull private final String myFullMessage;
+
+ @Nullable private byte[] myContent = null;
public VcsLogFileRevision(@NotNull VcsFullCommitDetails details, @NotNull ContentRevision revision, @NotNull FilePath path) {
myRevision = revision;
@@ -46,6 +48,7 @@ public class VcsLogFileRevision extends VcsFileRevisionEx {
myAuthor = details.getAuthor();
myCommitter = details.getCommitter();
myAuthorTime = details.getAuthorTime();
+ myCommitTime = details.getCommitTime();
myFullMessage = details.getFullMessage();
}
@@ -123,6 +126,14 @@ public class VcsLogFileRevision extends VcsFileRevisionEx {
@Override
public Date getRevisionDate() {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(myCommitTime);
+ return cal.getTime();
+ }
+
+ @Nullable
+ @Override
+ public Date getAuthorDate() {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(myAuthorTime);
return cal.getTime();
diff --git a/plugins/git4idea/src/git4idea/GitFileRevision.java b/plugins/git4idea/src/git4idea/GitFileRevision.java
index dbbc7edb1c3b..1d472ca3789b 100644
--- a/plugins/git4idea/src/git4idea/GitFileRevision.java
+++ b/plugins/git4idea/src/git4idea/GitFileRevision.java
@@ -21,7 +21,6 @@ import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsFileRevision;
-import com.intellij.openapi.vcs.history.VcsFileRevisionDvcsSpecific;
import com.intellij.openapi.vcs.history.VcsFileRevisionEx;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
@@ -35,7 +34,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
-public class GitFileRevision extends VcsFileRevisionEx implements Comparable, VcsFileRevisionDvcsSpecific {
+public class GitFileRevision extends VcsFileRevisionEx implements Comparable {
@NotNull private final Project myProject;
@NotNull private final FilePath myPath;
@@ -87,8 +86,7 @@ public class GitFileRevision extends VcsFileRevisionEx implements Comparable
Date: Sun, 9 Apr 2017 05:13:21 +0300
Subject: [PATCH 004/463] [git] code issues: inline methods, better variable
names, etc
---
.../src/git4idea/history/GitHistoryUtils.java | 90 ++++++++-----------
1 file changed, 39 insertions(+), 51 deletions(-)
diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
index ff981006948d..2bc08636171a 100644
--- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
+++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
@@ -504,43 +504,6 @@ public class GitHistoryUtils {
record.getAuthorTimeStamp()));
}
- private static void processHandlerOutputByLine(@NotNull GitLineHandler handler,
- @NotNull GitLogParser parser,
- @NotNull Consumer recordConsumer) throws VcsException {
- Ref parseError = new Ref<>();
- processHandlerOutputByLine(handler, builder -> {
- try {
- GitLogRecord record = parser.parseOneRecord(builder);
- if (record != null) {
- recordConsumer.consume(record);
- }
- }
- catch (ProcessCanceledException pce) {
- throw pce;
- }
- catch (Throwable t) {
- if (parseError.isNull()) {
- parseError.set(t);
- LOG.error("Could not parse \" " + StringUtil.escapeStringCharacters(builder.toString()) + "\"\n" +
- "Command " + handler.printableCommandLine(), t);
- }
- }
- }, 0);
-
- if (!parseError.isNull()) {
- throw new VcsException(parseError.get());
- }
- }
-
- private static void processHandlerOutputByLine(@NotNull GitLineHandler handler,
- @NotNull Consumer recordConsumer,
- int bufferSize)
- throws VcsException {
- MyGitLineHandlerListener handlerListener = new MyGitLineHandlerListener(handler, recordConsumer, bufferSize);
- handler.runInCurrentThread(null);
- handlerListener.reportErrors();
- }
-
public static void readCommits(@NotNull Project project,
@NotNull VirtualFile root,
@NotNull List parameters,
@@ -552,22 +515,23 @@ public class GitHistoryUtils {
return;
}
- GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
+ GitLineHandler handler = new GitLineHandler(project, root, GitCommand.LOG);
final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, COMMIT_TIME,
AUTHOR_NAME, AUTHOR_EMAIL, REF_NAMES);
- h.setStdoutSuppressed(true);
- h.addParameters(parser.getPretty(), "--encoding=UTF-8");
- h.addParameters("--decorate=full");
- h.addParameters(parameters);
- h.endOptions();
+ handler.setStdoutSuppressed(true);
+ handler.addParameters(parser.getPretty(), "--encoding=UTF-8");
+ handler.addParameters("--decorate=full");
+ handler.addParameters(parameters);
+ handler.endOptions();
- final int COMMIT_BUFFER = 1000;
- processHandlerOutputByLine(h, buffer -> {
- List commits = parseCommit(parser, buffer, userConsumer, refConsumer, factory, root);
+ MyGitLineHandlerListener handlerListener = new MyGitLineHandlerListener(handler, output -> {
+ List commits = parseCommit(parser, output, userConsumer, refConsumer, factory, root);
for (TimedVcsCommit commit : commits) {
commitConsumer.consume(commit);
}
- }, COMMIT_BUFFER);
+ }, 1000);
+ handler.runInCurrentThread(null);
+ handlerListener.reportErrors();
}
@NotNull
@@ -880,12 +844,36 @@ public class GitHistoryUtils {
List configParameters = Registry.is("git.diff.renameLimit.infinity") && withChanges ?
Collections.singletonList("diff.renameLimit=0") : Collections.emptyList();
- GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG, configParameters);
- GitLogParser parser = createParserForDetails(h, project, withRefs, withChanges, parameters);
+ GitLineHandler handler = new GitLineHandler(project, root, GitCommand.LOG, configParameters);
+ GitLogParser parser = createParserForDetails(handler, project, withRefs, withChanges, parameters);
- StopWatch sw = StopWatch.start("loading details");
+ StopWatch sw = StopWatch.start("loading details in [" + root.getName() + "]");
- processHandlerOutputByLine(h, parser, converter);
+ Ref parseError = new Ref<>();
+ MyGitLineHandlerListener handlerListener = new MyGitLineHandlerListener(handler, output -> {
+ try {
+ GitLogRecord record = parser.parseOneRecord(output);
+ if (record != null) {
+ converter.consume(record);
+ }
+ }
+ catch (ProcessCanceledException pce) {
+ throw pce;
+ }
+ catch (Throwable t) {
+ if (parseError.isNull()) {
+ parseError.set(t);
+ LOG.error("Could not parse \" " + StringUtil.escapeStringCharacters(output.toString()) + "\"\n" +
+ "Command " + handler.printableCommandLine(), t);
+ }
+ }
+ }, 0);
+ handler.runInCurrentThread(null);
+ handlerListener.reportErrors();
+
+ if (!parseError.isNull()) {
+ throw new VcsException(parseError.get());
+ }
sw.report();
}
From 3445114b9dcb1f6138c66dce75f0a8c1fbde18cc Mon Sep 17 00:00:00 2001
From: Dmitry Trofimov
Date: Sun, 9 Apr 2017 13:11:02 +0200
Subject: [PATCH 005/463] Use console environment to start a local terminal
instance (PY-17816)
---
.../jetbrains/plugins/terminal/LocalTerminalDirectRunner.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
index 3acb72f202af..78ee51b265be 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
@@ -114,7 +114,7 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner envs = new HashMap<>(System.getenv());
+ Map envs = new HashMap<>(EnvironmentUtil.getEnvironmentMap());
if (!SystemInfo.isWindows) {
envs.put("TERM", "xterm-256color");
}
From 5115f74a8116f62601d67c728bccabaa7c394df2 Mon Sep 17 00:00:00 2001
From: Dmitry Trofimov
Date: Sun, 9 Apr 2017 13:30:53 +0200
Subject: [PATCH 006/463] Cleanup: remove the deprecated usage
---
.../jetbrains/plugins/terminal/LocalTerminalDirectRunner.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
index 78ee51b265be..8a19ebdba87e 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
@@ -118,7 +118,6 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner
Date: Sun, 9 Apr 2017 20:51:38 +0300
Subject: [PATCH 007/463] Staging removed from test
---
.../com/jetbrains/env/python/testing/PythonUnitTestingTest.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java b/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java
index 62670fc0e028..c09eb54e7a34 100644
--- a/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java
+++ b/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java
@@ -454,7 +454,6 @@ public final class PythonUnitTestingTest extends PyEnvTestCase {
}
@Test
- @Staging
public void testRelativeImports() {
runPythonTest(new PyUnitTestProcessWithConsoleTestTask("/testRunner/env/unit/relativeImports",
PyUnitTestProcessRunner.TEST_PATTERN_PREFIX + "test_imps.py") {
From e5ddd95495ba76743b43ed08723c7f9edb38d1b5 Mon Sep 17 00:00:00 2001
From: Eldar Abusalimov
Date: Sun, 9 Apr 2017 19:40:56 +0300
Subject: [PATCH 008/463] CPP-9477 debugger: Add registry value to control
number of composite value children
---
platform/util/resources/misc/registry.properties | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties
index 6ba13d65b3b9..d83b2efb44a5 100644
--- a/platform/util/resources/misc/registry.properties
+++ b/platform/util/resources/misc/registry.properties
@@ -869,6 +869,10 @@ cidr.debugger.timeout.load.description=GDB timeout for loading and starting a ta
Increase this value, if your application loads a lot of shared libraries.
cidr.debugger.timeout.evaluate=30000
cidr.debugger.timeout.evaluate.description=GDB timeout for evaluating expressions and executing console commands.
+cidr.debugger.value.maxChildren=100
+cidr.debugger.value.maxChildren.description=Number of children of a composite variable or watch value shown by default.\n\
+ Increasing this value may lead to timeouts during evaluation.
+
cidr.show.compiler.info=false
cidr.show.clangtidy.info=false
@@ -1092,4 +1096,4 @@ performance.watcher.unresponsive.max.attempts.before.log=5
performance.watcher.unresponsive.max.attempts.before.log.description=If the product is unresponsive for performance.watcher.unresponsive.max.attempts.before.log * performance.watcher.sampling.interval.ms, dump threads every performance.watcher.sampling.interval.ms
performance.watcher.sampling.interval.ms=1000
-performance.watcher.sampling.interval.ms.description=If the product is unresponsive for performance.watcher.unresponsive.max.attempts.before.log * performance.watcher.sampling.interval.ms, dump threads every performance.watcher.sampling.interval.ms
\ No newline at end of file
+performance.watcher.sampling.interval.ms.description=If the product is unresponsive for performance.watcher.unresponsive.max.attempts.before.log * performance.watcher.sampling.interval.ms, dump threads every performance.watcher.sampling.interval.ms
From f4c6d909aba57ec7efeb566f54614f7a93e7d063 Mon Sep 17 00:00:00 2001
From: Tagir Valeev
Date: Mon, 10 Apr 2017 11:25:31 +0700
Subject: [PATCH 009/463] IDEA-171205 Create local variable from usage: honor
most suitable overload by parameter count
---
.../impl/quickfix/CreateFromUsageUtils.java | 167 ++++++++----------
.../createLocalFromUsage/afterOverload.java | 11 ++
.../createLocalFromUsage/beforeOverload.java | 10 ++
3 files changed, 97 insertions(+), 91 deletions(-)
create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterOverload.java
create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeOverload.java
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java
index 1285b99ebf95..9611625d7d53 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -67,6 +67,7 @@ import com.intellij.psi.util.proximity.PsiProximityComparator;
import com.intellij.refactoring.util.RefactoringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -388,71 +389,68 @@ public class CreateFromUsageUtils {
final PsiElementFactory factory = facade.getElementFactory();
return ApplicationManager.getApplication().runWriteAction(
- new Computable() {
- @Override
- public PsiClass compute() {
- try {
- PsiClass targetClass;
- if (directory != null) {
- try {
- if (classKind == CreateClassKind.INTERFACE) {
- targetClass = JavaDirectoryService.getInstance().createInterface(directory, name);
- }
- else if (classKind == CreateClassKind.CLASS) {
- targetClass = JavaDirectoryService.getInstance().createClass(directory, name);
- }
- else if (classKind == CreateClassKind.ENUM) {
- targetClass = JavaDirectoryService.getInstance().createEnum(directory, name);
- }
- else if (classKind == CreateClassKind.ANNOTATION) {
- targetClass = JavaDirectoryService.getInstance().createAnnotationType(directory, name);
- }
- else {
- LOG.error("Unknown kind of a class to create");
- return null;
- }
- }
- catch (final IncorrectOperationException e) {
- scheduleFileOrPackageCreationFailedMessageBox(e, name, directory, false);
- return null;
- }
- if (!facade.getResolveHelper().isAccessible(targetClass, contextElement, null)) {
- PsiUtil.setModifierProperty(targetClass, PsiModifier.PUBLIC, true);
- }
- }
- else { //tests
- PsiClass aClass;
+ (Computable)() -> {
+ try {
+ PsiClass targetClass;
+ if (directory != null) {
+ try {
if (classKind == CreateClassKind.INTERFACE) {
- aClass = factory.createInterface(name);
+ targetClass = JavaDirectoryService.getInstance().createInterface(directory, name);
}
else if (classKind == CreateClassKind.CLASS) {
- aClass = factory.createClass(name);
+ targetClass = JavaDirectoryService.getInstance().createClass(directory, name);
}
else if (classKind == CreateClassKind.ENUM) {
- aClass = factory.createEnum(name);
+ targetClass = JavaDirectoryService.getInstance().createEnum(directory, name);
}
else if (classKind == CreateClassKind.ANNOTATION) {
- aClass = factory.createAnnotationType(name);
+ targetClass = JavaDirectoryService.getInstance().createAnnotationType(directory, name);
}
else {
LOG.error("Unknown kind of a class to create");
return null;
}
- targetClass = (PsiClass) sourceFile.add(aClass);
}
+ catch (final IncorrectOperationException e) {
+ scheduleFileOrPackageCreationFailedMessageBox(e, name, directory, false);
+ return null;
+ }
+ if (!facade.getResolveHelper().isAccessible(targetClass, contextElement, null)) {
+ PsiUtil.setModifierProperty(targetClass, PsiModifier.PUBLIC, true);
+ }
+ }
+ else { //tests
+ PsiClass aClass;
+ if (classKind == CreateClassKind.INTERFACE) {
+ aClass = factory.createInterface(name);
+ }
+ else if (classKind == CreateClassKind.CLASS) {
+ aClass = factory.createClass(name);
+ }
+ else if (classKind == CreateClassKind.ENUM) {
+ aClass = factory.createEnum(name);
+ }
+ else if (classKind == CreateClassKind.ANNOTATION) {
+ aClass = factory.createAnnotationType(name);
+ }
+ else {
+ LOG.error("Unknown kind of a class to create");
+ return null;
+ }
+ targetClass = (PsiClass)sourceFile.add(aClass);
+ }
- if (superClassName != null && (classKind != CreateClassKind.ENUM || !superClassName.equals(CommonClassNames.JAVA_LANG_ENUM))) {
- setupSuperClassReference(targetClass, superClassName);
- }
- if (contextElement instanceof PsiJavaCodeReferenceElement) {
- CreateFromUsageBaseFix.setupGenericParameters(targetClass, (PsiJavaCodeReferenceElement)contextElement);
- }
- return targetClass;
+ if (superClassName != null && (classKind != CreateClassKind.ENUM || !superClassName.equals(CommonClassNames.JAVA_LANG_ENUM))) {
+ setupSuperClassReference(targetClass, superClassName);
}
- catch (IncorrectOperationException e) {
- LOG.error(e);
- return null;
+ if (contextElement instanceof PsiJavaCodeReferenceElement) {
+ CreateFromUsageBaseFix.setupGenericParameters(targetClass, (PsiJavaCodeReferenceElement)contextElement);
}
+ return targetClass;
+ }
+ catch (IncorrectOperationException e) {
+ LOG.error(e);
+ return null;
}
});
}
@@ -571,16 +569,27 @@ public class CreateFromUsageUtils {
List types,
List expectedMethodNames,
List expectedFieldNames) {
+ Comparator expectedTypesComparator = (o1, o2) -> compareExpectedTypes(o1, o2, expression);
for (PsiExpression expr : collectExpressions(expression, PsiMember.class, PsiFile.class)) {
PsiElement parent = expr.getParent();
if (!(parent instanceof PsiReferenceExpression)) {
boolean isAssignmentToFunctionalExpression = PsiUtil.isOnAssignmentLeftHand(expr) &&
((PsiAssignmentExpression)PsiUtil.skipParenthesizedExprUp(parent)).getRExpression() instanceof PsiFunctionalExpression;
- boolean forCompletion = PsiUtil.skipParenthesizedExprUp(isAssignmentToFunctionalExpression ? parent.getParent() : parent) instanceof PsiExpressionList;
+ PsiExpressionList expressionList = ObjectUtils
+ .tryCast(PsiUtil.skipParenthesizedExprUp(isAssignmentToFunctionalExpression ? parent.getParent() : parent),
+ PsiExpressionList.class);
+ boolean forCompletion = expressionList != null;
ExpectedTypeInfo[] someExpectedTypes = ExpectedTypesProvider.getExpectedTypes(expr, forCompletion);
if (someExpectedTypes.length > 0) {
- Arrays.sort(someExpectedTypes, (o1, o2) -> compareExpectedTypes(o1, o2, expression));
+ Comparator comparator = expectedTypesComparator;
+ if (expressionList != null) {
+ int argCount = expressionList.getExpressions().length;
+ Comparator mostSuitableMethodComparator = Comparator
+ .comparingInt((ExpectedTypeInfo eti) -> eti.getCalledMethod().getParameterList().getParametersCount() == argCount ? 0 : 1);
+ comparator = mostSuitableMethodComparator.thenComparing(comparator);
+ }
+ Arrays.sort(someExpectedTypes, comparator);
types.add(someExpectedTypes);
}
continue;
@@ -597,7 +606,7 @@ public class CreateFromUsageUtils {
if (refName.equals("equals")) {
ExpectedTypeInfo[] someExpectedTypes = equalsExpectedTypes((PsiMethodCallExpression)pparent);
if (someExpectedTypes.length > 0) {
- Arrays.sort(someExpectedTypes, (o1, o2) -> compareExpectedTypes(o1, o2, expression));
+ Arrays.sort(someExpectedTypes, expectedTypesComparator);
types.add(someExpectedTypes);
}
}
@@ -689,7 +698,7 @@ public class CreateFromUsageUtils {
}
- @Nullable
+ @NotNull
static PsiType[] guessType(PsiExpression expression, final boolean allowVoidType) {
final PsiManager manager = expression.getManager();
final GlobalSearchScope resolveScope = expression.getResolveScope();
@@ -876,12 +885,8 @@ public class CreateFromUsageUtils {
final Module moduleForFile = ModuleUtilCore.findModuleForPsiElement(file);
if (moduleForFile == null) return;
- final GlobalSearchScope searchScope = ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public GlobalSearchScope compute() {
- return file.getResolveScope();
- }
- });
+ final GlobalSearchScope searchScope =
+ ApplicationManager.getApplication().runReadAction((Computable)file::getResolveScope);
GlobalSearchScope descendantsSearchScope = GlobalSearchScope.moduleWithDependenciesScope(moduleForFile);
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
@@ -890,12 +895,10 @@ public class CreateFromUsageUtils {
return;
}
- final PsiMember[] members = ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public PsiMember[] compute() {
- return method ? cache.getMethodsByName(memberName, searchScope) : cache.getFieldsByName(memberName, searchScope);
- }
- });
+ final PsiMember[] members = ApplicationManager.getApplication().runReadAction(
+ (Computable)() -> method
+ ? cache.getMethodsByName(memberName, searchScope)
+ : cache.getFieldsByName(memberName, searchScope));
for (int i = 0; i < members.length; ++i) {
final PsiMember member = members[i];
@@ -942,19 +945,10 @@ public class CreateFromUsageUtils {
return true;
}
- final String[] strings = ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public String[] compute() {
- return cache.getAllClassNames();
- }
- });
+ final String[] strings = ApplicationManager.getApplication().runReadAction((Computable)cache::getAllClassNames);
for (final String className : strings) {
- final PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public PsiClass[] compute() {
- return cache.getClassesByName(className, searchScope);
- }
- });
+ final PsiClass[] classes = ApplicationManager.getApplication().runReadAction(
+ (Computable)() -> cache.getClassesByName(className, searchScope));
for (final PsiClass aClass : classes) {
final String qname = getQualifiedName(aClass);
ContainerUtil.addIfNotNull(possibleClassNames, qname);
@@ -967,13 +961,7 @@ public class CreateFromUsageUtils {
@Nullable
private static String getQualifiedName(final PsiClass aClass) {
- return ApplicationManager.getApplication().runReadAction(new Computable() {
- @Nullable
- @Override
- public String compute() {
- return aClass.getQualifiedName();
- }
- });
+ return ApplicationManager.getApplication().runReadAction((Computable)aClass::getQualifiedName);
}
private static boolean hasCorrectModifiers(@Nullable final PsiMember member, final boolean staticAccess) {
@@ -981,12 +969,9 @@ public class CreateFromUsageUtils {
return false;
}
- return ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public Boolean compute() {
- return !member.hasModifierProperty(PsiModifier.PRIVATE) && member.hasModifierProperty(PsiModifier.STATIC) == staticAccess;
- }
- }).booleanValue();
+ return ApplicationManager.getApplication().runReadAction(
+ (Computable)() -> !member.hasModifierProperty(PsiModifier.PRIVATE) &&
+ member.hasModifierProperty(PsiModifier.STATIC) == staticAccess).booleanValue();
}
private static class ParameterNameExpression extends Expression {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterOverload.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterOverload.java
new file mode 100644
index 000000000000..251ec4b18bc6
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterOverload.java
@@ -0,0 +1,11 @@
+// "Create local variable 'xyz'" "true"
+interface Other {
+ void add(int x, T y);
+ void add(T y);
+}
+class A {
+ public void foo(Other other) {
+ String xyz;
+ other.add(xyz);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeOverload.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeOverload.java
new file mode 100644
index 000000000000..ac0d06ebddb4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeOverload.java
@@ -0,0 +1,10 @@
+// "Create local variable 'xyz'" "true"
+interface Other {
+ void add(int x, T y);
+ void add(T y);
+}
+class A {
+ public void foo(Other other) {
+ other.add(xyz);
+ }
+}
\ No newline at end of file
From 3da23def833c7887198a9d6a785c9d485d223465 Mon Sep 17 00:00:00 2001
From: Tagir Valeev
Date: Mon, 10 Apr 2017 12:09:51 +0700
Subject: [PATCH 010/463] InvertIfCondition: some fixes for non-compilable code
---
.../invertIfCondition/afterEmptyParenthesis.java | 11 +++++++++++
.../codeInsight/invertIfCondition/afterNull.java | 11 +++++++++++
.../invertIfCondition/beforeEmptyParenthesis.java | 9 +++++++++
.../codeInsight/invertIfCondition/beforeNull.java | 9 +++++++++
.../codeInsight/CodeInsightServicesUtil.java | 15 +++++++++------
5 files changed, 49 insertions(+), 6 deletions(-)
create mode 100644 java/java-tests/testData/codeInsight/invertIfCondition/afterEmptyParenthesis.java
create mode 100644 java/java-tests/testData/codeInsight/invertIfCondition/afterNull.java
create mode 100644 java/java-tests/testData/codeInsight/invertIfCondition/beforeEmptyParenthesis.java
create mode 100644 java/java-tests/testData/codeInsight/invertIfCondition/beforeNull.java
diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterEmptyParenthesis.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterEmptyParenthesis.java
new file mode 100644
index 000000000000..f7fcfffc82bc
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterEmptyParenthesis.java
@@ -0,0 +1,11 @@
+// "Invert 'if' condition" "true"
+class A {
+ public boolean foo() {
+ if (!()) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterNull.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterNull.java
new file mode 100644
index 000000000000..208552c5bd18
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterNull.java
@@ -0,0 +1,11 @@
+// "Invert 'if' condition" "true"
+class A {
+ public boolean foo() {
+ if (!null) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/beforeEmptyParenthesis.java b/java/java-tests/testData/codeInsight/invertIfCondition/beforeEmptyParenthesis.java
new file mode 100644
index 000000000000..87b2ce7888b8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/invertIfCondition/beforeEmptyParenthesis.java
@@ -0,0 +1,9 @@
+// "Invert 'if' condition" "true"
+class A {
+ public boolean foo() {
+ if (())
+ return false;
+ else
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/beforeNull.java b/java/java-tests/testData/codeInsight/invertIfCondition/beforeNull.java
new file mode 100644
index 000000000000..584af553ad79
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/invertIfCondition/beforeNull.java
@@ -0,0 +1,9 @@
+// "Invert 'if' condition" "true"
+class A {
+ public boolean foo() {
+ if (null)
+ return false;
+ else
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/java/openapi/src/com/intellij/codeInsight/CodeInsightServicesUtil.java b/java/openapi/src/com/intellij/codeInsight/CodeInsightServicesUtil.java
index c9f28724dc17..a93a15836113 100644
--- a/java/openapi/src/com/intellij/codeInsight/CodeInsightServicesUtil.java
+++ b/java/openapi/src/com/intellij/codeInsight/CodeInsightServicesUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -78,15 +78,18 @@ public class CodeInsightServicesUtil {
}
}
else if (booleanExpression instanceof PsiLiteralExpression) {
- return booleanExpression.getText().equals("true") ?
- factory.createExpressionFromText("false", null) :
- factory.createExpressionFromText("true", null);
+ Object value = ((PsiLiteralExpression)booleanExpression).getValue();
+ if (value instanceof Boolean) {
+ return factory.createExpressionFromText(String.valueOf(!((Boolean)value)), booleanExpression);
+ }
}
if (booleanExpression instanceof PsiParenthesizedExpression) {
PsiExpression operand = ((PsiParenthesizedExpression)booleanExpression).getExpression();
- operand.replace(invertCondition(operand));
- return booleanExpression;
+ if (operand != null) {
+ operand.replace(invertCondition(operand));
+ return booleanExpression;
+ }
}
PsiPrefixExpression result = (PsiPrefixExpression)factory.createExpressionFromText("!(a)", null);
From e64d6cdf70461bfde5683dc2f9d0523645e62deb Mon Sep 17 00:00:00 2001
From: nik
Date: Fri, 7 Apr 2017 20:50:40 +0300
Subject: [PATCH 011/463] javadoc for build scripts updated: do not set custom
directories and JAR names for new plugins
---
.../jetbrains/intellij/build/impl/BaseLayoutSpec.groovy | 2 +-
.../jetbrains/intellij/build/impl/PluginLayout.groovy | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BaseLayoutSpec.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BaseLayoutSpec.groovy
index 76d5bf96cfb3..7c9016d55725 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BaseLayoutSpec.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BaseLayoutSpec.groovy
@@ -31,7 +31,7 @@ class BaseLayoutSpec {
* 'Runtime' to be copied to the 'lib' directory of the plugin.
*
* @param relativeJarPath target JAR path relative to 'lib' directory of the plugin; different modules may be packed into the same JAR,
- * but don't use this for new plugins; this parameter is temporary added to keep layout of old plugins.
+ * but don't use this for new plugins; this parameter is temporary added to keep layout of old plugins.
* @param localizableResourcesInCommonJar if {@code true} the translatable resources from the module (messages, inspection descriptions, etc) will be
* placed into a separate 'resources_en.jar'. Do not use this for new plugins, this parameter is temporary added to keep layout of old plugins.
*/
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/PluginLayout.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/PluginLayout.groovy
index 7bc8c7646730..31537047e51b 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/PluginLayout.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/PluginLayout.groovy
@@ -75,15 +75,18 @@ class PluginLayout extends BaseLayout {
static class PluginLayoutSpec extends BaseLayoutSpec {
private final PluginLayout layout
/**
- * Name of the directory (under 'plugins' directory) where the plugin should be placed
+ * Custom name of the directory (under 'plugins' directory) where the plugin should be placed. By default the main module name is used.
+ * Don't set this property for new plugins; it is temporary added to keep layout of old plugins unchanged.
*/
String directoryName
/**
- * Name of the main plugin JAR file
+ * Custom name of the main plugin JAR file. By default the main module name with 'jar' extension is used.
+ * Don't set this property for new plugins; it is temporary added to keep layout of old plugins unchanged.
*/
String mainJarName
/**
- * Version of the plugin if it differs from the global build number
+ * Version of the plugin if it differs from the global build number.
+ * Don't set this property for new plugins; it is temporary added to keep versioning scheme for some old plugins.
*/
String version
From be3b860c8dffa104e900be864183ed0922050ac2 Mon Sep 17 00:00:00 2001
From: nik
Date: Mon, 10 Apr 2017 10:19:27 +0300
Subject: [PATCH 012/463] build scripts: removed obsolete properties from
idea-community's build.xml
---
build.xml | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/build.xml b/build.xml
index 851b0e6ee3b0..27e0335454e0 100644
--- a/build.xml
+++ b/build.xml
@@ -3,7 +3,6 @@
-Dout=/path/to/out/dir, defaults to ${basedir}/out
-Dbuild=123, defaults to SNAPSHOT
-Dtestpatterns=com.foo.*, defaults to empty string
- -Dproduct=foo, defaults to idea
-->
@@ -20,14 +19,6 @@
-
-
-
-
-
-
-
-
@@ -55,8 +46,6 @@
-
-
From 19939a3d1094f86ba5a0f3325f0470d6590e39e6 Mon Sep 17 00:00:00 2001
From: Dmitry Batrak
Date: Thu, 6 Apr 2017 15:13:01 +0300
Subject: [PATCH 013/463] IDEA-170039 Honor new foldings 'collapse by default'
state - support for specific folding regions' dependencies in platform code
---
.../editor/CodeFoldingConfigurable.java | 31 ++-------
.../daemon/impl/CodeFoldingPass.java | 2 +-
.../impl/UpdateFoldRegionsOperation.java | 68 ++++++++++++++++---
3 files changed, 66 insertions(+), 35 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/CodeFoldingConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/editor/CodeFoldingConfigurable.java
index d996694fb11c..f8b280e3e7d1 100644
--- a/platform/lang-impl/src/com/intellij/application/options/editor/CodeFoldingConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/application/options/editor/CodeFoldingConfigurable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,24 +16,21 @@
package com.intellij.application.options.editor;
-import com.intellij.codeInsight.folding.CodeFoldingManager;
+import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
import com.intellij.openapi.options.CompositeConfigurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.ex.ConfigurableWrapper;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.project.ProjectManager;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -77,25 +74,11 @@ public class CodeFoldingConfigurable extends CompositeConfigurable> toUpdate = new ArrayList<>();
- for (final Editor editor : EditorFactory.getInstance().getAllEditors()) {
- final Project project = editor.getProject();
- if (project != null && !project.isDefault()) {
- toUpdate.add(Pair.create(editor, project));
- }
- }
-
ApplicationManager.getApplication().invokeLater(() -> {
- for (Pair each : toUpdate) {
- if (each.second == null || each.second.isDisposed()) {
- continue;
- }
- final CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(each.second);
- if (foldingManager != null) {
- foldingManager.buildInitialFoldings(each.first);
- }
- }
- EditorOptionsPanel.reinitAllEditors();
+ EditorOptionsPanel.reinitAllEditors();
+ for (Project project : ProjectManager.getInstance().getOpenProjects()) {
+ DaemonCodeAnalyzer.getInstance(project).restart();
+ }
}, ModalityState.NON_MODAL);
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/CodeFoldingPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/CodeFoldingPass.java
index 0d95d24bdb8e..2f58f9b159ee 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/CodeFoldingPass.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/CodeFoldingPass.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/UpdateFoldRegionsOperation.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/UpdateFoldRegionsOperation.java
index 26fede296b13..c04d625e80ca 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/UpdateFoldRegionsOperation.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/UpdateFoldRegionsOperation.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -29,12 +29,15 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.ModificationTracker;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.SmartPointerManager;
+import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashMap;
+import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -47,6 +50,8 @@ class UpdateFoldRegionsOperation implements Runnable {
private static final Logger LOG = Logger.getInstance("#" + UpdateFoldRegionsOperation.class.getName());
private static final Key CAN_BE_REMOVED_WHEN_COLLAPSED = Key.create("canBeRemovedWhenCollapsed");
+ private static final Key DEPENDENCIES = Key.create("dependencies");
+ private static final Key
+
+ In order to run a gant script without IntelliJ IDEA you can use build/gant.xml Ant file and pass path to the gant script via gant.script property.
+
If you want to add a new module to an existing product, add its name to {@link org.jetbrains.intellij.build.ProductModulesLayout#platformApiModules
platformApiModules/platformImplementationModules}. If the module is part of IntelliJ Platform and needs to be included into all products
From 40ee28ddae52fc378716c28091f89a6b0427c9de Mon Sep 17 00:00:00 2001
From: "Egor.Ushakov"
Date: Mon, 10 Apr 2017 14:39:11 +0300
Subject: [PATCH 033/463] IDEA-141596 Debugger: recursion in self references -
better icons
---
platform/icons/src/debugger/selfreference.png | Bin 300 -> 313 bytes
.../icons/src/debugger/selfreference@2x.png | Bin 645 -> 641 bytes
.../src/debugger/selfreference@2x_dark.png | Bin 0 -> 649 bytes
.../icons/src/debugger/selfreference_dark.png | Bin 0 -> 314 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 platform/icons/src/debugger/selfreference@2x_dark.png
create mode 100644 platform/icons/src/debugger/selfreference_dark.png
diff --git a/platform/icons/src/debugger/selfreference.png b/platform/icons/src/debugger/selfreference.png
index 71b18d1765e51fc62c79f4610bb02d56b7c557d4..c526e9281892a5956983d0b7dd9ddca8bad9a26a 100644
GIT binary patch
delta 287
zcmV+)0pR|u0=WW^BYyz^Nkloj-c}8WGl6&}8U~4};nm!hte1;LBOC+e
z4|S*Mp9a#~fH)CFbAP6O`O0eJ&4dhq;#_o_4ZG9z_rG3gGY45iZlKmVKO40NAPnMz
z)a>mvTMaeD5ZQp%4Gkt6kTsv0WWEfh5r((7nyv%UbBhgkfPeHL8*u2%WQ%3Uic@_w
zFM|vK(db?|(r3N`qz9~7Szdt+#JN1faxuC>bQi!dNG*l|x93?cB+CGp7eLM;)&LYQ
zzyc8zFvJ>wEf5W{xdNL3Fxye05d<3JbxUx01&iifoJkp^0OUlFVo+d#Fo+FxHg3&m
l-f2ZjwlLg^;TUXc000F_cK;j-^^X7m002ovPDHLkV1jkqc^3cx
delta 274
zcmV+t0qy>|0;~d%BYyz%Nkloj-c}8WGl6&}8U~4}5z-unMI$;+z@<6i
z!ZeE|_%z3RXj}tfA8XZ3%JK@nD9*k;&uZb6T!Y=n8gc`*&iUD>Jpf^31E3bEAsdj{
zldiXaSG(yNnC4TH%$LD5!f=|e=B1WI-NPWYAU((ifF++VvwxloQ=ICfc^PB?h=z&H
zEjHW%vK^!r#78jz34
z|0q76d%`CoGq03XG+hw=_(
zP7(K
zKs7KC*p`ThNPwY|dNA`!Z_X(NA6x)200rPrxR@;1p?_c$3HUY-qSk2>QQ#3|*1+Dx
z6SsiN$-oZKRGIz=(&4(S8ye$57`FhVOrm1I6AL6#z;_TLP!c6T7K9NuJs=TjsFQhk
z1@lS(_GC>-cPz#BD&~a%?8yXZj?G9V8{7!s%?KPy?HE15$rY*su!nLx<`)u~2s9yC
z`L&VDFJUB1M3{?EElzf`+sMOiZ^U7Kok9?)WCy;n1)O_wn>!4?8FCo~1yzj$V=T}4
z6+HOc{{|Y*4i`|ng1Z!=TNTp~5E|B;?kVw~f4%_oF|zNNxoV;S0000lQAuk}@oOSyiEsw-(Yjy&xYQJ14-iBg3@`I_uJ(ie&aZv21sM&UjiW-C$DyJBTFxX4Y#W0caq`@l4S!7C41J
z+>~_-0kb{+3t0`2*C5A#*pAItiv*yH8Sor0Kd+Uos|Y|Hi00ur{YG8DCKJ^GkpP`l
zD0#s5ESA?<7<%s~;QYpf?ZK&D@R0P15
z$~KH^L{4c)M1X1|()b0keVvE^YC?{!m_Ll@2)$b_+5D~mtc4Aw!$@=-+lg=zz>+g<
zS$DiAvSk+%Do7aO(}6=s)_yTY-yLtuczb%%esU~_I{=1HPd*7{R{}8)ah3x$eB2ecj4BQQ;&&&z
z^N0?1kcRh1>bH_>IW`ACu`MCXd7yE0=<{apd4w#Pn61Az)KUG8pN-lB7+zLsv<2<}
zU=)7Z5x)4{iH==J@y~6
z?Irkpe~4J$mxgPf0$CXArg8o0QtP=OvFo!f7r~m!91tPa0e{$fuaE97!ZafKwS9a-ptjo#E8uS;NStJT6~6JOL#C$C^SH3
z!|Wm30sA^lSA%e>kLG2NrFF5oM`2>fiI98;0J99O(g0OLfR+w`Btl?9p_Ky&CBjxx
z>Hu0~!%%ohh*W}6%K;!Wkt(H7yhSm3DMk$kfXqa401w{Eh?v|!iUW`j01$L|4bi4H80*098VSieEI#2{%ZP9FdFc2x1E-^k7G`JeSlKaV~Om3Y3V5
z$sHgyXbFyV%h94^8?s@bybLN(K&2Wo28ki%bL1wtEv0<}9^~9X0w%5rPNG9Xp(W-v
jEEaBq%7s$Z;$aT}kc6ZSQ!j#500000NkvXXu0mjfftC!}
literal 0
HcmV?d00001
diff --git a/platform/icons/src/debugger/selfreference_dark.png b/platform/icons/src/debugger/selfreference_dark.png
new file mode 100644
index 0000000000000000000000000000000000000000..dacebfd7261705b0e241a515b12c8c7c01da151a
GIT binary patch
literal 314
zcmV-A0mc4_P)oj-c}8WGl6&}8U~4};nn>1%(PrA8sQiyf9UP$NvDDIHXu$!(fsaIfBE~vm756~
z0KvKFHX8y>-v4={%N%44xq({e{A|=7fH2qqpqh_+Ggm_mF+?_?^~1rE4ak~LO)_5w
z(+I;K_UEqy(eI8m?*QpRHsH|5U2)5h6{q@WUIrNeqS3wbaZmCJkRGt+=g*(BfjFOb
zgfB){i0%Ry2C2m~U|ZlqvJ8NG0q87Z4M6b%ED%8fL#zSV0?`ngE3g>=vmGTG!G@fj
zRf5YaSTyJ2Ov)eyASZ$pg8~bLL2RhAacf5NPAgKfh2d5VXHx?J0D*tPi${u-QUCw|
M07*qoM6N<$f))&dM*si-
literal 0
HcmV?d00001
From 343642204e9f29fd34c59aec8cddc54d1aa9b8eb Mon Sep 17 00:00:00 2001
From: Anton Tarasov
Date: Mon, 10 Apr 2017 14:40:17 +0300
Subject: [PATCH 034/463] IDEA-170099 [followup] let Swing text components
dynamically scale HTML text on user scale factor change
---
platform/util/src/com/intellij/util/ui/UIUtil.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java
index cc5676f290c8..100442ac3751 100644
--- a/platform/util/src/com/intellij/util/ui/UIUtil.java
+++ b/platform/util/src/com/intellij/util/ui/UIUtil.java
@@ -2528,7 +2528,7 @@ public class UIUtil {
public JBHtmlEditorKit(boolean noGapsBetweenParagraphs) {
style.addStyleSheet(isUnderDarcula() ? (StyleSheet)UIManager.getDefaults().get("StyledEditorKit.JBDefaultStyle") : DEFAULT_HTML_KIT_CSS);
- style.addRule("code { font-size: 90%; }"); // small by Swing's default, make it b/w small and medium
+ style.addRule("code { font-size: 100%; }"); // small by Swing's default
style.addRule("small { font-size: small; }"); // x-small by Swing's default
if (noGapsBetweenParagraphs) style.addRule("p { margin-top: 0; }");
}
From 041fe2b1be4767ad2fb80d3677dad5505813b609 Mon Sep 17 00:00:00 2001
From: Mikhail Golubev
Date: Fri, 7 Apr 2017 18:41:06 +0300
Subject: [PATCH 035/463] PY-23578 Optimize Imports preserves a blank line
before the first import import
It happened due to the bug in the platform and only when the number of
blank lines after the import statement is greater than that before it.
As a temporary workaround before the relevant fix in the platform is
accepted I delete old imports as text through the underlying document.
---
.../imports/PyImportOptimizer.java | 13 ++++++----
.../src/com/jetbrains/python/psi/PyUtil.java | 19 +++++++++++++++
...nDocstringAndFirstImportPreserved.after.py | 9 +++++++
...BetweenDocstringAndFirstImportPreserved.py | 10 ++++++++
...eclarationAndFirstImportPreserved.after.py | 6 +++++
...odingDeclarationAndFirstImportPreserved.py | 6 +++++
.../python/PyOptimizeImportsTest.java | 24 +++++++++++++++----
7 files changed, 77 insertions(+), 10 deletions(-)
create mode 100644 python/testData/optimizeImports/blankLineBetweenDocstringAndFirstImportPreserved.after.py
create mode 100644 python/testData/optimizeImports/blankLineBetweenDocstringAndFirstImportPreserved.py
create mode 100644 python/testData/optimizeImports/blankLineBetweenEncodingDeclarationAndFirstImportPreserved.after.py
create mode 100644 python/testData/optimizeImports/blankLineBetweenEncodingDeclarationAndFirstImportPreserved.py
diff --git a/python/src/com/jetbrains/python/codeInsight/imports/PyImportOptimizer.java b/python/src/com/jetbrains/python/codeInsight/imports/PyImportOptimizer.java
index 75d3e40aed81..07d921bd2f60 100644
--- a/python/src/com/jetbrains/python/codeInsight/imports/PyImportOptimizer.java
+++ b/python/src/com/jetbrains/python/codeInsight/imports/PyImportOptimizer.java
@@ -22,10 +22,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiComment;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiWhiteSpace;
+import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.util.PsiTreeUtil;
@@ -286,7 +283,7 @@ public class PyImportOptimizer implements ImportOptimizer {
final PyImportStatementBase lastImport = ContainerUtil.getLastItem(myImportBlock);
assert lastImport != null;
addImportsAfter(lastImport);
- myFile.deleteChildRange(firstElementToRemove, PyPsiUtils.getNextNonWhitespaceSibling(lastImport).getPrevSibling());
+ deleteRangeThroughDocument(firstElementToRemove, PyPsiUtils.getNextNonWhitespaceSibling(lastImport).getPrevSibling());
}
private void addImportsAfter(@NotNull PsiElement anchor) {
@@ -331,5 +328,11 @@ public class PyImportOptimizer implements ImportOptimizer {
myFile.addRangeAfter(reformattedFile.getFirstChild(), reformattedFile.getLastChild(), anchor);
}
+
+ private static void deleteRangeThroughDocument(@NotNull PsiElement first, @NotNull PsiElement last) {
+ PyUtil.updateDocumentUnblockedAndCommitted(first, document -> {
+ document.deleteString(first.getTextRange().getStartOffset(), last.getTextRange().getEndOffset());
+ });
+ }
}
}
diff --git a/python/src/com/jetbrains/python/psi/PyUtil.java b/python/src/com/jetbrains/python/psi/PyUtil.java
index 7239f01cc7f3..d7fac1ed3fc4 100644
--- a/python/src/com/jetbrains/python/psi/PyUtil.java
+++ b/python/src/com/jetbrains/python/psi/PyUtil.java
@@ -910,6 +910,25 @@ public class PyUtil {
return as(PyPsiUtils.getPrevNonWhitespaceSibling(statementList), PsiComment.class);
}
+ /**
+ * Retrieve the document from {@link PsiDocumentManager} using the anchor PSI element and pass it to the consumer function
+ * first releasing it from pending PSI modifications it with {@link PsiDocumentManager#doPostponedOperationsAndUnblockDocument(Document)}
+ * and then committing in try/finally block, so that subsequent operations over the PSI can be performed.
+ */
+ public static void updateDocumentUnblockedAndCommitted(@NotNull PsiElement anchor, @NotNull Consumer consumer) {
+ final PsiDocumentManager manager = PsiDocumentManager.getInstance(anchor.getProject());
+ final Document document = manager.getDocument(anchor.getContainingFile());
+ if (document != null) {
+ manager.doPostponedOperationsAndUnblockDocument(document);
+ try {
+ consumer.consume(document);
+ }
+ finally {
+ manager.commitDocument(document);
+ }
+ }
+ }
+
public static class KnownDecoratorProviderHolder {
public static PyKnownDecoratorProvider[] KNOWN_DECORATOR_PROVIDERS = Extensions.getExtensions(PyKnownDecoratorProvider.EP_NAME);
diff --git a/python/testData/optimizeImports/blankLineBetweenDocstringAndFirstImportPreserved.after.py b/python/testData/optimizeImports/blankLineBetweenDocstringAndFirstImportPreserved.after.py
new file mode 100644
index 000000000000..64cebe733bee
--- /dev/null
+++ b/python/testData/optimizeImports/blankLineBetweenDocstringAndFirstImportPreserved.after.py
@@ -0,0 +1,9 @@
+# pylint: disable=missing-docstring, invalid-name
+
+"""2016 - Day 1 Puzzle Part 2 tests."""
+
+import sys
+
+from mod import solve, in_between, Point
+
+print(solve, in_between, Point, sys)
\ No newline at end of file
diff --git a/python/testData/optimizeImports/blankLineBetweenDocstringAndFirstImportPreserved.py b/python/testData/optimizeImports/blankLineBetweenDocstringAndFirstImportPreserved.py
new file mode 100644
index 000000000000..f748d726e656
--- /dev/null
+++ b/python/testData/optimizeImports/blankLineBetweenDocstringAndFirstImportPreserved.py
@@ -0,0 +1,10 @@
+# pylint: disable=missing-docstring, invalid-name
+
+"""2016 - Day 1 Puzzle Part 2 tests."""
+
+import sys
+
+
+from mod import solve, in_between, Point
+
+print(solve, in_between, Point, sys)
\ No newline at end of file
diff --git a/python/testData/optimizeImports/blankLineBetweenEncodingDeclarationAndFirstImportPreserved.after.py b/python/testData/optimizeImports/blankLineBetweenEncodingDeclarationAndFirstImportPreserved.after.py
new file mode 100644
index 000000000000..1e0b9391bd2f
--- /dev/null
+++ b/python/testData/optimizeImports/blankLineBetweenEncodingDeclarationAndFirstImportPreserved.after.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8
+from __future__ import unicode_literals, absolute_import
+
+import os
+
+os.listdir('.')
diff --git a/python/testData/optimizeImports/blankLineBetweenEncodingDeclarationAndFirstImportPreserved.py b/python/testData/optimizeImports/blankLineBetweenEncodingDeclarationAndFirstImportPreserved.py
new file mode 100644
index 000000000000..1e0b9391bd2f
--- /dev/null
+++ b/python/testData/optimizeImports/blankLineBetweenEncodingDeclarationAndFirstImportPreserved.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8
+from __future__ import unicode_literals, absolute_import
+
+import os
+
+os.listdir('.')
diff --git a/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java b/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java
index e8a3caa99b37..b198c7ea09da 100644
--- a/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java
+++ b/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java
@@ -88,11 +88,7 @@ public class PyOptimizeImportsTest extends PyTestCase {
// PY-16351
public void testNoExtraBlankLineAfterImportBlock() {
- final String testName = getTestName(true);
- myFixture.copyDirectoryToProject(testName, "");
- myFixture.configureByFile("main.py");
- OptimizeImportsAction.actionPerformedImpl(DataManager.getInstance().getDataContext(myFixture.getEditor().getContentComponent()));
- myFixture.checkResultByFile(testName + "/main.after.py");
+ doMultiFileTest();
}
// PY-18521
@@ -298,6 +294,24 @@ public class PyOptimizeImportsTest extends PyTestCase {
doTest();
}
+ // PY-23578
+ public void testBlankLineBetweenDocstringAndFirstImportPreserved() {
+ doTest();
+ }
+
+ // PY-23636
+ public void testBlankLineBetweenEncodingDeclarationAndFirstImportPreserved() {
+ doTest();
+ }
+
+ private void doMultiFileTest() {
+ final String testName = getTestName(true);
+ myFixture.copyDirectoryToProject(testName, "");
+ myFixture.configureByFile("main.py");
+ OptimizeImportsAction.actionPerformedImpl(DataManager.getInstance().getDataContext(myFixture.getEditor().getContentComponent()));
+ myFixture.checkResultByFile(testName + "/main.after.py");
+ }
+
private void doTest() {
myFixture.configureByFile(getTestName(true) + ".py");
OptimizeImportsAction.actionPerformedImpl(DataManager.getInstance().getDataContext(myFixture.getEditor().getContentComponent()));
From 5e6b280c9b1deb0dbc89eb608eda6197d0a8036c Mon Sep 17 00:00:00 2001
From: Alexandr Evstigneev
Date: Thu, 16 Mar 2017 16:12:05 +0300
Subject: [PATCH 036/463] restricted model building for template languages as
data languages IDEA-169720
---
.../SimpleTemplateLanguageFormattingModelBuilder.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/psi/templateLanguages/SimpleTemplateLanguageFormattingModelBuilder.java b/platform/lang-impl/src/com/intellij/psi/templateLanguages/SimpleTemplateLanguageFormattingModelBuilder.java
index 1e332e6749fe..0750472363c5 100644
--- a/platform/lang-impl/src/com/intellij/psi/templateLanguages/SimpleTemplateLanguageFormattingModelBuilder.java
+++ b/platform/lang-impl/src/com/intellij/psi/templateLanguages/SimpleTemplateLanguageFormattingModelBuilder.java
@@ -20,9 +20,9 @@ import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageFormatting;
import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
-import com.intellij.psi.FileViewProvider;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.formatter.DocumentBasedFormattingModel;
import com.intellij.psi.formatter.common.AbstractBlock;
@@ -41,10 +41,10 @@ public class SimpleTemplateLanguageFormattingModelBuilder implements FormattingM
if (element instanceof PsiFile) {
final FileViewProvider viewProvider = ((PsiFile)element).getViewProvider();
if (viewProvider instanceof TemplateLanguageFileViewProvider) {
- final Language language = ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage();
- FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forLanguage(language);
- if (builder != null) {
- return builder.createModel(viewProvider.getPsi(language), settings);
+ final Language templateDataLanguage = ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage();
+ FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forLanguage(templateDataLanguage);
+ if (builder != null && templateDataLanguage != element.getLanguage()) {
+ return builder.createModel(viewProvider.getPsi(templateDataLanguage), settings);
}
}
}
From 14bd8f50a15bfb5acd06aa765a06a3853fb83a7e Mon Sep 17 00:00:00 2001
From: peter
Date: Mon, 10 Apr 2017 13:57:56 +0200
Subject: [PATCH 037/463] add debug logging for flaky NewProjectWizardTest
---
java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java | 1 +
.../com/intellij/ide/util/projectWizard/JavaModuleBuilder.java | 1 +
2 files changed, 2 insertions(+)
diff --git a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java
index 62184dfc35d6..fb5ce69d4001 100644
--- a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java
+++ b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java
@@ -92,6 +92,7 @@ public class NewProjectUtil {
}
final ProjectBuilder projectBuilder = dialog.getProjectBuilder();
+ LOG.debug("builder " + projectBuilder);
try {
File projectDir = new File(projectFilePath).getParentFile();
diff --git a/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java b/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java
index 26a3a7cfc417..5a3be03ad43e 100644
--- a/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java
+++ b/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java
@@ -157,6 +157,7 @@ public class JavaModuleBuilder extends ModuleBuilder implements SourcePathsBuild
public List commit(@NotNull Project project, ModifiableModuleModel model, ModulesProvider modulesProvider) {
LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(ProjectManager.getInstance().getDefaultProject());
Boolean aDefault = extension.getDefault();
+ LOG.debug("commit: aDefault=" + aDefault);
LanguageLevelProjectExtension instance = LanguageLevelProjectExtension.getInstance(project);
if (aDefault != null && !aDefault) {
instance.setLanguageLevel(extension.getLanguageLevel());
From 63481734f6622309ffe936ea4f3a7e9c536bfd5a Mon Sep 17 00:00:00 2001
From: peter
Date: Mon, 10 Apr 2017 14:00:07 +0200
Subject: [PATCH 038/463] ShredImpl.isValid: don't check the same PSI element
validity twice (IDEA-169876)
---
.../com/intellij/psi/impl/source/tree/injected/ShredImpl.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
index 7d8844d7017c..4fbce72f315f 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
@@ -99,8 +99,7 @@ class ShredImpl implements PsiLanguageInjectionHost.Shred {
@Override
public boolean isValid() {
- PsiLanguageInjectionHost host = getHost();
- return getHostRangeMarker() != null && host != null && host.isValid();
+ return getHostRangeMarker() != null && getHost() != null;
}
@Override
From 9cab9c6e99b681d45f2b257906cb51cdc4afc374 Mon Sep 17 00:00:00 2001
From: Sergey Simonchik
Date: Mon, 10 Apr 2017 15:15:49 +0300
Subject: [PATCH 039/463] print multiple links correctly
---
.../sm/runner/TestProxyPrinterProvider.java | 20 +++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java
index d66162f22810..99f25af521a9 100644
--- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java
+++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java
@@ -25,7 +25,7 @@ import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.StringTokenizer;
+import java.util.*;
public final class TestProxyPrinterProvider {
@@ -96,18 +96,30 @@ public final class TestProxyPrinterProvider {
throw new RuntimeException("Error while applying " + myFilter + " to '"+line+"'", t);
}
if (result != null) {
- for (Filter.ResultItem item : result.getResultItems()) {
- defaultPrint(line.substring(0, item.getHighlightStartOffset()), contentType);
+ List items = sort(result.getResultItems());
+ int lastOffset = 0;
+ for (Filter.ResultItem item : items) {
+ defaultPrint(line.substring(lastOffset, item.getHighlightStartOffset()), contentType);
String linkText = line.substring(item.getHighlightStartOffset(), item.getHighlightEndOffset());
printHyperlink(linkText, item.getHyperlinkInfo());
- defaultPrint(line.substring(item.getHighlightEndOffset()), contentType);
+ lastOffset = item.getHighlightEndOffset();
}
+ defaultPrint(line.substring(lastOffset), contentType);
}
else {
defaultPrint(line, contentType);
}
}
+ @NotNull
+ private static List sort(@NotNull List items) {
+ if (items.size() <= 1) {
+ return items;
+ }
+ List copy = new ArrayList<>(items);
+ Collections.sort(copy, Comparator.comparingInt(Filter.ResultItem::getHighlightStartOffset));
+ return copy;
+ }
}
}
From 0d5d90577db20a704d44df807f6a47f4ef04509b Mon Sep 17 00:00:00 2001
From: Dmitry Batkovich
Date: Mon, 10 Apr 2017 15:16:12 +0300
Subject: [PATCH 040/463] PreferMostUsedWeigher should return null "helper"
methods (ex.: Objects.requireNonNull)
---
.../completion/PreferMostUsedWeigher.java | 34 +++++++++--
.../testHelperMethodIsNotAffected/Foo.java | 61 +++++++++++++++++++
...CompilerReferenceDataInCompletionTest.java | 11 ++++
3 files changed, 102 insertions(+), 4 deletions(-)
create mode 100644 java/java-tests/testData/compiler/completionOrdering/testHelperMethodIsNotAffected/Foo.java
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/PreferMostUsedWeigher.java b/java/java-impl/src/com/intellij/codeInsight/completion/PreferMostUsedWeigher.java
index 5ec1c85d7756..1c4949539d4e 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/PreferMostUsedWeigher.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/PreferMostUsedWeigher.java
@@ -20,9 +20,8 @@ import com.intellij.codeInsight.lookup.LookupElementWeigher;
import com.intellij.compiler.CompilerReferenceService;
import com.intellij.patterns.PsiMethodPattern;
import com.intellij.patterns.StandardPatterns;
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiMember;
+import com.intellij.psi.*;
+import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -30,7 +29,7 @@ import org.jetbrains.annotations.Nullable;
import static com.intellij.patterns.PsiJavaPatterns.psiMethod;
class PreferMostUsedWeigher extends LookupElementWeigher {
- static final PsiMethodPattern OBJECT_METHOD_PATTERN = psiMethod().withName(
+ private static final PsiMethodPattern OBJECT_METHOD_PATTERN = psiMethod().withName(
StandardPatterns.string().oneOf("hashCode", "equals", "finalize", "wait", "notify", "notifyAll", "getClass", "clone", "toString")).
inClass(CommonClassNames.JAVA_LANG_OBJECT);
@@ -61,8 +60,35 @@ class PreferMostUsedWeigher extends LookupElementWeigher {
if (OBJECT_METHOD_PATTERN.accepts(psi)) {
return null;
}
+ if (looksLikeHelperMethod(psi)) {
+ return null;
+ }
final Integer occurrenceCount = myCompilerReferenceService.getCompileTimeOccurrenceCount(psi, myConstructorSuggestion);
return occurrenceCount == null ? null : - occurrenceCount;
}
}
+
+ //Objects.requireNonNull is an example
+ private static boolean looksLikeHelperMethod(@NotNull PsiElement element) {
+ if (!(element instanceof PsiMethod)) return false;
+ PsiMethod method = (PsiMethod)element;
+ if (method.isConstructor()) return false;
+ if (isRawDeepTypeEqualToObject(method.getReturnType())) return true;
+ PsiParameter[] parameters = method.getParameterList().getParameters();
+ if (parameters.length == 0) return false;
+ for (PsiParameter parameter : parameters) {
+ PsiType paramType = parameter.getType();
+ if (!isRawDeepTypeEqualToObject(paramType)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean isRawDeepTypeEqualToObject(@Nullable PsiType type) {
+ if (type == null) return false;
+ PsiType rawType = TypeConversionUtil.erasure(type.getDeepComponentType());
+ if (rawType == null) return false;
+ return rawType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
+ }
}
diff --git a/java/java-tests/testData/compiler/completionOrdering/testHelperMethodIsNotAffected/Foo.java b/java/java-tests/testData/compiler/completionOrdering/testHelperMethodIsNotAffected/Foo.java
new file mode 100644
index 000000000000..5f9ba114e237
--- /dev/null
+++ b/java/java-tests/testData/compiler/completionOrdering/testHelperMethodIsNotAffected/Foo.java
@@ -0,0 +1,61 @@
+class Foo {
+
+ public static void someMethod1() {
+
+ }
+
+ public static void someMethod2(String string) {
+
+ }
+
+ void m() {
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+ nonNull("");
+
+ someMethod1();
+ someMethod1();
+ someMethod1();
+ someMethod2("");
+ someMethod2("");
+ someMethod2("");
+ someMethod2("");
+ someMethod2("");
+
+
+
+ }
+
+ public static T nonNull(T t) {
+ assert t != null;
+ return t;
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/compiler/CompilerReferenceDataInCompletionTest.java b/java/java-tests/testSrc/com/intellij/compiler/CompilerReferenceDataInCompletionTest.java
index 6b009fd7157e..21259d0f7928 100644
--- a/java/java-tests/testSrc/com/intellij/compiler/CompilerReferenceDataInCompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/compiler/CompilerReferenceDataInCompletionTest.java
@@ -72,6 +72,10 @@ public class CompilerReferenceDataInCompletionTest extends CompilerReferencesTes
doTestConstructorCompletionOrdering(new String[] {"Foo.java"}, "List l = new ", "AbstractList", "ArrayList");
}
+ public void testHelperMethodIsNotAffected() {
+ doTestStaticMemberCompletionOrdering(new String[] {"Foo.java"}, "someMethod2(1)", "someMethod1(0)", "m(0)", "nonNull(1)");
+ }
+
private void doTestConstructorCompletionOrdering(@NotNull String[] files,
@NotNull String phraseToComplete,
String... expectedOrder) {
@@ -82,6 +86,13 @@ public class CompilerReferenceDataInCompletionTest extends CompilerReferencesTes
doTestCompletion(files, "foo.", expectedOrder, m -> "Foo".equals(m.getContainingClass().getName()));
}
+ private void doTestStaticMemberCompletionOrdering(@NotNull String[] files, String... expectedOrder) {
+ doTestCompletion(files, "", expectedOrder, (PsiMember m) -> {
+ PsiClass aClass = m.getContainingClass();
+ return aClass != null && "Foo".equals(aClass.getName());
+ });
+ }
+
private void doTestCompletion(@NotNull String[] files,
@NotNull String phraseToComplete,
@NotNull String[] expectedOrder,
From 4963f53e03b84920c4b33bac7a2bdea168b99c63 Mon Sep 17 00:00:00 2001
From: Dmitry Jemerov
Date: Mon, 10 Apr 2017 14:35:58 +0200
Subject: [PATCH 041/463] Add missing UAST testdata
---
uast/uast-tests/java/DataClass/DataClass.java | 61 +++++
.../java/DataClass/DataClass.log.txt | 221 ++++++++++++++++++
.../java/DataClass/DataClass.render.txt | 33 +++
.../uast-tests/java/Simple/AliveThenElse.java | 29 +++
.../java/Simple/AliveThenElse.values.txt | 25 ++
uast/uast-tests/java/Simple/Anonymous.java | 31 +++
.../java/Simple/Anonymous.values.txt | 24 ++
uast/uast-tests/java/Simple/Bitwise.java | 30 +++
.../uast-tests/java/Simple/Bitwise.values.txt | 46 ++++
uast/uast-tests/java/Simple/ByteShort.java | 29 +++
.../java/Simple/ByteShort.values.txt | 46 ++++
uast/uast-tests/java/Simple/CascadeIf.java | 37 +++
.../java/Simple/CascadeIf.values.txt | 45 ++++
uast/uast-tests/java/Simple/Characters.java | 27 +++
.../java/Simple/Characters.values.txt | 48 ++++
uast/uast-tests/java/Simple/ClassLiteral.java | 20 ++
.../java/Simple/ClassLiteral.values.txt | 9 +
uast/uast-tests/java/Simple/DeadElse.java | 30 +++
.../java/Simple/DeadElse.values.txt | 27 +++
uast/uast-tests/java/Simple/DeadFor.java | 24 ++
.../uast-tests/java/Simple/DeadFor.values.txt | 24 ++
.../java/Simple/DeadIfComparison.java | 29 +++
.../java/Simple/DeadIfComparison.values.txt | 26 +++
.../java/Simple/DeadSwitchEntries.java | 40 ++++
.../java/Simple/DeadSwitchEntries.values.txt | 48 ++++
.../DeadSwitchEntriesWithoutBreaks.java | 38 +++
.../DeadSwitchEntriesWithoutBreaks.values.txt | 46 ++++
uast/uast-tests/java/Simple/DeadThen.java | 30 +++
.../java/Simple/DeadThen.values.txt | 28 +++
uast/uast-tests/java/Simple/Dependents.java | 24 ++
.../java/Simple/Dependents.values.txt | 18 ++
uast/uast-tests/java/Simple/DoWhile.java | 28 +++
.../uast-tests/java/Simple/DoWhile.values.txt | 32 +++
.../java/Simple/DoWhileInfinite.java | 27 +++
.../java/Simple/DoWhileInfinite.values.txt | 27 +++
.../java/Simple/DoWhileWithReturn.java | 27 +++
.../java/Simple/DoWhileWithReturn.values.txt | 28 +++
uast/uast-tests/java/Simple/EnumChoice.java | 30 +++
.../java/Simple/EnumChoice.values.txt | 23 ++
uast/uast-tests/java/Simple/EnumSwitch.java | 39 ++++
.../uast-tests/java/Simple/EnumSwitch.log.txt | 46 ++++
.../java/Simple/EnumSwitch.render.txt | 31 +++
.../java/Simple/EnumSwitch.values.txt | 46 ++++
.../Simple/EnumSwitchConditionalBreak.java | 39 ++++
.../EnumSwitchConditionalBreak.values.txt | 50 ++++
.../java/Simple/EnumSwitchWithoutBreaks.java | 37 +++
.../Simple/EnumSwitchWithoutBreaks.values.txt | 44 ++++
.../java/Simple/EnumValueMembers.java | 31 +++
.../java/Simple/EnumValueMembers.log.txt | 18 ++
.../java/Simple/EnumValueMembers.render.txt | 13 ++
.../java/Simple/EvaluatorExtension.java | 23 ++
.../java/Simple/EvaluatorExtension.values.txt | 16 ++
uast/uast-tests/java/Simple/External.java | 27 +++
.../java/Simple/External.values.txt | 21 ++
uast/uast-tests/java/Simple/Field.java | 18 ++
uast/uast-tests/java/Simple/FieldRef.java | 21 ++
.../java/Simple/FieldRef.values.txt | 16 ++
uast/uast-tests/java/Simple/FloatDouble.java | 26 +++
.../java/Simple/FloatDouble.values.txt | 36 +++
uast/uast-tests/java/Simple/For.java | 24 ++
uast/uast-tests/java/Simple/For.values.txt | 24 ++
uast/uast-tests/java/Simple/ForEach.java | 24 ++
.../uast-tests/java/Simple/ForEach.values.txt | 18 ++
.../java/Simple/ForEachMutableIterable.java | 38 +++
.../Simple/ForEachMutableIterable.values.txt | 60 +++++
.../java/Simple/IdentityEquals.java | 31 +++
.../java/Simple/IdentityEquals.values.txt | 41 ++++
.../java/Simple/ImmutableField.java | 28 +++
.../java/Simple/ImmutableField.values.txt | 19 ++
uast/uast-tests/java/Simple/IncDec.java | 25 ++
uast/uast-tests/java/Simple/IncDec.values.txt | 27 +++
uast/uast-tests/java/Simple/IntLong.java | 34 +++
.../uast-tests/java/Simple/IntLong.values.txt | 73 ++++++
uast/uast-tests/java/Simple/Labeled.java | 28 +++
.../uast-tests/java/Simple/Labeled.values.txt | 25 ++
uast/uast-tests/java/Simple/LabeledOuter.java | 30 +++
.../java/Simple/LabeledOuter.values.txt | 37 +++
uast/uast-tests/java/Simple/Lambda.java | 28 +++
uast/uast-tests/java/Simple/Lambda.values.txt | 22 ++
uast/uast-tests/java/Simple/LocalClass.java | 23 ++
.../uast-tests/java/Simple/LocalClass.log.txt | 13 ++
.../java/Simple/LocalClass.render.txt | 8 +
uast/uast-tests/java/Simple/Logicals.java | 28 +++
.../java/Simple/Logicals.values.txt | 55 +++++
.../java/Simple/MethodReference.java | 32 +++
.../java/Simple/MethodReference.values.txt | 24 ++
uast/uast-tests/java/Simple/Modification.java | 27 +++
.../java/Simple/Modification.values.txt | 35 +++
uast/uast-tests/java/Simple/MutableField.java | 28 +++
.../java/Simple/MutableField.values.txt | 18 ++
uast/uast-tests/java/Simple/NotANumber.java | 38 +++
.../java/Simple/NotANumber.values.txt | 94 ++++++++
.../Simple/ParamViaEvaluatorExtension.java | 20 ++
.../ParamViaEvaluatorExtension.values.txt | 10 +
.../java/Simple/QualifiedConstructorCall.java | 26 +++
.../Simple/QualifiedConstructorCall.log.txt | 14 ++
.../QualifiedConstructorCall.render.txt | 10 +
uast/uast-tests/java/Simple/ReturnMinusX.java | 21 ++
.../java/Simple/ReturnMinusX.values.txt | 10 +
uast/uast-tests/java/Simple/ReturnSum.java | 23 ++
.../java/Simple/ReturnSum.values.txt | 23 ++
uast/uast-tests/java/Simple/ReturnX.java | 21 ++
uast/uast-tests/java/Simple/ReturnX.log.txt | 9 +
.../uast-tests/java/Simple/ReturnX.render.txt | 6 +
.../uast-tests/java/Simple/ReturnX.values.txt | 9 +
uast/uast-tests/java/Simple/Shift.java | 38 +++
uast/uast-tests/java/Simple/Shift.values.txt | 68 ++++++
uast/uast-tests/java/Simple/Simple.java | 17 ++
uast/uast-tests/java/Simple/Simple.log.txt | 2 +
uast/uast-tests/java/Simple/Simple.render.txt | 2 +
uast/uast-tests/java/Simple/Strings.java | 25 ++
.../uast-tests/java/Simple/Strings.values.txt | 27 +++
uast/uast-tests/java/Simple/SuperTypes.java | 26 +++
.../uast-tests/java/Simple/SuperTypes.log.txt | 4 +
.../java/Simple/SuperTypes.render.txt | 8 +
uast/uast-tests/java/Simple/Ternary.java | 20 ++
.../uast-tests/java/Simple/Ternary.values.txt | 10 +
uast/uast-tests/java/Simple/TryCatch.java | 32 +++
.../java/Simple/TryCatch.values.txt | 42 ++++
.../java/Simple/TryWithResources.java | 23 ++
.../java/Simple/TryWithResources.log.txt | 17 ++
.../java/Simple/TryWithResources.render.txt | 8 +
.../uast-tests/java/Simple/TypeReference.java | 21 ++
uast/uast-tests/java/Simple/While.java | 24 ++
uast/uast-tests/java/Simple/While.values.txt | 22 ++
.../java/Simple/WhileWithContinue.java | 48 ++++
.../java/Simple/WhileWithContinue.values.txt | 60 +++++
.../java/Simple/WhileWithIncrement.java | 25 ++
.../java/Simple/WhileWithIncrement.values.txt | 22 ++
.../Simple/WhileWithMutableCondition.java | 24 ++
.../WhileWithMutableCondition.values.txt | 17 ++
.../java/Simple/WhileWithReturn.java | 28 +++
.../java/Simple/WhileWithReturn.values.txt | 27 +++
133 files changed, 3961 insertions(+)
create mode 100644 uast/uast-tests/java/DataClass/DataClass.java
create mode 100644 uast/uast-tests/java/DataClass/DataClass.log.txt
create mode 100644 uast/uast-tests/java/DataClass/DataClass.render.txt
create mode 100644 uast/uast-tests/java/Simple/AliveThenElse.java
create mode 100644 uast/uast-tests/java/Simple/AliveThenElse.values.txt
create mode 100644 uast/uast-tests/java/Simple/Anonymous.java
create mode 100644 uast/uast-tests/java/Simple/Anonymous.values.txt
create mode 100644 uast/uast-tests/java/Simple/Bitwise.java
create mode 100644 uast/uast-tests/java/Simple/Bitwise.values.txt
create mode 100644 uast/uast-tests/java/Simple/ByteShort.java
create mode 100644 uast/uast-tests/java/Simple/ByteShort.values.txt
create mode 100644 uast/uast-tests/java/Simple/CascadeIf.java
create mode 100644 uast/uast-tests/java/Simple/CascadeIf.values.txt
create mode 100644 uast/uast-tests/java/Simple/Characters.java
create mode 100644 uast/uast-tests/java/Simple/Characters.values.txt
create mode 100644 uast/uast-tests/java/Simple/ClassLiteral.java
create mode 100644 uast/uast-tests/java/Simple/ClassLiteral.values.txt
create mode 100644 uast/uast-tests/java/Simple/DeadElse.java
create mode 100644 uast/uast-tests/java/Simple/DeadElse.values.txt
create mode 100644 uast/uast-tests/java/Simple/DeadFor.java
create mode 100644 uast/uast-tests/java/Simple/DeadFor.values.txt
create mode 100644 uast/uast-tests/java/Simple/DeadIfComparison.java
create mode 100644 uast/uast-tests/java/Simple/DeadIfComparison.values.txt
create mode 100644 uast/uast-tests/java/Simple/DeadSwitchEntries.java
create mode 100644 uast/uast-tests/java/Simple/DeadSwitchEntries.values.txt
create mode 100644 uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.java
create mode 100644 uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.values.txt
create mode 100644 uast/uast-tests/java/Simple/DeadThen.java
create mode 100644 uast/uast-tests/java/Simple/DeadThen.values.txt
create mode 100644 uast/uast-tests/java/Simple/Dependents.java
create mode 100644 uast/uast-tests/java/Simple/Dependents.values.txt
create mode 100644 uast/uast-tests/java/Simple/DoWhile.java
create mode 100644 uast/uast-tests/java/Simple/DoWhile.values.txt
create mode 100644 uast/uast-tests/java/Simple/DoWhileInfinite.java
create mode 100644 uast/uast-tests/java/Simple/DoWhileInfinite.values.txt
create mode 100644 uast/uast-tests/java/Simple/DoWhileWithReturn.java
create mode 100644 uast/uast-tests/java/Simple/DoWhileWithReturn.values.txt
create mode 100644 uast/uast-tests/java/Simple/EnumChoice.java
create mode 100644 uast/uast-tests/java/Simple/EnumChoice.values.txt
create mode 100644 uast/uast-tests/java/Simple/EnumSwitch.java
create mode 100644 uast/uast-tests/java/Simple/EnumSwitch.log.txt
create mode 100644 uast/uast-tests/java/Simple/EnumSwitch.render.txt
create mode 100644 uast/uast-tests/java/Simple/EnumSwitch.values.txt
create mode 100644 uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.java
create mode 100644 uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.values.txt
create mode 100644 uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.java
create mode 100644 uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.values.txt
create mode 100644 uast/uast-tests/java/Simple/EnumValueMembers.java
create mode 100644 uast/uast-tests/java/Simple/EnumValueMembers.log.txt
create mode 100644 uast/uast-tests/java/Simple/EnumValueMembers.render.txt
create mode 100644 uast/uast-tests/java/Simple/EvaluatorExtension.java
create mode 100644 uast/uast-tests/java/Simple/EvaluatorExtension.values.txt
create mode 100644 uast/uast-tests/java/Simple/External.java
create mode 100644 uast/uast-tests/java/Simple/External.values.txt
create mode 100644 uast/uast-tests/java/Simple/Field.java
create mode 100644 uast/uast-tests/java/Simple/FieldRef.java
create mode 100644 uast/uast-tests/java/Simple/FieldRef.values.txt
create mode 100644 uast/uast-tests/java/Simple/FloatDouble.java
create mode 100644 uast/uast-tests/java/Simple/FloatDouble.values.txt
create mode 100644 uast/uast-tests/java/Simple/For.java
create mode 100644 uast/uast-tests/java/Simple/For.values.txt
create mode 100644 uast/uast-tests/java/Simple/ForEach.java
create mode 100644 uast/uast-tests/java/Simple/ForEach.values.txt
create mode 100644 uast/uast-tests/java/Simple/ForEachMutableIterable.java
create mode 100644 uast/uast-tests/java/Simple/ForEachMutableIterable.values.txt
create mode 100644 uast/uast-tests/java/Simple/IdentityEquals.java
create mode 100644 uast/uast-tests/java/Simple/IdentityEquals.values.txt
create mode 100644 uast/uast-tests/java/Simple/ImmutableField.java
create mode 100644 uast/uast-tests/java/Simple/ImmutableField.values.txt
create mode 100644 uast/uast-tests/java/Simple/IncDec.java
create mode 100644 uast/uast-tests/java/Simple/IncDec.values.txt
create mode 100644 uast/uast-tests/java/Simple/IntLong.java
create mode 100644 uast/uast-tests/java/Simple/IntLong.values.txt
create mode 100644 uast/uast-tests/java/Simple/Labeled.java
create mode 100644 uast/uast-tests/java/Simple/Labeled.values.txt
create mode 100644 uast/uast-tests/java/Simple/LabeledOuter.java
create mode 100644 uast/uast-tests/java/Simple/LabeledOuter.values.txt
create mode 100644 uast/uast-tests/java/Simple/Lambda.java
create mode 100644 uast/uast-tests/java/Simple/Lambda.values.txt
create mode 100644 uast/uast-tests/java/Simple/LocalClass.java
create mode 100644 uast/uast-tests/java/Simple/LocalClass.log.txt
create mode 100644 uast/uast-tests/java/Simple/LocalClass.render.txt
create mode 100644 uast/uast-tests/java/Simple/Logicals.java
create mode 100644 uast/uast-tests/java/Simple/Logicals.values.txt
create mode 100644 uast/uast-tests/java/Simple/MethodReference.java
create mode 100644 uast/uast-tests/java/Simple/MethodReference.values.txt
create mode 100644 uast/uast-tests/java/Simple/Modification.java
create mode 100644 uast/uast-tests/java/Simple/Modification.values.txt
create mode 100644 uast/uast-tests/java/Simple/MutableField.java
create mode 100644 uast/uast-tests/java/Simple/MutableField.values.txt
create mode 100644 uast/uast-tests/java/Simple/NotANumber.java
create mode 100644 uast/uast-tests/java/Simple/NotANumber.values.txt
create mode 100644 uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.java
create mode 100644 uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.values.txt
create mode 100644 uast/uast-tests/java/Simple/QualifiedConstructorCall.java
create mode 100644 uast/uast-tests/java/Simple/QualifiedConstructorCall.log.txt
create mode 100644 uast/uast-tests/java/Simple/QualifiedConstructorCall.render.txt
create mode 100644 uast/uast-tests/java/Simple/ReturnMinusX.java
create mode 100644 uast/uast-tests/java/Simple/ReturnMinusX.values.txt
create mode 100644 uast/uast-tests/java/Simple/ReturnSum.java
create mode 100644 uast/uast-tests/java/Simple/ReturnSum.values.txt
create mode 100644 uast/uast-tests/java/Simple/ReturnX.java
create mode 100644 uast/uast-tests/java/Simple/ReturnX.log.txt
create mode 100644 uast/uast-tests/java/Simple/ReturnX.render.txt
create mode 100644 uast/uast-tests/java/Simple/ReturnX.values.txt
create mode 100644 uast/uast-tests/java/Simple/Shift.java
create mode 100644 uast/uast-tests/java/Simple/Shift.values.txt
create mode 100644 uast/uast-tests/java/Simple/Simple.java
create mode 100644 uast/uast-tests/java/Simple/Simple.log.txt
create mode 100644 uast/uast-tests/java/Simple/Simple.render.txt
create mode 100644 uast/uast-tests/java/Simple/Strings.java
create mode 100644 uast/uast-tests/java/Simple/Strings.values.txt
create mode 100644 uast/uast-tests/java/Simple/SuperTypes.java
create mode 100644 uast/uast-tests/java/Simple/SuperTypes.log.txt
create mode 100644 uast/uast-tests/java/Simple/SuperTypes.render.txt
create mode 100644 uast/uast-tests/java/Simple/Ternary.java
create mode 100644 uast/uast-tests/java/Simple/Ternary.values.txt
create mode 100644 uast/uast-tests/java/Simple/TryCatch.java
create mode 100644 uast/uast-tests/java/Simple/TryCatch.values.txt
create mode 100644 uast/uast-tests/java/Simple/TryWithResources.java
create mode 100644 uast/uast-tests/java/Simple/TryWithResources.log.txt
create mode 100644 uast/uast-tests/java/Simple/TryWithResources.render.txt
create mode 100644 uast/uast-tests/java/Simple/TypeReference.java
create mode 100644 uast/uast-tests/java/Simple/While.java
create mode 100644 uast/uast-tests/java/Simple/While.values.txt
create mode 100644 uast/uast-tests/java/Simple/WhileWithContinue.java
create mode 100644 uast/uast-tests/java/Simple/WhileWithContinue.values.txt
create mode 100644 uast/uast-tests/java/Simple/WhileWithIncrement.java
create mode 100644 uast/uast-tests/java/Simple/WhileWithIncrement.values.txt
create mode 100644 uast/uast-tests/java/Simple/WhileWithMutableCondition.java
create mode 100644 uast/uast-tests/java/Simple/WhileWithMutableCondition.values.txt
create mode 100644 uast/uast-tests/java/Simple/WhileWithReturn.java
create mode 100644 uast/uast-tests/java/Simple/WhileWithReturn.values.txt
diff --git a/uast/uast-tests/java/DataClass/DataClass.java b/uast/uast-tests/java/DataClass/DataClass.java
new file mode 100644
index 000000000000..e476d0c3e83a
--- /dev/null
+++ b/uast/uast-tests/java/DataClass/DataClass.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class DataClass {
+ public final String STRING_CONSTANT = "ABC";
+
+ private final String firstName;
+ private final String lastName;
+ private final String age;
+
+ public DataClass(String firstName, String lastName, String age) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+
+ @Override
+ public String toString() {
+ return "DataClass{" +
+ "STRING_CONSTANT='" + STRING_CONSTANT + '\'' +
+ ", firstName='" + firstName + '\'' +
+ ", lastName='" + lastName + '\'' +
+ ", age='" + age + '\'' +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ DataClass dataClass = (DataClass) o;
+
+ if (STRING_CONSTANT != null ? !STRING_CONSTANT.equals(dataClass.STRING_CONSTANT) : dataClass.STRING_CONSTANT != null)
+ return false;
+ if (firstName != null ? !firstName.equals(dataClass.firstName) : dataClass.firstName != null) return false;
+ if (lastName != null ? !lastName.equals(dataClass.lastName) : dataClass.lastName != null) return false;
+ return age != null ? age.equals(dataClass.age) : dataClass.age == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = STRING_CONSTANT != null ? STRING_CONSTANT.hashCode() : 0;
+ result = 31 * result + (firstName != null ? firstName.hashCode() : 0);
+ result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
+ result = 31 * result + (age != null ? age.hashCode() : 0);
+ return result;
+ }
+}
diff --git a/uast/uast-tests/java/DataClass/DataClass.log.txt b/uast/uast-tests/java/DataClass/DataClass.log.txt
new file mode 100644
index 000000000000..e75078c3cbb9
--- /dev/null
+++ b/uast/uast-tests/java/DataClass/DataClass.log.txt
@@ -0,0 +1,221 @@
+UFile (package = )
+ UClass (name = DataClass)
+ UField (name = STRING_CONSTANT)
+ ULiteralExpression (value = "ABC")
+ UField (name = firstName)
+ UField (name = lastName)
+ UField (name = age)
+ UMethod (name = DataClass)
+ UParameter (name = firstName)
+ UParameter (name = lastName)
+ UParameter (name = age)
+ UBlockExpression
+ UBinaryExpression (operator = =)
+ UQualifiedReferenceExpression
+ UThisExpression (label = null)
+ USimpleNameReferenceExpression (identifier = firstName)
+ USimpleNameReferenceExpression (identifier = firstName)
+ UBinaryExpression (operator = =)
+ UQualifiedReferenceExpression
+ UThisExpression (label = null)
+ USimpleNameReferenceExpression (identifier = lastName)
+ USimpleNameReferenceExpression (identifier = lastName)
+ UBinaryExpression (operator = =)
+ UQualifiedReferenceExpression
+ UThisExpression (label = null)
+ USimpleNameReferenceExpression (identifier = age)
+ USimpleNameReferenceExpression (identifier = age)
+ UMethod (name = toString)
+ UAnnotation (fqName = java.lang.Override)
+ UBlockExpression
+ UReturnExpression
+ UPolyadicExpression (operator = +)
+ ULiteralExpression (value = "DataClass{")
+ ULiteralExpression (value = "STRING_CONSTANT='")
+ USimpleNameReferenceExpression (identifier = STRING_CONSTANT)
+ ULiteralExpression (value = ''')
+ ULiteralExpression (value = ", firstName='")
+ USimpleNameReferenceExpression (identifier = firstName)
+ ULiteralExpression (value = ''')
+ ULiteralExpression (value = ", lastName='")
+ USimpleNameReferenceExpression (identifier = lastName)
+ ULiteralExpression (value = ''')
+ ULiteralExpression (value = ", age='")
+ USimpleNameReferenceExpression (identifier = age)
+ ULiteralExpression (value = ''')
+ ULiteralExpression (value = '}')
+ UMethod (name = equals)
+ UAnnotation (fqName = java.lang.Override)
+ UParameter (name = o)
+ UBlockExpression
+ UIfExpression
+ UBinaryExpression (operator = ===)
+ UThisExpression (label = null)
+ USimpleNameReferenceExpression (identifier = o)
+ UReturnExpression
+ ULiteralExpression (value = true)
+ UastEmptyExpression
+ UIfExpression
+ UBinaryExpression (operator = ||)
+ UBinaryExpression (operator = ===)
+ USimpleNameReferenceExpression (identifier = o)
+ ULiteralExpression (value = null)
+ UBinaryExpression (operator = !==)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
+ UIdentifier (Identifier (getClass))
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = o)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
+ UIdentifier (Identifier (getClass))
+ UReturnExpression
+ ULiteralExpression (value = false)
+ UastEmptyExpression
+ UDeclarationsExpression
+ ULocalVariable (name = dataClass)
+ UBinaryExpressionWithType
+ USimpleNameReferenceExpression (identifier = o)
+ UTypeReferenceExpression (name = DataClass)
+ UIfExpression
+ UIfExpression
+ UBinaryExpression (operator = !==)
+ USimpleNameReferenceExpression (identifier = STRING_CONSTANT)
+ ULiteralExpression (value = null)
+ UPrefixExpression (operator = !)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = STRING_CONSTANT)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
+ UIdentifier (Identifier (equals))
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = dataClass)
+ USimpleNameReferenceExpression (identifier = STRING_CONSTANT)
+ UBinaryExpression (operator = !==)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = dataClass)
+ USimpleNameReferenceExpression (identifier = STRING_CONSTANT)
+ ULiteralExpression (value = null)
+ UReturnExpression
+ ULiteralExpression (value = false)
+ UastEmptyExpression
+ UIfExpression
+ UIfExpression
+ UBinaryExpression (operator = !==)
+ USimpleNameReferenceExpression (identifier = firstName)
+ ULiteralExpression (value = null)
+ UPrefixExpression (operator = !)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = firstName)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
+ UIdentifier (Identifier (equals))
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = dataClass)
+ USimpleNameReferenceExpression (identifier = firstName)
+ UBinaryExpression (operator = !==)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = dataClass)
+ USimpleNameReferenceExpression (identifier = firstName)
+ ULiteralExpression (value = null)
+ UReturnExpression
+ ULiteralExpression (value = false)
+ UastEmptyExpression
+ UIfExpression
+ UIfExpression
+ UBinaryExpression (operator = !==)
+ USimpleNameReferenceExpression (identifier = lastName)
+ ULiteralExpression (value = null)
+ UPrefixExpression (operator = !)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = lastName)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
+ UIdentifier (Identifier (equals))
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = dataClass)
+ USimpleNameReferenceExpression (identifier = lastName)
+ UBinaryExpression (operator = !==)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = dataClass)
+ USimpleNameReferenceExpression (identifier = lastName)
+ ULiteralExpression (value = null)
+ UReturnExpression
+ ULiteralExpression (value = false)
+ UastEmptyExpression
+ UReturnExpression
+ UIfExpression
+ UBinaryExpression (operator = !==)
+ USimpleNameReferenceExpression (identifier = age)
+ ULiteralExpression (value = null)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = age)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
+ UIdentifier (Identifier (equals))
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = dataClass)
+ USimpleNameReferenceExpression (identifier = age)
+ UBinaryExpression (operator = ===)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = dataClass)
+ USimpleNameReferenceExpression (identifier = age)
+ ULiteralExpression (value = null)
+ UMethod (name = hashCode)
+ UAnnotation (fqName = java.lang.Override)
+ UBlockExpression
+ UDeclarationsExpression
+ ULocalVariable (name = result)
+ UIfExpression
+ UBinaryExpression (operator = !==)
+ USimpleNameReferenceExpression (identifier = STRING_CONSTANT)
+ ULiteralExpression (value = null)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = STRING_CONSTANT)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
+ UIdentifier (Identifier (hashCode))
+ ULiteralExpression (value = 0)
+ UBinaryExpression (operator = =)
+ USimpleNameReferenceExpression (identifier = result)
+ UBinaryExpression (operator = +)
+ UBinaryExpression (operator = *)
+ ULiteralExpression (value = 31)
+ USimpleNameReferenceExpression (identifier = result)
+ UParenthesizedExpression
+ UIfExpression
+ UBinaryExpression (operator = !==)
+ USimpleNameReferenceExpression (identifier = firstName)
+ ULiteralExpression (value = null)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = firstName)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
+ UIdentifier (Identifier (hashCode))
+ ULiteralExpression (value = 0)
+ UBinaryExpression (operator = =)
+ USimpleNameReferenceExpression (identifier = result)
+ UBinaryExpression (operator = +)
+ UBinaryExpression (operator = *)
+ ULiteralExpression (value = 31)
+ USimpleNameReferenceExpression (identifier = result)
+ UParenthesizedExpression
+ UIfExpression
+ UBinaryExpression (operator = !==)
+ USimpleNameReferenceExpression (identifier = lastName)
+ ULiteralExpression (value = null)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = lastName)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
+ UIdentifier (Identifier (hashCode))
+ ULiteralExpression (value = 0)
+ UBinaryExpression (operator = =)
+ USimpleNameReferenceExpression (identifier = result)
+ UBinaryExpression (operator = +)
+ UBinaryExpression (operator = *)
+ ULiteralExpression (value = 31)
+ USimpleNameReferenceExpression (identifier = result)
+ UParenthesizedExpression
+ UIfExpression
+ UBinaryExpression (operator = !==)
+ USimpleNameReferenceExpression (identifier = age)
+ ULiteralExpression (value = null)
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = age)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
+ UIdentifier (Identifier (hashCode))
+ ULiteralExpression (value = 0)
+ UReturnExpression
+ USimpleNameReferenceExpression (identifier = result)
diff --git a/uast/uast-tests/java/DataClass/DataClass.render.txt b/uast/uast-tests/java/DataClass/DataClass.render.txt
new file mode 100644
index 000000000000..593ce02f1c31
--- /dev/null
+++ b/uast/uast-tests/java/DataClass/DataClass.render.txt
@@ -0,0 +1,33 @@
+public class DataClass {
+ public final var STRING_CONSTANT: java.lang.String = "ABC"
+ private final var firstName: java.lang.String
+ private final var lastName: java.lang.String
+ private final var age: java.lang.String
+ public fun DataClass(firstName: java.lang.String, lastName: java.lang.String, age: java.lang.String) {
+ this.firstName = firstName
+ this.lastName = lastName
+ this.age = age
+ }
+ @java.lang.Override
+ public fun toString() : java.lang.String {
+ return "DataClass{" + "STRING_CONSTANT='" + STRING_CONSTANT + ''' + ", firstName='" + firstName + ''' + ", lastName='" + lastName + ''' + ", age='" + age + ''' + '}'
+ }
+ @java.lang.Override
+ public fun equals(o: java.lang.Object) : boolean {
+ if (this === o) return true
+ if (o === null || getClass() !== o.getClass()) return false
+ var dataClass: DataClass = o as DataClass
+ if ((STRING_CONSTANT !== null) ? (!STRING_CONSTANT.equals(dataClass.STRING_CONSTANT)) : (dataClass.STRING_CONSTANT !== null)) return false
+ if ((firstName !== null) ? (!firstName.equals(dataClass.firstName)) : (dataClass.firstName !== null)) return false
+ if ((lastName !== null) ? (!lastName.equals(dataClass.lastName)) : (dataClass.lastName !== null)) return false
+ return (age !== null) ? (age.equals(dataClass.age)) : (dataClass.age === null)
+ }
+ @java.lang.Override
+ public fun hashCode() : int {
+ var result: int = (STRING_CONSTANT !== null) ? (STRING_CONSTANT.hashCode()) : (0)
+ result = 31 * result + ((firstName !== null) ? (firstName.hashCode()) : (0))
+ result = 31 * result + ((lastName !== null) ? (lastName.hashCode()) : (0))
+ result = 31 * result + ((age !== null) ? (age.hashCode()) : (0))
+ return result
+ }
+}
diff --git a/uast/uast-tests/java/Simple/AliveThenElse.java b/uast/uast-tests/java/Simple/AliveThenElse.java
new file mode 100644
index 000000000000..ac9157a42416
--- /dev/null
+++ b/uast/uast-tests/java/Simple/AliveThenElse.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class AliveThenElse {
+ public static int foo(boolean f) {
+ int x = 0;
+ int y = 1;
+ int z;
+ if (f) {
+ z = y;
+ }
+ else {
+ z = x;
+ }
+ return z;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/AliveThenElse.values.txt b/uast/uast-tests/java/Simple/AliveThenElse.values.txt
new file mode 100644
index 000000000000..9d4fa95960ab
--- /dev/null
+++ b/uast/uast-tests/java/Simple/AliveThenElse.values.txt
@@ -0,0 +1,25 @@
+UFile (package = ) [public class AliveThenElse {...]
+ UClass (name = AliveThenElse) [public class AliveThenElse {...}]
+ UMethod (name = foo) [public static fun foo(f: boolean) : int {...}]
+ UParameter (name = f) [var f: boolean]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: int = 0] = Undetermined
+ ULocalVariable (name = x) [var x: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var y: int = 1] = Undetermined
+ ULocalVariable (name = y) [var y: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var z: int] = Undetermined
+ ULocalVariable (name = z) [var z: int]
+ UIfExpression [if (f) {...}] = Phi((var y = 1), (var x = 0))
+ USimpleNameReferenceExpression (identifier = f) [f] = Undetermined
+ UBlockExpression [{...}] = (var y = 1)
+ UBinaryExpression (operator = =) [z = y] = (var y = 1)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1)
+ UBlockExpression [{...}] = (var x = 0)
+ UBinaryExpression (operator = =) [z = x] = (var x = 0)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0)
+ UReturnExpression [return z] = Nothing
+ USimpleNameReferenceExpression (identifier = z) [z] = Phi((var z = (var y = 1)), (var z = (var x = 0)))
diff --git a/uast/uast-tests/java/Simple/Anonymous.java b/uast/uast-tests/java/Simple/Anonymous.java
new file mode 100644
index 000000000000..0992c52cf3c9
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Anonymous.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Anonymous {
+ public static int foo() {
+ int variable = 42;
+
+ Runnable runnable = new Runnable() {
+
+ public void run() {
+ int variable = 24;
+ variable++;
+ }
+ };
+ runnable.run();
+
+ return variable;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Anonymous.values.txt b/uast/uast-tests/java/Simple/Anonymous.values.txt
new file mode 100644
index 000000000000..2b3cb21457a8
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Anonymous.values.txt
@@ -0,0 +1,24 @@
+UFile (package = ) [public class Anonymous {...]
+ UClass (name = Anonymous) [public class Anonymous {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var variable: int = 42] = Undetermined
+ ULocalVariable (name = variable) [var variable: int = 42]
+ ULiteralExpression (value = 42) [42] = 42
+ UDeclarationsExpression [var runnable: java.lang.Runnable = anonymous Runnable() {... }] = Undetermined
+ ULocalVariable (name = runnable) [var runnable: java.lang.Runnable = anonymous Runnable() {... }]
+ UObjectLiteralExpression [anonymous Runnable() {... }] = Undetermined
+ UClass (name = null) [final class null {...}]
+ UMethod (name = run) [public fun run() : void {...}]
+ UBlockExpression [{...}] = (var variable = 24)
+ UDeclarationsExpression [var variable: int = 24] = Undetermined
+ ULocalVariable (name = variable) [var variable: int = 24]
+ ULiteralExpression (value = 24) [24] = 24
+ UPostfixExpression (operator = ++) [variable++] = (var variable = 24)
+ USimpleNameReferenceExpression (identifier = variable) [variable] = (var variable = 24)
+ UQualifiedReferenceExpression [runnable.run()] = external run()()
+ USimpleNameReferenceExpression (identifier = runnable) [runnable] = (var runnable = Undetermined)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [run()] = external run()()
+ UIdentifier (Identifier (run)) [UIdentifier (Identifier (run))]
+ UReturnExpression [return variable] = Nothing
+ USimpleNameReferenceExpression (identifier = variable) [variable] = (var variable = 42)
diff --git a/uast/uast-tests/java/Simple/Bitwise.java b/uast/uast-tests/java/Simple/Bitwise.java
new file mode 100644
index 000000000000..76e6f18b5de9
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Bitwise.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Bitwise {
+ public static int foo() {
+ int first = 0x1234567;
+ int second = 0x89abcde;
+
+ return (first & second) + (first | second) + (first ^ second);
+ }
+
+ public static long bar() {
+ long first = 0x123456789abcdefL;
+ long second = 0xfedcba987654321L;
+
+ return (first & second) + (first | second) + (first ^ second);
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Bitwise.values.txt b/uast/uast-tests/java/Simple/Bitwise.values.txt
new file mode 100644
index 000000000000..d218f59de384
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Bitwise.values.txt
@@ -0,0 +1,46 @@
+UFile (package = ) [public class Bitwise {...]
+ UClass (name = Bitwise) [public class Bitwise {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var first: int = 19088743] = Undetermined
+ ULocalVariable (name = first) [var first: int = 19088743]
+ ULiteralExpression (value = 19088743) [19088743] = 19088743
+ UDeclarationsExpression [var second: int = 144358622] = Undetermined
+ ULocalVariable (name = second) [var second: int = 144358622]
+ ULiteralExpression (value = 144358622) [144358622] = 144358622
+ UReturnExpression [return (first & second) + (first | second) + (first ^ second)] = Nothing
+ UPolyadicExpression (operator = +) [(first & second) + (first | second) + (first ^ second)] = 326630398 (depending on: (var first = 19088743), (var second = 144358622))
+ UParenthesizedExpression [(first & second)] = 132166 (depending on: (var first = 19088743), (var second = 144358622))
+ UBinaryExpression (operator = &) [first & second] = 132166 (depending on: (var first = 19088743), (var second = 144358622))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 19088743)
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 144358622)
+ UParenthesizedExpression [(first | second)] = 163315199 (depending on: (var first = 19088743), (var second = 144358622))
+ UBinaryExpression (operator = |) [first | second] = 163315199 (depending on: (var first = 19088743), (var second = 144358622))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 19088743)
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 144358622)
+ UParenthesizedExpression [(first ^ second)] = 163183033 (depending on: (var first = 19088743), (var second = 144358622))
+ UBinaryExpression (operator = ^) [first ^ second] = 163183033 (depending on: (var first = 19088743), (var second = 144358622))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 19088743)
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 144358622)
+ UMethod (name = bar) [public static fun bar() : long {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var first: long = 81985529216486895] = Undetermined
+ ULocalVariable (name = first) [var first: long = 81985529216486895]
+ ULiteralExpression (value = 81985529216486895) [81985529216486895] = (long)81985529216486895
+ UDeclarationsExpression [var second: long = 1147797409030816545] = Undetermined
+ ULocalVariable (name = second) [var second: long = 1147797409030816545]
+ ULiteralExpression (value = 1147797409030816545) [1147797409030816545] = (long)1147797409030816545
+ UReturnExpression [return (first & second) + (first | second) + (first ^ second)] = Nothing
+ UPolyadicExpression (operator = +) [(first & second) + (first | second) + (first ^ second)] = (long)2296730115643514846 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545))
+ UParenthesizedExpression [(first & second)] = (long)81417880425546017 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545))
+ UBinaryExpression (operator = &) [first & second] = (long)81417880425546017 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = (long)81985529216486895)
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = (long)1147797409030816545)
+ UParenthesizedExpression [(first | second)] = (long)1148365057821757423 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545))
+ UBinaryExpression (operator = |) [first | second] = (long)1148365057821757423 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = (long)81985529216486895)
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = (long)1147797409030816545)
+ UParenthesizedExpression [(first ^ second)] = (long)1066947177396211406 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545))
+ UBinaryExpression (operator = ^) [first ^ second] = (long)1066947177396211406 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = (long)81985529216486895)
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = (long)1147797409030816545)
diff --git a/uast/uast-tests/java/Simple/ByteShort.java b/uast/uast-tests/java/Simple/ByteShort.java
new file mode 100644
index 000000000000..b601dd58d081
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ByteShort.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class ByteShort {
+ public static int foo() {
+ byte b1 = 100;
+ short s2 = 2;
+ byte b11 = b1;
+ short s21 = s2;
+ int i3 = b11 + b1;
+ int i4 = s21 + s2;
+ int i5 = b11 + s21;
+ byte b3 = (byte) i3;
+ short s4 = (short) i4;
+ return i5 + b3 + s4;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/ByteShort.values.txt b/uast/uast-tests/java/Simple/ByteShort.values.txt
new file mode 100644
index 000000000000..d8e3cad80b6a
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ByteShort.values.txt
@@ -0,0 +1,46 @@
+UFile (package = ) [public class ByteShort {...]
+ UClass (name = ByteShort) [public class ByteShort {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var b1: byte = 100] = Undetermined
+ ULocalVariable (name = b1) [var b1: byte = 100]
+ ULiteralExpression (value = 100) [100] = 100
+ UDeclarationsExpression [var s2: short = 2] = Undetermined
+ ULocalVariable (name = s2) [var s2: short = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ UDeclarationsExpression [var b11: byte = b1] = Undetermined
+ ULocalVariable (name = b11) [var b11: byte = b1]
+ USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = (byte)100)
+ UDeclarationsExpression [var s21: short = s2] = Undetermined
+ ULocalVariable (name = s21) [var s21: short = s2]
+ USimpleNameReferenceExpression (identifier = s2) [s2] = (var s2 = (short)2)
+ UDeclarationsExpression [var i3: int = b11 + b1] = Undetermined
+ ULocalVariable (name = i3) [var i3: int = b11 + b1]
+ UBinaryExpression (operator = +) [b11 + b1] = 200 (depending on: (var b11 = (var b1 = (byte)100)), (var b1 = (byte)100))
+ USimpleNameReferenceExpression (identifier = b11) [b11] = (var b11 = (var b1 = (byte)100))
+ USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = (byte)100)
+ UDeclarationsExpression [var i4: int = s21 + s2] = Undetermined
+ ULocalVariable (name = i4) [var i4: int = s21 + s2]
+ UBinaryExpression (operator = +) [s21 + s2] = 4 (depending on: (var s21 = (var s2 = (short)2)), (var s2 = (short)2))
+ USimpleNameReferenceExpression (identifier = s21) [s21] = (var s21 = (var s2 = (short)2))
+ USimpleNameReferenceExpression (identifier = s2) [s2] = (var s2 = (short)2)
+ UDeclarationsExpression [var i5: int = b11 + s21] = Undetermined
+ ULocalVariable (name = i5) [var i5: int = b11 + s21]
+ UBinaryExpression (operator = +) [b11 + s21] = 102 (depending on: (var b11 = (var b1 = (byte)100)), (var s21 = (var s2 = (short)2)))
+ USimpleNameReferenceExpression (identifier = b11) [b11] = (var b11 = (var b1 = (byte)100))
+ USimpleNameReferenceExpression (identifier = s21) [s21] = (var s21 = (var s2 = (short)2))
+ UDeclarationsExpression [var b3: byte = i3 as byte] = Undetermined
+ ULocalVariable (name = b3) [var b3: byte = i3 as byte]
+ UBinaryExpressionWithType [i3 as byte] = (byte)-56
+ USimpleNameReferenceExpression (identifier = i3) [i3] = (var i3 = 200 (depending on: (var b11 = (var b1 = (byte)100)), (var b1 = (byte)100)))
+ UTypeReferenceExpression (name = byte) [byte] = Undetermined
+ UDeclarationsExpression [var s4: short = i4 as short] = Undetermined
+ ULocalVariable (name = s4) [var s4: short = i4 as short]
+ UBinaryExpressionWithType [i4 as short] = (short)4
+ USimpleNameReferenceExpression (identifier = i4) [i4] = (var i4 = 4 (depending on: (var s21 = (var s2 = (short)2)), (var s2 = (short)2)))
+ UTypeReferenceExpression (name = short) [short] = Undetermined
+ UReturnExpression [return i5 + b3 + s4] = Nothing
+ UPolyadicExpression (operator = +) [i5 + b3 + s4] = 50 (depending on: (var i5 = 102 (depending on: (var b11 = (var b1 = (byte)100)), (var s21 = (var s2 = (short)2)))), (var b3 = (byte)-56), (var s4 = (short)4))
+ USimpleNameReferenceExpression (identifier = i5) [i5] = (var i5 = 102 (depending on: (var b11 = (var b1 = (byte)100)), (var s21 = (var s2 = (short)2))))
+ USimpleNameReferenceExpression (identifier = b3) [b3] = (var b3 = (byte)-56)
+ USimpleNameReferenceExpression (identifier = s4) [s4] = (var s4 = (short)4)
diff --git a/uast/uast-tests/java/Simple/CascadeIf.java b/uast/uast-tests/java/Simple/CascadeIf.java
new file mode 100644
index 000000000000..e42d0b0a92c6
--- /dev/null
+++ b/uast/uast-tests/java/Simple/CascadeIf.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class CascadeIf {
+ public static int foo(boolean f, boolean g, boolean h) {
+ int x = 0;
+ int y = 1;
+ int v = 2;
+ int w = 3;
+ int z;
+ if (f) {
+ z = y;
+ }
+ else if (g) {
+ z = x;
+ }
+ else if (h) {
+ z = v;
+ }
+ else {
+ z = w;
+ }
+ return z;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/CascadeIf.values.txt b/uast/uast-tests/java/Simple/CascadeIf.values.txt
new file mode 100644
index 000000000000..baad4b1f1f73
--- /dev/null
+++ b/uast/uast-tests/java/Simple/CascadeIf.values.txt
@@ -0,0 +1,45 @@
+UFile (package = ) [public class CascadeIf {...]
+ UClass (name = CascadeIf) [public class CascadeIf {...}]
+ UMethod (name = foo) [public static fun foo(f: boolean, g: boolean, h: boolean) : int {...}]
+ UParameter (name = f) [var f: boolean]
+ UParameter (name = g) [var g: boolean]
+ UParameter (name = h) [var h: boolean]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: int = 0] = Undetermined
+ ULocalVariable (name = x) [var x: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var y: int = 1] = Undetermined
+ ULocalVariable (name = y) [var y: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var v: int = 2] = Undetermined
+ ULocalVariable (name = v) [var v: int = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ UDeclarationsExpression [var w: int = 3] = Undetermined
+ ULocalVariable (name = w) [var w: int = 3]
+ ULiteralExpression (value = 3) [3] = 3
+ UDeclarationsExpression [var z: int] = Undetermined
+ ULocalVariable (name = z) [var z: int]
+ UIfExpression [if (f) {...}] = Phi((var y = 1), (var x = 0), (var v = 2), (var w = 3))
+ USimpleNameReferenceExpression (identifier = f) [f] = Undetermined
+ UBlockExpression [{...}] = (var y = 1)
+ UBinaryExpression (operator = =) [z = y] = (var y = 1)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1)
+ UIfExpression [if (g) {...}] = Phi((var x = 0), (var v = 2), (var w = 3))
+ USimpleNameReferenceExpression (identifier = g) [g] = Undetermined
+ UBlockExpression [{...}] = (var x = 0)
+ UBinaryExpression (operator = =) [z = x] = (var x = 0)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0)
+ UIfExpression [if (h) {...}] = Phi((var v = 2), (var w = 3))
+ USimpleNameReferenceExpression (identifier = h) [h] = Undetermined
+ UBlockExpression [{...}] = (var v = 2)
+ UBinaryExpression (operator = =) [z = v] = (var v = 2)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = v) [v] = (var v = 2)
+ UBlockExpression [{...}] = (var w = 3)
+ UBinaryExpression (operator = =) [z = w] = (var w = 3)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = w) [w] = (var w = 3)
+ UReturnExpression [return z] = Nothing
+ USimpleNameReferenceExpression (identifier = z) [z] = Phi((var z = (var y = 1)), (var z = (var x = 0)), (var z = (var v = 2)), (var z = (var w = 3)))
diff --git a/uast/uast-tests/java/Simple/Characters.java b/uast/uast-tests/java/Simple/Characters.java
new file mode 100644
index 000000000000..6c509284f86a
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Characters.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Characters {
+ public static char foo() {
+ char a = 'a';
+ char c = (char) (a + 2);
+ char f = (char) (c + 3);
+ char d = (char) (f - 2);
+ int diff = f - a;
+ int aa = a + a;
+ char cdiff = (char) diff;
+ return d;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Characters.values.txt b/uast/uast-tests/java/Simple/Characters.values.txt
new file mode 100644
index 000000000000..2c138eccc6cf
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Characters.values.txt
@@ -0,0 +1,48 @@
+UFile (package = ) [public class Characters {...]
+ UClass (name = Characters) [public class Characters {...}]
+ UMethod (name = foo) [public static fun foo() : char {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var a: char = 'a'] = Undetermined
+ ULocalVariable (name = a) [var a: char = 'a']
+ ULiteralExpression (value = 'a') ['a'] = 'a'
+ UDeclarationsExpression [var c: char = (a + 2) as char] = Undetermined
+ ULocalVariable (name = c) [var c: char = (a + 2) as char]
+ UBinaryExpressionWithType [(a + 2) as char] = 'c' (depending on: (var a = 'a'))
+ UParenthesizedExpression [(a + 2)] = 'c' (depending on: (var a = 'a'))
+ UBinaryExpression (operator = +) [a + 2] = 'c' (depending on: (var a = 'a'))
+ USimpleNameReferenceExpression (identifier = a) [a] = (var a = 'a')
+ ULiteralExpression (value = 2) [2] = 2
+ UTypeReferenceExpression (name = char) [char] = Undetermined
+ UDeclarationsExpression [var f: char = (c + 3) as char] = Undetermined
+ ULocalVariable (name = f) [var f: char = (c + 3) as char]
+ UBinaryExpressionWithType [(c + 3) as char] = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))
+ UParenthesizedExpression [(c + 3)] = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))
+ UBinaryExpression (operator = +) [c + 3] = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))
+ USimpleNameReferenceExpression (identifier = c) [c] = (var c = 'c' (depending on: (var a = 'a')))
+ ULiteralExpression (value = 3) [3] = 3
+ UTypeReferenceExpression (name = char) [char] = Undetermined
+ UDeclarationsExpression [var d: char = (f - 2) as char] = Undetermined
+ ULocalVariable (name = d) [var d: char = (f - 2) as char]
+ UBinaryExpressionWithType [(f - 2) as char] = 'd' (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))))
+ UParenthesizedExpression [(f - 2)] = 'd' (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))))
+ UBinaryExpression (operator = -) [f - 2] = 'd' (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))))
+ USimpleNameReferenceExpression (identifier = f) [f] = (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))))
+ ULiteralExpression (value = 2) [2] = 2
+ UTypeReferenceExpression (name = char) [char] = Undetermined
+ UDeclarationsExpression [var diff: int = f - a] = Undetermined
+ ULocalVariable (name = diff) [var diff: int = f - a]
+ UBinaryExpression (operator = -) [f - a] = 5 (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))), (var a = 'a'))
+ USimpleNameReferenceExpression (identifier = f) [f] = (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))))
+ USimpleNameReferenceExpression (identifier = a) [a] = (var a = 'a')
+ UDeclarationsExpression [var aa: int = a + a] = Undetermined
+ ULocalVariable (name = aa) [var aa: int = a + a]
+ UBinaryExpression (operator = +) [a + a] = 'Â' (depending on: (var a = 'a'))
+ USimpleNameReferenceExpression (identifier = a) [a] = (var a = 'a')
+ USimpleNameReferenceExpression (identifier = a) [a] = (var a = 'a')
+ UDeclarationsExpression [var cdiff: char = diff as char] = Undetermined
+ ULocalVariable (name = cdiff) [var cdiff: char = diff as char]
+ UBinaryExpressionWithType [diff as char] = ''
+ USimpleNameReferenceExpression (identifier = diff) [diff] = (var diff = 5 (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))), (var a = 'a')))
+ UTypeReferenceExpression (name = char) [char] = Undetermined
+ UReturnExpression [return d] = Nothing
+ USimpleNameReferenceExpression (identifier = d) [d] = (var d = 'd' (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))))))
diff --git a/uast/uast-tests/java/Simple/ClassLiteral.java b/uast/uast-tests/java/Simple/ClassLiteral.java
new file mode 100644
index 000000000000..5e7fa5ccd7c4
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ClassLiteral.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Foo {
+ public static void bar() {
+ Class<*> FOO_CLASS = Foo.class;
+ }
+}
diff --git a/uast/uast-tests/java/Simple/ClassLiteral.values.txt b/uast/uast-tests/java/Simple/ClassLiteral.values.txt
new file mode 100644
index 000000000000..cda616f7e52a
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ClassLiteral.values.txt
@@ -0,0 +1,9 @@
+UFile (package = ) [public class Foo {...]
+ UClass (name = Foo) [public class Foo {...}]
+ UMethod (name = bar) [public static fun bar() : void {...}]
+ UBlockExpression [{...}] = Undetermined
+ UDeclarationsExpression [] = Undetermined
+ UBinaryExpression (operator = =) [FOO_CLASS = Foo] = Undetermined
+ USimpleNameReferenceExpression (identifier = FOO_CLASS) [FOO_CLASS] = external FOO_CLASS()
+ UClassLiteralExpression [Foo] = Foo
+ UTypeReferenceExpression (name = Foo) [Foo] = Undetermined
diff --git a/uast/uast-tests/java/Simple/DeadElse.java b/uast/uast-tests/java/Simple/DeadElse.java
new file mode 100644
index 000000000000..d180cc4d42eb
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadElse.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class DeadElse {
+ public static int foo() {
+ boolean f = true;
+ int x = 0;
+ int y = 1;
+ int z;
+ if (f) {
+ z = y;
+ }
+ else {
+ z = x;
+ }
+ return z;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/DeadElse.values.txt b/uast/uast-tests/java/Simple/DeadElse.values.txt
new file mode 100644
index 000000000000..37c520928801
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadElse.values.txt
@@ -0,0 +1,27 @@
+UFile (package = ) [public class DeadElse {...]
+ UClass (name = DeadElse) [public class DeadElse {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var f: boolean = true] = Undetermined
+ ULocalVariable (name = f) [var f: boolean = true]
+ ULiteralExpression (value = true) [true] = true
+ UDeclarationsExpression [var x: int = 0] = Undetermined
+ ULocalVariable (name = x) [var x: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var y: int = 1] = Undetermined
+ ULocalVariable (name = y) [var y: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var z: int] = Undetermined
+ ULocalVariable (name = z) [var z: int]
+ UIfExpression [if (f) {...}] = (var y = 1)
+ USimpleNameReferenceExpression (identifier = f) [f] = (var f = true)
+ UBlockExpression [{...}] = (var y = 1)
+ UBinaryExpression (operator = =) [z = y] = (var y = 1)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1)
+ UBlockExpression [{...}] = (var x = 0)
+ UBinaryExpression (operator = =) [z = x] = (var x = 0)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0)
+ UReturnExpression [return z] = Nothing
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = (var y = 1))
diff --git a/uast/uast-tests/java/Simple/DeadFor.java b/uast/uast-tests/java/Simple/DeadFor.java
new file mode 100644
index 000000000000..9eab78a9d71a
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadFor.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class DeadFor {
+ public static int foo() {
+ int result = 0;
+ for (int i = 9; i < 5; i++) {
+ result = result + i;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/DeadFor.values.txt b/uast/uast-tests/java/Simple/DeadFor.values.txt
new file mode 100644
index 000000000000..43e2220ae986
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadFor.values.txt
@@ -0,0 +1,24 @@
+UFile (package = ) [public class DeadFor {...]
+ UClass (name = DeadFor) [public class DeadFor {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: int = 0] = Undetermined
+ ULocalVariable (name = result) [var result: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UForExpression [for (var i: int = 9; i < 5; i++) {...}] = Undetermined
+ UDeclarationsExpression [var i: int = 9] = Undetermined
+ ULocalVariable (name = i) [var i: int = 9]
+ ULiteralExpression (value = 9) [9] = 9
+ UBinaryExpression (operator = <) [i < 5] = false (depending on: (var i = 9))
+ USimpleNameReferenceExpression (identifier = i) [i] = (var i = 9)
+ ULiteralExpression (value = 5) [5] = 5
+ UPostfixExpression (operator = ++) [i++] = Undetermined
+ USimpleNameReferenceExpression (identifier = i) [i] = Undetermined
+ UBlockExpression [{...}] = Undetermined
+ UBinaryExpression (operator = =) [result = result + i] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Undetermined
+ UBinaryExpression (operator = +) [result + i] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Undetermined
+ USimpleNameReferenceExpression (identifier = i) [i] = Undetermined
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = 0)
diff --git a/uast/uast-tests/java/Simple/DeadIfComparison.java b/uast/uast-tests/java/Simple/DeadIfComparison.java
new file mode 100644
index 000000000000..ee1c3fcb649c
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadIfComparison.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class DeadIfComparison {
+ public static int foo() {
+ int x = 0;
+ int y = 1;
+ int z;
+ if (x == y) {
+ z = y;
+ }
+ else {
+ z = x;
+ }
+ return z;
+ }
+}
diff --git a/uast/uast-tests/java/Simple/DeadIfComparison.values.txt b/uast/uast-tests/java/Simple/DeadIfComparison.values.txt
new file mode 100644
index 000000000000..cc18b781974b
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadIfComparison.values.txt
@@ -0,0 +1,26 @@
+UFile (package = ) [public class DeadIfComparison {...]
+ UClass (name = DeadIfComparison) [public class DeadIfComparison {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: int = 0] = Undetermined
+ ULocalVariable (name = x) [var x: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var y: int = 1] = Undetermined
+ ULocalVariable (name = y) [var y: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var z: int] = Undetermined
+ ULocalVariable (name = z) [var z: int]
+ UIfExpression [if (x === y) {...}] = (var x = 0)
+ UBinaryExpression (operator = ===) [x === y] = false (depending on: (var x = 0), (var y = 1))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0)
+ USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1)
+ UBlockExpression [{...}] = (var y = 1)
+ UBinaryExpression (operator = =) [z = y] = (var y = 1)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1)
+ UBlockExpression [{...}] = (var x = 0)
+ UBinaryExpression (operator = =) [z = x] = (var x = 0)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0)
+ UReturnExpression [return z] = Nothing
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = (var x = 0))
diff --git a/uast/uast-tests/java/Simple/DeadSwitchEntries.java b/uast/uast-tests/java/Simple/DeadSwitchEntries.java
new file mode 100644
index 000000000000..98d62cd6de5e
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadSwitchEntries.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public enum DeadSwitchEntries {
+ FIRST,
+ SECOND,
+ THIRD;
+
+ public static int bar() {
+ DeadSwitchEntries key = THIRD;
+ int result;
+ switch (key) {
+ case FIRST:
+ result = 3;
+ break;
+ case SECOND:
+ result = 7;
+ break;
+ case THIRD:
+ result = 13;
+ break;
+ default:
+ result = 66;
+ break;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/DeadSwitchEntries.values.txt b/uast/uast-tests/java/Simple/DeadSwitchEntries.values.txt
new file mode 100644
index 000000000000..c56fd22f053e
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadSwitchEntries.values.txt
@@ -0,0 +1,48 @@
+UFile (package = ) [public final enum DeadSwitchEntries {...]
+ UClass (name = DeadSwitchEntries) [public final enum DeadSwitchEntries {...}]
+ UEnumConstant (name = FIRST) [FIRST] = Undetermined
+ USimpleNameReferenceExpression (identifier = DeadSwitchEntries) [DeadSwitchEntries] = Undetermined
+ UEnumConstant (name = SECOND) [SECOND] = Undetermined
+ USimpleNameReferenceExpression (identifier = DeadSwitchEntries) [DeadSwitchEntries] = Undetermined
+ UEnumConstant (name = THIRD) [THIRD] = Undetermined
+ USimpleNameReferenceExpression (identifier = DeadSwitchEntries) [DeadSwitchEntries] = Undetermined
+ UMethod (name = bar) [public static fun bar() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var key: DeadSwitchEntries = THIRD] = Undetermined
+ ULocalVariable (name = key) [var key: DeadSwitchEntries = THIRD]
+ USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry)
+ UDeclarationsExpression [var result: int] = Undetermined
+ ULocalVariable (name = result) [var result: int]
+ USwitchExpression [switch (key) ...] = Undetermined
+ USimpleNameReferenceExpression (identifier = key) [key] = (var key = THIRD (enum entry))
+ UExpressionList (switch) [ FIRST -> {... ] = Undetermined
+ USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 3] = 3
+ USimpleNameReferenceExpression (identifier = result) [result] = Undetermined
+ ULiteralExpression (value = 3) [3] = 3
+ UBreakExpression (label = null) [break] = Nothing(break)
+ USwitchClauseExpressionWithBody [SECOND -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 7] = 7
+ USimpleNameReferenceExpression (identifier = result) [result] = Undetermined
+ ULiteralExpression (value = 7) [7] = 7
+ UBreakExpression (label = null) [break] = Nothing(break)
+ USwitchClauseExpressionWithBody [THIRD -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 13] = 13
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ ULiteralExpression (value = 13) [13] = 13
+ UBreakExpression (label = null) [break] = Nothing(break)
+ USwitchClauseExpressionWithBody [else -> {...] = Undetermined
+ UDefaultCaseExpression [else] = Undetermined
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 66] = 66
+ USimpleNameReferenceExpression (identifier = result) [result] = Undetermined
+ ULiteralExpression (value = 66) [66] = 66
+ UBreakExpression (label = null) [break] = Nothing(break)
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = 13)
diff --git a/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.java b/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.java
new file mode 100644
index 000000000000..ba706c0611e8
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public enum DeadSwitchEntriesWithoutBreaks {
+ FIRST,
+ SECOND,
+ THIRD;
+
+ public static int bar() {
+ DeadSwitchEntriesWithoutBreaks key = SECOND;
+ int result;
+ switch (key) {
+ case FIRST:
+ result = 3;
+ break;
+ case SECOND:
+ result = 7;
+ case THIRD:
+ result = 13;
+ default:
+ result = 66;
+ break;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.values.txt b/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.values.txt
new file mode 100644
index 000000000000..9f45b9fdee13
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.values.txt
@@ -0,0 +1,46 @@
+UFile (package = ) [public final enum DeadSwitchEntriesWithoutBreaks {...]
+ UClass (name = DeadSwitchEntriesWithoutBreaks) [public final enum DeadSwitchEntriesWithoutBreaks {...}]
+ UEnumConstant (name = FIRST) [FIRST] = Undetermined
+ USimpleNameReferenceExpression (identifier = DeadSwitchEntriesWithoutBreaks) [DeadSwitchEntriesWithoutBreaks] = Undetermined
+ UEnumConstant (name = SECOND) [SECOND] = Undetermined
+ USimpleNameReferenceExpression (identifier = DeadSwitchEntriesWithoutBreaks) [DeadSwitchEntriesWithoutBreaks] = Undetermined
+ UEnumConstant (name = THIRD) [THIRD] = Undetermined
+ USimpleNameReferenceExpression (identifier = DeadSwitchEntriesWithoutBreaks) [DeadSwitchEntriesWithoutBreaks] = Undetermined
+ UMethod (name = bar) [public static fun bar() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var key: DeadSwitchEntriesWithoutBreaks = SECOND] = Undetermined
+ ULocalVariable (name = key) [var key: DeadSwitchEntriesWithoutBreaks = SECOND]
+ USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry)
+ UDeclarationsExpression [var result: int] = Undetermined
+ ULocalVariable (name = result) [var result: int]
+ USwitchExpression [switch (key) ...] = Undetermined
+ USimpleNameReferenceExpression (identifier = key) [key] = (var key = SECOND (enum entry))
+ UExpressionList (switch) [ FIRST -> {... ] = Undetermined
+ USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 3] = 3
+ USimpleNameReferenceExpression (identifier = result) [result] = Undetermined
+ ULiteralExpression (value = 3) [3] = 3
+ UBreakExpression (label = null) [break] = Nothing(break)
+ USwitchClauseExpressionWithBody [SECOND -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 7] = 7
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ ULiteralExpression (value = 7) [7] = 7
+ USwitchClauseExpressionWithBody [THIRD -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 13] = 13
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 7), (var result = Undetermined))
+ ULiteralExpression (value = 13) [13] = 13
+ USwitchClauseExpressionWithBody [else -> {...] = Undetermined
+ UDefaultCaseExpression [else] = Undetermined
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 66] = 66
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 13), (var result = Undetermined))
+ ULiteralExpression (value = 66) [66] = 66
+ UBreakExpression (label = null) [break] = Nothing(break)
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = 66)
diff --git a/uast/uast-tests/java/Simple/DeadThen.java b/uast/uast-tests/java/Simple/DeadThen.java
new file mode 100644
index 000000000000..b56b175612fd
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadThen.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class DeadThen {
+ public static int foo() {
+ boolean f = true;
+ int x = 0;
+ int y = 1;
+ int z;
+ if (!f) {
+ z = y;
+ }
+ else {
+ z = x;
+ }
+ return z;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/DeadThen.values.txt b/uast/uast-tests/java/Simple/DeadThen.values.txt
new file mode 100644
index 000000000000..14528bcb2a84
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DeadThen.values.txt
@@ -0,0 +1,28 @@
+UFile (package = ) [public class DeadThen {...]
+ UClass (name = DeadThen) [public class DeadThen {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var f: boolean = true] = Undetermined
+ ULocalVariable (name = f) [var f: boolean = true]
+ ULiteralExpression (value = true) [true] = true
+ UDeclarationsExpression [var x: int = 0] = Undetermined
+ ULocalVariable (name = x) [var x: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var y: int = 1] = Undetermined
+ ULocalVariable (name = y) [var y: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var z: int] = Undetermined
+ ULocalVariable (name = z) [var z: int]
+ UIfExpression [if (!f) {...}] = (var x = 0)
+ UPrefixExpression (operator = !) [!f] = false (depending on: (var f = true))
+ USimpleNameReferenceExpression (identifier = f) [f] = (var f = true)
+ UBlockExpression [{...}] = (var y = 1)
+ UBinaryExpression (operator = =) [z = y] = (var y = 1)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1)
+ UBlockExpression [{...}] = (var x = 0)
+ UBinaryExpression (operator = =) [z = x] = (var x = 0)
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0)
+ UReturnExpression [return z] = Nothing
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = (var x = 0))
diff --git a/uast/uast-tests/java/Simple/Dependents.java b/uast/uast-tests/java/Simple/Dependents.java
new file mode 100644
index 000000000000..db5662b48b09
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Dependents.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Dependents {
+ public static int foo() {
+ int x = 42;
+ int y = x;
+ int z = y;
+ int w = z;
+ return w;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Dependents.values.txt b/uast/uast-tests/java/Simple/Dependents.values.txt
new file mode 100644
index 000000000000..4a1e915fe974
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Dependents.values.txt
@@ -0,0 +1,18 @@
+UFile (package = ) [public class Dependents {...]
+ UClass (name = Dependents) [public class Dependents {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: int = 42] = Undetermined
+ ULocalVariable (name = x) [var x: int = 42]
+ ULiteralExpression (value = 42) [42] = 42
+ UDeclarationsExpression [var y: int = x] = Undetermined
+ ULocalVariable (name = y) [var y: int = x]
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 42)
+ UDeclarationsExpression [var z: int = y] = Undetermined
+ ULocalVariable (name = z) [var z: int = y]
+ USimpleNameReferenceExpression (identifier = y) [y] = (var y = (var x = 42))
+ UDeclarationsExpression [var w: int = z] = Undetermined
+ ULocalVariable (name = w) [var w: int = z]
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = (var y = (var x = 42)))
+ UReturnExpression [return w] = Nothing
+ USimpleNameReferenceExpression (identifier = w) [w] = (var w = (var z = (var y = (var x = 42))))
diff --git a/uast/uast-tests/java/Simple/DoWhile.java b/uast/uast-tests/java/Simple/DoWhile.java
new file mode 100644
index 000000000000..835c25676a82
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DoWhile.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class DoWhile {
+ public static int foo() {
+ int count = 0;
+ int number = 42;
+ do {
+ if (number % 10 == 7) {
+ count++;
+ }
+ number = number / 10;
+ } while (number > 0);
+ return count;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/DoWhile.values.txt b/uast/uast-tests/java/Simple/DoWhile.values.txt
new file mode 100644
index 000000000000..5fc329e61778
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DoWhile.values.txt
@@ -0,0 +1,32 @@
+UFile (package = ) [public class DoWhile {...]
+ UClass (name = DoWhile) [public class DoWhile {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var count: int = 0] = Undetermined
+ ULocalVariable (name = count) [var count: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var number: int = 42] = Undetermined
+ ULocalVariable (name = number) [var number: int = 42]
+ ULiteralExpression (value = 42) [42] = 42
+ UDoWhileExpression [do {...] = Undetermined
+ UBinaryExpression (operator = >) [number > 0] = Undetermined
+ USimpleNameReferenceExpression (identifier = number) [number] = Phi((var number = Undetermined), (var number = 0), (var number = 4))
+ ULiteralExpression (value = 0) [0] = 0
+ UBlockExpression [{...}] = Undetermined
+ UIfExpression [if (number % 10 === 7) {...}] = Phi((var count = Undetermined), (var count = 0), (var count = 1), Undetermined)
+ UBinaryExpression (operator = ===) [number % 10 === 7] = Undetermined
+ UBinaryExpression (operator = %) [number % 10] = Undetermined
+ USimpleNameReferenceExpression (identifier = number) [number] = Phi((var number = Undetermined), (var number = 0), (var number = 4))
+ ULiteralExpression (value = 10) [10] = 10
+ ULiteralExpression (value = 7) [7] = 7
+ UBlockExpression [{...}] = Phi((var count = Undetermined), (var count = 0), (var count = 1))
+ UPostfixExpression (operator = ++) [count++] = Phi((var count = Undetermined), (var count = 0), (var count = 1))
+ USimpleNameReferenceExpression (identifier = count) [count] = Phi((var count = Undetermined), (var count = 0), (var count = 1))
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UBinaryExpression (operator = =) [number = number / 10] = Undetermined
+ USimpleNameReferenceExpression (identifier = number) [number] = Phi((var number = Undetermined), (var number = 0), (var number = 4))
+ UBinaryExpression (operator = /) [number / 10] = Undetermined
+ USimpleNameReferenceExpression (identifier = number) [number] = Phi((var number = Undetermined), (var number = 0), (var number = 4))
+ ULiteralExpression (value = 10) [10] = 10
+ UReturnExpression [return count] = Nothing
+ USimpleNameReferenceExpression (identifier = count) [count] = Phi((var count = Undetermined), (var count = 0), (var count = 1))
diff --git a/uast/uast-tests/java/Simple/DoWhileInfinite.java b/uast/uast-tests/java/Simple/DoWhileInfinite.java
new file mode 100644
index 000000000000..596790528e55
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DoWhileInfinite.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class DoWhileInfinite {
+ public static int foo() {
+ int count = 0;
+ int number = 42;
+ do {
+ if (number % 10 == 7) {
+ count++;
+ }
+ } while (number > 0);
+ return count;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/DoWhileInfinite.values.txt b/uast/uast-tests/java/Simple/DoWhileInfinite.values.txt
new file mode 100644
index 000000000000..e668733bdf39
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DoWhileInfinite.values.txt
@@ -0,0 +1,27 @@
+UFile (package = ) [public class DoWhileInfinite {...]
+ UClass (name = DoWhileInfinite) [public class DoWhileInfinite {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var count: int = 0] = Undetermined
+ ULocalVariable (name = count) [var count: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var number: int = 42] = Undetermined
+ ULocalVariable (name = number) [var number: int = 42]
+ ULiteralExpression (value = 42) [42] = 42
+ UDoWhileExpression [do {...] = Undetermined
+ UBinaryExpression (operator = >) [number > 0] = true (depending on: (var number = 42))
+ USimpleNameReferenceExpression (identifier = number) [number] = (var number = 42)
+ ULiteralExpression (value = 0) [0] = 0
+ UBlockExpression [{...}] = Undetermined
+ UIfExpression [if (number % 10 === 7) {...}] = Undetermined
+ UBinaryExpression (operator = ===) [number % 10 === 7] = false (depending on: (var number = 42))
+ UBinaryExpression (operator = %) [number % 10] = 2 (depending on: (var number = 42))
+ USimpleNameReferenceExpression (identifier = number) [number] = (var number = 42)
+ ULiteralExpression (value = 10) [10] = 10
+ ULiteralExpression (value = 7) [7] = 7
+ UBlockExpression [{...}] = (var count = 0)
+ UPostfixExpression (operator = ++) [count++] = (var count = 0)
+ USimpleNameReferenceExpression (identifier = count) [count] = (var count = 0)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UReturnExpression [return count] = Nothing
+ USimpleNameReferenceExpression (identifier = count) [count] = (var count = 0)
diff --git a/uast/uast-tests/java/Simple/DoWhileWithReturn.java b/uast/uast-tests/java/Simple/DoWhileWithReturn.java
new file mode 100644
index 000000000000..393beaf41142
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DoWhileWithReturn.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class DoWhileWithReturn {
+ public static int foo() {
+ int count = 0;
+ int number = 1;
+ do {
+ if (number > 0) return count;
+ count++;
+ number--;
+ } while (number >= 0);
+ return count;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/DoWhileWithReturn.values.txt b/uast/uast-tests/java/Simple/DoWhileWithReturn.values.txt
new file mode 100644
index 000000000000..42194a60f153
--- /dev/null
+++ b/uast/uast-tests/java/Simple/DoWhileWithReturn.values.txt
@@ -0,0 +1,28 @@
+UFile (package = ) [public class DoWhileWithReturn {...]
+ UClass (name = DoWhileWithReturn) [public class DoWhileWithReturn {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var count: int = 0] = Undetermined
+ ULocalVariable (name = count) [var count: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var number: int = 1] = Undetermined
+ ULocalVariable (name = number) [var number: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDoWhileExpression [do {...] = Nothing
+ UBinaryExpression (operator = >=) [number >= 0] = true (depending on: (var number = 1))
+ USimpleNameReferenceExpression (identifier = number) [number] = (var number = 1)
+ ULiteralExpression (value = 0) [0] = 0
+ UBlockExpression [{...}] = Nothing
+ UIfExpression [if (number > 0) return count] = Nothing
+ UBinaryExpression (operator = >) [number > 0] = true (depending on: (var number = 1))
+ USimpleNameReferenceExpression (identifier = number) [number] = (var number = 1)
+ ULiteralExpression (value = 0) [0] = 0
+ UReturnExpression [return count] = Nothing
+ USimpleNameReferenceExpression (identifier = count) [count] = (var count = 0)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UPostfixExpression (operator = ++) [count++] = Undetermined
+ USimpleNameReferenceExpression (identifier = count) [count] = Undetermined
+ UPostfixExpression (operator = --) [number--] = Undetermined
+ USimpleNameReferenceExpression (identifier = number) [number] = Undetermined
+ UReturnExpression [return count] = Nothing
+ USimpleNameReferenceExpression (identifier = count) [count] = Undetermined
diff --git a/uast/uast-tests/java/Simple/EnumChoice.java b/uast/uast-tests/java/Simple/EnumChoice.java
new file mode 100644
index 000000000000..b51fe3c8fe83
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumChoice.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public enum EnumChoice {
+ FIRST,
+ SECOND;
+
+ public EnumChoice foo(boolean flag) {
+ EnumChoice result;
+ if (flag) {
+ result = FIRST;
+ }
+ else {
+ result = SECOND;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/EnumChoice.values.txt b/uast/uast-tests/java/Simple/EnumChoice.values.txt
new file mode 100644
index 000000000000..6cd8576fb434
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumChoice.values.txt
@@ -0,0 +1,23 @@
+UFile (package = ) [public final enum EnumChoice {...]
+ UClass (name = EnumChoice) [public final enum EnumChoice {...}]
+ UEnumConstant (name = FIRST) [FIRST] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumChoice) [EnumChoice] = Undetermined
+ UEnumConstant (name = SECOND) [SECOND] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumChoice) [EnumChoice] = Undetermined
+ UMethod (name = foo) [public fun foo(flag: boolean) : EnumChoice {...}]
+ UParameter (name = flag) [var flag: boolean]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: EnumChoice] = Undetermined
+ ULocalVariable (name = result) [var result: EnumChoice]
+ UIfExpression [if (flag) {...}] = Phi(FIRST (enum entry), SECOND (enum entry))
+ USimpleNameReferenceExpression (identifier = flag) [flag] = Undetermined
+ UBlockExpression [{...}] = FIRST (enum entry)
+ UBinaryExpression (operator = =) [result = FIRST] = FIRST (enum entry)
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry)
+ UBlockExpression [{...}] = SECOND (enum entry)
+ UBinaryExpression (operator = =) [result = SECOND] = SECOND (enum entry)
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry)
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = FIRST (enum entry)), (var result = SECOND (enum entry)))
diff --git a/uast/uast-tests/java/Simple/EnumSwitch.java b/uast/uast-tests/java/Simple/EnumSwitch.java
new file mode 100644
index 000000000000..445a20ddaa5a
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumSwitch.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public enum EnumSwitch {
+ FIRST,
+ SECOND,
+ THIRD;
+
+ public static int foo(EnumSwitch key) {
+ int result;
+ switch (key) {
+ case FIRST:
+ result = 3;
+ break;
+ case SECOND:
+ result = 7;
+ break;
+ case THIRD:
+ result = 13;
+ break;
+ default:
+ result = 66;
+ break;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/EnumSwitch.log.txt b/uast/uast-tests/java/Simple/EnumSwitch.log.txt
new file mode 100644
index 000000000000..a515b98f5770
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumSwitch.log.txt
@@ -0,0 +1,46 @@
+UFile (package = )
+ UClass (name = EnumSwitch)
+ UEnumConstant (name = FIRST)
+ USimpleNameReferenceExpression (identifier = EnumSwitch)
+ UEnumConstant (name = SECOND)
+ USimpleNameReferenceExpression (identifier = EnumSwitch)
+ UEnumConstant (name = THIRD)
+ USimpleNameReferenceExpression (identifier = EnumSwitch)
+ UMethod (name = foo)
+ UParameter (name = key)
+ UBlockExpression
+ UDeclarationsExpression
+ ULocalVariable (name = result)
+ USwitchExpression
+ USimpleNameReferenceExpression (identifier = key)
+ UExpressionList (switch)
+ USwitchClauseExpressionWithBody
+ USimpleNameReferenceExpression (identifier = FIRST)
+ UExpressionList (switch_entry)
+ UBinaryExpression (operator = =)
+ USimpleNameReferenceExpression (identifier = result)
+ ULiteralExpression (value = 3)
+ UBreakExpression (label = null)
+ USwitchClauseExpressionWithBody
+ USimpleNameReferenceExpression (identifier = SECOND)
+ UExpressionList (switch_entry)
+ UBinaryExpression (operator = =)
+ USimpleNameReferenceExpression (identifier = result)
+ ULiteralExpression (value = 7)
+ UBreakExpression (label = null)
+ USwitchClauseExpressionWithBody
+ USimpleNameReferenceExpression (identifier = THIRD)
+ UExpressionList (switch_entry)
+ UBinaryExpression (operator = =)
+ USimpleNameReferenceExpression (identifier = result)
+ ULiteralExpression (value = 13)
+ UBreakExpression (label = null)
+ USwitchClauseExpressionWithBody
+ UDefaultCaseExpression
+ UExpressionList (switch_entry)
+ UBinaryExpression (operator = =)
+ USimpleNameReferenceExpression (identifier = result)
+ ULiteralExpression (value = 66)
+ UBreakExpression (label = null)
+ UReturnExpression
+ USimpleNameReferenceExpression (identifier = result)
diff --git a/uast/uast-tests/java/Simple/EnumSwitch.render.txt b/uast/uast-tests/java/Simple/EnumSwitch.render.txt
new file mode 100644
index 000000000000..cf067075fdad
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumSwitch.render.txt
@@ -0,0 +1,31 @@
+public final enum EnumSwitch {
+ FIRST
+ SECOND
+ THIRD
+ public static fun foo(key: EnumSwitch) : int {
+ var result: int
+ switch (key)
+ FIRST -> {
+ result = 3
+ break
+ }
+
+ SECOND -> {
+ result = 7
+ break
+ }
+
+ THIRD -> {
+ result = 13
+ break
+ }
+
+ else -> {
+ result = 66
+ break
+ }
+
+
+ return result
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/EnumSwitch.values.txt b/uast/uast-tests/java/Simple/EnumSwitch.values.txt
new file mode 100644
index 000000000000..7b16d1328964
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumSwitch.values.txt
@@ -0,0 +1,46 @@
+UFile (package = ) [public final enum EnumSwitch {...]
+ UClass (name = EnumSwitch) [public final enum EnumSwitch {...}]
+ UEnumConstant (name = FIRST) [FIRST] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitch) [EnumSwitch] = Undetermined
+ UEnumConstant (name = SECOND) [SECOND] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitch) [EnumSwitch] = Undetermined
+ UEnumConstant (name = THIRD) [THIRD] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitch) [EnumSwitch] = Undetermined
+ UMethod (name = foo) [public static fun foo(key: EnumSwitch) : int {...}]
+ UParameter (name = key) [var key: EnumSwitch]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: int] = Undetermined
+ ULocalVariable (name = result) [var result: int]
+ USwitchExpression [switch (key) ...] = Undetermined
+ USimpleNameReferenceExpression (identifier = key) [key] = Undetermined
+ UExpressionList (switch) [ FIRST -> {... ] = Undetermined
+ USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 3] = 3
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ ULiteralExpression (value = 3) [3] = 3
+ UBreakExpression (label = null) [break] = Nothing(break)
+ USwitchClauseExpressionWithBody [SECOND -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 7] = 7
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ ULiteralExpression (value = 7) [7] = 7
+ UBreakExpression (label = null) [break] = Nothing(break)
+ USwitchClauseExpressionWithBody [THIRD -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 13] = 13
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ ULiteralExpression (value = 13) [13] = 13
+ UBreakExpression (label = null) [break] = Nothing(break)
+ USwitchClauseExpressionWithBody [else -> {...] = Undetermined
+ UDefaultCaseExpression [else] = Undetermined
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 66] = 66
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ ULiteralExpression (value = 66) [66] = 66
+ UBreakExpression (label = null) [break] = Nothing(break)
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 66), (var result = 13), (var result = 3), (var result = 7))
diff --git a/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.java b/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.java
new file mode 100644
index 000000000000..8489559bf10d
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public enum EnumSwitchConditionalBreak {
+ FIRST,
+ SECOND,
+ THIRD;
+
+ public static int foo(EnumSwitchConditionalBreak key, int result) {
+ int newResult;
+ int counter = 0;
+ switch (key) {
+ case FIRST:
+ if (result > 0) {
+ newResult = 42;
+ counter++;
+ break;
+ }
+ counter++;
+ default:
+ newResult = 42;
+ counter++;
+ break;
+ }
+ return newResult + counter;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.values.txt b/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.values.txt
new file mode 100644
index 000000000000..cc1f591a577e
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.values.txt
@@ -0,0 +1,50 @@
+UFile (package = ) [public final enum EnumSwitchConditionalBreak {...]
+ UClass (name = EnumSwitchConditionalBreak) [public final enum EnumSwitchConditionalBreak {...}]
+ UEnumConstant (name = FIRST) [FIRST] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitchConditionalBreak) [EnumSwitchConditionalBreak] = Undetermined
+ UEnumConstant (name = SECOND) [SECOND] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitchConditionalBreak) [EnumSwitchConditionalBreak] = Undetermined
+ UEnumConstant (name = THIRD) [THIRD] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitchConditionalBreak) [EnumSwitchConditionalBreak] = Undetermined
+ UMethod (name = foo) [public static fun foo(key: EnumSwitchConditionalBreak, result: int) : int {...}]
+ UParameter (name = key) [var key: EnumSwitchConditionalBreak]
+ UParameter (name = result) [var result: int]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var newResult: int] = Undetermined
+ ULocalVariable (name = newResult) [var newResult: int]
+ UDeclarationsExpression [var counter: int = 0] = Undetermined
+ ULocalVariable (name = counter) [var counter: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ USwitchExpression [switch (key) ...] = Undetermined
+ USimpleNameReferenceExpression (identifier = key) [key] = Undetermined
+ UExpressionList (switch) [ FIRST -> {... ] = Undetermined
+ USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UIfExpression [if (result > 0) {...}] = Undetermined
+ UBinaryExpression (operator = >) [result > 0] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Undetermined
+ ULiteralExpression (value = 0) [0] = 0
+ UBlockExpression [{...}] = Nothing(break)
+ UBinaryExpression (operator = =) [newResult = 42] = 42
+ USimpleNameReferenceExpression (identifier = newResult) [newResult] = (var newResult = Undetermined)
+ ULiteralExpression (value = 42) [42] = 42
+ UPostfixExpression (operator = ++) [counter++] = (var counter = 0)
+ USimpleNameReferenceExpression (identifier = counter) [counter] = (var counter = 0)
+ UBreakExpression (label = null) [break] = Nothing(break)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UPostfixExpression (operator = ++) [counter++] = (var counter = 0)
+ USimpleNameReferenceExpression (identifier = counter) [counter] = (var counter = 0)
+ USwitchClauseExpressionWithBody [else -> {...] = Undetermined
+ UDefaultCaseExpression [else] = Undetermined
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [newResult = 42] = 42
+ USimpleNameReferenceExpression (identifier = newResult) [newResult] = (var newResult = Undetermined)
+ ULiteralExpression (value = 42) [42] = 42
+ UPostfixExpression (operator = ++) [counter++] = Phi((var counter = 1), (var counter = 0))
+ USimpleNameReferenceExpression (identifier = counter) [counter] = Phi((var counter = 1), (var counter = 0))
+ UBreakExpression (label = null) [break] = Nothing(break)
+ UReturnExpression [return newResult + counter] = Nothing
+ UBinaryExpression (operator = +) [newResult + counter] = Undetermined (depending on: (var newResult = 42), (var counter = Undetermined))
+ USimpleNameReferenceExpression (identifier = newResult) [newResult] = (var newResult = 42)
+ USimpleNameReferenceExpression (identifier = counter) [counter] = (var counter = Undetermined)
diff --git a/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.java b/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.java
new file mode 100644
index 000000000000..b79b9059d3be
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public enum EnumSwitchWithoutBreaks {
+ FIRST,
+ SECOND,
+ THIRD;
+
+ public static int foo(EnumSwitchWithoutBreaks key) {
+ int result;
+ switch (key) {
+ case FIRST:
+ result = 3;
+ break;
+ case SECOND:
+ result = 7;
+ case THIRD:
+ result = 13;
+ default:
+ result = 66;
+ break;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.values.txt b/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.values.txt
new file mode 100644
index 000000000000..f05f090d2b70
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.values.txt
@@ -0,0 +1,44 @@
+UFile (package = ) [public final enum EnumSwitchWithoutBreaks {...]
+ UClass (name = EnumSwitchWithoutBreaks) [public final enum EnumSwitchWithoutBreaks {...}]
+ UEnumConstant (name = FIRST) [FIRST] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitchWithoutBreaks) [EnumSwitchWithoutBreaks] = Undetermined
+ UEnumConstant (name = SECOND) [SECOND] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitchWithoutBreaks) [EnumSwitchWithoutBreaks] = Undetermined
+ UEnumConstant (name = THIRD) [THIRD] = Undetermined
+ USimpleNameReferenceExpression (identifier = EnumSwitchWithoutBreaks) [EnumSwitchWithoutBreaks] = Undetermined
+ UMethod (name = foo) [public static fun foo(key: EnumSwitchWithoutBreaks) : int {...}]
+ UParameter (name = key) [var key: EnumSwitchWithoutBreaks]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: int] = Undetermined
+ ULocalVariable (name = result) [var result: int]
+ USwitchExpression [switch (key) ...] = Undetermined
+ USimpleNameReferenceExpression (identifier = key) [key] = Undetermined
+ UExpressionList (switch) [ FIRST -> {... ] = Undetermined
+ USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 3] = 3
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ ULiteralExpression (value = 3) [3] = 3
+ UBreakExpression (label = null) [break] = Nothing(break)
+ USwitchClauseExpressionWithBody [SECOND -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 7] = 7
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined)
+ ULiteralExpression (value = 7) [7] = 7
+ USwitchClauseExpressionWithBody [THIRD -> {...] = Undetermined
+ USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry)
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 13] = 13
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 7), (var result = Undetermined))
+ ULiteralExpression (value = 13) [13] = 13
+ USwitchClauseExpressionWithBody [else -> {...] = Undetermined
+ UDefaultCaseExpression [else] = Undetermined
+ UExpressionList (switch_entry) [{...] = Undetermined
+ UBinaryExpression (operator = =) [result = 66] = 66
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 13), (var result = Undetermined))
+ ULiteralExpression (value = 66) [66] = 66
+ UBreakExpression (label = null) [break] = Nothing(break)
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 3), (var result = 66))
diff --git a/uast/uast-tests/java/Simple/EnumValueMembers.java b/uast/uast-tests/java/Simple/EnumValueMembers.java
new file mode 100644
index 000000000000..969a169b8ceb
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumValueMembers.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public enum Style {
+ SHEET("foo") {
+ @Override
+ public String getExitAnimation() {
+ return "bar";
+ }
+ };
+
+ Style(String s) {
+ }
+
+ public String getExitAnimation() {
+ return null;
+ }
+}
+
diff --git a/uast/uast-tests/java/Simple/EnumValueMembers.log.txt b/uast/uast-tests/java/Simple/EnumValueMembers.log.txt
new file mode 100644
index 000000000000..388659dbdbd0
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumValueMembers.log.txt
@@ -0,0 +1,18 @@
+UFile (package = )
+ UClass (name = Style)
+ UEnumConstant (name = SHEET)
+ USimpleNameReferenceExpression (identifier = Style)
+ ULiteralExpression (value = "foo")
+ UClass (name = null)
+ UMethod (name = getExitAnimation)
+ UAnnotation (fqName = java.lang.Override)
+ UBlockExpression
+ UReturnExpression
+ ULiteralExpression (value = "bar")
+ UMethod (name = Style)
+ UParameter (name = s)
+ UBlockExpression
+ UMethod (name = getExitAnimation)
+ UBlockExpression
+ UReturnExpression
+ ULiteralExpression (value = null)
diff --git a/uast/uast-tests/java/Simple/EnumValueMembers.render.txt b/uast/uast-tests/java/Simple/EnumValueMembers.render.txt
new file mode 100644
index 000000000000..36242a0117ed
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EnumValueMembers.render.txt
@@ -0,0 +1,13 @@
+public enum Style {
+ SHEET("foo") {
+ @java.lang.Override
+ public fun getExitAnimation() : java.lang.String {
+ return "bar"
+ }
+ }
+ private fun Style(s: java.lang.String) {
+ }
+ public fun getExitAnimation() : java.lang.String {
+ return null
+ }
+}
diff --git a/uast/uast-tests/java/Simple/EvaluatorExtension.java b/uast/uast-tests/java/Simple/EvaluatorExtension.java
new file mode 100644
index 000000000000..7ce432f94203
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EvaluatorExtension.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public abstract class Foo {
+ public abstract String getTestName(boolean upper);
+
+ public void bar() {
+ String t1 = getTestName(false);
+ String t2 = getTestName(true);
+ }
+}
diff --git a/uast/uast-tests/java/Simple/EvaluatorExtension.values.txt b/uast/uast-tests/java/Simple/EvaluatorExtension.values.txt
new file mode 100644
index 000000000000..8086de82bd51
--- /dev/null
+++ b/uast/uast-tests/java/Simple/EvaluatorExtension.values.txt
@@ -0,0 +1,16 @@
+UFile (package = ) [public abstract class Foo {...]
+ UClass (name = Foo) [public abstract class Foo {...}]
+ UMethod (name = getTestName) [public abstract fun getTestName(upper: boolean) : java.lang.String = UastEmptyExpression]
+ UParameter (name = upper) [var upper: boolean]
+ UMethod (name = bar) [public fun bar() : void {...}]
+ UBlockExpression [{...}] = Undetermined
+ UDeclarationsExpression [var t1: java.lang.String = getTestName(false)] = Undetermined
+ ULocalVariable (name = t1) [var t1: java.lang.String = getTestName(false)]
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [getTestName(false)] = "lower"
+ UIdentifier (Identifier (getTestName)) [UIdentifier (Identifier (getTestName))]
+ ULiteralExpression (value = false) [false] = false
+ UDeclarationsExpression [var t2: java.lang.String = getTestName(true)] = Undetermined
+ ULocalVariable (name = t2) [var t2: java.lang.String = getTestName(true)]
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [getTestName(true)] = "UPPER"
+ UIdentifier (Identifier (getTestName)) [UIdentifier (Identifier (getTestName))]
+ ULiteralExpression (value = true) [true] = true
diff --git a/uast/uast-tests/java/Simple/External.java b/uast/uast-tests/java/Simple/External.java
new file mode 100644
index 000000000000..42b1b4bee5ec
--- /dev/null
+++ b/uast/uast-tests/java/Simple/External.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+import java.util.LinkedList;
+
+public class External {
+ public static boolean foo() {
+ return new LinkedList() == new LinkedList();
+ }
+
+ public static boolean bar() {
+ List list = new LinkedList();
+ return list == list;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/External.values.txt b/uast/uast-tests/java/Simple/External.values.txt
new file mode 100644
index 000000000000..ae5881ee5965
--- /dev/null
+++ b/uast/uast-tests/java/Simple/External.values.txt
@@ -0,0 +1,21 @@
+UFile (package = ) [import java.util.LinkedList...]
+ UImportStatement (isOnDemand = false) [import java.util.LinkedList]
+ UClass (name = External) [public class External {...}]
+ UMethod (name = foo) [public static fun foo() : boolean {...}]
+ UBlockExpression [{...}] = Nothing
+ UReturnExpression [return LinkedList() === LinkedList()] = Nothing
+ UBinaryExpression (operator = ===) [LinkedList() === LinkedList()] = Undetermined
+ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [LinkedList()] = external LinkedList()()
+ USimpleNameReferenceExpression (identifier = LinkedList) [LinkedList] = external LinkedList()
+ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [LinkedList()] = external LinkedList()()
+ USimpleNameReferenceExpression (identifier = LinkedList) [LinkedList] = external LinkedList()
+ UMethod (name = bar) [public static fun bar() : boolean {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var list: List = LinkedList()] = Undetermined
+ ULocalVariable (name = list) [var list: List = LinkedList()]
+ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [LinkedList()] = external LinkedList()()
+ USimpleNameReferenceExpression (identifier = LinkedList) [LinkedList] = external LinkedList()
+ UReturnExpression [return list === list] = Nothing
+ UBinaryExpression (operator = ===) [list === list] = Undetermined (depending on: (var list = external LinkedList()()))
+ USimpleNameReferenceExpression (identifier = list) [list] = (var list = external LinkedList()())
+ USimpleNameReferenceExpression (identifier = list) [list] = (var list = external LinkedList()())
diff --git a/uast/uast-tests/java/Simple/Field.java b/uast/uast-tests/java/Simple/Field.java
new file mode 100644
index 000000000000..f29d37bcc956
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Field.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Simple {
+ public static String foo = "a";
+}
diff --git a/uast/uast-tests/java/Simple/FieldRef.java b/uast/uast-tests/java/Simple/FieldRef.java
new file mode 100644
index 000000000000..60954fdfc184
--- /dev/null
+++ b/uast/uast-tests/java/Simple/FieldRef.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Foo {
+ public static void bar() {
+ int s = Integer.SIZE;
+ System.out.println(s);
+ }
+}
diff --git a/uast/uast-tests/java/Simple/FieldRef.values.txt b/uast/uast-tests/java/Simple/FieldRef.values.txt
new file mode 100644
index 000000000000..70a313911c62
--- /dev/null
+++ b/uast/uast-tests/java/Simple/FieldRef.values.txt
@@ -0,0 +1,16 @@
+UFile (package = ) [public class Foo {...]
+ UClass (name = Foo) [public class Foo {...}]
+ UMethod (name = bar) [public static fun bar() : void {...}]
+ UBlockExpression [{...}] = external println(s)((var s = 32))
+ UDeclarationsExpression [var s: int = Integer.SIZE] = Undetermined
+ ULocalVariable (name = s) [var s: int = Integer.SIZE]
+ UQualifiedReferenceExpression [Integer.SIZE] = 32
+ USimpleNameReferenceExpression (identifier = Integer) [Integer] = external Integer()
+ USimpleNameReferenceExpression (identifier = SIZE) [SIZE] = 32
+ UQualifiedReferenceExpression [System.out.println(s)] = external println(s)((var s = 32))
+ UQualifiedReferenceExpression [System.out] = Undetermined
+ USimpleNameReferenceExpression (identifier = System) [System] = external System()
+ USimpleNameReferenceExpression (identifier = out) [out] = Undetermined
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [println(s)] = external println(s)((var s = 32))
+ UIdentifier (Identifier (println)) [UIdentifier (Identifier (println))]
+ USimpleNameReferenceExpression (identifier = s) [s] = (var s = 32)
diff --git a/uast/uast-tests/java/Simple/FloatDouble.java b/uast/uast-tests/java/Simple/FloatDouble.java
new file mode 100644
index 000000000000..e66365bdd84e
--- /dev/null
+++ b/uast/uast-tests/java/Simple/FloatDouble.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class FloatDouble {
+ public static double foo() {
+ float f1 = 1.0F;
+ double d2 = 2.0;
+ double d3 = f1 + d2;
+ float f2 = f1 + f1;
+ float f3 = (float) d3;
+ double d1 = (double) f1;
+ return d1 + f1 + f2 + f3;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/FloatDouble.values.txt b/uast/uast-tests/java/Simple/FloatDouble.values.txt
new file mode 100644
index 000000000000..ee1d2a94717c
--- /dev/null
+++ b/uast/uast-tests/java/Simple/FloatDouble.values.txt
@@ -0,0 +1,36 @@
+UFile (package = ) [public class FloatDouble {...]
+ UClass (name = FloatDouble) [public class FloatDouble {...}]
+ UMethod (name = foo) [public static fun foo() : double {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var f1: float = 1.0] = Undetermined
+ ULocalVariable (name = f1) [var f1: float = 1.0]
+ ULiteralExpression (value = 1.0) [1.0] = (float)1.0
+ UDeclarationsExpression [var d2: double = 2.0] = Undetermined
+ ULocalVariable (name = d2) [var d2: double = 2.0]
+ ULiteralExpression (value = 2.0) [2.0] = 2.0
+ UDeclarationsExpression [var d3: double = f1 + d2] = Undetermined
+ ULocalVariable (name = d3) [var d3: double = f1 + d2]
+ UBinaryExpression (operator = +) [f1 + d2] = 3.0 (depending on: (var f1 = (float)1.0), (var d2 = 2.0))
+ USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0)
+ USimpleNameReferenceExpression (identifier = d2) [d2] = (var d2 = 2.0)
+ UDeclarationsExpression [var f2: float = f1 + f1] = Undetermined
+ ULocalVariable (name = f2) [var f2: float = f1 + f1]
+ UBinaryExpression (operator = +) [f1 + f1] = (float)2.0 (depending on: (var f1 = (float)1.0))
+ USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0)
+ USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0)
+ UDeclarationsExpression [var f3: float = d3 as float] = Undetermined
+ ULocalVariable (name = f3) [var f3: float = d3 as float]
+ UBinaryExpressionWithType [d3 as float] = (float)3.0
+ USimpleNameReferenceExpression (identifier = d3) [d3] = (var d3 = 3.0 (depending on: (var f1 = (float)1.0), (var d2 = 2.0)))
+ UTypeReferenceExpression (name = float) [float] = Undetermined
+ UDeclarationsExpression [var d1: double = f1 as double] = Undetermined
+ ULocalVariable (name = d1) [var d1: double = f1 as double]
+ UBinaryExpressionWithType [f1 as double] = 1.0
+ USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0)
+ UTypeReferenceExpression (name = double) [double] = Undetermined
+ UReturnExpression [return d1 + f1 + f2 + f3] = Nothing
+ UPolyadicExpression (operator = +) [d1 + f1 + f2 + f3] = 7.0 (depending on: (var d1 = 1.0), (var f1 = (float)1.0), (var f2 = (float)2.0 (depending on: (var f1 = (float)1.0))), (var f3 = (float)3.0))
+ USimpleNameReferenceExpression (identifier = d1) [d1] = (var d1 = 1.0)
+ USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0)
+ USimpleNameReferenceExpression (identifier = f2) [f2] = (var f2 = (float)2.0 (depending on: (var f1 = (float)1.0)))
+ USimpleNameReferenceExpression (identifier = f3) [f3] = (var f3 = (float)3.0)
diff --git a/uast/uast-tests/java/Simple/For.java b/uast/uast-tests/java/Simple/For.java
new file mode 100644
index 000000000000..890908365954
--- /dev/null
+++ b/uast/uast-tests/java/Simple/For.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class For {
+ public static int foo() {
+ int result = 0;
+ for (int i = 0; i < 10; i++) {
+ result = result + i;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/For.values.txt b/uast/uast-tests/java/Simple/For.values.txt
new file mode 100644
index 000000000000..23f047977deb
--- /dev/null
+++ b/uast/uast-tests/java/Simple/For.values.txt
@@ -0,0 +1,24 @@
+UFile (package = ) [public class For {...]
+ UClass (name = For) [public class For {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: int = 0] = Undetermined
+ ULocalVariable (name = result) [var result: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UForExpression [for (var i: int = 0; i < 10; i++) {...}] = Undetermined
+ UDeclarationsExpression [var i: int = 0] = Undetermined
+ ULocalVariable (name = i) [var i: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UBinaryExpression (operator = <) [i < 10] = Undetermined
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ ULiteralExpression (value = 10) [10] = 10
+ UPostfixExpression (operator = ++) [i++] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ UBlockExpression [{...}] = Undetermined
+ UBinaryExpression (operator = =) [result = result + i] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0))
+ UBinaryExpression (operator = +) [result + i] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0))
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0))
diff --git a/uast/uast-tests/java/Simple/ForEach.java b/uast/uast-tests/java/Simple/ForEach.java
new file mode 100644
index 000000000000..da4089f53351
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ForEach.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class For {
+ public static int sum(List numbers) {
+ int result = 0;
+ for (int number: numbers) {
+ result = result + number;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/ForEach.values.txt b/uast/uast-tests/java/Simple/ForEach.values.txt
new file mode 100644
index 000000000000..9de4c4192e3b
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ForEach.values.txt
@@ -0,0 +1,18 @@
+UFile (package = ) [public class For {...]
+ UClass (name = For) [public class For {...}]
+ UMethod (name = sum) [public static fun sum(numbers: List) : int {...}]
+ UParameter (name = numbers) [var numbers: List]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: int = 0] = Undetermined
+ ULocalVariable (name = result) [var result: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UForEachExpression [for (number : numbers) {...}] = Undetermined
+ USimpleNameReferenceExpression (identifier = numbers) [numbers] = Undetermined
+ UBlockExpression [{...}] = Undetermined
+ UBinaryExpression (operator = =) [result = result + number] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0))
+ UBinaryExpression (operator = +) [result + number] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0))
+ USimpleNameReferenceExpression (identifier = number) [number] = Undetermined
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0))
diff --git a/uast/uast-tests/java/Simple/ForEachMutableIterable.java b/uast/uast-tests/java/Simple/ForEachMutableIterable.java
new file mode 100644
index 000000000000..bec500fa634d
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ForEachMutableIterable.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+import java.util.*;
+
+public class For {
+
+ public static List getList(int size) {
+ List result = new LinkedList();
+ int a = 0;
+ for (int i = a++; i < size; i++) {
+ result.add(i);
+ }
+ result.add(a);
+ return result;
+ }
+
+ public static int sum(List numbers) {
+ int result = 0;
+ int size = 3;
+ for (int number: getList(++size)) {
+ result = result + number;
+ }
+ return result + size;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/ForEachMutableIterable.values.txt b/uast/uast-tests/java/Simple/ForEachMutableIterable.values.txt
new file mode 100644
index 000000000000..11b4815d6d7d
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ForEachMutableIterable.values.txt
@@ -0,0 +1,60 @@
+UFile (package = ) [import java.util...]
+ UImportStatement (isOnDemand = true) [import java.util]
+ UClass (name = For) [public class For {...}]
+ UMethod (name = getList) [public static fun getList(size: int) : java.util.List {...}]
+ UParameter (name = size) [var size: int]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: java.util.List = LinkedList()] = Undetermined
+ ULocalVariable (name = result) [var result: java.util.List = LinkedList()]
+ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [LinkedList()] = external LinkedList()()
+ USimpleNameReferenceExpression (identifier = LinkedList) [LinkedList] = external LinkedList()
+ UDeclarationsExpression [var a: int = 0] = Undetermined
+ ULocalVariable (name = a) [var a: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UForExpression [for (var i: int = a++; i < size; i++) {...}] = Undetermined
+ UDeclarationsExpression [var i: int = a++] = Undetermined
+ ULocalVariable (name = i) [var i: int = a++]
+ UPostfixExpression (operator = ++) [a++] = (var a = 0)
+ USimpleNameReferenceExpression (identifier = a) [a] = (var a = 0)
+ UBinaryExpression (operator = <) [i < size] = Undetermined
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0)))
+ USimpleNameReferenceExpression (identifier = size) [size] = Undetermined
+ UPostfixExpression (operator = ++) [i++] = Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0)))
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0)))
+ UBlockExpression [{...}] = external add(i)(Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0))))
+ UQualifiedReferenceExpression [result.add(i)] = external add(i)(Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0))))
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = external LinkedList()())
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [add(i)] = external add(i)(Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0))))
+ UIdentifier (Identifier (add)) [UIdentifier (Identifier (add))]
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0)))
+ UQualifiedReferenceExpression [result.add(a)] = external add(a)((var a = 1))
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = external LinkedList()())
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [add(a)] = external add(a)((var a = 1))
+ UIdentifier (Identifier (add)) [UIdentifier (Identifier (add))]
+ USimpleNameReferenceExpression (identifier = a) [a] = (var a = 1)
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = (var result = external LinkedList()())
+ UMethod (name = sum) [public static fun sum(numbers: java.util.List) : int {...}]
+ UParameter (name = numbers) [var numbers: java.util.List]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: int = 0] = Undetermined
+ ULocalVariable (name = result) [var result: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UDeclarationsExpression [var size: int = 3] = Undetermined
+ ULocalVariable (name = size) [var size: int = 3]
+ ULiteralExpression (value = 3) [3] = 3
+ UForEachExpression [for (number : getList(++size)) {...}] = Undetermined
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [getList(++size)] = external getList(++size)(4 (depending on: (var size = 3)))
+ UIdentifier (Identifier (getList)) [UIdentifier (Identifier (getList))]
+ UPrefixExpression (operator = ++) [++size] = 4 (depending on: (var size = 3))
+ USimpleNameReferenceExpression (identifier = size) [size] = (var size = 3)
+ UBlockExpression [{...}] = Undetermined
+ UBinaryExpression (operator = =) [result = result + number] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0))
+ UBinaryExpression (operator = +) [result + number] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0))
+ USimpleNameReferenceExpression (identifier = number) [number] = Undetermined
+ UReturnExpression [return result + size] = Nothing
+ UBinaryExpression (operator = +) [result + size] = Undetermined (depending on: (var size = 4))
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0))
+ USimpleNameReferenceExpression (identifier = size) [size] = (var size = 4)
diff --git a/uast/uast-tests/java/Simple/IdentityEquals.java b/uast/uast-tests/java/Simple/IdentityEquals.java
new file mode 100644
index 000000000000..4a1661cd7ec7
--- /dev/null
+++ b/uast/uast-tests/java/Simple/IdentityEquals.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class IdentityEquals {
+ public static boolean foo() {
+ Integer i1 = 111;
+ Integer i2 = 222;
+ Integer i12 = i1 + i2;
+ Integer i21 = i2 + i1;
+ return i12 == i21;
+ }
+
+ public static boolean bar() {
+ String s1 = "hello";
+ String s2 = s1 + s1;
+ String s3 = "hellohello";
+ return s2 == s3;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/IdentityEquals.values.txt b/uast/uast-tests/java/Simple/IdentityEquals.values.txt
new file mode 100644
index 000000000000..893208fe9337
--- /dev/null
+++ b/uast/uast-tests/java/Simple/IdentityEquals.values.txt
@@ -0,0 +1,41 @@
+UFile (package = ) [public class IdentityEquals {...]
+ UClass (name = IdentityEquals) [public class IdentityEquals {...}]
+ UMethod (name = foo) [public static fun foo() : boolean {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var i1: java.lang.Integer = 111] = Undetermined
+ ULocalVariable (name = i1) [var i1: java.lang.Integer = 111]
+ ULiteralExpression (value = 111) [111] = 111
+ UDeclarationsExpression [var i2: java.lang.Integer = 222] = Undetermined
+ ULocalVariable (name = i2) [var i2: java.lang.Integer = 222]
+ ULiteralExpression (value = 222) [222] = 222
+ UDeclarationsExpression [var i12: java.lang.Integer = i1 + i2] = Undetermined
+ ULocalVariable (name = i12) [var i12: java.lang.Integer = i1 + i2]
+ UBinaryExpression (operator = +) [i1 + i2] = 333 (depending on: (var i1 = 111), (var i2 = 222))
+ USimpleNameReferenceExpression (identifier = i1) [i1] = (var i1 = 111)
+ USimpleNameReferenceExpression (identifier = i2) [i2] = (var i2 = 222)
+ UDeclarationsExpression [var i21: java.lang.Integer = i2 + i1] = Undetermined
+ ULocalVariable (name = i21) [var i21: java.lang.Integer = i2 + i1]
+ UBinaryExpression (operator = +) [i2 + i1] = 333 (depending on: (var i2 = 222), (var i1 = 111))
+ USimpleNameReferenceExpression (identifier = i2) [i2] = (var i2 = 222)
+ USimpleNameReferenceExpression (identifier = i1) [i1] = (var i1 = 111)
+ UReturnExpression [return i12 === i21] = Nothing
+ UBinaryExpression (operator = ===) [i12 === i21] = Undetermined
+ USimpleNameReferenceExpression (identifier = i12) [i12] = (var i12 = 333 (depending on: (var i1 = 111), (var i2 = 222)))
+ USimpleNameReferenceExpression (identifier = i21) [i21] = (var i21 = 333 (depending on: (var i2 = 222), (var i1 = 111)))
+ UMethod (name = bar) [public static fun bar() : boolean {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var s1: java.lang.String = "hello"] = Undetermined
+ ULocalVariable (name = s1) [var s1: java.lang.String = "hello"]
+ ULiteralExpression (value = "hello") ["hello"] = "hello"
+ UDeclarationsExpression [var s2: java.lang.String = s1 + s1] = Undetermined
+ ULocalVariable (name = s2) [var s2: java.lang.String = s1 + s1]
+ UBinaryExpression (operator = +) [s1 + s1] = "hellohello" (depending on: (var s1 = "hello"))
+ USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "hello")
+ USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "hello")
+ UDeclarationsExpression [var s3: java.lang.String = "hellohello"] = Undetermined
+ ULocalVariable (name = s3) [var s3: java.lang.String = "hellohello"]
+ ULiteralExpression (value = "hellohello") ["hellohello"] = "hellohello"
+ UReturnExpression [return s2 === s3] = Nothing
+ UBinaryExpression (operator = ===) [s2 === s3] = Undetermined
+ USimpleNameReferenceExpression (identifier = s2) [s2] = (var s2 = "hellohello" (depending on: (var s1 = "hello")))
+ USimpleNameReferenceExpression (identifier = s3) [s3] = (var s3 = "hellohello")
diff --git a/uast/uast-tests/java/Simple/ImmutableField.java b/uast/uast-tests/java/Simple/ImmutableField.java
new file mode 100644
index 000000000000..243b610d65fa
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ImmutableField.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class ImmutableField {
+ final int immutable;
+
+ public ImmutableField() {
+ immutable = 1;
+ bar(immutable);
+ bar(immutable);
+ }
+
+ public static int bar(int arg) {
+ return arg;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/ImmutableField.values.txt b/uast/uast-tests/java/Simple/ImmutableField.values.txt
new file mode 100644
index 000000000000..66381b3068b8
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ImmutableField.values.txt
@@ -0,0 +1,19 @@
+UFile (package = ) [public class ImmutableField {...]
+ UClass (name = ImmutableField) [public class ImmutableField {...}]
+ UField (name = immutable) [final var immutable: int]
+ UMethod (name = ImmutableField) [public fun ImmutableField() {...}]
+ UBlockExpression [{...}] = external bar(immutable)((var immutable = 1))
+ UBinaryExpression (operator = =) [immutable = 1] = 1
+ USimpleNameReferenceExpression (identifier = immutable) [immutable] = Undetermined
+ ULiteralExpression (value = 1) [1] = 1
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [bar(immutable)] = external bar(immutable)((var immutable = 1))
+ UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))]
+ USimpleNameReferenceExpression (identifier = immutable) [immutable] = (var immutable = 1)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [bar(immutable)] = external bar(immutable)((var immutable = 1))
+ UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))]
+ USimpleNameReferenceExpression (identifier = immutable) [immutable] = (var immutable = 1)
+ UMethod (name = bar) [public static fun bar(arg: int) : int {...}]
+ UParameter (name = arg) [var arg: int]
+ UBlockExpression [{...}] = Nothing
+ UReturnExpression [return arg] = Nothing
+ USimpleNameReferenceExpression (identifier = arg) [arg] = Undetermined
diff --git a/uast/uast-tests/java/Simple/IncDec.java b/uast/uast-tests/java/Simple/IncDec.java
new file mode 100644
index 000000000000..3706f0386acf
--- /dev/null
+++ b/uast/uast-tests/java/Simple/IncDec.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class IncDec {
+ public static int foo() {
+ int i1 = 1; // 1
+ int i2 = ++i1; // 2, 2
+ int i3 = i2++; // 2, 3
+ int i4 = --i3; // 1, 1
+ int i5 = i4--; // 1, 0
+ return i4 + i5;// 1
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/IncDec.values.txt b/uast/uast-tests/java/Simple/IncDec.values.txt
new file mode 100644
index 000000000000..a59a78c6b32f
--- /dev/null
+++ b/uast/uast-tests/java/Simple/IncDec.values.txt
@@ -0,0 +1,27 @@
+UFile (package = ) [public class IncDec {...]
+ UClass (name = IncDec) [public class IncDec {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var i1: int = 1] = Undetermined
+ ULocalVariable (name = i1) [var i1: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var i2: int = ++i1] = Undetermined
+ ULocalVariable (name = i2) [var i2: int = ++i1]
+ UPrefixExpression (operator = ++) [++i1] = 2 (depending on: (var i1 = 1))
+ USimpleNameReferenceExpression (identifier = i1) [i1] = (var i1 = 1)
+ UDeclarationsExpression [var i3: int = i2++] = Undetermined
+ ULocalVariable (name = i3) [var i3: int = i2++]
+ UPostfixExpression (operator = ++) [i2++] = (var i2 = 2 (depending on: (var i1 = 1)))
+ USimpleNameReferenceExpression (identifier = i2) [i2] = (var i2 = 2 (depending on: (var i1 = 1)))
+ UDeclarationsExpression [var i4: int = --i3] = Undetermined
+ ULocalVariable (name = i4) [var i4: int = --i3]
+ UPrefixExpression (operator = --) [--i3] = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1)))))
+ USimpleNameReferenceExpression (identifier = i3) [i3] = (var i3 = (var i2 = 2 (depending on: (var i1 = 1))))
+ UDeclarationsExpression [var i5: int = i4--] = Undetermined
+ ULocalVariable (name = i5) [var i5: int = i4--]
+ UPostfixExpression (operator = --) [i4--] = (var i4 = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1))))))
+ USimpleNameReferenceExpression (identifier = i4) [i4] = (var i4 = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1))))))
+ UReturnExpression [return i4 + i5] = Nothing
+ UBinaryExpression (operator = +) [i4 + i5] = 1 (depending on: (var i4 = 0), (var i5 = (var i4 = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1))))))))
+ USimpleNameReferenceExpression (identifier = i4) [i4] = (var i4 = 0)
+ USimpleNameReferenceExpression (identifier = i5) [i5] = (var i5 = (var i4 = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1)))))))
diff --git a/uast/uast-tests/java/Simple/IntLong.java b/uast/uast-tests/java/Simple/IntLong.java
new file mode 100644
index 000000000000..c092f0fe0952
--- /dev/null
+++ b/uast/uast-tests/java/Simple/IntLong.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class IntLong {
+ public static long foo() {
+ int one = 1;
+ int two = one + one;
+ int four = two * two;
+ int sixteen = four * four;
+ int twoPowerEight = sixteen * sixteen;
+ int twoPowerSixteen = twoPowerEight * twoPowerEight;
+ int twoPowerTwentyFour = twoPowerSixteen * twoPowerEight;
+ int twoPowerThirtyTwo = twoPowerSixteen * twoPowerSixteen;
+
+ long twoPowerFourty = ((long) twoPowerSixteen) * ((long) twoPowerTwentyFour);
+ long eight = 8L;
+ long twoPowerFourtyThree = twoPowerFourty * eight;
+ long twoPowerFourtyEight = twoPowerFourty * twoPowerEight;
+ long twoPowerFiftySix = twoPowerEight * twoPowerFourty;
+ return twoPowerFiftySix;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/IntLong.values.txt b/uast/uast-tests/java/Simple/IntLong.values.txt
new file mode 100644
index 000000000000..f88de3aac911
--- /dev/null
+++ b/uast/uast-tests/java/Simple/IntLong.values.txt
@@ -0,0 +1,73 @@
+UFile (package = ) [public class IntLong {...]
+ UClass (name = IntLong) [public class IntLong {...}]
+ UMethod (name = foo) [public static fun foo() : long {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var one: int = 1] = Undetermined
+ ULocalVariable (name = one) [var one: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var two: int = one + one] = Undetermined
+ ULocalVariable (name = two) [var two: int = one + one]
+ UBinaryExpression (operator = +) [one + one] = 2 (depending on: (var one = 1))
+ USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1)
+ USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1)
+ UDeclarationsExpression [var four: int = two * two] = Undetermined
+ ULocalVariable (name = four) [var four: int = two * two]
+ UBinaryExpression (operator = *) [two * two] = 4 (depending on: (var two = 2 (depending on: (var one = 1))))
+ USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2 (depending on: (var one = 1)))
+ USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2 (depending on: (var one = 1)))
+ UDeclarationsExpression [var sixteen: int = four * four] = Undetermined
+ ULocalVariable (name = sixteen) [var sixteen: int = four * four]
+ UBinaryExpression (operator = *) [four * four] = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))
+ USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))
+ USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))
+ UDeclarationsExpression [var twoPowerEight: int = sixteen * sixteen] = Undetermined
+ ULocalVariable (name = twoPowerEight) [var twoPowerEight: int = sixteen * sixteen]
+ UBinaryExpression (operator = *) [sixteen * sixteen] = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))
+ USimpleNameReferenceExpression (identifier = sixteen) [sixteen] = (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))
+ USimpleNameReferenceExpression (identifier = sixteen) [sixteen] = (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))
+ UDeclarationsExpression [var twoPowerSixteen: int = twoPowerEight * twoPowerEight] = Undetermined
+ ULocalVariable (name = twoPowerSixteen) [var twoPowerSixteen: int = twoPowerEight * twoPowerEight]
+ UBinaryExpression (operator = *) [twoPowerEight * twoPowerEight] = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))
+ USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))
+ USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))
+ UDeclarationsExpression [var twoPowerTwentyFour: int = twoPowerSixteen * twoPowerEight] = Undetermined
+ ULocalVariable (name = twoPowerTwentyFour) [var twoPowerTwentyFour: int = twoPowerSixteen * twoPowerEight]
+ UBinaryExpression (operator = *) [twoPowerSixteen * twoPowerEight] = 16777216 (depending on: (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))), (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))
+ USimpleNameReferenceExpression (identifier = twoPowerSixteen) [twoPowerSixteen] = (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))))
+ USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))
+ UDeclarationsExpression [var twoPowerThirtyTwo: int = twoPowerSixteen * twoPowerSixteen] = Undetermined
+ ULocalVariable (name = twoPowerThirtyTwo) [var twoPowerThirtyTwo: int = twoPowerSixteen * twoPowerSixteen]
+ UBinaryExpression (operator = *) [twoPowerSixteen * twoPowerSixteen] = 0 (depending on: (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))))
+ USimpleNameReferenceExpression (identifier = twoPowerSixteen) [twoPowerSixteen] = (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))))
+ USimpleNameReferenceExpression (identifier = twoPowerSixteen) [twoPowerSixteen] = (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))))
+ UDeclarationsExpression [var twoPowerFourty: long = (twoPowerSixteen as long) * (twoPowerTwentyFour as long)] = Undetermined
+ ULocalVariable (name = twoPowerFourty) [var twoPowerFourty: long = (twoPowerSixteen as long) * (twoPowerTwentyFour as long)]
+ UBinaryExpression (operator = *) [(twoPowerSixteen as long) * (twoPowerTwentyFour as long)] = (long)1099511627776
+ UParenthesizedExpression [(twoPowerSixteen as long)] = (long)65536
+ UBinaryExpressionWithType [twoPowerSixteen as long] = (long)65536
+ USimpleNameReferenceExpression (identifier = twoPowerSixteen) [twoPowerSixteen] = (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))))
+ UTypeReferenceExpression (name = long) [long] = Undetermined
+ UParenthesizedExpression [(twoPowerTwentyFour as long)] = (long)16777216
+ UBinaryExpressionWithType [twoPowerTwentyFour as long] = (long)16777216
+ USimpleNameReferenceExpression (identifier = twoPowerTwentyFour) [twoPowerTwentyFour] = (var twoPowerTwentyFour = 16777216 (depending on: (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))), (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))))
+ UTypeReferenceExpression (name = long) [long] = Undetermined
+ UDeclarationsExpression [var eight: long = 8] = Undetermined
+ ULocalVariable (name = eight) [var eight: long = 8]
+ ULiteralExpression (value = 8) [8] = (long)8
+ UDeclarationsExpression [var twoPowerFourtyThree: long = twoPowerFourty * eight] = Undetermined
+ ULocalVariable (name = twoPowerFourtyThree) [var twoPowerFourtyThree: long = twoPowerFourty * eight]
+ UBinaryExpression (operator = *) [twoPowerFourty * eight] = (long)8796093022208 (depending on: (var twoPowerFourty = (long)1099511627776), (var eight = (long)8))
+ USimpleNameReferenceExpression (identifier = twoPowerFourty) [twoPowerFourty] = (var twoPowerFourty = (long)1099511627776)
+ USimpleNameReferenceExpression (identifier = eight) [eight] = (var eight = (long)8)
+ UDeclarationsExpression [var twoPowerFourtyEight: long = twoPowerFourty * twoPowerEight] = Undetermined
+ ULocalVariable (name = twoPowerFourtyEight) [var twoPowerFourtyEight: long = twoPowerFourty * twoPowerEight]
+ UBinaryExpression (operator = *) [twoPowerFourty * twoPowerEight] = (long)281474976710656 (depending on: (var twoPowerFourty = (long)1099511627776), (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))
+ USimpleNameReferenceExpression (identifier = twoPowerFourty) [twoPowerFourty] = (var twoPowerFourty = (long)1099511627776)
+ USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))
+ UDeclarationsExpression [var twoPowerFiftySix: long = twoPowerEight * twoPowerFourty] = Undetermined
+ ULocalVariable (name = twoPowerFiftySix) [var twoPowerFiftySix: long = twoPowerEight * twoPowerFourty]
+ UBinaryExpression (operator = *) [twoPowerEight * twoPowerFourty] = (long)281474976710656 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))), (var twoPowerFourty = (long)1099511627776))
+ USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))
+ USimpleNameReferenceExpression (identifier = twoPowerFourty) [twoPowerFourty] = (var twoPowerFourty = (long)1099511627776)
+ UReturnExpression [return twoPowerFiftySix] = Nothing
+ USimpleNameReferenceExpression (identifier = twoPowerFiftySix) [twoPowerFiftySix] = (var twoPowerFiftySix = (long)281474976710656 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))), (var twoPowerFourty = (long)1099511627776)))
diff --git a/uast/uast-tests/java/Simple/Labeled.java b/uast/uast-tests/java/Simple/Labeled.java
new file mode 100644
index 000000000000..98a142acba67
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Labeled.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Labeled {
+ public static int foo() {
+ int first = 1;
+ int second = 2;
+
+ labeled: while (true) {
+ second = 3;
+ if (first > 0) break labeled;
+ }
+
+ return second;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Labeled.values.txt b/uast/uast-tests/java/Simple/Labeled.values.txt
new file mode 100644
index 000000000000..e0fa02bda527
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Labeled.values.txt
@@ -0,0 +1,25 @@
+UFile (package = ) [public class Labeled {...]
+ UClass (name = Labeled) [public class Labeled {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var first: int = 1] = Undetermined
+ ULocalVariable (name = first) [var first: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var second: int = 2] = Undetermined
+ ULocalVariable (name = second) [var second: int = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ ULabeledExpression (label = labeled) [labeled@ while (true) {...}] = Undetermined
+ UWhileExpression [while (true) {...}] = Undetermined
+ ULiteralExpression (value = true) [true] = true
+ UBlockExpression [{...}] = Nothing(break)
+ UBinaryExpression (operator = =) [second = 3] = 3
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 2)
+ ULiteralExpression (value = 3) [3] = 3
+ UIfExpression [if (first > 0) break@labeled] = Nothing(break)
+ UBinaryExpression (operator = >) [first > 0] = true (depending on: (var first = 1))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1)
+ ULiteralExpression (value = 0) [0] = 0
+ UBreakExpression (label = labeled) [break@labeled] = Nothing(break)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UReturnExpression [return second] = Nothing
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 3)
diff --git a/uast/uast-tests/java/Simple/LabeledOuter.java b/uast/uast-tests/java/Simple/LabeledOuter.java
new file mode 100644
index 000000000000..7fdd00fcbb86
--- /dev/null
+++ b/uast/uast-tests/java/Simple/LabeledOuter.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class LabeledOuter {
+ public static int foo() {
+
+ int second = 2;
+ labeled: for (int first = 1; first < 4; first++) {
+ while (second < 10) {
+ second = 3;
+ if (first > 0) break labeled;
+ }
+ second = 4;
+ }
+
+ return second;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/LabeledOuter.values.txt b/uast/uast-tests/java/Simple/LabeledOuter.values.txt
new file mode 100644
index 000000000000..f9fba44b5ce0
--- /dev/null
+++ b/uast/uast-tests/java/Simple/LabeledOuter.values.txt
@@ -0,0 +1,37 @@
+UFile (package = ) [public class LabeledOuter {...]
+ UClass (name = LabeledOuter) [public class LabeledOuter {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var second: int = 2] = Undetermined
+ ULocalVariable (name = second) [var second: int = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ ULabeledExpression (label = labeled) [labeled@ for (var first: int = 1; first < 4; first++) {...}] = Undetermined
+ UForExpression [for (var first: int = 1; first < 4; first++) {...}] = Undetermined
+ UDeclarationsExpression [var first: int = 1] = Undetermined
+ ULocalVariable (name = first) [var first: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UBinaryExpression (operator = <) [first < 4] = true (depending on: (var first = 1))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1)
+ ULiteralExpression (value = 4) [4] = 4
+ UPostfixExpression (operator = ++) [first++] = Undetermined
+ USimpleNameReferenceExpression (identifier = first) [first] = Undetermined
+ UBlockExpression [{...}] = Nothing(break)
+ UWhileExpression [while (second < 10) {...}] = Nothing(break)
+ UBinaryExpression (operator = <) [second < 10] = true (depending on: (var second = 2))
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 2)
+ ULiteralExpression (value = 10) [10] = 10
+ UBlockExpression [{...}] = Nothing(break)
+ UBinaryExpression (operator = =) [second = 3] = 3
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 2)
+ ULiteralExpression (value = 3) [3] = 3
+ UIfExpression [if (first > 0) break@labeled] = Nothing(break)
+ UBinaryExpression (operator = >) [first > 0] = true (depending on: (var first = 1))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1)
+ ULiteralExpression (value = 0) [0] = 0
+ UBreakExpression (label = labeled) [break@labeled] = Nothing(break)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UBinaryExpression (operator = =) [second = 4] = 4
+ USimpleNameReferenceExpression (identifier = second) [second] = Undetermined
+ ULiteralExpression (value = 4) [4] = 4
+ UReturnExpression [return second] = Nothing
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 3)
diff --git a/uast/uast-tests/java/Simple/Lambda.java b/uast/uast-tests/java/Simple/Lambda.java
new file mode 100644
index 000000000000..73132ada0cd8
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Lambda.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Lambda {
+ public static int foo() {
+ int variable = 42;
+
+ Runnable runnable = () -> {
+ int variable1 = 24;
+ variable1++;
+ };
+ runnable.run();
+
+ return variable;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Lambda.values.txt b/uast/uast-tests/java/Simple/Lambda.values.txt
new file mode 100644
index 000000000000..24ffdef44238
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Lambda.values.txt
@@ -0,0 +1,22 @@
+UFile (package = ) [public class Lambda {...]
+ UClass (name = Lambda) [public class Lambda {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var variable: int = 42] = Undetermined
+ ULocalVariable (name = variable) [var variable: int = 42]
+ ULiteralExpression (value = 42) [42] = 42
+ UDeclarationsExpression [var runnable: java.lang.Runnable = { {...}] = Undetermined
+ ULocalVariable (name = runnable) [var runnable: java.lang.Runnable = { {...}]
+ ULambdaExpression [{ {...}] = Undetermined
+ UBlockExpression [{...}] = (var variable1 = 24)
+ UDeclarationsExpression [var variable1: int = 24] = Undetermined
+ ULocalVariable (name = variable1) [var variable1: int = 24]
+ ULiteralExpression (value = 24) [24] = 24
+ UPostfixExpression (operator = ++) [variable1++] = (var variable1 = 24)
+ USimpleNameReferenceExpression (identifier = variable1) [variable1] = (var variable1 = 24)
+ UQualifiedReferenceExpression [runnable.run()] = external run()()
+ USimpleNameReferenceExpression (identifier = runnable) [runnable] = (var runnable = Undetermined)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [run()] = external run()()
+ UIdentifier (Identifier (run)) [UIdentifier (Identifier (run))]
+ UReturnExpression [return variable] = Nothing
+ USimpleNameReferenceExpression (identifier = variable) [variable] = (var variable = 42)
diff --git a/uast/uast-tests/java/Simple/LocalClass.java b/uast/uast-tests/java/Simple/LocalClass.java
new file mode 100644
index 000000000000..bbde570f9b60
--- /dev/null
+++ b/uast/uast-tests/java/Simple/LocalClass.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class LocalClass {
+ public static int foo() {
+
+ class Local {};
+
+ return new Local().hashCode();
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/LocalClass.log.txt b/uast/uast-tests/java/Simple/LocalClass.log.txt
new file mode 100644
index 000000000000..ea3fbc4c0482
--- /dev/null
+++ b/uast/uast-tests/java/Simple/LocalClass.log.txt
@@ -0,0 +1,13 @@
+UFile (package = )
+ UClass (name = LocalClass)
+ UMethod (name = foo)
+ UBlockExpression
+ UDeclarationsExpression
+ UClass (name = Local)
+ UastEmptyExpression
+ UReturnExpression
+ UQualifiedReferenceExpression
+ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
+ USimpleNameReferenceExpression (identifier = Local)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
+ UIdentifier (Identifier (hashCode))
diff --git a/uast/uast-tests/java/Simple/LocalClass.render.txt b/uast/uast-tests/java/Simple/LocalClass.render.txt
new file mode 100644
index 000000000000..cbafd0e13e3c
--- /dev/null
+++ b/uast/uast-tests/java/Simple/LocalClass.render.txt
@@ -0,0 +1,8 @@
+public class LocalClass {
+ public static fun foo() : int {
+ class Local {
+ }
+ UastEmptyExpression
+ return Local().hashCode()
+ }
+}
diff --git a/uast/uast-tests/java/Simple/Logicals.java b/uast/uast-tests/java/Simple/Logicals.java
new file mode 100644
index 000000000000..13cb161cc8b8
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Logicals.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Logicals {
+ public static boolean foo() {
+ int one = 1;
+ int two = 2;
+ int three = 3;
+ int four = 4;
+ boolean b1 = two > one && four > three;
+ boolean b2 = one > two && four > three;
+ boolean b3 = b1 || b2;
+ boolean b4 = two > one || three > four;
+ return b1 && !b2 && b3 && b4;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Logicals.values.txt b/uast/uast-tests/java/Simple/Logicals.values.txt
new file mode 100644
index 000000000000..ac9f049a7a3d
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Logicals.values.txt
@@ -0,0 +1,55 @@
+UFile (package = ) [public class Logicals {...]
+ UClass (name = Logicals) [public class Logicals {...}]
+ UMethod (name = foo) [public static fun foo() : boolean {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var one: int = 1] = Undetermined
+ ULocalVariable (name = one) [var one: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var two: int = 2] = Undetermined
+ ULocalVariable (name = two) [var two: int = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ UDeclarationsExpression [var three: int = 3] = Undetermined
+ ULocalVariable (name = three) [var three: int = 3]
+ ULiteralExpression (value = 3) [3] = 3
+ UDeclarationsExpression [var four: int = 4] = Undetermined
+ ULocalVariable (name = four) [var four: int = 4]
+ ULiteralExpression (value = 4) [4] = 4
+ UDeclarationsExpression [var b1: boolean = two > one && four > three] = Undetermined
+ ULocalVariable (name = b1) [var b1: boolean = two > one && four > three]
+ UBinaryExpression (operator = &&) [two > one && four > three] = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))
+ UBinaryExpression (operator = >) [two > one] = true (depending on: (var two = 2), (var one = 1))
+ USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2)
+ USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1)
+ UBinaryExpression (operator = >) [four > three] = true (depending on: (var four = 4), (var three = 3))
+ USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4)
+ USimpleNameReferenceExpression (identifier = three) [three] = (var three = 3)
+ UDeclarationsExpression [var b2: boolean = one > two && four > three] = Undetermined
+ ULocalVariable (name = b2) [var b2: boolean = one > two && four > three]
+ UBinaryExpression (operator = &&) [one > two && four > three] = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))
+ UBinaryExpression (operator = >) [one > two] = false (depending on: (var one = 1), (var two = 2))
+ USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1)
+ USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2)
+ UBinaryExpression (operator = >) [four > three] = true (depending on: (var four = 4), (var three = 3))
+ USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4)
+ USimpleNameReferenceExpression (identifier = three) [three] = (var three = 3)
+ UDeclarationsExpression [var b3: boolean = b1 || b2] = Undetermined
+ ULocalVariable (name = b3) [var b3: boolean = b1 || b2]
+ UBinaryExpression (operator = ||) [b1 || b2] = true (depending on: (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))), (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))))
+ USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3)))
+ USimpleNameReferenceExpression (identifier = b2) [b2] = (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3)))
+ UDeclarationsExpression [var b4: boolean = two > one || three > four] = Undetermined
+ ULocalVariable (name = b4) [var b4: boolean = two > one || three > four]
+ UBinaryExpression (operator = ||) [two > one || three > four] = true (depending on: (var two = 2), (var one = 1), (var three = 3), (var four = 4))
+ UBinaryExpression (operator = >) [two > one] = true (depending on: (var two = 2), (var one = 1))
+ USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2)
+ USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1)
+ UBinaryExpression (operator = >) [three > four] = false (depending on: (var three = 3), (var four = 4))
+ USimpleNameReferenceExpression (identifier = three) [three] = (var three = 3)
+ USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4)
+ UReturnExpression [return b1 && !b2 && b3 && b4] = Nothing
+ UPolyadicExpression (operator = &&) [b1 && !b2 && b3 && b4] = true (depending on: (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))), (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))), (var b3 = true (depending on: (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))), (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))))), (var b4 = true (depending on: (var two = 2), (var one = 1), (var three = 3), (var four = 4))))
+ USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3)))
+ UPrefixExpression (operator = !) [!b2] = true (depending on: (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))))
+ USimpleNameReferenceExpression (identifier = b2) [b2] = (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3)))
+ USimpleNameReferenceExpression (identifier = b3) [b3] = (var b3 = true (depending on: (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))), (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3)))))
+ USimpleNameReferenceExpression (identifier = b4) [b4] = (var b4 = true (depending on: (var two = 2), (var one = 1), (var three = 3), (var four = 4)))
diff --git a/uast/uast-tests/java/Simple/MethodReference.java b/uast/uast-tests/java/Simple/MethodReference.java
new file mode 100644
index 000000000000..0e2d3e13e7b0
--- /dev/null
+++ b/uast/uast-tests/java/Simple/MethodReference.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Anonymous {
+
+ public static void bar() {
+ int variable1 = 24;
+ variable1++;
+
+ }
+
+ public static int foo() {
+ int variable = 42;
+
+ Runnable runnable = User::bar;
+ runnable.run();
+
+ return variable;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/MethodReference.values.txt b/uast/uast-tests/java/Simple/MethodReference.values.txt
new file mode 100644
index 000000000000..4d27136513cd
--- /dev/null
+++ b/uast/uast-tests/java/Simple/MethodReference.values.txt
@@ -0,0 +1,24 @@
+UFile (package = ) [public class Anonymous {...]
+ UClass (name = Anonymous) [public class Anonymous {...}]
+ UMethod (name = bar) [public static fun bar() : void {...}]
+ UBlockExpression [{...}] = (var variable1 = 24)
+ UDeclarationsExpression [var variable1: int = 24] = Undetermined
+ ULocalVariable (name = variable1) [var variable1: int = 24]
+ ULiteralExpression (value = 24) [24] = 24
+ UPostfixExpression (operator = ++) [variable1++] = (var variable1 = 24)
+ USimpleNameReferenceExpression (identifier = variable1) [variable1] = (var variable1 = 24)
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var variable: int = 42] = Undetermined
+ ULocalVariable (name = variable) [var variable: int = 42]
+ ULiteralExpression (value = 42) [42] = 42
+ UDeclarationsExpression [var runnable: java.lang.Runnable = User::bar] = Undetermined
+ ULocalVariable (name = runnable) [var runnable: java.lang.Runnable = User::bar]
+ UCallableReferenceExpression (name = bar) [User::bar] = external User::bar()
+ USimpleNameReferenceExpression (identifier = User) [User] = external User()
+ UQualifiedReferenceExpression [runnable.run()] = external run()()
+ USimpleNameReferenceExpression (identifier = runnable) [runnable] = (var runnable = external User::bar())
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [run()] = external run()()
+ UIdentifier (Identifier (run)) [UIdentifier (Identifier (run))]
+ UReturnExpression [return variable] = Nothing
+ USimpleNameReferenceExpression (identifier = variable) [variable] = (var variable = 42)
diff --git a/uast/uast-tests/java/Simple/Modification.java b/uast/uast-tests/java/Simple/Modification.java
new file mode 100644
index 000000000000..6bd1d17213cf
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Modification.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Modification {
+ public static String foo() {
+ String s1 = "Hello ";
+ s1 += "world";
+ int m = 10;
+ int n = 5;
+ m += n -= 3;
+ m /= n *= 2;
+ s1 += " = ";
+ return s1 + m + " / " + n;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Modification.values.txt b/uast/uast-tests/java/Simple/Modification.values.txt
new file mode 100644
index 000000000000..4c56d62f7b20
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Modification.values.txt
@@ -0,0 +1,35 @@
+UFile (package = ) [public class Modification {...]
+ UClass (name = Modification) [public class Modification {...}]
+ UMethod (name = foo) [public static fun foo() : java.lang.String {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var s1: java.lang.String = "Hello "] = Undetermined
+ ULocalVariable (name = s1) [var s1: java.lang.String = "Hello "]
+ ULiteralExpression (value = "Hello ") ["Hello "] = "Hello "
+ UBinaryExpression (operator = +=) [s1 += "world"] = "Hello world" (depending on: (var s1 = "Hello "))
+ USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "Hello ")
+ ULiteralExpression (value = "world") ["world"] = "world"
+ UDeclarationsExpression [var m: int = 10] = Undetermined
+ ULocalVariable (name = m) [var m: int = 10]
+ ULiteralExpression (value = 10) [10] = 10
+ UDeclarationsExpression [var n: int = 5] = Undetermined
+ ULocalVariable (name = n) [var n: int = 5]
+ ULiteralExpression (value = 5) [5] = 5
+ UBinaryExpression (operator = +=) [m += n -= 3] = 12 (depending on: (var m = 10), (var n = 5))
+ USimpleNameReferenceExpression (identifier = m) [m] = (var m = 10)
+ UBinaryExpression (operator = -=) [n -= 3] = 2 (depending on: (var n = 5))
+ USimpleNameReferenceExpression (identifier = n) [n] = (var n = 5)
+ ULiteralExpression (value = 3) [3] = 3
+ UBinaryExpression (operator = /=) [m /= n *= 2] = 3 (depending on: (var m = 12 (depending on: (var n = 5))), (var n = 2))
+ USimpleNameReferenceExpression (identifier = m) [m] = (var m = 12 (depending on: (var n = 5)))
+ UBinaryExpression (operator = *=) [n *= 2] = 4 (depending on: (var n = 2))
+ USimpleNameReferenceExpression (identifier = n) [n] = (var n = 2)
+ ULiteralExpression (value = 2) [2] = 2
+ UBinaryExpression (operator = +=) [s1 += " = "] = "Hello world = " (depending on: (var s1 = "Hello world"))
+ USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "Hello world")
+ ULiteralExpression (value = " = ") [" = "] = " = "
+ UReturnExpression [return s1 + m + " / " + n] = Nothing
+ UPolyadicExpression (operator = +) [s1 + m + " / " + n] = "Hello world = 3 / 4" (depending on: (var s1 = "Hello world = "), (var m = 3 (depending on: (var n = 2))), (var n = 4))
+ USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "Hello world = ")
+ USimpleNameReferenceExpression (identifier = m) [m] = (var m = 3 (depending on: (var n = 2)))
+ ULiteralExpression (value = " / ") [" / "] = " / "
+ USimpleNameReferenceExpression (identifier = n) [n] = (var n = 4)
diff --git a/uast/uast-tests/java/Simple/MutableField.java b/uast/uast-tests/java/Simple/MutableField.java
new file mode 100644
index 000000000000..cebe2389496d
--- /dev/null
+++ b/uast/uast-tests/java/Simple/MutableField.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class MutableField {
+ static int mutable = 0;
+
+ public static int foo() {
+ mutable = 1;
+ bar();
+ return mutable;
+ }
+
+ public static void bar() {
+ mutable = 2;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/MutableField.values.txt b/uast/uast-tests/java/Simple/MutableField.values.txt
new file mode 100644
index 000000000000..4e40e71579d4
--- /dev/null
+++ b/uast/uast-tests/java/Simple/MutableField.values.txt
@@ -0,0 +1,18 @@
+UFile (package = ) [public class MutableField {...]
+ UClass (name = MutableField) [public class MutableField {...}]
+ UField (name = mutable) [static var mutable: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UBinaryExpression (operator = =) [mutable = 1] = 1
+ USimpleNameReferenceExpression (identifier = mutable) [mutable] = external mutable()
+ ULiteralExpression (value = 1) [1] = 1
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [bar()] = external bar()()
+ UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))]
+ UReturnExpression [return mutable] = Nothing
+ USimpleNameReferenceExpression (identifier = mutable) [mutable] = external mutable()
+ UMethod (name = bar) [public static fun bar() : void {...}]
+ UBlockExpression [{...}] = 2
+ UBinaryExpression (operator = =) [mutable = 2] = 2
+ USimpleNameReferenceExpression (identifier = mutable) [mutable] = external mutable()
+ ULiteralExpression (value = 2) [2] = 2
diff --git a/uast/uast-tests/java/Simple/NotANumber.java b/uast/uast-tests/java/Simple/NotANumber.java
new file mode 100644
index 000000000000..40e08441189e
--- /dev/null
+++ b/uast/uast-tests/java/Simple/NotANumber.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class NotANumber {
+ public static boolean foo() {
+ double x = 0.0 / 0.0;
+ boolean b1 = x < x;
+ boolean b2 = x > x;
+ boolean b3 = x <= x;
+ boolean b4 = x >= x;
+ boolean b5 = x == x;
+ boolean b6 = x != x;
+ return b1 || b2 || b3 || b4 || b5 || !b6;
+ }
+
+ public static boolean bar() {
+ float x = 0.0f / 0.0f;
+ boolean b1 = x <= x;
+ boolean b2 = x >= x;
+ boolean b3 = x < x;
+ boolean b4 = x > x;
+ boolean b5 = x == x;
+ boolean b6 = x != x;
+ return b1 || b2 || b3 || b4 || b5 || !b6;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/NotANumber.values.txt b/uast/uast-tests/java/Simple/NotANumber.values.txt
new file mode 100644
index 000000000000..73cb8d5de2f6
--- /dev/null
+++ b/uast/uast-tests/java/Simple/NotANumber.values.txt
@@ -0,0 +1,94 @@
+UFile (package = ) [public class NotANumber {...]
+ UClass (name = NotANumber) [public class NotANumber {...}]
+ UMethod (name = foo) [public static fun foo() : boolean {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: double = 0.0 / 0.0] = Undetermined
+ ULocalVariable (name = x) [var x: double = 0.0 / 0.0]
+ UBinaryExpression (operator = /) [0.0 / 0.0] = NaN
+ ULiteralExpression (value = 0.0) [0.0] = 0.0
+ ULiteralExpression (value = 0.0) [0.0] = 0.0
+ UDeclarationsExpression [var b1: boolean = x < x] = Undetermined
+ ULocalVariable (name = b1) [var b1: boolean = x < x]
+ UBinaryExpression (operator = <) [x < x] = false (depending on: (var x = NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ UDeclarationsExpression [var b2: boolean = x > x] = Undetermined
+ ULocalVariable (name = b2) [var b2: boolean = x > x]
+ UBinaryExpression (operator = >) [x > x] = false (depending on: (var x = NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ UDeclarationsExpression [var b3: boolean = x <= x] = Undetermined
+ ULocalVariable (name = b3) [var b3: boolean = x <= x]
+ UBinaryExpression (operator = <=) [x <= x] = false (depending on: (var x = NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ UDeclarationsExpression [var b4: boolean = x >= x] = Undetermined
+ ULocalVariable (name = b4) [var b4: boolean = x >= x]
+ UBinaryExpression (operator = >=) [x >= x] = false (depending on: (var x = NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ UDeclarationsExpression [var b5: boolean = x === x] = Undetermined
+ ULocalVariable (name = b5) [var b5: boolean = x === x]
+ UBinaryExpression (operator = ===) [x === x] = false (depending on: (var x = NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ UDeclarationsExpression [var b6: boolean = x !== x] = Undetermined
+ ULocalVariable (name = b6) [var b6: boolean = x !== x]
+ UBinaryExpression (operator = !==) [x !== x] = true (depending on: (var x = NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN)
+ UReturnExpression [return b1 || b2 || b3 || b4 || b5 || !b6] = Nothing
+ UPolyadicExpression (operator = ||) [b1 || b2 || b3 || b4 || b5 || !b6] = false (depending on: (var b1 = false (depending on: (var x = NaN))), (var b2 = false (depending on: (var x = NaN))), (var b3 = false (depending on: (var x = NaN))), (var b4 = false (depending on: (var x = NaN))), (var b5 = false (depending on: (var x = NaN))), (var b6 = true (depending on: (var x = NaN))))
+ USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = false (depending on: (var x = NaN)))
+ USimpleNameReferenceExpression (identifier = b2) [b2] = (var b2 = false (depending on: (var x = NaN)))
+ USimpleNameReferenceExpression (identifier = b3) [b3] = (var b3 = false (depending on: (var x = NaN)))
+ USimpleNameReferenceExpression (identifier = b4) [b4] = (var b4 = false (depending on: (var x = NaN)))
+ USimpleNameReferenceExpression (identifier = b5) [b5] = (var b5 = false (depending on: (var x = NaN)))
+ UPrefixExpression (operator = !) [!b6] = false (depending on: (var b6 = true (depending on: (var x = NaN))))
+ USimpleNameReferenceExpression (identifier = b6) [b6] = (var b6 = true (depending on: (var x = NaN)))
+ UMethod (name = bar) [public static fun bar() : boolean {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: float = 0.0 / 0.0] = Undetermined
+ ULocalVariable (name = x) [var x: float = 0.0 / 0.0]
+ UBinaryExpression (operator = /) [0.0 / 0.0] = (float)NaN
+ ULiteralExpression (value = 0.0) [0.0] = (float)0.0
+ ULiteralExpression (value = 0.0) [0.0] = (float)0.0
+ UDeclarationsExpression [var b1: boolean = x <= x] = Undetermined
+ ULocalVariable (name = b1) [var b1: boolean = x <= x]
+ UBinaryExpression (operator = <=) [x <= x] = false (depending on: (var x = (float)NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ UDeclarationsExpression [var b2: boolean = x >= x] = Undetermined
+ ULocalVariable (name = b2) [var b2: boolean = x >= x]
+ UBinaryExpression (operator = >=) [x >= x] = false (depending on: (var x = (float)NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ UDeclarationsExpression [var b3: boolean = x < x] = Undetermined
+ ULocalVariable (name = b3) [var b3: boolean = x < x]
+ UBinaryExpression (operator = <) [x < x] = false (depending on: (var x = (float)NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ UDeclarationsExpression [var b4: boolean = x > x] = Undetermined
+ ULocalVariable (name = b4) [var b4: boolean = x > x]
+ UBinaryExpression (operator = >) [x > x] = false (depending on: (var x = (float)NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ UDeclarationsExpression [var b5: boolean = x === x] = Undetermined
+ ULocalVariable (name = b5) [var b5: boolean = x === x]
+ UBinaryExpression (operator = ===) [x === x] = false (depending on: (var x = (float)NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ UDeclarationsExpression [var b6: boolean = x !== x] = Undetermined
+ ULocalVariable (name = b6) [var b6: boolean = x !== x]
+ UBinaryExpression (operator = !==) [x !== x] = true (depending on: (var x = (float)NaN))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN)
+ UReturnExpression [return b1 || b2 || b3 || b4 || b5 || !b6] = Nothing
+ UPolyadicExpression (operator = ||) [b1 || b2 || b3 || b4 || b5 || !b6] = false (depending on: (var b1 = false (depending on: (var x = (float)NaN))), (var b2 = false (depending on: (var x = (float)NaN))), (var b3 = false (depending on: (var x = (float)NaN))), (var b4 = false (depending on: (var x = (float)NaN))), (var b5 = false (depending on: (var x = (float)NaN))), (var b6 = true (depending on: (var x = (float)NaN))))
+ USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = false (depending on: (var x = (float)NaN)))
+ USimpleNameReferenceExpression (identifier = b2) [b2] = (var b2 = false (depending on: (var x = (float)NaN)))
+ USimpleNameReferenceExpression (identifier = b3) [b3] = (var b3 = false (depending on: (var x = (float)NaN)))
+ USimpleNameReferenceExpression (identifier = b4) [b4] = (var b4 = false (depending on: (var x = (float)NaN)))
+ USimpleNameReferenceExpression (identifier = b5) [b5] = (var b5 = false (depending on: (var x = (float)NaN)))
+ UPrefixExpression (operator = !) [!b6] = false (depending on: (var b6 = true (depending on: (var x = (float)NaN))))
+ USimpleNameReferenceExpression (identifier = b6) [b6] = (var b6 = true (depending on: (var x = (float)NaN)))
diff --git a/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.java b/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.java
new file mode 100644
index 000000000000..82d67bce1709
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Foo {
+ public void bar(String x) {
+ String f = x + "1";
+ }
+}
diff --git a/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.values.txt b/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.values.txt
new file mode 100644
index 000000000000..74ce53b3f529
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.values.txt
@@ -0,0 +1,10 @@
+UFile (package = ) [public class Foo {...]
+ UClass (name = Foo) [public class Foo {...}]
+ UMethod (name = bar) [public fun bar(x: java.lang.String) : void {...}]
+ UParameter (name = x) [var x: java.lang.String]
+ UBlockExpression [{...}] = Undetermined
+ UDeclarationsExpression [var f: java.lang.String = x + "1"] = Undetermined
+ ULocalVariable (name = f) [var f: java.lang.String = x + "1"]
+ UBinaryExpression (operator = +) [x + "1"] = "01"
+ USimpleNameReferenceExpression (identifier = x) [x] = "0"
+ ULiteralExpression (value = "1") ["1"] = "1"
diff --git a/uast/uast-tests/java/Simple/QualifiedConstructorCall.java b/uast/uast-tests/java/Simple/QualifiedConstructorCall.java
new file mode 100644
index 000000000000..b0227c5627f5
--- /dev/null
+++ b/uast/uast-tests/java/Simple/QualifiedConstructorCall.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2017 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 A.B.C;
+
+class Foo {
+
+}
+
+class Bar {
+ public Foo getFoo() {
+ return new A.B.C.Foo();
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/QualifiedConstructorCall.log.txt b/uast/uast-tests/java/Simple/QualifiedConstructorCall.log.txt
new file mode 100644
index 000000000000..bd859e793ac1
--- /dev/null
+++ b/uast/uast-tests/java/Simple/QualifiedConstructorCall.log.txt
@@ -0,0 +1,14 @@
+UFile (package = A.B.C)
+ UClass (name = Foo)
+ UClass (name = Bar)
+ UMethod (name = getFoo)
+ UBlockExpression
+ UReturnExpression
+ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0))
+ UQualifiedReferenceExpression
+ UQualifiedReferenceExpression
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = A)
+ USimpleNameReferenceExpression (identifier = B)
+ USimpleNameReferenceExpression (identifier = C)
+ USimpleNameReferenceExpression (identifier = Foo)
diff --git a/uast/uast-tests/java/Simple/QualifiedConstructorCall.render.txt b/uast/uast-tests/java/Simple/QualifiedConstructorCall.render.txt
new file mode 100644
index 000000000000..bdc0e8955a32
--- /dev/null
+++ b/uast/uast-tests/java/Simple/QualifiedConstructorCall.render.txt
@@ -0,0 +1,10 @@
+package A.B.C
+
+class Foo {
+}
+
+class Bar {
+ public fun getFoo() : A.B.C.Foo {
+ return A.B.C.Foo()
+ }
+}
diff --git a/uast/uast-tests/java/Simple/ReturnMinusX.java b/uast/uast-tests/java/Simple/ReturnMinusX.java
new file mode 100644
index 000000000000..1c2c270c2591
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ReturnMinusX.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class ReturnMinusX {
+ public static int foo() {
+ int x = 42;
+ return -x;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/ReturnMinusX.values.txt b/uast/uast-tests/java/Simple/ReturnMinusX.values.txt
new file mode 100644
index 000000000000..66c9678cfc92
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ReturnMinusX.values.txt
@@ -0,0 +1,10 @@
+UFile (package = ) [public class ReturnMinusX {...]
+ UClass (name = ReturnMinusX) [public class ReturnMinusX {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: int = 42] = Undetermined
+ ULocalVariable (name = x) [var x: int = 42]
+ ULiteralExpression (value = 42) [42] = 42
+ UReturnExpression [return -x] = Nothing
+ UPrefixExpression (operator = -) [-x] = -42 (depending on: (var x = 42))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 42)
diff --git a/uast/uast-tests/java/Simple/ReturnSum.java b/uast/uast-tests/java/Simple/ReturnSum.java
new file mode 100644
index 000000000000..8b20e1c3f6a8
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ReturnSum.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class ReturnSum {
+ public static int foo() {
+ int x = 1 + 2;
+ int y = 3 + 4;
+ int z = x + y;
+ return z + z; // 20
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/ReturnSum.values.txt b/uast/uast-tests/java/Simple/ReturnSum.values.txt
new file mode 100644
index 000000000000..6c2ac3ef30fd
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ReturnSum.values.txt
@@ -0,0 +1,23 @@
+UFile (package = ) [public class ReturnSum {...]
+ UClass (name = ReturnSum) [public class ReturnSum {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: int = 1 + 2] = Undetermined
+ ULocalVariable (name = x) [var x: int = 1 + 2]
+ UBinaryExpression (operator = +) [1 + 2] = 3
+ ULiteralExpression (value = 1) [1] = 1
+ ULiteralExpression (value = 2) [2] = 2
+ UDeclarationsExpression [var y: int = 3 + 4] = Undetermined
+ ULocalVariable (name = y) [var y: int = 3 + 4]
+ UBinaryExpression (operator = +) [3 + 4] = 7
+ ULiteralExpression (value = 3) [3] = 3
+ ULiteralExpression (value = 4) [4] = 4
+ UDeclarationsExpression [var z: int = x + y] = Undetermined
+ ULocalVariable (name = z) [var z: int = x + y]
+ UBinaryExpression (operator = +) [x + y] = 10 (depending on: (var x = 3), (var y = 7))
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 3)
+ USimpleNameReferenceExpression (identifier = y) [y] = (var y = 7)
+ UReturnExpression [return z + z] = Nothing
+ UBinaryExpression (operator = +) [z + z] = 20 (depending on: (var z = 10 (depending on: (var x = 3), (var y = 7))))
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = 10 (depending on: (var x = 3), (var y = 7)))
+ USimpleNameReferenceExpression (identifier = z) [z] = (var z = 10 (depending on: (var x = 3), (var y = 7)))
diff --git a/uast/uast-tests/java/Simple/ReturnX.java b/uast/uast-tests/java/Simple/ReturnX.java
new file mode 100644
index 000000000000..d3e19fec0a8a
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ReturnX.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class ReturnX {
+ public static int foo() {
+ int x = 42;
+ return x;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/ReturnX.log.txt b/uast/uast-tests/java/Simple/ReturnX.log.txt
new file mode 100644
index 000000000000..fe73c63683e4
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ReturnX.log.txt
@@ -0,0 +1,9 @@
+UFile (package = )
+ UClass (name = ReturnX)
+ UMethod (name = foo)
+ UBlockExpression
+ UDeclarationsExpression
+ ULocalVariable (name = x)
+ ULiteralExpression (value = 42)
+ UReturnExpression
+ USimpleNameReferenceExpression (identifier = x)
diff --git a/uast/uast-tests/java/Simple/ReturnX.render.txt b/uast/uast-tests/java/Simple/ReturnX.render.txt
new file mode 100644
index 000000000000..1d1c273e2c77
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ReturnX.render.txt
@@ -0,0 +1,6 @@
+public class ReturnX {
+ public static fun foo() : int {
+ var x: int = 42
+ return x
+ }
+}
diff --git a/uast/uast-tests/java/Simple/ReturnX.values.txt b/uast/uast-tests/java/Simple/ReturnX.values.txt
new file mode 100644
index 000000000000..9e63d7990cbc
--- /dev/null
+++ b/uast/uast-tests/java/Simple/ReturnX.values.txt
@@ -0,0 +1,9 @@
+UFile (package = ) [public class ReturnX {...]
+ UClass (name = ReturnX) [public class ReturnX {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var x: int = 42] = Undetermined
+ ULocalVariable (name = x) [var x: int = 42]
+ ULiteralExpression (value = 42) [42] = 42
+ UReturnExpression [return x] = Nothing
+ USimpleNameReferenceExpression (identifier = x) [x] = (var x = 42)
diff --git a/uast/uast-tests/java/Simple/Shift.java b/uast/uast-tests/java/Simple/Shift.java
new file mode 100644
index 000000000000..2f95814a8c6d
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Shift.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Shift {
+ public static int foo() {
+ int one = 1;
+ int two = one << 1;
+ int sixteen = two << 3;
+ int minInt = 0x80000000;
+ int quarter = minInt >> 2;
+ int unsignedQuarter = minInt >>> 2;
+
+ return sixteen + quarter + unsignedQuarter;
+ }
+
+ public static long bar() {
+ long one = 1L;
+ long two = one << 1;
+ long large = two << 61;
+ long minLong = 0x8000000000000000L;
+ long eighth = minLong >> 3;
+ long unsignedEighth = minLong >>> 3;
+
+ return large + eighth + unsignedEighth;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Shift.values.txt b/uast/uast-tests/java/Simple/Shift.values.txt
new file mode 100644
index 000000000000..aea68b579aca
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Shift.values.txt
@@ -0,0 +1,68 @@
+UFile (package = ) [public class Shift {...]
+ UClass (name = Shift) [public class Shift {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var one: int = 1] = Undetermined
+ ULocalVariable (name = one) [var one: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var two: int = one << 1] = Undetermined
+ ULocalVariable (name = two) [var two: int = one << 1]
+ UBinaryExpression (operator = <<) [one << 1] = 2 (depending on: (var one = 1))
+ USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1)
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var sixteen: int = two << 3] = Undetermined
+ ULocalVariable (name = sixteen) [var sixteen: int = two << 3]
+ UBinaryExpression (operator = <<) [two << 3] = 16 (depending on: (var two = 2 (depending on: (var one = 1))))
+ USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2 (depending on: (var one = 1)))
+ ULiteralExpression (value = 3) [3] = 3
+ UDeclarationsExpression [var minInt: int = -2147483648] = Undetermined
+ ULocalVariable (name = minInt) [var minInt: int = -2147483648]
+ ULiteralExpression (value = -2147483648) [-2147483648] = -2147483648
+ UDeclarationsExpression [var quarter: int = minInt >> 2] = Undetermined
+ ULocalVariable (name = quarter) [var quarter: int = minInt >> 2]
+ UBinaryExpression (operator = >>) [minInt >> 2] = -536870912 (depending on: (var minInt = -2147483648))
+ USimpleNameReferenceExpression (identifier = minInt) [minInt] = (var minInt = -2147483648)
+ ULiteralExpression (value = 2) [2] = 2
+ UDeclarationsExpression [var unsignedQuarter: int = minInt >>> 2] = Undetermined
+ ULocalVariable (name = unsignedQuarter) [var unsignedQuarter: int = minInt >>> 2]
+ UBinaryExpression (operator = >>>) [minInt >>> 2] = 536870912 (depending on: (var minInt = -2147483648))
+ USimpleNameReferenceExpression (identifier = minInt) [minInt] = (var minInt = -2147483648)
+ ULiteralExpression (value = 2) [2] = 2
+ UReturnExpression [return sixteen + quarter + unsignedQuarter] = Nothing
+ UPolyadicExpression (operator = +) [sixteen + quarter + unsignedQuarter] = 16 (depending on: (var sixteen = 16 (depending on: (var two = 2 (depending on: (var one = 1))))), (var quarter = -536870912 (depending on: (var minInt = -2147483648))), (var unsignedQuarter = 536870912 (depending on: (var minInt = -2147483648))))
+ USimpleNameReferenceExpression (identifier = sixteen) [sixteen] = (var sixteen = 16 (depending on: (var two = 2 (depending on: (var one = 1)))))
+ USimpleNameReferenceExpression (identifier = quarter) [quarter] = (var quarter = -536870912 (depending on: (var minInt = -2147483648)))
+ USimpleNameReferenceExpression (identifier = unsignedQuarter) [unsignedQuarter] = (var unsignedQuarter = 536870912 (depending on: (var minInt = -2147483648)))
+ UMethod (name = bar) [public static fun bar() : long {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var one: long = 1] = Undetermined
+ ULocalVariable (name = one) [var one: long = 1]
+ ULiteralExpression (value = 1) [1] = (long)1
+ UDeclarationsExpression [var two: long = one << 1] = Undetermined
+ ULocalVariable (name = two) [var two: long = one << 1]
+ UBinaryExpression (operator = <<) [one << 1] = (long)2 (depending on: (var one = (long)1))
+ USimpleNameReferenceExpression (identifier = one) [one] = (var one = (long)1)
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var large: long = two << 61] = Undetermined
+ ULocalVariable (name = large) [var large: long = two << 61]
+ UBinaryExpression (operator = <<) [two << 61] = (long)4611686018427387904 (depending on: (var two = (long)2 (depending on: (var one = (long)1))))
+ USimpleNameReferenceExpression (identifier = two) [two] = (var two = (long)2 (depending on: (var one = (long)1)))
+ ULiteralExpression (value = 61) [61] = 61
+ UDeclarationsExpression [var minLong: long = -9223372036854775808] = Undetermined
+ ULocalVariable (name = minLong) [var minLong: long = -9223372036854775808]
+ ULiteralExpression (value = -9223372036854775808) [-9223372036854775808] = (long)-9223372036854775808
+ UDeclarationsExpression [var eighth: long = minLong >> 3] = Undetermined
+ ULocalVariable (name = eighth) [var eighth: long = minLong >> 3]
+ UBinaryExpression (operator = >>) [minLong >> 3] = (long)-1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808))
+ USimpleNameReferenceExpression (identifier = minLong) [minLong] = (var minLong = (long)-9223372036854775808)
+ ULiteralExpression (value = 3) [3] = 3
+ UDeclarationsExpression [var unsignedEighth: long = minLong >>> 3] = Undetermined
+ ULocalVariable (name = unsignedEighth) [var unsignedEighth: long = minLong >>> 3]
+ UBinaryExpression (operator = >>>) [minLong >>> 3] = (long)1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808))
+ USimpleNameReferenceExpression (identifier = minLong) [minLong] = (var minLong = (long)-9223372036854775808)
+ ULiteralExpression (value = 3) [3] = 3
+ UReturnExpression [return large + eighth + unsignedEighth] = Nothing
+ UPolyadicExpression (operator = +) [large + eighth + unsignedEighth] = (long)4611686018427387904 (depending on: (var large = (long)4611686018427387904 (depending on: (var two = (long)2 (depending on: (var one = (long)1))))), (var eighth = (long)-1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808))), (var unsignedEighth = (long)1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808))))
+ USimpleNameReferenceExpression (identifier = large) [large] = (var large = (long)4611686018427387904 (depending on: (var two = (long)2 (depending on: (var one = (long)1)))))
+ USimpleNameReferenceExpression (identifier = eighth) [eighth] = (var eighth = (long)-1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808)))
+ USimpleNameReferenceExpression (identifier = unsignedEighth) [unsignedEighth] = (var unsignedEighth = (long)1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808)))
diff --git a/uast/uast-tests/java/Simple/Simple.java b/uast/uast-tests/java/Simple/Simple.java
new file mode 100644
index 000000000000..4be305a21ea9
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Simple.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Simple {
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Simple.log.txt b/uast/uast-tests/java/Simple/Simple.log.txt
new file mode 100644
index 000000000000..da0855030aed
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Simple.log.txt
@@ -0,0 +1,2 @@
+UFile (package = )
+ UClass (name = Simple)
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Simple.render.txt b/uast/uast-tests/java/Simple/Simple.render.txt
new file mode 100644
index 000000000000..10f71395e452
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Simple.render.txt
@@ -0,0 +1,2 @@
+public class Simple {
+}
diff --git a/uast/uast-tests/java/Simple/Strings.java b/uast/uast-tests/java/Simple/Strings.java
new file mode 100644
index 000000000000..ffcb89ee1b63
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Strings.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Strings {
+ public static String foo() {
+ String s1 = "Hello ";
+ String s2 = s1 + "wounderful";
+ String s3 = " world ";
+ String s4 = s2 + s3;
+ String s5 = s4 + 2016;
+ return s5;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Strings.values.txt b/uast/uast-tests/java/Simple/Strings.values.txt
new file mode 100644
index 000000000000..a9e424b6e1c0
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Strings.values.txt
@@ -0,0 +1,27 @@
+UFile (package = ) [public class Strings {...]
+ UClass (name = Strings) [public class Strings {...}]
+ UMethod (name = foo) [public static fun foo() : java.lang.String {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var s1: java.lang.String = "Hello "] = Undetermined
+ ULocalVariable (name = s1) [var s1: java.lang.String = "Hello "]
+ ULiteralExpression (value = "Hello ") ["Hello "] = "Hello "
+ UDeclarationsExpression [var s2: java.lang.String = s1 + "wounderful"] = Undetermined
+ ULocalVariable (name = s2) [var s2: java.lang.String = s1 + "wounderful"]
+ UBinaryExpression (operator = +) [s1 + "wounderful"] = "Hello wounderful" (depending on: (var s1 = "Hello "))
+ USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "Hello ")
+ ULiteralExpression (value = "wounderful") ["wounderful"] = "wounderful"
+ UDeclarationsExpression [var s3: java.lang.String = " world "] = Undetermined
+ ULocalVariable (name = s3) [var s3: java.lang.String = " world "]
+ ULiteralExpression (value = " world ") [" world "] = " world "
+ UDeclarationsExpression [var s4: java.lang.String = s2 + s3] = Undetermined
+ ULocalVariable (name = s4) [var s4: java.lang.String = s2 + s3]
+ UBinaryExpression (operator = +) [s2 + s3] = "Hello wounderful world " (depending on: (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))), (var s3 = " world "))
+ USimpleNameReferenceExpression (identifier = s2) [s2] = (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello ")))
+ USimpleNameReferenceExpression (identifier = s3) [s3] = (var s3 = " world ")
+ UDeclarationsExpression [var s5: java.lang.String = s4 + 2016] = Undetermined
+ ULocalVariable (name = s5) [var s5: java.lang.String = s4 + 2016]
+ UBinaryExpression (operator = +) [s4 + 2016] = "Hello wounderful world 2016" (depending on: (var s4 = "Hello wounderful world " (depending on: (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))), (var s3 = " world "))))
+ USimpleNameReferenceExpression (identifier = s4) [s4] = (var s4 = "Hello wounderful world " (depending on: (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))), (var s3 = " world ")))
+ ULiteralExpression (value = 2016) [2016] = 2016
+ UReturnExpression [return s5] = Nothing
+ USimpleNameReferenceExpression (identifier = s5) [s5] = (var s5 = "Hello wounderful world 2016" (depending on: (var s4 = "Hello wounderful world " (depending on: (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))), (var s3 = " world ")))))
diff --git a/uast/uast-tests/java/Simple/SuperTypes.java b/uast/uast-tests/java/Simple/SuperTypes.java
new file mode 100644
index 000000000000..323fbbdb7163
--- /dev/null
+++ b/uast/uast-tests/java/Simple/SuperTypes.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+class A {
+
+}
+
+interface B {
+
+}
+
+class Test extends A implements B {
+
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/SuperTypes.log.txt b/uast/uast-tests/java/Simple/SuperTypes.log.txt
new file mode 100644
index 000000000000..ad8f041d703b
--- /dev/null
+++ b/uast/uast-tests/java/Simple/SuperTypes.log.txt
@@ -0,0 +1,4 @@
+UFile (package = )
+ UClass (name = A)
+ UClass (name = B)
+ UClass (name = Test)
diff --git a/uast/uast-tests/java/Simple/SuperTypes.render.txt b/uast/uast-tests/java/Simple/SuperTypes.render.txt
new file mode 100644
index 000000000000..37b885785f78
--- /dev/null
+++ b/uast/uast-tests/java/Simple/SuperTypes.render.txt
@@ -0,0 +1,8 @@
+class A {
+}
+
+abstract interface B {
+}
+
+class Test : A, B {
+}
diff --git a/uast/uast-tests/java/Simple/Ternary.java b/uast/uast-tests/java/Simple/Ternary.java
new file mode 100644
index 000000000000..5fb7f71e820c
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Ternary.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Ternary {
+ public static int foo(boolean flag) {
+ return flag ? 1 : 0;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/Ternary.values.txt b/uast/uast-tests/java/Simple/Ternary.values.txt
new file mode 100644
index 000000000000..3eeda2ed597a
--- /dev/null
+++ b/uast/uast-tests/java/Simple/Ternary.values.txt
@@ -0,0 +1,10 @@
+UFile (package = ) [public class Ternary {...]
+ UClass (name = Ternary) [public class Ternary {...}]
+ UMethod (name = foo) [public static fun foo(flag: boolean) : int {...}]
+ UParameter (name = flag) [var flag: boolean]
+ UBlockExpression [{...}] = Nothing
+ UReturnExpression [return (flag) ? (1) : (0)] = Nothing
+ UIfExpression [(flag) ? (1) : (0)] = Phi(1, 0)
+ USimpleNameReferenceExpression (identifier = flag) [flag] = Undetermined
+ ULiteralExpression (value = 1) [1] = 1
+ ULiteralExpression (value = 0) [0] = 0
diff --git a/uast/uast-tests/java/Simple/TryCatch.java b/uast/uast-tests/java/Simple/TryCatch.java
new file mode 100644
index 000000000000..235d63d33434
--- /dev/null
+++ b/uast/uast-tests/java/Simple/TryCatch.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class TryCatch {
+ public static int foo(String str) {
+ int sum = 0;
+ for (String part: str.split(" ")) {
+ int b = 0;
+ try {
+ sum = sum + Integer.parseInt(part);
+ b = 1;
+ }
+ catch (NumberFormatException ex) {
+ b = 1;
+ }
+ int c = b;
+ }
+ return sum;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/TryCatch.values.txt b/uast/uast-tests/java/Simple/TryCatch.values.txt
new file mode 100644
index 000000000000..e6b6fa985964
--- /dev/null
+++ b/uast/uast-tests/java/Simple/TryCatch.values.txt
@@ -0,0 +1,42 @@
+UFile (package = ) [public class TryCatch {...]
+ UClass (name = TryCatch) [public class TryCatch {...}]
+ UMethod (name = foo) [public static fun foo(str: java.lang.String) : int {...}]
+ UParameter (name = str) [var str: java.lang.String]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var sum: int = 0] = Undetermined
+ ULocalVariable (name = sum) [var sum: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UForEachExpression [for (part : str.split(" ")) {...}] = Undetermined
+ UQualifiedReferenceExpression [str.split(" ")] = external split(" ")(" ")
+ USimpleNameReferenceExpression (identifier = str) [str] = Undetermined
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [split(" ")] = external split(" ")(" ")
+ UIdentifier (Identifier (split)) [UIdentifier (Identifier (split))]
+ ULiteralExpression (value = " ") [" "] = " "
+ UBlockExpression [{...}] = Undetermined
+ UDeclarationsExpression [var b: int = 0] = Undetermined
+ ULocalVariable (name = b) [var b: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UTryExpression [try {...] = Phi(1, Undetermined)
+ UBlockExpression [{...}] = 1
+ UBinaryExpression (operator = =) [sum = sum + Integer.parseInt(part)] = Undetermined
+ USimpleNameReferenceExpression (identifier = sum) [sum] = Phi((var sum = 0), (var sum = Undetermined))
+ UBinaryExpression (operator = +) [sum + Integer.parseInt(part)] = Undetermined
+ USimpleNameReferenceExpression (identifier = sum) [sum] = Phi((var sum = 0), (var sum = Undetermined))
+ UQualifiedReferenceExpression [Integer.parseInt(part)] = external parseInt(part)(Undetermined)
+ USimpleNameReferenceExpression (identifier = Integer) [Integer] = external Integer()
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [parseInt(part)] = external parseInt(part)(Undetermined)
+ UIdentifier (Identifier (parseInt)) [UIdentifier (Identifier (parseInt))]
+ USimpleNameReferenceExpression (identifier = part) [part] = Undetermined
+ UBinaryExpression (operator = =) [b = 1] = 1
+ USimpleNameReferenceExpression (identifier = b) [b] = (var b = 0)
+ ULiteralExpression (value = 1) [1] = 1
+ UCatchClause (ex) [catch (e) {...}]
+ UBlockExpression [{...}] = 1
+ UBinaryExpression (operator = =) [b = 1] = 1
+ USimpleNameReferenceExpression (identifier = b) [b] = Undetermined
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var c: int = b] = Undetermined
+ ULocalVariable (name = c) [var c: int = b]
+ USimpleNameReferenceExpression (identifier = b) [b] = Phi((var b = 1), (var b = 0))
+ UReturnExpression [return sum] = Nothing
+ USimpleNameReferenceExpression (identifier = sum) [sum] = Phi((var sum = Undetermined), (var sum = 0))
diff --git a/uast/uast-tests/java/Simple/TryWithResources.java b/uast/uast-tests/java/Simple/TryWithResources.java
new file mode 100644
index 000000000000..9093205483d6
--- /dev/null
+++ b/uast/uast-tests/java/Simple/TryWithResources.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class TryWithResources {
+ public void foo() {
+ try (BufferedReader br =
+ new BufferedReader(new FileReader(path))) {
+ return br.readLine();
+ }
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/TryWithResources.log.txt b/uast/uast-tests/java/Simple/TryWithResources.log.txt
new file mode 100644
index 000000000000..1261b0e13552
--- /dev/null
+++ b/uast/uast-tests/java/Simple/TryWithResources.log.txt
@@ -0,0 +1,17 @@
+UFile (package = )
+ UClass (name = TryWithResources)
+ UMethod (name = foo)
+ UBlockExpression
+ UTryExpression (with resources)
+ ULocalVariable (name = br)
+ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
+ USimpleNameReferenceExpression (identifier = BufferedReader)
+ UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
+ USimpleNameReferenceExpression (identifier = FileReader)
+ USimpleNameReferenceExpression (identifier = path)
+ UBlockExpression
+ UReturnExpression
+ UQualifiedReferenceExpression
+ USimpleNameReferenceExpression (identifier = br)
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
+ UIdentifier (Identifier (readLine))
diff --git a/uast/uast-tests/java/Simple/TryWithResources.render.txt b/uast/uast-tests/java/Simple/TryWithResources.render.txt
new file mode 100644
index 000000000000..3f3b1da675b4
--- /dev/null
+++ b/uast/uast-tests/java/Simple/TryWithResources.render.txt
@@ -0,0 +1,8 @@
+public class TryWithResources {
+ public fun foo() : void {
+ try (final var br: BufferedReader = BufferedReader(FileReader(path))){
+ return br.readLine()
+ }
+
+ }
+}
diff --git a/uast/uast-tests/java/Simple/TypeReference.java b/uast/uast-tests/java/Simple/TypeReference.java
new file mode 100644
index 000000000000..4f9383e7e621
--- /dev/null
+++ b/uast/uast-tests/java/Simple/TypeReference.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class Foo {
+ public void bar() {
+ String s;
+ s = 1;
+ }
+}
diff --git a/uast/uast-tests/java/Simple/While.java b/uast/uast-tests/java/Simple/While.java
new file mode 100644
index 000000000000..5e3bb51140da
--- /dev/null
+++ b/uast/uast-tests/java/Simple/While.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class While {
+ public static int foo() {
+ int result = 0, i = 0;
+ while (i < 10) {
+ result = result + i++;
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/While.values.txt b/uast/uast-tests/java/Simple/While.values.txt
new file mode 100644
index 000000000000..595b63082ebe
--- /dev/null
+++ b/uast/uast-tests/java/Simple/While.values.txt
@@ -0,0 +1,22 @@
+UFile (package = ) [public class While {...]
+ UClass (name = While) [public class While {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var result: int = 0...var i: int = 0] = Undetermined
+ ULocalVariable (name = result) [var result: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ ULocalVariable (name = i) [var i: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UWhileExpression [while (i < 10) {...}] = Undetermined
+ UBinaryExpression (operator = <) [i < 10] = Undetermined
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ ULiteralExpression (value = 10) [10] = 10
+ UBlockExpression [{...}] = Undetermined
+ UBinaryExpression (operator = =) [result = result + i++] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0))
+ UBinaryExpression (operator = +) [result + i++] = Undetermined
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0))
+ UPostfixExpression (operator = ++) [i++] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ UReturnExpression [return result] = Nothing
+ USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0))
diff --git a/uast/uast-tests/java/Simple/WhileWithContinue.java b/uast/uast-tests/java/Simple/WhileWithContinue.java
new file mode 100644
index 000000000000..66fdef096cae
--- /dev/null
+++ b/uast/uast-tests/java/Simple/WhileWithContinue.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class WhileWithContinue {
+
+ public static boolean bar() {
+ return true;
+ }
+
+ public static int foo() {
+ int first = 1;
+ int second = 2;
+
+ while (bar()) {
+ second = 3;
+ if (first > 0) continue;
+ second = 4;
+ }
+
+ return second;
+ }
+
+ public static int baz() {
+ int first = 2;
+ int second = 2;
+
+ while (bar()) {
+ second = 3;
+ first--;
+ if (first > 0) continue;
+ second = 4;
+ }
+
+ return second;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/WhileWithContinue.values.txt b/uast/uast-tests/java/Simple/WhileWithContinue.values.txt
new file mode 100644
index 000000000000..5cd5760dc995
--- /dev/null
+++ b/uast/uast-tests/java/Simple/WhileWithContinue.values.txt
@@ -0,0 +1,60 @@
+UFile (package = ) [public class WhileWithContinue {...]
+ UClass (name = WhileWithContinue) [public class WhileWithContinue {...}]
+ UMethod (name = bar) [public static fun bar() : boolean {...}]
+ UBlockExpression [{...}] = Nothing
+ UReturnExpression [return true] = Nothing
+ ULiteralExpression (value = true) [true] = true
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var first: int = 1] = Undetermined
+ ULocalVariable (name = first) [var first: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var second: int = 2] = Undetermined
+ ULocalVariable (name = second) [var second: int = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ UWhileExpression [while (bar()) {...}] = Undetermined
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [bar()] = external bar()()
+ UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))]
+ UBlockExpression [{...}] = Nothing(continue)
+ UBinaryExpression (operator = =) [second = 3] = 3
+ USimpleNameReferenceExpression (identifier = second) [second] = Phi((var second = 3), (var second = 2))
+ ULiteralExpression (value = 3) [3] = 3
+ UIfExpression [if (first > 0) continue] = Nothing(continue)
+ UBinaryExpression (operator = >) [first > 0] = true (depending on: (var first = 1))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1)
+ ULiteralExpression (value = 0) [0] = 0
+ UContinueExpression (label = null) [continue] = Nothing(continue)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UBinaryExpression (operator = =) [second = 4] = 4
+ USimpleNameReferenceExpression (identifier = second) [second] = Undetermined
+ ULiteralExpression (value = 4) [4] = 4
+ UReturnExpression [return second] = Nothing
+ USimpleNameReferenceExpression (identifier = second) [second] = Phi((var second = 3), (var second = 2))
+ UMethod (name = baz) [public static fun baz() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var first: int = 2] = Undetermined
+ ULocalVariable (name = first) [var first: int = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ UDeclarationsExpression [var second: int = 2] = Undetermined
+ ULocalVariable (name = second) [var second: int = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ UWhileExpression [while (bar()) {...}] = Undetermined
+ UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [bar()] = external bar()()
+ UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))]
+ UBlockExpression [{...}] = 4
+ UBinaryExpression (operator = =) [second = 3] = 3
+ USimpleNameReferenceExpression (identifier = second) [second] = Phi((var second = 4), (var second = 3), (var second = 2))
+ ULiteralExpression (value = 3) [3] = 3
+ UPostfixExpression (operator = --) [first--] = Phi((var first = Undetermined), (var first = 1), (var first = 2))
+ USimpleNameReferenceExpression (identifier = first) [first] = Phi((var first = Undetermined), (var first = 1), (var first = 2))
+ UIfExpression [if (first > 0) continue] = Undetermined
+ UBinaryExpression (operator = >) [first > 0] = Undetermined (depending on: (var first = Undetermined))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = Undetermined)
+ ULiteralExpression (value = 0) [0] = 0
+ UContinueExpression (label = null) [continue] = Nothing(continue)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UBinaryExpression (operator = =) [second = 4] = 4
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 3)
+ ULiteralExpression (value = 4) [4] = 4
+ UReturnExpression [return second] = Nothing
+ USimpleNameReferenceExpression (identifier = second) [second] = Phi((var second = 4), (var second = 3), (var second = 2))
diff --git a/uast/uast-tests/java/Simple/WhileWithIncrement.java b/uast/uast-tests/java/Simple/WhileWithIncrement.java
new file mode 100644
index 000000000000..8c2cbab055c7
--- /dev/null
+++ b/uast/uast-tests/java/Simple/WhileWithIncrement.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class WhileWithIncrement {
+ public static int foo() {
+ int i = 0;
+ while (true) {
+ i++;
+ if (i % 42 == 0) break;
+ }
+ return i;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/WhileWithIncrement.values.txt b/uast/uast-tests/java/Simple/WhileWithIncrement.values.txt
new file mode 100644
index 000000000000..98c2a255a416
--- /dev/null
+++ b/uast/uast-tests/java/Simple/WhileWithIncrement.values.txt
@@ -0,0 +1,22 @@
+UFile (package = ) [public class WhileWithIncrement {...]
+ UClass (name = WhileWithIncrement) [public class WhileWithIncrement {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var i: int = 0] = Undetermined
+ ULocalVariable (name = i) [var i: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UWhileExpression [while (true) {...}] = Undetermined
+ ULiteralExpression (value = true) [true] = true
+ UBlockExpression [{...}] = Undetermined
+ UPostfixExpression (operator = ++) [i++] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
+ UIfExpression [if (i % 42 === 0) break] = Undetermined
+ UBinaryExpression (operator = ===) [i % 42 === 0] = Undetermined (depending on: (var i = Undetermined))
+ UBinaryExpression (operator = %) [i % 42] = Undetermined (depending on: (var i = Undetermined))
+ USimpleNameReferenceExpression (identifier = i) [i] = (var i = Undetermined)
+ ULiteralExpression (value = 42) [42] = 42
+ ULiteralExpression (value = 0) [0] = 0
+ UBreakExpression (label = null) [break] = Nothing(break)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UReturnExpression [return i] = Nothing
+ USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0))
diff --git a/uast/uast-tests/java/Simple/WhileWithMutableCondition.java b/uast/uast-tests/java/Simple/WhileWithMutableCondition.java
new file mode 100644
index 000000000000..d39b5b5a3600
--- /dev/null
+++ b/uast/uast-tests/java/Simple/WhileWithMutableCondition.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class WhileWithMutableCondition {
+ public static int foo() {
+ int i = 0;
+ while (++i < 2) {
+ i--;
+ }
+ return i;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/WhileWithMutableCondition.values.txt b/uast/uast-tests/java/Simple/WhileWithMutableCondition.values.txt
new file mode 100644
index 000000000000..e2b6751b467d
--- /dev/null
+++ b/uast/uast-tests/java/Simple/WhileWithMutableCondition.values.txt
@@ -0,0 +1,17 @@
+UFile (package = ) [public class WhileWithMutableCondition {...]
+ UClass (name = WhileWithMutableCondition) [public class WhileWithMutableCondition {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var i: int = 0] = Undetermined
+ ULocalVariable (name = i) [var i: int = 0]
+ ULiteralExpression (value = 0) [0] = 0
+ UWhileExpression [while (++i < 2) {...}] = Undetermined
+ UBinaryExpression (operator = <) [++i < 2] = true (depending on: (var i = 0))
+ UPrefixExpression (operator = ++) [++i] = 1 (depending on: (var i = 0))
+ USimpleNameReferenceExpression (identifier = i) [i] = (var i = 0)
+ ULiteralExpression (value = 2) [2] = 2
+ UBlockExpression [{...}] = (var i = 1)
+ UPostfixExpression (operator = --) [i--] = (var i = 1)
+ USimpleNameReferenceExpression (identifier = i) [i] = (var i = 1)
+ UReturnExpression [return i] = Nothing
+ USimpleNameReferenceExpression (identifier = i) [i] = (var i = 0)
diff --git a/uast/uast-tests/java/Simple/WhileWithReturn.java b/uast/uast-tests/java/Simple/WhileWithReturn.java
new file mode 100644
index 000000000000..b2870046571f
--- /dev/null
+++ b/uast/uast-tests/java/Simple/WhileWithReturn.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2017 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.
+ */
+public class WhileWithReturn {
+ public static int foo() {
+ int first = 1;
+ int second = 2;
+
+ while (first == 1) {
+ second = 3;
+ if (first > 0) return second;
+ }
+
+ return second;
+ }
+}
\ No newline at end of file
diff --git a/uast/uast-tests/java/Simple/WhileWithReturn.values.txt b/uast/uast-tests/java/Simple/WhileWithReturn.values.txt
new file mode 100644
index 000000000000..1b13429edf66
--- /dev/null
+++ b/uast/uast-tests/java/Simple/WhileWithReturn.values.txt
@@ -0,0 +1,27 @@
+UFile (package = ) [public class WhileWithReturn {...]
+ UClass (name = WhileWithReturn) [public class WhileWithReturn {...}]
+ UMethod (name = foo) [public static fun foo() : int {...}]
+ UBlockExpression [{...}] = Nothing
+ UDeclarationsExpression [var first: int = 1] = Undetermined
+ ULocalVariable (name = first) [var first: int = 1]
+ ULiteralExpression (value = 1) [1] = 1
+ UDeclarationsExpression [var second: int = 2] = Undetermined
+ ULocalVariable (name = second) [var second: int = 2]
+ ULiteralExpression (value = 2) [2] = 2
+ UWhileExpression [while (first === 1) {...}] = Nothing
+ UBinaryExpression (operator = ===) [first === 1] = true (depending on: (var first = 1))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1)
+ ULiteralExpression (value = 1) [1] = 1
+ UBlockExpression [{...}] = Nothing
+ UBinaryExpression (operator = =) [second = 3] = 3
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 2)
+ ULiteralExpression (value = 3) [3] = 3
+ UIfExpression [if (first > 0) return second] = Nothing
+ UBinaryExpression (operator = >) [first > 0] = true (depending on: (var first = 1))
+ USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1)
+ ULiteralExpression (value = 0) [0] = 0
+ UReturnExpression [return second] = Nothing
+ USimpleNameReferenceExpression (identifier = second) [second] = (var second = 3)
+ UastEmptyExpression [UastEmptyExpression] = Undetermined
+ UReturnExpression [return second] = Nothing
+ USimpleNameReferenceExpression (identifier = second) [second] = Undetermined
From 654725fb969b1d029dd979d3c68bffea839b931b Mon Sep 17 00:00:00 2001
From: Yaroslav Lepenkin
Date: Thu, 6 Apr 2017 16:23:42 +0300
Subject: [PATCH 042/463] option to keep simple switch label statements in one
line [IDEA-171063]
---
...JavaLanguageCodeStyleSettingsProvider.java | 1 +
.../java/JavaSpacePropertyProcessor.java | 12 +++--
.../psi/formatter/java/JavaFormatterTest.java | 50 ++++++++++++++++---
.../CodeStyleSettingsCustomizable.java | 1 +
.../codeStyle/CommonCodeStyleSettings.java | 2 +
.../CodeStyleSettingPresentation.java | 3 +-
.../src/messages/ApplicationBundle.properties | 1 +
7 files changed, 58 insertions(+), 12 deletions(-)
diff --git a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java
index 631b02079716..7e67d189bf20 100644
--- a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java
+++ b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java
@@ -154,6 +154,7 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
"CATCH_ON_NEW_LINE",
"FINALLY_ON_NEW_LINE",
"INDENT_CASE_FROM_SWITCH",
+ "CASE_STATEMENT_ON_NEW_LINE",
"SPECIAL_ELSE_IF_TREATMENT",
"ENUM_CONSTANTS_WRAP",
"ALIGN_CONSECUTIVE_VARIABLE_DECLARATIONS",
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
index 45d84b017760..62e2c3def786 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
@@ -869,10 +869,14 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
myResult = Spacing.createDependentLFSpacing(0, 1, textRange, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
}
- else if (myChild1.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT
- && myChild2.getElementType() == JavaElementType.BLOCK_STATEMENT)
- {
- myResult = getSpaceBeforeLBrace(myChild2, mySettings.SPACE_BEFORE_SWITCH_LBRACE, null);
+ else if (myChild1.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT) {
+ if (myChild2.getElementType() == JavaElementType.BLOCK_STATEMENT) {
+ myResult = getSpaceBeforeLBrace(myChild2, mySettings.SPACE_BEFORE_SWITCH_LBRACE, null);
+ }
+ else {
+ int lineFeeds = mySettings.CASE_STATEMENT_ON_NEW_LINE ? 1 : 0;
+ myResult = Spacing.createSpacing(1, 1, lineFeeds, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ }
}
else if (lhsStatement && rhsStatement) {
int minSpaces = 0;
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
index fc7e9141459f..ee1b6fa7c8ee 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
@@ -192,7 +192,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testWrapAssertion() throws Exception {
doTest();
}
-
+
public void testIfElse() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.DO_NOT_FORCE;
@@ -2303,7 +2303,8 @@ public void testSCR260() throws Exception {
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = false;
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
-
+ getSettings().CASE_STATEMENT_ON_NEW_LINE = false;
+
doTextTest("class Foo{\n" +
"void foo() {\n" +
"if(a) {return;}\n" +
@@ -2317,11 +2318,7 @@ public void testSCR260() throws Exception {
" void foo() {\n" +
" if (a) {return;}\n" +
" for (a = 0; a < 10; a++) {return;}\n" +
- " switch (a)\n" +
- " {\n" +
- " case 1:\n" +
- " return;\n" +
- " }\n" +
+ " switch (a) {case 1: return;}\n" +
" do {return;} while (a);\n" +
" while (a) {return;}\n" +
" try {return;} catch (Ex e) {return;} finally {return;}\n" +
@@ -3329,4 +3326,43 @@ public void testSCR260() throws Exception {
);
}
+ public void testKeepSimpleSwitchInOneLine() {
+ getSettings().CASE_STATEMENT_ON_NEW_LINE = false;
+ doMethodTest(
+ "switch (b) {\n" +
+ "case 1: case 2: break;\n" +
+ "}",
+ "switch (b) {\n" +
+ " case 1: case 2: break;\n" +
+ "}");
+ }
+
+ public void testExpandSwitch() {
+ getSettings().CASE_STATEMENT_ON_NEW_LINE = false;
+ doMethodTest(
+ "switch (b) {\n" +
+ "case 1: { println(1); } case 2: break;\n" +
+ "}",
+ "switch (b) {\n" +
+ " case 1: {\n" +
+ " println(1);\n" +
+ " }\n" +
+ " case 2: break;\n" +
+ "}");
+ }
+
+ public void testKeepBreakOnSameLine() {
+ getSettings().CASE_STATEMENT_ON_NEW_LINE = false;
+ doMethodTest(
+ "switch (b) {\n" +
+ "case 1: case 2:\n" +
+ "\n\n\n\n\n\n" +
+ "break;\n" +
+ "}",
+ "switch (b) {\n" +
+ " case 1: case 2:\n\n\n" +
+ " break;\n" +
+ "}");
+ }
+
}
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsCustomizable.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsCustomizable.java
index ffb1634077cf..54dba1d0da33 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsCustomizable.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsCustomizable.java
@@ -197,6 +197,7 @@ public interface CodeStyleSettingsCustomizable {
CATCH_ON_NEW_LINE,
FINALLY_ON_NEW_LINE,
INDENT_CASE_FROM_SWITCH,
+ CASE_STATEMENT_ON_NEW_LINE,
SPECIAL_ELSE_IF_TREATMENT,
ENUM_CONSTANTS_WRAP,
ALIGN_CONSECUTIVE_VARIABLE_DECLARATIONS,
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java
index fd51fdcd66c1..947b0ddb863f 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java
@@ -388,6 +388,8 @@ public class CommonCodeStyleSettings {
public boolean FINALLY_ON_NEW_LINE = false;
public boolean INDENT_CASE_FROM_SWITCH = true;
+
+ public boolean CASE_STATEMENT_ON_NEW_LINE = true;
/**
* Controls "break" position relative to "case".
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/presentation/CodeStyleSettingPresentation.java b/platform/lang-api/src/com/intellij/psi/codeStyle/presentation/CodeStyleSettingPresentation.java
index a7a032b3586f..8ba7302051a8 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/presentation/CodeStyleSettingPresentation.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/presentation/CodeStyleSettingPresentation.java
@@ -411,7 +411,8 @@ public class CodeStyleSettingPresentation {
result.put(new SettingsGroup(WRAPPING_SWITCH_STATEMENT), ContainerUtil.immutableList(
new CodeStyleSettingPresentation("INDENT_CASE_FROM_SWITCH", ApplicationBundle.message("wrapping.indent.case.from.switch")),
- new CodeStyleSettingPresentation("INDENT_BREAK_FROM_CASE", ApplicationBundle.message("wrapping.indent.break.from.case"))
+ new CodeStyleSettingPresentation("INDENT_BREAK_FROM_CASE", ApplicationBundle.message("wrapping.indent.break.from.case")),
+ new CodeStyleSettingPresentation("CASE_STATEMENT_ON_NEW_LINE", ApplicationBundle.message("wrapping.case.statements.on.one.line"))
));
putGroupTop(result, "RESOURCE_LIST_WRAP", WRAPPING_TRY_RESOURCE_LIST, WRAP_VALUES, WRAP_OPTIONS);
diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties
index 57ce58e9a482..a6877e41e25b 100644
--- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties
+++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties
@@ -186,6 +186,7 @@ wrapping.method.parentheses=Method parentheses
wrapping.special.else.if.braces.treatment=Special 'else if' treatment
wrapping.indent.case.from.switch=Indent 'case' branches
wrapping.indent.break.from.case=Indent 'break' from 'case'
+wrapping.case.statements.on.one.line='case' on new line
wrapping.force.braces=Force braces
wrapping.method.parameters=Method declaration parameters
From 3a7609084268bb9c467facb91099a192c65753f3 Mon Sep 17 00:00:00 2001
From: Yaroslav Lepenkin
Date: Mon, 10 Apr 2017 14:32:19 +0300
Subject: [PATCH 043/463] removed unused class
---
.../reporting/ReportExcessiveInlineHint.kt | 137 ------------------
1 file changed, 137 deletions(-)
delete mode 100644 platform/lang-impl/src/com/intellij/reporting/ReportExcessiveInlineHint.kt
diff --git a/platform/lang-impl/src/com/intellij/reporting/ReportExcessiveInlineHint.kt b/platform/lang-impl/src/com/intellij/reporting/ReportExcessiveInlineHint.kt
deleted file mode 100644
index d18d9dc48230..000000000000
--- a/platform/lang-impl/src/com/intellij/reporting/ReportExcessiveInlineHint.kt
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2000-2016 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.reporting
-
-import com.intellij.codeInsight.daemon.impl.ParameterHintsPresentationManager
-import com.intellij.notification.Notification
-import com.intellij.notification.NotificationType
-import com.intellij.openapi.actionSystem.AnAction
-import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.actionSystem.CommonDataKeys
-import com.intellij.openapi.application.ApplicationManager
-import com.intellij.openapi.application.PathManager
-import com.intellij.openapi.diagnostic.Logger
-import com.intellij.openapi.editor.Editor
-import com.intellij.openapi.editor.Inlay
-import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.util.TextRange
-import java.io.File
-
-class ReportExcessiveInlineHint : AnAction() {
-
- private val text = "Report Excessive Inline Hint"
- private val description = "Text line at caret will be anonymously reported to our servers"
-
- companion object {
- private val LOG = Logger.getInstance(ReportExcessiveInlineHint::class.java)
- }
-
- init {
- val presentation = templatePresentation
- presentation.text = text
- presentation.description = description
- }
-
- private val recorderId = "inline-hints-reports"
- private val file = File(PathManager.getTempPath(), recorderId)
-
- override fun update(e: AnActionEvent) {
- e.presentation.isEnabledAndVisible = false
-
- if (!isHintsEnabled()) return
- CommonDataKeys.PROJECT.getData(e.dataContext) ?: return
- val editor = CommonDataKeys.EDITOR.getData(e.dataContext) ?: return
-
- val range = getCurrentLineRange(editor)
- if (editor.getInlays(range).isNotEmpty()) {
- e.presentation.isEnabledAndVisible = true
- }
- }
-
- override fun actionPerformed(e: AnActionEvent) {
- val project = CommonDataKeys.PROJECT.getData(e.dataContext)!!
- val editor = CommonDataKeys.EDITOR.getData(e.dataContext)!!
- val document = editor.document
-
- val range = getCurrentLineRange(editor)
- val inlays = editor.getInlays(range)
-
- if (inlays.isNotEmpty()) {
- val line = document.getText(range)
- reportInlays(line.trim(), inlays)
- showHint(project)
- }
- }
-
- private fun reportInlays(text: String, inlays: List) {
- val hintManager = ParameterHintsPresentationManager.getInstance()
- val hints = inlays.mapNotNull { hintManager.getHintText(it) }
- trySend(text, hints)
- }
-
- private fun trySend(text: String, inlays: List) {
- val report = InlayReport(text, inlays)
- writeToFile(createReportLine(recorderId, report))
- trySendFileInBackground()
- }
-
- private fun trySendFileInBackground() {
- LOG.debug("File: ${file.path} Length: ${file.length()}")
- if (!file.exists() || file.length() == 0L) return
- ApplicationManager.getApplication().executeOnPooledThread {
- val text = file.readText()
- LOG.debug("File text $text")
- if (StatsSender.send(text, compress = false)) {
- file.delete()
- LOG.debug("File deleted")
- }
- }
- }
-
- private fun showHint(project: Project) {
- val notification = Notification(
- "Inline Hints",
- "Inline Hints Reporting",
- "Problematic inline hint was reported",
- NotificationType.INFORMATION
- )
- notification.notify(project)
- }
-
- private fun writeToFile(line: String) {
- if (!file.exists()) {
- file.createNewFile()
- }
- file.appendText(line)
- }
-
- private fun getCurrentLineRange(editor: Editor): TextRange {
- val offset = editor.caretModel.currentCaret.offset
- val document = editor.document
- val line = document.getLineNumber(offset)
- return TextRange(document.getLineStartOffset(line), document.getLineEndOffset(line))
- }
-
-}
-
-private fun isHintsEnabled() = EditorSettingsExternalizable.getInstance().isShowParameterNameHints
-
-private fun Editor.getInlays(range: TextRange): List {
- return inlayModel.getInlineElementsInRange(range.startOffset, range.endOffset)
-}
-
-private class InlayReport(@JvmField var text: String, @JvmField var inlays: List)
\ No newline at end of file
From 5253236f4dd8f0c9250d25473e09af1cad2f7dd8 Mon Sep 17 00:00:00 2001
From: Yaroslav Lepenkin
Date: Mon, 10 Apr 2017 15:38:55 +0300
Subject: [PATCH 044/463] [param hints] get all implementations by processing
all registered extensions
---
.../src/com/intellij/codeInsight/hints/HintUtils.kt | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/HintUtils.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/HintUtils.kt
index e2b5cf038d6e..9f89791d1e29 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hints/HintUtils.kt
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/HintUtils.kt
@@ -17,14 +17,19 @@ package com.intellij.codeInsight.hints
import com.intellij.codeInsight.hints.filtering.MatcherConstructor
import com.intellij.lang.Language
+import com.intellij.lang.LanguageExtensionPoint
+import com.intellij.openapi.extensions.ExtensionPoint
+import com.intellij.openapi.extensions.ExtensionPointName
+import com.intellij.openapi.extensions.Extensions
import com.intellij.openapi.util.text.StringUtil
fun getHintProviders(): List> {
- return Language.getRegisteredLanguages()
- .filter { it.baseLanguage == null }
+ val name = ExtensionPointName>("com.intellij.codeInsight.parameterNameHints")
+ val languages = Extensions.getExtensions(name).map { it.language }
+ return languages
+ .mapNotNull { Language.findLanguageByID(it) }
.map { it to InlayParameterHintsExtension.forLanguage(it) }
- .filter { it.second != null }
}
From e4f1994aee5374bebd6728e8835e2bf7f616c2ff Mon Sep 17 00:00:00 2001
From: peter
Date: Mon, 10 Apr 2017 14:49:19 +0200
Subject: [PATCH 045/463] support initial wildcards in IDEA-24615 Auto-Import
"Exclude from Import and Completion" should allow wildcards
---
.../intellij/codeInsight/JavaProjectCodeInsightSettings.java | 2 +-
.../completion/GlobalMemberNameCompletionTest.groovy | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/java/java-impl/src/com/intellij/codeInsight/JavaProjectCodeInsightSettings.java b/java/java-impl/src/com/intellij/codeInsight/JavaProjectCodeInsightSettings.java
index 0ce294107be2..09ca840aa7e1 100644
--- a/java/java-impl/src/com/intellij/codeInsight/JavaProjectCodeInsightSettings.java
+++ b/java/java-impl/src/com/intellij/codeInsight/JavaProjectCodeInsightSettings.java
@@ -84,7 +84,7 @@ public class JavaProjectCodeInsightSettings implements PersistentStateComponent<
return excluded.length();
}
- if (excluded.indexOf('*') > 0) {
+ if (excluded.indexOf('*') >= 0) {
Matcher matcher = ourPatterns.get(excluded).matcher(name);
if (matcher.lookingAt()) {
return matcher.end();
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy
index e24e151ffb81..47538a326834 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy
@@ -138,7 +138,7 @@ class Bar {{ abcmethod(); anotherMethod() }}"""
}
""")
- JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "foo.Excl")
+ JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "*Excl")
doTest "class Bar {{ abcm }}", true, """import static foo.Foo.abcmethod;
From 80548595d38783fb1d879c2c8f13a7b04abfdef3 Mon Sep 17 00:00:00 2001
From: Dmitry Batkovich
Date: Mon, 10 Apr 2017 15:54:38 +0300
Subject: [PATCH 046/463] PreferMostUsedWeigher is moved down
---
.../completion/JavaCompletionSorting.java | 13 ++++---
.../completion/PreferMostUsedWeigher.java | 10 +++---
.../testExpectedByTypeAreFirst/Foo.java | 35 +++++++++++++++++++
...CompilerReferenceDataInCompletionTest.java | 7 ++++
4 files changed, 55 insertions(+), 10 deletions(-)
create mode 100644 java/java-tests/testData/compiler/completionOrdering/testExpectedByTypeAreFirst/Foo.java
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
index e84265cdbb6b..f0c07886e73d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
@@ -72,18 +72,21 @@ public class JavaCompletionSorting {
sorter = sorter.weighAfter("priority", new PreferDefaultTypeWeigher(expectedTypes, parameters));
}
+ final PreferMostUsedWeigher preferMostUsedWeigher = PreferMostUsedWeigher.create(position);
List afterStats = ContainerUtil.newArrayList();
afterStats.add(new PreferByKindWeigher(type, position, expectedTypes));
- final PreferMostUsedWeigher preferMostUsedWeigher = PreferMostUsedWeigher.create(position);
- if (preferMostUsedWeigher != null) {
- afterStats.add(preferMostUsedWeigher);
- }
if (!smart) {
- ContainerUtil.addIfNotNull(afterStats, preferStatics(position, expectedTypes));
+ if (preferMostUsedWeigher == null) {
+ ContainerUtil.addIfNotNull(afterStats, preferStatics(position, expectedTypes));
+ }
if (!afterNew) {
afterStats.add(new PreferExpected(false, expectedTypes, position));
}
}
+ if (preferMostUsedWeigher != null) {
+ afterStats.add(preferMostUsedWeigher);
+ ContainerUtil.addIfNotNull(afterStats, preferStatics(position, expectedTypes));
+ }
ContainerUtil.addIfNotNull(afterStats, recursion(parameters, expectedTypes));
afterStats.add(new PreferSimilarlyEnding(expectedTypes));
if (ContainerUtil.or(expectedTypes, info -> !info.getType().equals(PsiType.VOID))) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/PreferMostUsedWeigher.java b/java/java-impl/src/com/intellij/codeInsight/completion/PreferMostUsedWeigher.java
index 1c4949539d4e..eb70ab28f935 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/PreferMostUsedWeigher.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/PreferMostUsedWeigher.java
@@ -60,7 +60,7 @@ class PreferMostUsedWeigher extends LookupElementWeigher {
if (OBJECT_METHOD_PATTERN.accepts(psi)) {
return null;
}
- if (looksLikeHelperMethod(psi)) {
+ if (looksLikeHelperMethodOrConst(psi)) {
return null;
}
final Integer occurrenceCount = myCompilerReferenceService.getCompileTimeOccurrenceCount(psi, myConstructorSuggestion);
@@ -69,7 +69,7 @@ class PreferMostUsedWeigher extends LookupElementWeigher {
}
//Objects.requireNonNull is an example
- private static boolean looksLikeHelperMethod(@NotNull PsiElement element) {
+ private static boolean looksLikeHelperMethodOrConst(@NotNull PsiElement element) {
if (!(element instanceof PsiMethod)) return false;
PsiMethod method = (PsiMethod)element;
if (method.isConstructor()) return false;
@@ -78,11 +78,11 @@ class PreferMostUsedWeigher extends LookupElementWeigher {
if (parameters.length == 0) return false;
for (PsiParameter parameter : parameters) {
PsiType paramType = parameter.getType();
- if (!isRawDeepTypeEqualToObject(paramType)) {
- return false;
+ if (isRawDeepTypeEqualToObject(paramType)) {
+ return true;
}
}
- return true;
+ return false;
}
private static boolean isRawDeepTypeEqualToObject(@Nullable PsiType type) {
diff --git a/java/java-tests/testData/compiler/completionOrdering/testExpectedByTypeAreFirst/Foo.java b/java/java-tests/testData/compiler/completionOrdering/testExpectedByTypeAreFirst/Foo.java
new file mode 100644
index 000000000000..269aa3ca9741
--- /dev/null
+++ b/java/java-tests/testData/compiler/completionOrdering/testExpectedByTypeAreFirst/Foo.java
@@ -0,0 +1,35 @@
+class Foo {
+ public String someMethod1() {
+ return null;
+ }
+
+ public String someMethod2(String s) {
+ return null;
+ }
+
+ public Runnable someMethod3() {
+ return null;
+ }
+
+ void m() {
+ someMethod1();
+ someMethod1();
+ someMethod1();
+
+ someMethod2("");
+ someMethod2("");
+ someMethod2("");
+ someMethod2("");
+
+ someMethod3();
+ someMethod3();
+ someMethod3();
+ someMethod3();
+ someMethod3();
+ }
+
+ void mm(Foo f) {
+
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/compiler/CompilerReferenceDataInCompletionTest.java b/java/java-tests/testSrc/com/intellij/compiler/CompilerReferenceDataInCompletionTest.java
index 21259d0f7928..3df72b2fe78d 100644
--- a/java/java-tests/testSrc/com/intellij/compiler/CompilerReferenceDataInCompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/compiler/CompilerReferenceDataInCompletionTest.java
@@ -76,6 +76,13 @@ public class CompilerReferenceDataInCompletionTest extends CompilerReferencesTes
doTestStaticMemberCompletionOrdering(new String[] {"Foo.java"}, "someMethod2(1)", "someMethod1(0)", "m(0)", "nonNull(1)");
}
+ public void testExpectedByTypeAreFirst() {
+ doTestCompletion(new String[] {"Foo.java"}, "String s = ", new String[] {"someMethod2(1)", "someMethod1(0)", "someMethod3(0)", "m(0)", "mm(1)"}, m -> {
+ PsiClass aClass = m.getContainingClass();
+ return aClass != null && "Foo".equals(aClass.getName());
+ });
+ }
+
private void doTestConstructorCompletionOrdering(@NotNull String[] files,
@NotNull String phraseToComplete,
String... expectedOrder) {
From 31b766d6ff28a5fd65756ba55f81108c1206c41e Mon Sep 17 00:00:00 2001
From: Elizaveta Shashkova
Date: Mon, 10 Apr 2017 15:54:39 +0300
Subject: [PATCH 047/463] Tests: temporarily disable optimization with tags
coverage
---
python/setup-test-environment/build.gradle | 6 +++---
python/testSrc/com/jetbrains/env/PyEnvTaskRunner.java | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/python/setup-test-environment/build.gradle b/python/setup-test-environment/build.gradle
index 3bf8ca047159..425245906576 100644
--- a/python/setup-test-environment/build.gradle
+++ b/python/setup-test-environment/build.gradle
@@ -13,10 +13,10 @@ envs {
_64Bits = true
conda "django19", "2.7", ["django==1.9", "tox", "nose", "pytest", "behave", "lettuce>=0.2.22"], true
- textfile "django19/tags.txt", "python2.7\ndjango\ndjango19\nnose\npytest\nbehave\nlettuce\npackaging\ntox"
+ textfile "django19/tags.txt", "python2.7\ndjango\nnose\npytest\nbehave\nlettuce\npackaging\ntox"
conda "django110", "3.4", ["django==1.10"], false
- textfile "django110/tags.txt", "python3.4\ndjango\ndjango110\nskeletons"
+ textfile "django110/tags.txt", "python3.4\ndjango\nskeletons"
conda "python34", "3.4", ["ipython==2.1", "django==1.8", "behave", "jinja2", "tox>=2.0", "pandas"], true
textfile "python34/tags.txt", "python3.4\npython3\nipython\nipython200\nskeletons\ndjango\nbehave\ntox\njinja2\npython34\npackaging\npandas"
@@ -32,7 +32,7 @@ envs {
}
conda "django_latest", "3.5", ["django"], true
- textfile "django_latest/tags.txt", "python3.5\ndjango\ndjango_latest"
+ textfile "django_latest/tags.txt", "python3.5\ndjango"
}
if (new File(envs.envsDirectory, "django_latest").exists() &&
diff --git a/python/testSrc/com/jetbrains/env/PyEnvTaskRunner.java b/python/testSrc/com/jetbrains/env/PyEnvTaskRunner.java
index e16abae85e16..7334034260c2 100644
--- a/python/testSrc/com/jetbrains/env/PyEnvTaskRunner.java
+++ b/python/testSrc/com/jetbrains/env/PyEnvTaskRunner.java
@@ -38,7 +38,7 @@ public class PyEnvTaskRunner {
final Set requiredTags = Sets.union(testTask.getTags(), Sets.newHashSet(tagsRequiedByTest));
- final Set tagsToCover = testTask.getTagsToCover();
+ final Set tagsToCover = null;
for (String root : myRoots) {
From 79398f482c0d7f5b48d60546155fb7cc7439fae8 Mon Sep 17 00:00:00 2001
From: Roman Shevchenko
Date: Mon, 10 Apr 2017 15:18:54 +0200
Subject: [PATCH 048/463] Cleanup (drops outdated L&F check; formatting)
---
.../src/com/intellij/ide/ui/LafManager.java | 13 +++---
.../ide/ui/AppearanceConfigurable.java | 12 +++---
.../ide/ui/laf/HeadlessLafManagerImpl.java | 28 ++++++-------
.../intellij/ide/ui/laf/LafManagerImpl.java | 42 +------------------
.../src/messages/IdeBundle.properties | 2 -
5 files changed, 24 insertions(+), 73 deletions(-)
diff --git a/platform/platform-api/src/com/intellij/ide/ui/LafManager.java b/platform/platform-api/src/com/intellij/ide/ui/LafManager.java
index 347ba6ca64df..babae60dae37 100644
--- a/platform/platform-api/src/com/intellij/ide/ui/LafManager.java
+++ b/platform/platform-api/src/com/intellij/ide/ui/LafManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.ide.ui;
import com.intellij.openapi.application.ApplicationManager;
@@ -21,11 +20,11 @@ import com.intellij.openapi.application.ApplicationManager;
import javax.swing.*;
/**
- * User: anna
- * Date: 17-May-2006
+ * @author anna
+ * @since 17-May-2006
*/
public abstract class LafManager {
- public static LafManager getInstance(){
+ public static LafManager getInstance() {
return ApplicationManager.getApplication().getComponent(LafManager.class);
}
@@ -33,8 +32,6 @@ public abstract class LafManager {
public abstract UIManager.LookAndFeelInfo getCurrentLookAndFeel();
- public abstract boolean checkLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo);
-
public abstract void setCurrentLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo);
public abstract void updateUI();
@@ -44,4 +41,4 @@ public abstract class LafManager {
public abstract void addLafManagerListener(LafManagerListener l);
public abstract void removeLafManagerListener(LafManagerListener l);
-}
+}
\ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
index 7762cef877c8..85a0d1157d3b 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
+++ b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
@@ -244,13 +244,11 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
settings.setShowIconInQuickNavigation(myComponent.myHideIconsInQuickNavigation.isSelected());
if (!Comparing.equal(myComponent.myLafComboBox.getSelectedItem(), lafManager.getCurrentLookAndFeel())) {
- final UIManager.LookAndFeelInfo lafInfo = (UIManager.LookAndFeelInfo)myComponent.myLafComboBox.getSelectedItem();
- if (lafManager.checkLookAndFeel(lafInfo)) {
- update = true;
- shouldUpdateUI = false;
- //noinspection SSBasedInspection
- SwingUtilities.invokeLater(() -> QuickChangeLookAndFeel.switchLafAndUpdateUI(lafManager, lafInfo));
- }
+ UIManager.LookAndFeelInfo lafInfo = (UIManager.LookAndFeelInfo)myComponent.myLafComboBox.getSelectedItem();
+ update = true;
+ shouldUpdateUI = false;
+ //noinspection SSBasedInspection
+ SwingUtilities.invokeLater(() -> QuickChangeLookAndFeel.switchLafAndUpdateUI(lafManager, lafInfo));
}
if (shouldUpdateUI) {
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/HeadlessLafManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/HeadlessLafManagerImpl.java
index 523368a6fa3a..8b0661a327cc 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/laf/HeadlessLafManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/HeadlessLafManagerImpl.java
@@ -21,30 +21,28 @@ import com.intellij.ide.ui.LafManagerListener;
import javax.swing.*;
public class HeadlessLafManagerImpl extends LafManager {
+ @Override
public UIManager.LookAndFeelInfo[] getInstalledLookAndFeels() {
return new UIManager.LookAndFeelInfo[0];
}
+ @Override
public UIManager.LookAndFeelInfo getCurrentLookAndFeel() {
return null;
}
- public boolean checkLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) {
- return true;
- }
+ @Override
+ public void setCurrentLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) { }
- public void setCurrentLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) {
- }
+ @Override
+ public void updateUI() { }
- public void updateUI() {
- }
+ @Override
+ public void repaintUI() { }
- public void repaintUI() {
- }
+ @Override
+ public void addLafManagerListener(LafManagerListener l) { }
- public void addLafManagerListener(LafManagerListener l) {
- }
-
- public void removeLafManagerListener(LafManagerListener l) {
- }
-}
+ @Override
+ public void removeLafManagerListener(LafManagerListener l) { }
+}
\ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java
index 5ff33c38a1c9..9cc050c80c9e 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java
@@ -25,10 +25,6 @@ import com.intellij.ide.ui.UISettings;
import com.intellij.ide.ui.laf.darcula.DarculaInstaller;
import com.intellij.ide.ui.laf.darcula.DarculaLaf;
import com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo;
-import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationListener;
-import com.intellij.notification.NotificationType;
-import com.intellij.notification.Notifications;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
@@ -119,9 +115,8 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC
private final UIManager.LookAndFeelInfo[] myLaFs;
private UIManager.LookAndFeelInfo myCurrentLaf;
private final Map> myStoredDefaults = ContainerUtil.newHashMap();
- private String myLastWarning = null;
- private static final Map ourLafClassesAliases = ContainerUtil.newHashMap();
+ private static final Map ourLafClassesAliases = ContainerUtil.newHashMap();
static {
ourLafClassesAliases.put("idea.dark.laf.classname", DarculaLookAndFeelInfo.CLASS_NAME);
}
@@ -407,8 +402,6 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC
}
}
myCurrentLaf = ObjectUtils.chooseNotNull(findLaf(lookAndFeelInfo.getClassName()), lookAndFeelInfo);
-
- checkLookAndFeel(lookAndFeelInfo, false);
}
public void setLookAndFeelAfterRestart(UIManager.LookAndFeelInfo lookAndFeelInfo) {
@@ -445,39 +438,6 @@ public final class LafManagerImpl extends LafManager implements PersistentStateC
return null;
}
- @Override
- public boolean checkLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) {
- return checkLookAndFeel(lookAndFeelInfo, true);
- }
-
- private boolean checkLookAndFeel(final UIManager.LookAndFeelInfo lafInfo, final boolean confirm) {
- String message = null;
-
- if (lafInfo.getName().contains("GTK") && SystemInfo.isXWindow && !SystemInfo.isJavaVersionAtLeast("1.6.0_12")) {
- message = IdeBundle.message("warning.problem.laf.1");
- }
-
- if (message != null) {
- if (confirm) {
- final String[] options = {IdeBundle.message("confirm.set.look.and.feel"), CommonBundle.getCancelButtonText()};
- final int result = Messages.showOkCancelDialog(message, CommonBundle.getWarningTitle(), options[0], options[1], Messages.getWarningIcon());
- if (result == Messages.OK) {
- myLastWarning = message;
- return true;
- }
- return false;
- }
-
- if (!message.equals(myLastWarning)) {
- Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "L&F Manager", message, NotificationType.WARNING,
- NotificationListener.URL_OPENING_LISTENER));
- myLastWarning = message;
- }
- }
-
- return true;
- }
-
/**
* Updates LAF of all windows. The method also updates font of components
* as it's configured in UISettings.
diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties
index 02e9ccf47d6d..6cc803c918e2 100644
--- a/platform/platform-resources-en/src/messages/IdeBundle.properties
+++ b/platform/platform-resources-en/src/messages/IdeBundle.properties
@@ -690,9 +690,7 @@ checkbox.use.lcd.rendered.font.in.editor=LCD rendering
idea.default.look.and.feel=IDEA (4.5 default)
idea.intellij.look.and.feel=IntelliJ
idea.dark.look.and.feel=Darcula
-confirm.set.look.and.feel=Change &theme
error.cannot.set.look.and.feel=Cannot set {0} theme:
{1}
-warning.problem.laf.1=GTK+ theme is known to be problematic on a JDK prior to 1.6 b12.
Please choose another theme, or upgrade your JDK. More info...
error.adding.action.without.icon.to.toolbar=You are adding an action without icon to the toolbar. The default icon will be added to this action.
title.unable.to.add.action.without.icon.to.toolbar=Unable to Add Action Without Icon to the Toolbar
error.please.specify.new.name.for.schema=Please, specify new name for scheme ''{0}''.
From 34351a335fe6fae61762e68e07017fee296a128d Mon Sep 17 00:00:00 2001
From: Alexey Kudravtsev
Date: Mon, 10 Apr 2017 16:03:57 +0300
Subject: [PATCH 049/463] cleanup
---
.../psi/PsiLanguageInjectionHost.java | 3 +-
.../InjectedSelfElementInfo.java | 23 +++++-----
.../tree/injected/ClassMapCachingNulls.java | 6 +--
.../injected/InjectedFileViewProvider.java | 20 +++------
.../injected/InjectedLanguageManagerImpl.java | 1 +
.../tree/injected/InjectedLanguageUtil.java | 42 ++++++-------------
.../tree/injected/MultiHostRegistrarImpl.java | 2 +-
.../impl/source/tree/injected/ShredImpl.java | 7 ++--
8 files changed, 40 insertions(+), 64 deletions(-)
diff --git a/platform/core-api/src/com/intellij/psi/PsiLanguageInjectionHost.java b/platform/core-api/src/com/intellij/psi/PsiLanguageInjectionHost.java
index bc447903aa84..ea89efe4101c 100644
--- a/platform/core-api/src/com/intellij/psi/PsiLanguageInjectionHost.java
+++ b/platform/core-api/src/com/intellij/psi/PsiLanguageInjectionHost.java
@@ -45,7 +45,7 @@ public interface PsiLanguageInjectionHost extends PsiElement {
/**
* Update the host element using the provided text of the injected file. It may be required to escape characters from {@code text}
- * in accordance with the host language syntax. The implementation may delegate to {@link com.intellij.psi.ElementManipulators#handleContentChange(PsiElement, String)}
+ * in accordance with the host language syntax. The implementation may delegate to {@link ElementManipulators#handleContentChange(PsiElement, String)}
* if {@link com.intellij.psi.ElementManipulator} implementation is registered for this element class
* @param text text of the injected file
* @return the updated instance
@@ -59,6 +59,7 @@ public interface PsiLanguageInjectionHost extends PsiElement {
LiteralTextEscaper extends PsiLanguageInjectionHost> createLiteralTextEscaper();
+ @FunctionalInterface
interface InjectedPsiVisitor {
void visit(@NotNull PsiFile injectedPsi, @NotNull List places);
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java
index 7c1c9f3d6127..44c56393d5e6 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java
@@ -122,16 +122,13 @@ class InjectedSelfElementInfo extends SmartPointerElementInfo {
@NotNull final TextRange rangeInHostFile) {
final PsiDocumentManagerBase docManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(getProject());
final PsiFile[] result = {null};
- final PsiLanguageInjectionHost.InjectedPsiVisitor visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() {
- @Override
- public void visit(@NotNull PsiFile injectedPsi, @NotNull List places) {
- Document document = docManager.getDocument(injectedPsi);
- if (document instanceof DocumentWindow) {
- DocumentWindow window = (DocumentWindow)docManager.getLastCommittedDocument(document);
- TextRange hostRange = window.injectedToHost(new TextRange(0, injectedPsi.getTextLength()));
- if (hostRange.contains(rangeInHostFile)) {
- result[0] = injectedPsi;
- }
+ final PsiLanguageInjectionHost.InjectedPsiVisitor visitor = (injectedPsi, places) -> {
+ Document document = docManager.getDocument(injectedPsi);
+ if (document instanceof DocumentWindow) {
+ DocumentWindow window = (DocumentWindow)docManager.getLastCommittedDocument(document);
+ TextRange hostRange = window.injectedToHost(new TextRange(0, injectedPsi.getTextLength()));
+ if (hostRange.contains(rangeInHostFile)) {
+ result[0] = injectedPsi;
}
}
};
@@ -142,7 +139,7 @@ class InjectedSelfElementInfo extends SmartPointerElementInfo {
for (DocumentWindow documentWindow : InjectedLanguageManager.getInstance(getProject()).getCachedInjectedDocuments(hostFile)) {
PsiFile injected = documentManager.getPsiFile(documentWindow);
if (injected != null) {
- visitor.visit(injected, Collections.emptyList());
+ visitor.visit(injected, Collections.emptyList());
}
}
}
@@ -151,7 +148,7 @@ class InjectedSelfElementInfo extends SmartPointerElementInfo {
if (injected != null) {
for (Pair pair : injected) {
PsiFile injectedFile = pair.first.getContainingFile();
- visitor.visit(injectedFile, ContainerUtil.emptyList());
+ visitor.visit(injectedFile, ContainerUtil.emptyList());
}
}
}
@@ -162,7 +159,7 @@ class InjectedSelfElementInfo extends SmartPointerElementInfo {
@Override
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
if (getClass() != other.getClass()) return false;
- if (!(((InjectedSelfElementInfo)other).myHostContext).equals(myHostContext)) return false;
+ if (!((InjectedSelfElementInfo)other).myHostContext.equals(myHostContext)) return false;
SmartPointerElementInfo myElementInfo = ((SmartPsiElementPointerImpl)myInjectedFileRangeInHostFile).getElementInfo();
SmartPointerElementInfo oElementInfo = ((SmartPsiElementPointerImpl)((InjectedSelfElementInfo)other).myInjectedFileRangeInHostFile).getElementInfo();
return myElementInfo.pointsToTheSameElementAs(oElementInfo);
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ClassMapCachingNulls.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ClassMapCachingNulls.java
index 58885b674497..5169de8e0a89 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ClassMapCachingNulls.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ClassMapCachingNulls.java
@@ -27,13 +27,13 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-public class ClassMapCachingNulls {
+class ClassMapCachingNulls {
private final Map myBackingMap;
private final T[] myEmptyArray;
private final List myOrderingArray;
private final Map myMap = ContainerUtil.newConcurrentMap();
- public ClassMapCachingNulls(@NotNull Map backingMap, T[] emptyArray, @NotNull List orderingArray) {
+ ClassMapCachingNulls(@NotNull Map backingMap, T[] emptyArray, @NotNull List orderingArray) {
myBackingMap = backingMap;
myEmptyArray = emptyArray;
myOrderingArray = orderingArray;
@@ -103,7 +103,7 @@ public class ClassMapCachingNulls {
return value;
}
- public Map getBackingMap() {
+ Map getBackingMap() {
return myBackingMap;
}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java
index b4d75db7cdd9..971b910dbc00 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java
@@ -43,12 +43,7 @@ public class InjectedFileViewProvider extends SingleRootFileViewProvider impleme
private Project myProject;
private final Object myLock = new Object();
private final DocumentWindowImpl myDocumentWindow;
- private static final ThreadLocal disabledTemporarily = new ThreadLocal(){
- @Override
- protected Boolean initialValue() {
- return false;
- }
- };
+ private static final ThreadLocal disabledTemporarily = ThreadLocal.withInitial(() -> false);
private boolean myPatchingLeaves;
InjectedFileViewProvider(@NotNull PsiManager psiManager,
@@ -98,13 +93,10 @@ public class InjectedFileViewProvider extends SingleRootFileViewProvider impleme
PsiElement hostElementCopy = hostPsiFileCopy.getViewProvider().findElementAt(firstTextRange.getStartOffset(), hostFileLanguage);
assert hostElementCopy != null;
final Ref provider = new Ref<>();
- PsiLanguageInjectionHost.InjectedPsiVisitor visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() {
- @Override
- public void visit(@NotNull PsiFile injectedPsi, @NotNull List places) {
- Document document = documentManager.getCachedDocument(injectedPsi);
- if (document instanceof DocumentWindowImpl && oldDocumentWindow.areRangesEqual((DocumentWindowImpl)document)) {
- provider.set(injectedPsi.getViewProvider());
- }
+ PsiLanguageInjectionHost.InjectedPsiVisitor visitor = (injectedPsi, places) -> {
+ Document document = documentManager.getCachedDocument(injectedPsi);
+ if (document instanceof DocumentWindowImpl && oldDocumentWindow.areRangesEqual((DocumentWindowImpl)document)) {
+ provider.set(injectedPsi.getViewProvider());
}
};
for (PsiElement current = hostElementCopy; current != null && current != hostPsiFileCopy; current = current.getParent()) {
@@ -179,7 +171,7 @@ public class InjectedFileViewProvider extends SingleRootFileViewProvider impleme
return isEventSystemEnabled();
}
- public void performNonPhysically(Runnable runnable) {
+ void performNonPhysically(Runnable runnable) {
synchronized (myLock) {
disabledTemporarily.set(true);
try {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java
index 135030e86cbb..1a56b0a31b80 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java
@@ -64,6 +64,7 @@ import java.util.*;
*/
public class InjectedLanguageManagerImpl extends InjectedLanguageManager implements Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl");
+ @SuppressWarnings("RedundantStringConstructorCall")
static final Object ourInjectionPsiLock = new String("injectionPsiLock");
private final Project myProject;
private final DumbService myDumbService;
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
index 42da2e201538..23d34bc2e419 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
@@ -56,10 +56,7 @@ public class InjectedLanguageUtil {
// meaning: injected file text is probably incorrect
public static void forceInjectionOnElement(@NotNull PsiElement host) {
- enumerate(host, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
- @Override
- public void visit(@NotNull PsiFile injectedPsi, @NotNull List places) {
- }
+ enumerate(host, (injectedPsi, places) -> {
});
}
@@ -408,18 +405,15 @@ public class InjectedLanguageUtil {
final int hostOffset,
@NotNull final PsiDocumentManager documentManager) {
final Ref out = new Ref<>();
- enumerate(element, hostFile, true, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
- @Override
- public void visit(@NotNull PsiFile injectedPsi, @NotNull List places) {
- for (PsiLanguageInjectionHost.Shred place : places) {
- TextRange hostRange = place.getHost().getTextRange();
- if (hostRange.cutOut(place.getRangeInsideHost()).grown(1).contains(hostOffset)) {
- DocumentWindowImpl document = (DocumentWindowImpl)documentManager.getCachedDocument(injectedPsi);
- if (document == null) return;
- int injectedOffset = document.hostToInjected(hostOffset);
- PsiElement injElement = injectedPsi.findElementAt(injectedOffset);
- out.set(injElement == null ? injectedPsi : injElement);
- }
+ enumerate(element, hostFile, true, (injectedPsi, places) -> {
+ for (PsiLanguageInjectionHost.Shred place : places) {
+ TextRange hostRange = place.getHost().getTextRange();
+ if (hostRange.cutOut(place.getRangeInsideHost()).grown(1).contains(hostOffset)) {
+ DocumentWindowImpl document = (DocumentWindowImpl)documentManager.getCachedDocument(injectedPsi);
+ if (document == null) return;
+ int injectedOffset = document.hostToInjected(hostOffset);
+ PsiElement injElement = injectedPsi.findElementAt(injectedOffset);
+ out.set(injElement == null ? injectedPsi : injElement);
}
}
});
@@ -439,7 +433,7 @@ public class InjectedLanguageUtil {
return injected;
}
- public static void clearCachedInjectedFragmentsForFile(@NotNull PsiFile file) {
+ static void clearCachedInjectedFragmentsForFile(@NotNull PsiFile file) {
file.putUserData(INJECTED_DOCS_KEY, null);
}
@@ -527,12 +521,7 @@ public class InjectedLanguageUtil {
public static boolean hasInjections(@NotNull PsiLanguageInjectionHost host) {
if (!host.isPhysical()) return false;
final Ref result = Ref.create(false);
- enumerate(host, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
- @Override
- public void visit(@NotNull final PsiFile injectedPsi, @NotNull final List places) {
- result.set(true);
- }
- });
+ enumerate(host, (injectedPsi, places) -> result.set(true));
return result.get().booleanValue();
}
@@ -602,12 +591,7 @@ public class InjectedLanguageUtil {
@Nullable
public static PsiElement findElementInInjected(@NotNull PsiLanguageInjectionHost injectionHost, final int offset) {
final Ref ref = Ref.create();
- enumerate(injectionHost, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
- @Override
- public void visit(@NotNull final PsiFile injectedPsi, @NotNull final List places) {
- ref.set(injectedPsi.findElementAt(offset - getInjectedStart(places)));
- }
- });
+ enumerate(injectionHost, (injectedPsi, places) -> ref.set(injectedPsi.findElementAt(offset - getInjectedStart(places))));
return ref.get();
}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
index f4d30117effd..fe1e9f5949c7 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
@@ -496,7 +496,6 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
Place shreds,
VirtualFileWindow virtualFile,
Project project) {
- List, TextRange>> tokens = new ArrayList<>(10);
SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, (VirtualFile)virtualFile);
Lexer lexer = syntaxHighlighter.getHighlightingLexer();
lexer.start(outChars);
@@ -508,6 +507,7 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
int suffixLength = 0;
TextRange rangeInsideHost = null;
int shredEndOffset = -1;
+ List, TextRange>> tokens = new ArrayList<>(10);
for (IElementType tokenType = lexer.getTokenType(); tokenType != null; lexer.advance(), tokenType = lexer.getTokenType()) {
TextRange range = new ProperTextRange(lexer.getTokenStart(), lexer.getTokenEnd());
while (range != null && !range.isEmpty()) {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
index 4fbce72f315f..eaf9560627c1 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
@@ -59,7 +59,7 @@ class ShredImpl implements PsiLanguageInjectionHost.Shred {
}
@NotNull
- public SmartPsiElementPointer getSmartPointer() {
+ SmartPsiElementPointer getSmartPointer() {
return hostElementPointer;
}
@@ -88,13 +88,14 @@ class ShredImpl implements PsiLanguageInjectionHost.Shred {
}
@Override
- @SuppressWarnings({"HardCodedStringLiteral"})
+ @SuppressWarnings("HardCodedStringLiteral")
public String toString() {
PsiLanguageInjectionHost host = getHost();
Segment hostRange = getHostRangeMarker();
return "Shred " + (host == null ? null : host.getTextRange()) + ": " + host +
" In host range: " + (hostRange != null ? "(" + hostRange.getStartOffset() + "," + hostRange.getEndOffset() + ");" : "invalid;") +
- " PSI range: " + this.range;
+ " PSI range: " +
+ range;
}
@Override
From a8a300533e094b3918fad82ae2ad77ab47b98e43 Mon Sep 17 00:00:00 2001
From: peter
Date: Mon, 10 Apr 2017 15:13:10 +0200
Subject: [PATCH 050/463] run Sphinx VFS refresh in a write-safe context
(EA-99840 - assert: RefreshQueueImpl.execute)
---
.../src/com/jetbrains/rest/run/RestCommandLineState.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/python/python-rest/src/com/jetbrains/rest/run/RestCommandLineState.java b/python/python-rest/src/com/jetbrains/rest/run/RestCommandLineState.java
index 74860a7312d3..4e69172d749f 100644
--- a/python/python-rest/src/com/jetbrains/rest/run/RestCommandLineState.java
+++ b/python/python-rest/src/com/jetbrains/rest/run/RestCommandLineState.java
@@ -23,6 +23,8 @@ import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.TransactionGuard;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -31,8 +33,6 @@ import com.jetbrains.python.run.PythonCommandLineState;
import com.jetbrains.python.run.PythonProcessRunner;
import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
-
/**
* User : catherine
*/
@@ -79,7 +79,7 @@ public abstract class RestCommandLineState extends PythonCommandLineState {
if (afterTask != null) {
processHandler.addProcessListener(new ProcessAdapter() {
public void processTerminated(ProcessEvent event) {
- SwingUtilities.invokeLater(afterTask);
+ TransactionGuard.getInstance().submitTransactionLater(ApplicationManager.getApplication(), afterTask);
}});
}
return processHandler;
From 86f7e215dba39141924156879ade7d7759ed2bd2 Mon Sep 17 00:00:00 2001
From: peter
Date: Mon, 10 Apr 2017 15:28:41 +0200
Subject: [PATCH 051/463] search for tests in a single restartable smart-mode
read action
to avoid occasional log.infos about INREs
---
.../testframework/SearchForTestsTask.java | 38 ++++++++++++++++++-
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/java/execution/impl/src/com/intellij/execution/testframework/SearchForTestsTask.java b/java/execution/impl/src/com/intellij/execution/testframework/SearchForTestsTask.java
index 74a9f465a87c..6df268e6c6d2 100644
--- a/java/execution/impl/src/com/intellij/execution/testframework/SearchForTestsTask.java
+++ b/java/execution/impl/src/com/intellij/execution/testframework/SearchForTestsTask.java
@@ -15,6 +15,7 @@
*/
package com.intellij.execution.testframework;
+import com.intellij.concurrency.SensitiveProgressWrapper;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.process.OSProcessHandler;
@@ -27,6 +28,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
+import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
@@ -36,6 +38,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
+import java.util.concurrent.atomic.AtomicBoolean;
public abstract class SearchForTestsTask extends Task.Backgroundable {
@@ -101,14 +104,16 @@ public abstract class SearchForTestsTask extends Task.Backgroundable {
try {
mySocket = myServerSocket.accept();
final ExecutionException[] ex = new ExecutionException[1];
- DumbService.getInstance(getProject()).repeatUntilPassesInSmartMode(() -> {
+ Runnable runnable = () -> {
try {
search();
}
catch (ExecutionException e) {
ex[0] = e;
}
- });
+ };
+ //noinspection StatementWithEmptyBody
+ while (!runSmartModeReadActionWithWritePriority(runnable, new SensitiveProgressWrapper(indicator)));
if (ex[0] != null) {
logCantRunException(ex[0]);
}
@@ -124,6 +129,35 @@ public abstract class SearchForTestsTask extends Task.Backgroundable {
}
}
+ /**
+ * @return true if runnable has been executed with no write action interference and in "smart" mode
+ */
+ private boolean runSmartModeReadActionWithWritePriority(@NotNull Runnable runnable, ProgressIndicator indicator) {
+ DumbService dumbService = DumbService.getInstance(myProject);
+
+ indicator.checkCanceled();
+ dumbService.waitForSmartMode();
+
+ AtomicBoolean dumb = new AtomicBoolean();
+ boolean success = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(() -> {
+ if (myProject.isDisposed()) return;
+
+ if (dumbService.isDumb()) {
+ dumb.set(true);
+ return;
+ }
+
+ runnable.run();
+ }, indicator);
+ if (dumb.get()) {
+ return false;
+ }
+ if (!success) {
+ ProgressIndicatorUtils.yieldToPendingWriteActions();
+ }
+ return success;
+ }
+
protected void logCantRunException(ExecutionException e) throws ExecutionException {
throw e;
}
From ac5eae0209b104a8a0b727c6411e39dced41aa16 Mon Sep 17 00:00:00 2001
From: Sergey Malenkov
Date: Mon, 10 Apr 2017 16:30:03 +0300
Subject: [PATCH 052/463] search through async file tree model
---
.../fileChooser/tree/FileTreeModel.java | 127 +++++++++++++++++-
.../com/intellij/ui/tree/MapBasedTree.java | 9 +-
2 files changed, 132 insertions(+), 4 deletions(-)
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileChooser/tree/FileTreeModel.java b/platform/platform-impl/src/com/intellij/openapi/fileChooser/tree/FileTreeModel.java
index e2cda9333f9c..bedbea93557a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileChooser/tree/FileTreeModel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileChooser/tree/FileTreeModel.java
@@ -22,23 +22,31 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VFileProperty;
+import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.*;
+import com.intellij.ui.tree.Identifiable;
import com.intellij.ui.tree.MapBasedTree;
import com.intellij.ui.tree.MapBasedTree.Entry;
import com.intellij.ui.tree.MapBasedTree.UpdateResult;
+import com.intellij.ui.tree.Searchable;
import com.intellij.util.concurrency.Invoker;
import com.intellij.util.concurrency.InvokerSupplier;
import com.intellij.util.ui.tree.AbstractTreeModel;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.concurrency.AsyncPromise;
+import org.jetbrains.concurrency.Promise;
+import org.jetbrains.concurrency.Promises;
import javax.swing.Icon;
import javax.swing.tree.TreePath;
import java.io.File;
+import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import static com.intellij.openapi.application.ApplicationManager.getApplication;
import static com.intellij.openapi.util.Disposer.register;
@@ -51,7 +59,7 @@ import static java.util.stream.Collectors.toList;
/**
* @author Sergey.Malenkov
*/
-public final class FileTreeModel extends AbstractTreeModel implements Disposable, InvokerSupplier {
+public final class FileTreeModel extends AbstractTreeModel implements Disposable, Identifiable, Searchable, InvokerSupplier {
private final Invoker invoker = new Invoker.BackgroundThread(this);
private final State state;
private volatile List roots;
@@ -75,6 +83,121 @@ public final class FileTreeModel extends AbstractTreeModel implements Disposable
public void dispose() {
}
+ @Override
+ public Object getUniqueID(@NotNull TreePath path) {
+ Object object = path.getLastPathComponent();
+ TreePath parent = path.getParentPath();
+ return parent != null && object instanceof Node
+ ? getUniqueID(parent, (Node)object, new ArrayDeque<>())
+ : parent != null || object != state ? null : state.toString();
+ }
+
+ private Object getUniqueID(TreePath path, Node node, ArrayDeque deque) {
+ deque.addFirst(node.getName());
+ Object object = path.getLastPathComponent();
+ TreePath parent = path.getParentPath();
+ return parent != null && object instanceof Node
+ ? getUniqueID(parent, (Node)object, deque)
+ : parent != null || object != state ? null : deque.toArray();
+ }
+
+ @NotNull
+ @Override
+ public Promise getTreePath(Object object) {
+ if (object == null) return Promises.rejectedPromise();
+ if (object instanceof String && object.equals(state.toString())) return Promises.resolvedPromise(state.path);
+ AsyncPromise promise = new AsyncPromise<>();
+ invoker.invokeLaterIfNeeded(() -> {
+ if (object instanceof Object[]) {
+ resolveID(promise, (Object[])object);
+ }
+ else if (object instanceof VirtualFile) {
+ resolveFile(promise, (VirtualFile)object);
+ }
+ else if (object instanceof String) {
+ VirtualFile file = findFile((String)object);
+ if (file != null) {
+ resolveFile(promise, file);
+ }
+ else {
+ promise.setError("file not found");
+ }
+ }
+ else {
+ promise.setError("unsupported object");
+ }
+ });
+ return promise;
+ }
+
+ private void resolveID(AsyncPromise promise, Object[] array) {
+ if (array.length > 0) {
+ if (roots == null) roots = state.getRoots();
+ for (Root root : roots) {
+ Entry child = root.tree.getRootEntry();
+ if (child != null && Objects.equals(child.getNode().getName(), array[0])) {
+ resolveID(promise, array, 1, root, child);
+ return;
+ }
+ }
+ promise.setError("root entry not found");
+ }
+ else {
+ promise.setResult(state.path);
+ }
+ }
+
+ private void resolveID(AsyncPromise promise, Object[] array, int index, Root root, Entry entry) {
+ if (index < array.length) {
+ if (entry.isLoadingRequired()) {
+ root.updateChildren(state, entry);
+ }
+ for (int i = 0; i < entry.getChildCount(); i++) {
+ Entry child = entry.getChildEntry(i);
+ if (child != null && Objects.equals(child.getNode().getName(), array[index])) {
+ resolveID(promise, array, index + 1, root, child);
+ return;
+ }
+ }
+ promise.setError("entry not found");
+ }
+ else {
+ promise.setResult(entry);
+ }
+ }
+
+ private void resolveFile(AsyncPromise promise, VirtualFile file) {
+ if (roots == null) roots = state.getRoots();
+ for (Root root : roots) {
+ if (resolveFile(promise, file, root, root.tree.getRootEntry())) {
+ return;
+ }
+ }
+ promise.setError("root entry not found");
+ }
+
+ private boolean resolveFile(AsyncPromise promise, VirtualFile file, Root root, Entry entry) {
+ if (entry != null) {
+ if (entry.getNode().getFile().equals(file)) {
+ promise.setResult(entry);
+ return true;
+ }
+ if (VfsUtilCore.isAncestor(entry.getNode().getFile(), file, true)) {
+ if (entry.isLoadingRequired()) {
+ root.updateChildren(state, entry);
+ }
+ for (int i = 0; i < entry.getChildCount(); i++) {
+ if (resolveFile(promise, file, root, entry.getChildEntry(i))) {
+ return true;
+ }
+ }
+ promise.setError("entry not found");
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public Invoker getInvoker() {
return invoker;
@@ -241,7 +364,7 @@ public final class FileTreeModel extends AbstractTreeModel implements Disposable
private List roots;
private State(FileChooserDescriptor descriptor, FileRefresher refresher, boolean sortDirectories, boolean sortArchives) {
- this.path = new TreePath(descriptor);
+ this.path = new TreePath(this);
this.descriptor = descriptor;
this.refresher = refresher;
this.sortDirectories = sortDirectories;
diff --git a/platform/platform-impl/src/com/intellij/ui/tree/MapBasedTree.java b/platform/platform-impl/src/com/intellij/ui/tree/MapBasedTree.java
index abde56174efc..836f286ac969 100644
--- a/platform/platform-impl/src/com/intellij/ui/tree/MapBasedTree.java
+++ b/platform/platform-impl/src/com/intellij/ui/tree/MapBasedTree.java
@@ -247,13 +247,18 @@ public final class MapBasedTree {
return children == null ? 0 : children.size();
}
- public N getChild(int index) {
+ public Entry getChildEntry(int index) {
if (children != null && 0 <= index && index < children.size()) {
- return children.get(index).getNode();
+ return children.get(index);
}
return null;
}
+ public N getChild(int index) {
+ Entry entry = getChildEntry(index);
+ return entry == null ? null : entry.getNode();
+ }
+
public int getIndexOf(N child) {
if (children != null) {
for (int i = 0; i < children.size(); i++) {
From db25f8378e7d9da4509e198f4c06b20c43e2e5b3 Mon Sep 17 00:00:00 2001
From: Rustam Vishnyakov
Date: Mon, 10 Apr 2017 16:41:23 +0300
Subject: [PATCH 053/463] AbstractTemplateFormattingModelBuilder moved to
community/xml
---
...ractXmlTemplateFormattingModelBuilder.java | 287 +++++++++++++++++
.../formatter/CompositeTemplateBlock.java | 81 +++++
.../FragmentedTemplateException.java | 23 ++
.../formatter/IndentInheritingBlock.java | 22 ++
.../formatter/TemplateFormatUtil.java | 300 ++++++++++++++++++
.../formatter/TemplateLanguageBlock.java | 255 +++++++++++++++
.../formatter/TemplateSyntheticBlock.java | 67 ++++
.../template/formatter/TemplateXmlBlock.java | 155 +++++++++
.../formatter/TemplateXmlTagBlock.java | 85 +++++
9 files changed, 1275 insertions(+)
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/AbstractXmlTemplateFormattingModelBuilder.java
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/CompositeTemplateBlock.java
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/FragmentedTemplateException.java
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/IndentInheritingBlock.java
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/TemplateFormatUtil.java
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/TemplateLanguageBlock.java
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/TemplateSyntheticBlock.java
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlBlock.java
create mode 100644 xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlTagBlock.java
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/AbstractXmlTemplateFormattingModelBuilder.java b/xml/impl/src/com/intellij/xml/template/formatter/AbstractXmlTemplateFormattingModelBuilder.java
new file mode 100644
index 000000000000..ac14ac3a697f
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/AbstractXmlTemplateFormattingModelBuilder.java
@@ -0,0 +1,287 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+import com.intellij.formatting.*;
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.Language;
+import com.intellij.lang.LanguageFormatting;
+import com.intellij.lang.xml.XMLLanguage;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.FileViewProvider;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.formatter.DocumentBasedFormattingModel;
+import com.intellij.psi.formatter.FormatterUtil;
+import com.intellij.psi.formatter.FormattingDocumentModelImpl;
+import com.intellij.psi.formatter.xml.*;
+import com.intellij.psi.templateLanguages.OuterLanguageElement;
+import com.intellij.psi.templateLanguages.SimpleTemplateLanguageFormattingModelBuilder;
+import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.xml.XmlAttributeValue;
+import com.intellij.psi.xml.XmlTag;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SuppressWarnings("Duplicates")
+public abstract class AbstractXmlTemplateFormattingModelBuilder extends SimpleTemplateLanguageFormattingModelBuilder {
+ @NotNull
+ @Override
+ public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
+ final PsiFile psiFile = element.getContainingFile();
+ if (psiFile.getViewProvider() instanceof TemplateLanguageFileViewProvider) {
+ final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)psiFile.getViewProvider();
+ if (isTemplateFile(psiFile)) {
+ Language templateDataLanguage = viewProvider.getTemplateDataLanguage();
+ if (templateDataLanguage != psiFile.getLanguage()) {
+ return createDataLanguageFormattingModel(
+ viewProvider.getPsi(templateDataLanguage),
+ templateDataLanguage,
+ settings,
+ psiFile,
+ Indent.getNoneIndent());
+ }
+ }
+ else if (element instanceof OuterLanguageElement && isOuterLanguageElement(element)) {
+ FormattingModel model =
+ createTemplateFormattingModel(psiFile, viewProvider, (OuterLanguageElement)element, settings, Indent.getNoneIndent());
+ if (model != null) return model;
+ }
+ }
+ return super.createModel(element, settings);
+ }
+
+ @Nullable
+ FormattingModel createTemplateFormattingModel(@NotNull PsiFile psiFile,
+ @NotNull TemplateLanguageFileViewProvider viewProvider,
+ @NotNull OuterLanguageElement outerTemplateElement,
+ @NotNull CodeStyleSettings settings,
+ @Nullable Indent indent) {
+ List templateElements = TemplateFormatUtil.findAllTemplateLanguageElementsInside(outerTemplateElement, viewProvider);
+ return createTemplateFormattingModel(psiFile, settings, getPolicy(settings, psiFile), templateElements, indent);
+ }
+
+ @Nullable
+ public FormattingModel createTemplateFormattingModel(PsiFile file,
+ CodeStyleSettings settings,
+ XmlFormattingPolicy xmlFormattingPolicy,
+ List elements,
+ Indent indent) {
+ if (elements.size() == 0) return null;
+ List templateBlocks = new ArrayList<>();
+ for (PsiElement element : elements) {
+ if (!isMarkupLanguageElement(element) && !FormatterUtil.containsWhiteSpacesOnly(element.getNode())) {
+ templateBlocks.add(createTemplateLanguageBlock(element.getNode(), settings, xmlFormattingPolicy, indent, null, null));
+ }
+ }
+ if (templateBlocks.size() == 0) return null;
+ Block topBlock = templateBlocks.size() == 1 ? templateBlocks.get(0) : new CompositeTemplateBlock(templateBlocks);
+ return new DocumentBasedFormattingModel(topBlock, file.getProject(), settings, file.getFileType(), file);
+ }
+
+ protected abstract boolean isTemplateFile(PsiFile file);
+
+ public abstract boolean isOuterLanguageElement(PsiElement element);
+
+ public abstract boolean isMarkupLanguageElement(PsiElement element);
+
+ private FormattingModel createDataLanguageFormattingModel(PsiElement dataElement,
+ Language language,
+ CodeStyleSettings settings,
+ PsiFile psiFile,
+ @Nullable Indent indent) {
+ Block block = createDataLanguageRootBlock(dataElement, language, settings, getPolicy(settings, psiFile), psiFile, indent);
+ return new DocumentBasedFormattingModel(block, psiFile.getProject(), settings, psiFile.getFileType(), psiFile);
+ }
+
+ public Block createDataLanguageRootBlock(PsiElement dataElement,
+ Language language,
+ CodeStyleSettings settings,
+ XmlFormattingPolicy xmlFormattingPolicy,
+ PsiFile psiFile,
+ Indent indent) {
+ Block block;
+ if (dataElement instanceof XmlTag) {
+ block = createXmlTagBlock(dataElement.getNode(), null, null, xmlFormattingPolicy, indent);
+ }
+ else {
+ if (language.isKindOf(XMLLanguage.INSTANCE)) {
+ block =
+ createXmlBlock(dataElement.getNode(), null, Alignment.createAlignment(), xmlFormattingPolicy,
+ indent,
+ dataElement.getTextRange());
+ }
+ else {
+ final FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(language, dataElement);
+ if (builder != null && !isInsideXmlAttributeValue(dataElement)) {
+ FormattingModel otherLanguageModel = builder.createModel(dataElement, settings);
+ block = otherLanguageModel.getRootBlock();
+ }
+ else {
+ block = new ReadOnlyBlock(dataElement.getNode());
+ }
+ }
+ }
+ return block;
+ }
+
+ protected abstract Block createTemplateLanguageBlock(ASTNode node,
+ CodeStyleSettings settings,
+ XmlFormattingPolicy xmlFormattingPolicy,
+ Indent indent,
+ @Nullable Alignment alignment,
+ @Nullable Wrap wrap);
+
+ /**
+ * Creates an xml block. Override this method to create your own xml block if you want
+ * to control spacing etc. By default the method returns TemplateXmlTagBlock instance.
+ */
+ protected XmlTagBlock createXmlTagBlock(ASTNode node,
+ @Nullable Wrap wrap,
+ @Nullable Alignment alignment,
+ XmlFormattingPolicy policy,
+ @Nullable Indent indent) {
+ return new TemplateXmlTagBlock(this, node, wrap, alignment, policy, indent);
+ }
+
+ protected XmlBlock createXmlBlock(ASTNode node,
+ @Nullable Wrap wrap,
+ @Nullable Alignment alignment,
+ XmlFormattingPolicy policy,
+ @Nullable Indent indent,
+ @Nullable TextRange textRange) {
+ return new TemplateXmlBlock(this, node, wrap, alignment, policy, indent, textRange);
+ }
+
+ /**
+ * Creates a synthetic block containing given sub-blocks. Override this method to create your own synthetic block if you want
+ * to control spacing etc. between child blocks. By default the method returns TemplateSyntheticBlock instance.
+ *
+ * @param subBlocks The sub-blocks which will be contained in the synthetic block.
+ * @param parent Synthetic block's parent.
+ * @param indent The sub-block default indent. Block merge algorithm may overwrite it if synthetic block is
+ * implementing IndentInheritingBlock interface.
+ * @param policy Xml formatting policy.
+ * @param childIndent The indent to be used with child blocks.
+ * @return A newly created template synthetic block.
+ */
+ protected SyntheticBlock createSyntheticBlock(List subBlocks,
+ Block parent,
+ Indent indent,
+ XmlFormattingPolicy policy,
+ Indent childIndent) {
+ return new TemplateSyntheticBlock(subBlocks, parent, indent, policy, childIndent);
+ }
+
+ public List mergeWithTemplateBlocks(List markupBlocks,
+ CodeStyleSettings settings,
+ XmlFormattingPolicy xmlFormattingPolicy,
+ Indent childrenIndent) throws FragmentedTemplateException {
+ int templateLangRangeStart = Integer.MAX_VALUE;
+ int templateLangRangeEnd = -1;
+ int rangeStart = Integer.MAX_VALUE;
+ int rangeEnd = -1;
+ PsiFile templateFile = null;
+ List pureMarkupBlocks = new ArrayList<>();
+ for (Block block : markupBlocks) {
+ TextRange currRange = block.getTextRange();
+ rangeStart = Math.min(currRange.getStartOffset(), rangeStart);
+ rangeEnd = Math.max(currRange.getEndOffset(), rangeEnd);
+ boolean isMarkupBlock = true;
+ if (block instanceof AnotherLanguageBlockWrapper) {
+ AnotherLanguageBlockWrapper wrapper = (AnotherLanguageBlockWrapper)block;
+ PsiElement otherLangElement = wrapper.getNode().getPsi();
+ if (isOuterLanguageElement(otherLangElement)) {
+ isMarkupBlock = false;
+ if (templateFile == null) {
+ FileViewProvider provider = otherLangElement.getContainingFile().getViewProvider();
+ templateFile = provider.getPsi(provider.getBaseLanguage());
+ }
+ templateLangRangeStart = Math.min(currRange.getStartOffset(), templateLangRangeStart);
+ templateLangRangeEnd = Math.max(currRange.getEndOffset(), templateLangRangeEnd);
+ }
+ }
+ if (isMarkupBlock) {
+ pureMarkupBlocks.add(block);
+ }
+ }
+ if (templateLangRangeEnd > templateLangRangeStart && templateFile != null) {
+ List templateBlocks =
+ buildTemplateLanguageBlocksInside(templateFile, new TextRange(templateLangRangeStart, templateLangRangeEnd), settings,
+ xmlFormattingPolicy, childrenIndent);
+ if (pureMarkupBlocks.isEmpty()) {
+ return afterMerge(templateBlocks, true, settings, xmlFormattingPolicy);
+ }
+ return afterMerge(TemplateFormatUtil.mergeBlocks(pureMarkupBlocks, templateBlocks, new TextRange(rangeStart, rangeEnd)), false,
+ settings, xmlFormattingPolicy);
+ }
+ return markupBlocks;
+ }
+
+
+ private List buildTemplateLanguageBlocksInside(@NotNull PsiFile templateFile,
+ @NotNull TextRange range,
+ CodeStyleSettings settings,
+ XmlFormattingPolicy xmlFormattingPolicy,
+ Indent childrenIndent) {
+ List templateBlocks = new ArrayList<>();
+ TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)templateFile.getViewProvider();
+ List templateElements = TemplateFormatUtil.findAllElementsInside(range,
+ viewProvider,
+ true);
+ FormattingModel localModel = createTemplateFormattingModel(templateFile, settings, xmlFormattingPolicy, templateElements, childrenIndent);
+ if (localModel != null) {
+ Block rootBlock = localModel.getRootBlock();
+ if (rootBlock instanceof CompositeTemplateBlock) {
+ templateBlocks.addAll(rootBlock.getSubBlocks());
+ }
+ else {
+ templateBlocks.add(rootBlock);
+ }
+ }
+ return templateBlocks;
+ }
+
+ /**
+ * The method is called after markup blocks are merged with template language blocks which may require some additional block
+ * rearrangement. By default returns the same block sequence.
+ *
+ * @param originalBlocks A sequence of template and markup blocks.
+ * @param templateOnly True if originalBlocks contain only template blocks and no markup.
+ * @return Rearranged blocks.
+ */
+ protected List afterMerge(List originalBlocks,
+ boolean templateOnly,
+ CodeStyleSettings settings,
+ @NotNull XmlFormattingPolicy xmlFormattingPolicy) {
+ return originalBlocks;
+ }
+
+ protected static XmlFormattingPolicy getPolicy(CodeStyleSettings settings, PsiFile psiFile) {
+ final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(psiFile);
+ return new HtmlPolicy(settings, documentModel);
+ }
+
+ private static boolean isInsideXmlAttributeValue(PsiElement element) {
+ XmlAttributeValue value = PsiTreeUtil.getParentOfType(element, XmlAttributeValue.class, true);
+ return value != null;
+ }
+}
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/CompositeTemplateBlock.java b/xml/impl/src/com/intellij/xml/template/formatter/CompositeTemplateBlock.java
new file mode 100644
index 000000000000..e4fbd568ef79
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/CompositeTemplateBlock.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+import com.intellij.formatting.*;
+import com.intellij.openapi.util.TextRange;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+public class CompositeTemplateBlock implements Block {
+ private final List mySubBlocks;
+ private final TextRange myTextRange;
+
+ public CompositeTemplateBlock(List subBlocks) {
+ mySubBlocks = subBlocks;
+ myTextRange = new TextRange(mySubBlocks.get(0).getTextRange().getStartOffset(),
+ mySubBlocks.get(mySubBlocks.size() - 1).getTextRange().getEndOffset());
+ }
+
+ @NotNull
+ @Override
+ public TextRange getTextRange() {
+ return myTextRange;
+ }
+
+ @NotNull
+ @Override
+ public List getSubBlocks() {
+ return mySubBlocks;
+ }
+
+ @Override
+ public Wrap getWrap() {
+ return null;
+ }
+
+ @Override
+ public Indent getIndent() {
+ return Indent.getNoneIndent();
+ }
+
+ @Override
+ public Alignment getAlignment() {
+ return null;
+ }
+
+ @Override
+ public Spacing getSpacing(Block child1, @NotNull Block child2) {
+ return null;
+ }
+
+ @NotNull
+ @Override
+ public ChildAttributes getChildAttributes(int newChildIndex) {
+ return new ChildAttributes(null, null);
+ }
+
+ @Override
+ public boolean isIncomplete() {
+ return false;
+ }
+
+ @Override
+ public boolean isLeaf() {
+ return false;
+ }
+}
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/FragmentedTemplateException.java b/xml/impl/src/com/intellij/xml/template/formatter/FragmentedTemplateException.java
new file mode 100644
index 000000000000..bc6f0a2c7b3a
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/FragmentedTemplateException.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+/**
+ * Thrown if there are syntax errors in the template which make it difficult or impossible to merge a mix of template and markup/data
+ * languages.
+ */
+public class FragmentedTemplateException extends Exception {
+}
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/IndentInheritingBlock.java b/xml/impl/src/com/intellij/xml/template/formatter/IndentInheritingBlock.java
new file mode 100644
index 000000000000..04c7403eae55
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/IndentInheritingBlock.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+import com.intellij.formatting.Indent;
+
+public interface IndentInheritingBlock {
+ void setIndent(Indent indent);
+}
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/TemplateFormatUtil.java b/xml/impl/src/com/intellij/xml/template/formatter/TemplateFormatUtil.java
new file mode 100644
index 000000000000..d64c308c24fb
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/TemplateFormatUtil.java
@@ -0,0 +1,300 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+import com.intellij.codeInsight.daemon.XmlErrorMessages;
+import com.intellij.formatting.Block;
+import com.intellij.formatting.FormattingModel;
+import com.intellij.formatting.FormattingModelBuilder;
+import com.intellij.formatting.Indent;
+import com.intellij.lang.Language;
+import com.intellij.lang.LanguageFormatting;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.FileViewProvider;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiErrorElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.templateLanguages.OuterLanguageElement;
+import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+@SuppressWarnings("Duplicates")
+public class TemplateFormatUtil {
+
+ private final static List EMPTY_PSI_ELEMENT_LIST = new ArrayList<>();
+
+ private final static String[] IGNORABLE_ERROR_MESSAGES = {
+ XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing"),
+ XmlErrorMessages.message("xml.parsing.closing.tag.name.missing")
+ };
+
+ private TemplateFormatUtil() {
+ }
+
+ @NotNull
+ static List findAllMarkupLanguageElementsInside(PsiElement outerLangElement) {
+ PsiFile file = outerLangElement.getContainingFile();
+ if (file != null && file.getViewProvider() instanceof TemplateLanguageFileViewProvider) {
+ TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)file.getViewProvider();
+ return findAllElementsInside(outerLangElement.getTextRange(), viewProvider, false);
+ }
+ return EMPTY_PSI_ELEMENT_LIST;
+ }
+
+ @NotNull
+ static List findAllTemplateLanguageElementsInside(@NotNull PsiElement outerLangElement,
+ @NotNull TemplateLanguageFileViewProvider viewProvider) {
+ return findAllElementsInside(outerLangElement.getTextRange(), viewProvider, true);
+ }
+
+ @NotNull
+ static List findAllElementsInside(@NotNull TextRange range,
+ @NotNull TemplateLanguageFileViewProvider viewProvider,
+ boolean fromTemplate) {
+ return findAllElementsInside(range, viewProvider, viewProvider.getBaseLanguage(),
+ fromTemplate ? viewProvider.getBaseLanguage() : viewProvider.getTemplateDataLanguage());
+ }
+
+ @NotNull
+ public static List findAllElementsInside(TextRange range,
+ TemplateLanguageFileViewProvider viewProvider,
+ Language templateLanguage, Language language) {
+ List matchingElements = new ArrayList<>();
+ PsiElement currElement = viewProvider.findElementAt(range.getStartOffset(), language);
+ while (currElement instanceof OuterLanguageElement) {
+ currElement = currElement.getNextSibling();
+ }
+ if (currElement != null) {
+ currElement = findTopmostElementInRange(currElement, range);
+ Pair result =
+ addElementSequence(currElement, templateLanguage, range, matchingElements, templateLanguage == language);
+ int lastOffset = result.first;
+ assert lastOffset >= 0 : "Failed to process elements in range: " + range;
+ if (lastOffset < range.getEndOffset()) {
+ List moreElements =
+ findAllElementsInside(new TextRange(lastOffset, range.getEndOffset()), viewProvider, templateLanguage, language);
+ matchingElements.addAll(moreElements);
+ }
+ }
+ return matchingElements;
+ }
+
+ private static Pair addElementSequence(PsiElement startElement, Language templateLanguage, TextRange range, List targetList, boolean fromTemplate) {
+ PsiElement currElement = startElement;
+ int lastOffset = -1;
+ while (currElement != null && (lastOffset = currElement.getTextRange().getEndOffset()) <= range.getEndOffset()) {
+ boolean isTemplateLanguage = currElement.getLanguage().is(templateLanguage);
+ if (fromTemplate == isTemplateLanguage) {
+ targetList.add(currElement);
+ }
+ currElement = currElement.getNextSibling();
+ }
+ if (currElement != null && currElement.getTextRange().intersects(range)) {
+ PsiElement child = currElement.getFirstChild();
+ if (child != null) {
+ addElementSequence(child, templateLanguage, range, targetList, fromTemplate);
+ }
+ }
+ return new Pair<>(lastOffset, currElement);
+ }
+
+
+ @NotNull
+ public static PsiElement findTopmostElementInRange(@NotNull PsiElement original, TextRange fitToRange) {
+ PsiElement currElement = original;
+ PsiElement prevElement = original;
+ while (currElement != null) {
+ if ((currElement instanceof PsiFile) || !fitToRange.contains(currElement.getTextRange())) {
+ if (!fitToRange.contains(prevElement.getTextRange())) {
+ return original;
+ }
+ return prevElement;
+ }
+ prevElement = currElement;
+ currElement = currElement.getParent();
+ }
+ return original;
+ }
+
+ static List mergeBlocks(List originalBlocks, List blocksToMerge, TextRange range)
+ throws FragmentedTemplateException {
+ if (blocksToMerge.isEmpty()) return originalBlocks;
+ List result = new ArrayList<>();
+ if (originalBlocks.isEmpty()) {
+ for (Block mergeCandidate : blocksToMerge) {
+ if (range.contains(mergeCandidate.getTextRange())) {
+ result.add(mergeCandidate);
+ }
+ }
+ return result;
+ }
+ List originalRanges = new ArrayList<>();
+ for (Block originalBlock : originalBlocks) {
+ originalRanges.add(originalBlock.getTextRange());
+ }
+ int lastOffset = range.getStartOffset();
+ for (Iterator originalBlockIterator = originalBlocks.iterator(); originalBlockIterator.hasNext();) {
+ Block originalBlock = originalBlockIterator.next();
+ int startOffset = originalBlock.getTextRange().getStartOffset();
+ if (lastOffset < startOffset) {
+ lastOffset = fillGap(originalRanges, blocksToMerge, result, lastOffset, startOffset);
+ if (lastOffset < startOffset) {
+ lastOffset = fillGap(originalRanges, originalBlocks, result, lastOffset, startOffset);
+ }
+ }
+ Block mergeableBlock = getBlockContaining(blocksToMerge, originalRanges, originalBlock.getTextRange());
+ if (mergeableBlock != null) {
+ if (mergeableBlock.getTextRange().getStartOffset() >= lastOffset) {
+ result.add(mergeableBlock);
+ lastOffset = mergeableBlock.getTextRange().getEndOffset();
+ }
+ }
+ else {
+ if (startOffset >= lastOffset) {
+ result.add(originalBlock);
+ originalBlockIterator.remove();
+ lastOffset = originalBlock.getTextRange().getEndOffset();
+ }
+ }
+ }
+ if (lastOffset < range.getEndOffset()) {
+ lastOffset = fillGap(originalRanges, blocksToMerge, result, lastOffset, range.getEndOffset());
+ if (lastOffset < range.getEndOffset()) {
+ fillGap(originalRanges, originalBlocks, result, lastOffset, range.getEndOffset());
+ }
+ }
+ return result;
+ }
+
+ private static int fillGap(List originalRanges, List blocks, List result, int startOffset, int endOffset)
+ throws FragmentedTemplateException {
+ return fillGap(null, originalRanges, blocks, result, startOffset, endOffset, 0);
+ }
+
+ private static int fillGap(@Nullable Block parent,
+ List originalRanges,
+ List blocks,
+ List result,
+ int startOffset,
+ int endOffset,
+ int depth) throws
+ FragmentedTemplateException {
+ int lastOffset = startOffset;
+ TextRange currRange = new TextRange(lastOffset, endOffset);
+ for (Block block : blocks) {
+ if (lastOffset == endOffset || block.getTextRange().getStartOffset() > endOffset) return lastOffset;
+ if (currRange.contains(block.getTextRange())) {
+ result.add(block);
+ if (parent != null && block instanceof IndentInheritingBlock) {
+ ((IndentInheritingBlock)block).setIndent(parent.getIndent());
+ }
+ lastOffset = block.getTextRange().getEndOffset();
+ currRange = new TextRange(lastOffset, endOffset);
+ }
+ else if (currRange.intersects(block.getTextRange()) && intersectsOneOf(block.getTextRange(), originalRanges)) {
+ List subBlocks = block.getSubBlocks();
+ if (block instanceof TemplateLanguageBlock && ((TemplateLanguageBlock)block).containsErrorElements()) {
+ throw new FragmentedTemplateException();
+ }
+ lastOffset = fillGap(block, originalRanges, subBlocks, result, lastOffset, endOffset, depth + 1);
+ currRange = new TextRange(lastOffset, endOffset);
+ }
+ }
+ return lastOffset;
+ }
+
+ public static boolean intersectsOneOf(TextRange blockRange, List originalRanges) {
+ return
+ rangesContain(originalRanges, 0, originalRanges.size() - 1, blockRange.getStartOffset()) ||
+ rangesContain(originalRanges, 0, originalRanges.size() - 1, blockRange.getEndOffset());
+ }
+
+ static boolean rangesContain(List ranges, int startIndex, int endIndex, int offset) {
+ if (endIndex < startIndex || ranges.size() <= startIndex || ranges.size() <= endIndex) return false;
+ int startOffset = ranges.get(startIndex).getStartOffset();
+ int endOffset = ranges.get(endIndex).getEndOffset();
+ if (offset < startOffset || offset > endOffset) return false;
+ if (startIndex == endIndex) return true;
+ int midIndex = (endIndex + startIndex) / 2;
+ return rangesContain(ranges, startIndex, midIndex, offset) || rangesContain(ranges, midIndex + 1, endIndex, offset);
+ }
+
+ private static Block getBlockContaining(List blockList, List originalRanges, TextRange range) {
+ return getBlockContaining(blockList, originalRanges, range, 0);
+ }
+
+ @Nullable
+ private static Block getBlockContaining(List blockList, List originalRanges, TextRange range, int depth) {
+ for (Block block : blockList) {
+ if (block.getTextRange().contains(range)) {
+ if (intersectsOneOf(block.getTextRange(), originalRanges)) {
+ Block containingBlock = getBlockContaining(block.getSubBlocks(), originalRanges, range, depth + 1);
+ if (containingBlock != null) return containingBlock;
+ }
+ return block;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates a template language block for the given outer element if possible. Finds all the elements matching the current outerElement in
+ * a template language PSI tree and builds a submodel for them with a composite root block.
+ *
+ * @param outerElement The outer element for which the submodel (template language root block) is to be built.
+ * @param settings Code style settings to be used to build the submodel.
+ * @param indent The indent for the root block.
+ * @return Template language root block (submodel) or null if it can't be built.
+ */
+
+ @Nullable
+ public static Block buildTemplateLanguageBlock(@NotNull OuterLanguageElement outerElement,
+ @NotNull CodeStyleSettings settings,
+ @Nullable Indent indent) {
+ PsiFile file = outerElement.getContainingFile();
+ FileViewProvider viewProvider = outerElement.getContainingFile().getViewProvider();
+ if (viewProvider instanceof TemplateLanguageFileViewProvider) {
+ Language language = outerElement.getLanguage();
+ FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(language, outerElement);
+ if (builder instanceof AbstractXmlTemplateFormattingModelBuilder) {
+ FormattingModel model = ((AbstractXmlTemplateFormattingModelBuilder)builder)
+ .createTemplateFormattingModel(file, (TemplateLanguageFileViewProvider)viewProvider, outerElement, settings, indent);
+ if (model != null) {
+ return model.getRootBlock();
+ }
+ }
+ }
+ return null;
+ }
+
+ public static boolean isErrorElement(@NotNull PsiElement element) {
+ if (element instanceof PsiErrorElement) {
+ String description = ((PsiErrorElement)element).getErrorDescription();
+ for (String ignorableMessage : IGNORABLE_ERROR_MESSAGES) {
+ if (ignorableMessage.equals(description)) return false;
+ }
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/TemplateLanguageBlock.java b/xml/impl/src/com/intellij/xml/template/formatter/TemplateLanguageBlock.java
new file mode 100644
index 000000000000..7c3bea5fbc7a
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/TemplateLanguageBlock.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+import com.intellij.formatting.*;
+import com.intellij.formatting.templateLanguages.BlockWithParent;
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.Language;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.formatter.FormatterUtil;
+import com.intellij.psi.formatter.common.AbstractBlock;
+import com.intellij.psi.formatter.xml.XmlFormattingPolicy;
+import com.intellij.psi.xml.XmlDocument;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SuppressWarnings("Duplicates")
+public abstract class TemplateLanguageBlock extends AbstractBlock implements BlockEx, IndentInheritingBlock, BlockWithParent {
+
+ protected final ASTNode myNode;
+ private final CodeStyleSettings mySettings;
+ private final AbstractXmlTemplateFormattingModelBuilder myBuilder;
+ private XmlFormattingPolicy myXmlFormattingPolicy;
+ private Indent myIndent;
+ private BlockWithParent myParent;
+ private boolean myContainsErrorElements = false;
+
+ protected TemplateLanguageBlock(AbstractXmlTemplateFormattingModelBuilder builder,
+ @NotNull ASTNode node,
+ @Nullable Wrap wrap,
+ @Nullable Alignment alignment,
+ CodeStyleSettings settings,
+ XmlFormattingPolicy xmlFormattingPolicy,
+ Indent indent) {
+ super(node, wrap, alignment);
+ myNode = node;
+ mySettings = settings;
+ myBuilder = builder;
+ myXmlFormattingPolicy = xmlFormattingPolicy;
+ myIndent = indent;
+ }
+
+ protected List buildChildrenWithMerge() throws FragmentedTemplateException {
+ final List markupBlocks = new ArrayList<>();
+ List markupElements = TemplateFormatUtil.findAllMarkupLanguageElementsInside(myNode.getPsi());
+ if (markupElements.size() == 1 && markupElements.get(0) instanceof XmlDocument) {
+ markupElements = getXmlDocumentChildren(markupElements.get(0));
+ }
+ boolean mergeFromMarkup = false;
+ for (PsiElement markupElement : markupElements) {
+ if (TemplateFormatUtil.isErrorElement(markupElement)) {
+ throw new FragmentedTemplateException();
+ }
+ if (!(FormatterUtil.containsWhiteSpacesOnly(markupElement.getNode()))) {
+ Block rootBlock = myBuilder
+ .createDataLanguageRootBlock(markupElement, markupElement.getLanguage(), mySettings, myXmlFormattingPolicy,
+ myNode.getPsi().getContainingFile(), getDefaultMarkupIndent());
+ PsiElement parent = markupElement.getParent();
+ if (!mergeFromMarkup) mergeFromMarkup = isScriptBlock(rootBlock);
+ if (parent instanceof PsiFile ||
+ (rootBlock instanceof TemplateXmlBlock && ((TemplateXmlBlock)rootBlock).isTextContainingTemplateElements())) {
+ for (Block block : rootBlock.getSubBlocks()) {
+ if (containsErrorElement(block)) {
+ throw new FragmentedTemplateException();
+ }
+ markupBlocks.add(block);
+ }
+ }
+ else {
+ markupBlocks.add(rootBlock);
+ }
+ }
+ }
+ List result = new ArrayList<>();
+ ASTNode child = myNode.getFirstChildNode();
+ while (child != null) {
+ if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0) {
+ if (!myBuilder.isMarkupLanguageElement(child.getPsi())) {
+ addBlocksForNonMarkupChild(result, child);
+ }
+ }
+ child = child.getTreeNext();
+ }
+ if (markupBlocks.size() > 0) {
+ if (result.isEmpty()) return markupBlocks;
+ if (mergeFromMarkup) {
+ result = TemplateFormatUtil.mergeBlocks(markupBlocks, result, myNode.getTextRange());
+ }
+ else {
+ result = TemplateFormatUtil.mergeBlocks(result, markupBlocks, myNode.getTextRange());
+ }
+ for (Block resultBlock : result) {
+ ASTNode node = resultBlock instanceof ASTBlock ? ((ASTBlock)resultBlock).getNode() : null;
+ if (node != null && resultBlock instanceof IndentInheritingBlock) {
+ ((IndentInheritingBlock)resultBlock).setIndent(getChildIndent(node));
+ }
+ if (resultBlock instanceof BlockWithParent) {
+ ((BlockWithParent)resultBlock).setParent(this);
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ protected List buildChildren() {
+ try {
+ return buildChildrenWithMerge();
+ }
+ catch (FragmentedTemplateException e) {
+ myContainsErrorElements = true;
+ return AbstractBlock.EMPTY;
+ }
+ }
+
+ @NotNull
+ private List getXmlDocumentChildren(@NotNull PsiElement xmlDocument) {
+ List children = new ArrayList<>();
+ PsiElement child = xmlDocument.getFirstChild();
+ while (child != null) {
+ if (!myBuilder.isOuterLanguageElement(child)) {
+ children.add(child);
+ }
+ child = child.getNextSibling();
+ }
+ return children;
+ }
+
+ private static boolean containsErrorElement(@NotNull Block block) {
+ if (block instanceof ASTBlock) {
+ ASTNode node = ((ASTBlock)block).getNode();
+ if (node != null) {
+ return TemplateFormatUtil.isErrorElement(node.getPsi());
+ }
+ }
+ return false;
+ }
+
+ protected void addBlocksForNonMarkupChild(List result, ASTNode child) {
+ Block templateLanguageBlock = myBuilder.createTemplateLanguageBlock(
+ child,
+ mySettings,
+ myXmlFormattingPolicy,
+ getChildIndent(child),
+ getChildAlignment(child),
+ getChildWrap(child)
+ );
+ if (templateLanguageBlock instanceof BlockWithParent) {
+ ((BlockWithParent)templateLanguageBlock).setParent(this);
+ }
+ result.add(templateLanguageBlock);
+ }
+
+
+ private static boolean isScriptBlock(Block block) {
+ if (block instanceof TemplateXmlTagBlock) {
+ return ((TemplateXmlTagBlock)block).isScriptBlock();
+ }
+ return false;
+ }
+
+ @SuppressWarnings("MethodMayBeStatic")
+ @Nullable
+ protected Alignment getChildAlignment(@SuppressWarnings("UnusedParameters") ASTNode child) {
+ return null;
+ }
+
+ @Override
+ public Indent getIndent() {
+ return myIndent;
+ }
+
+ @Override
+ protected final Indent getChildIndent() {
+ return Indent.getNoneIndent();
+ }
+
+ @NotNull
+ protected abstract Indent getChildIndent(@NotNull ASTNode node);
+
+ @Override
+ public boolean isLeaf() {
+ return myNode.getFirstChildNode() == null || myContainsErrorElements;
+ }
+
+ @Override
+ public void setIndent(Indent indent) {
+ myIndent = indent;
+ }
+
+ @NotNull
+ @Override
+ public ChildAttributes getChildAttributes(int newChildIndex) {
+ return new ChildAttributes(Indent.getNormalIndent(), null);
+ }
+
+ @SuppressWarnings("MethodMayBeStatic")
+ protected Indent getDefaultMarkupIndent() {
+ return Indent.getNormalIndent();
+ }
+
+ public CodeStyleSettings getSettings() {
+ return mySettings;
+ }
+
+ @Override
+ public BlockWithParent getParent() {
+ return myParent;
+ }
+
+ @Override
+ public void setParent(BlockWithParent newParent) {
+ myParent = newParent;
+ }
+
+ @Nullable
+ @SuppressWarnings("MethodMayBeStatic")
+ protected Wrap getChildWrap(@SuppressWarnings("UnusedParameters") ASTNode child) {
+ return Wrap.createWrap(WrapType.NONE, false);
+ }
+
+ protected abstract Spacing getSpacing(TemplateLanguageBlock adjacentBlock);
+
+ public XmlFormattingPolicy getXmlFormattingPolicy() {
+ return myXmlFormattingPolicy;
+ }
+
+ public boolean containsErrorElements() {
+ return myContainsErrorElements;
+ }
+
+ @Nullable
+ @Override
+ public Language getLanguage() {
+ return myNode.getPsi().getLanguage();
+ }
+}
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/TemplateSyntheticBlock.java b/xml/impl/src/com/intellij/xml/template/formatter/TemplateSyntheticBlock.java
new file mode 100644
index 000000000000..dea432014f7d
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/TemplateSyntheticBlock.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+import com.intellij.formatting.ASTBlock;
+import com.intellij.formatting.Block;
+import com.intellij.formatting.Indent;
+import com.intellij.formatting.Spacing;
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.xml.XMLLanguage;
+import com.intellij.psi.formatter.xml.SyntheticBlock;
+import com.intellij.psi.formatter.xml.XmlFormattingPolicy;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+public class TemplateSyntheticBlock extends SyntheticBlock implements IndentInheritingBlock {
+ private Indent myInheritedIndent;
+
+ public TemplateSyntheticBlock(final List subBlocks,
+ final Block parent,
+ final Indent indent,
+ XmlFormattingPolicy policy,
+ final Indent childIndent) {
+ super(subBlocks, parent, indent, policy, childIndent);
+ }
+
+ @Override
+ public void setIndent(Indent indent) {
+ myInheritedIndent = indent;
+ }
+
+ @Override
+ public Indent getIndent() {
+ return myInheritedIndent != null ? myInheritedIndent : super.getIndent();
+ }
+
+ @Override
+ public Spacing getSpacing(Block child1, @NotNull Block child2) {
+ if (child1 != null && isXmlBlock(child1) != isXmlBlock(child2)) {
+ return Spacing.createSpacing(0, 1, 0, true, myXmlFormattingPolicy.getKeepBlankLines());
+ }
+ return super.getSpacing(child1, child2);
+ }
+
+ private static boolean isXmlBlock(@NotNull Block block) {
+ if (block instanceof TemplateXmlTagBlock || block instanceof TemplateXmlBlock) return true;
+ if (block instanceof ASTBlock) {
+ ASTNode node = ((ASTBlock)block).getNode();
+ return node != null && node.getPsi().getLanguage().isKindOf(XMLLanguage.INSTANCE);
+ }
+ return false;
+ }
+}
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlBlock.java b/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlBlock.java
new file mode 100644
index 000000000000..bc1e43cb033c
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlBlock.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+import com.intellij.formatting.*;
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.formatter.xml.*;
+import com.intellij.psi.templateLanguages.OuterLanguageElement;
+import com.intellij.psi.xml.XmlElementType;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SuppressWarnings("Duplicates")
+public class TemplateXmlBlock extends XmlBlock implements IndentInheritingBlock {
+ private AbstractXmlTemplateFormattingModelBuilder myBuilder;
+ private Indent myIndent;
+
+ private final static List EMPTY_BLOCK_LIST = new ArrayList<>();
+
+ public TemplateXmlBlock(final AbstractXmlTemplateFormattingModelBuilder builder,
+ final ASTNode node,
+ final Wrap wrap,
+ final Alignment alignment,
+ final XmlFormattingPolicy policy,
+ final Indent indent,
+ final TextRange textRange) {
+ super(node, wrap, alignment, policy, indent, textRange);
+ myBuilder = builder;
+ }
+
+ @Override
+ protected XmlBlock createSimpleChild(ASTNode child, Indent indent, Wrap wrap, Alignment alignment) {
+ return myBuilder.createXmlBlock(child, wrap, alignment, myXmlFormattingPolicy,indent, child.getTextRange());
+ }
+
+ @Override
+ protected XmlTagBlock createTagBlock(ASTNode child, Indent indent, Wrap wrap, Alignment alignment) {
+ return myBuilder.createXmlTagBlock(child, wrap, alignment, myXmlFormattingPolicy, indent);
+ }
+
+ @Override
+ protected Indent getChildDefaultIndent() {
+ Indent indent = super.getChildDefaultIndent();
+ if (indent == null) {
+ indent = Indent.getNoneIndent();
+ }
+ return indent;
+ }
+
+ protected List buildChildrenNoMerge() {
+ return super.buildChildren();
+ }
+
+ @Override
+ protected List buildChildren() {
+ List childBlocks = patchTopLevelChildBlocks(buildChildrenNoMerge());
+ try {
+ return myBuilder.mergeWithTemplateBlocks(childBlocks, myXmlFormattingPolicy.getSettings(), myXmlFormattingPolicy, getChildDefaultIndent());
+ }
+ catch (FragmentedTemplateException e) {
+ return EMPTY_BLOCK_LIST;
+ }
+ }
+
+ private List patchTopLevelChildBlocks(List originalBlocks) {
+ if (myNode.getPsi() instanceof PsiFile) {
+ List patchedBlocks = new ArrayList<>();
+ for (Block block : originalBlocks) {
+ if (block == originalBlocks.get(0) && block instanceof TemplateXmlBlock) {
+ patchedBlocks.addAll(((TemplateXmlBlock)block).buildChildrenNoMerge());
+ }
+ else {
+ patchedBlocks.add(block);
+ }
+ }
+ return patchedBlocks;
+ }
+ else {
+ return originalBlocks;
+ }
+ }
+
+ @Override
+ public void setIndent(Indent indent) {
+ myIndent = indent;
+ }
+
+ @Override
+ public Indent getIndent() {
+ return myIndent != null ? myIndent : super.getIndent();
+ }
+
+ @Override
+ public Spacing getSpacing(Block child1, @NotNull Block child2) {
+ if (child1 instanceof TemplateLanguageBlock && child2 instanceof TemplateLanguageBlock) {
+ return ((TemplateLanguageBlock)child1).getSpacing((TemplateLanguageBlock)child2);
+ }
+ if (child1 instanceof TemplateLanguageBlock || child2 instanceof TemplateLanguageBlock) {
+ return Spacing.createSpacing(0, Integer.MAX_VALUE, 0, true, myXmlFormattingPolicy.getKeepBlankLines());
+ }
+ return super.getSpacing(child1, child2);
+ }
+
+ public boolean isTextContainingTemplateElements() {
+ if (isTextElement()) {
+ for (ASTNode child = myNode.getFirstChildNode(); child != null; child = child.getTreeNext()) {
+ if (myBuilder.isOuterLanguageElement(child.getPsi())) return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected List splitComment() {
+ if (myNode.getElementType() != XmlElementType.XML_COMMENT) return EMPTY;
+ final ArrayList result = new ArrayList<>(3);
+ ASTNode child = myNode.getFirstChildNode();
+ boolean hasOuterLangElements = false;
+ while (child != null) {
+ if (child instanceof OuterLanguageElement) {
+ hasOuterLangElements = true;
+ }
+ if (myBuilder.isOuterLanguageElement(child.getPsi())) {
+ result.add(createTemplateFragmentWrapper(child));
+ }
+ else {
+ result.add(new XmlBlock(child, null, null, myXmlFormattingPolicy, getChildIndent(), null, isPreserveSpace()));
+ }
+ child = child.getTreeNext();
+ }
+ return hasOuterLangElements ? result : EMPTY;
+ }
+
+ private AnotherLanguageBlockWrapper createTemplateFragmentWrapper(@NotNull ASTNode child) {
+ return new AnotherLanguageBlockWrapper(child, myXmlFormattingPolicy, new ReadOnlyBlock(child), null, child.getStartOffset(),
+ child.getTextRange());
+ }
+}
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlTagBlock.java b/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlTagBlock.java
new file mode 100644
index 000000000000..b81d4c8d3dd1
--- /dev/null
+++ b/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlTagBlock.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2000-2017 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.xml.template.formatter;
+
+import com.intellij.formatting.Alignment;
+import com.intellij.formatting.Block;
+import com.intellij.formatting.Indent;
+import com.intellij.formatting.Wrap;
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.formatter.xml.XmlBlock;
+import com.intellij.psi.formatter.xml.XmlFormattingPolicy;
+import com.intellij.psi.formatter.xml.XmlTagBlock;
+import com.intellij.xml.util.HtmlUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TemplateXmlTagBlock extends XmlTagBlock implements IndentInheritingBlock {
+ private AbstractXmlTemplateFormattingModelBuilder myBuilder;
+ private Indent myInheritedIndent;
+
+ public TemplateXmlTagBlock(final AbstractXmlTemplateFormattingModelBuilder builder,
+ final ASTNode node,
+ final Wrap wrap,
+ final Alignment alignment,
+ final XmlFormattingPolicy policy,
+ final Indent indent) {
+ super(node, wrap, alignment, policy, indent);
+ myBuilder = builder;
+ }
+
+ @Override
+ protected XmlTagBlock createTagBlock(ASTNode child, Indent indent, Wrap wrap, Alignment alignment) {
+ return myBuilder.createXmlTagBlock(child, wrap, alignment, myXmlFormattingPolicy, indent);
+ }
+
+ @Override
+ protected final Block createSyntheticBlock(ArrayList localResult, Indent childrenIndent) {
+ try {
+ List merged = myBuilder.mergeWithTemplateBlocks(localResult, myXmlFormattingPolicy.getSettings(), myXmlFormattingPolicy, childrenIndent);
+ return myBuilder.createSyntheticBlock(merged, this, Indent.getNoneIndent(), myXmlFormattingPolicy, childrenIndent);
+ }
+ catch (FragmentedTemplateException e) {
+ return myBuilder.createSyntheticBlock(localResult, this, Indent.getNoneIndent(), myXmlFormattingPolicy, childrenIndent);
+ }
+ }
+
+
+ @Override
+ protected XmlBlock createSimpleChild(ASTNode child, Indent indent, Wrap wrap, Alignment alignment) {
+ return myBuilder.createXmlBlock(child, wrap, alignment, myXmlFormattingPolicy, indent, null);
+ }
+
+ @Override
+ public void setIndent(Indent indent) {
+ myInheritedIndent = indent;
+ }
+
+ @Override
+ public Indent getIndent() {
+ return myInheritedIndent == null ? super.getIndent() : myInheritedIndent;
+ }
+
+ @Override
+ protected Indent getChildrenIndent() {
+ return Indent.getIndent(myXmlFormattingPolicy.indentChildrenOf(getTag()) ? Indent.Type.NORMAL : Indent.Type.NONE, false, true);
+ }
+
+ boolean isScriptBlock() {
+ return HtmlUtil.isScriptTag(getTag());
+ }
+}
From 26dc4b301ce45daf9d6fbd3ac548f611c9c5319d Mon Sep 17 00:00:00 2001
From: peter
Date: Mon, 10 Apr 2017 15:46:23 +0200
Subject: [PATCH 054/463] add debug logging for flaky NewProjectWizardTest
---
.../src/com/intellij/ide/projectWizard/ProjectTypeStep.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
index f7a0ffccbf5b..27cb4d410370 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
@@ -123,6 +123,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
myTemplatesMap = new ConcurrentMultiMap<>();
final List groups = fillTemplatesMap(context);
+ LOG.debug("groups=" + groups);
myProjectTypeList.setModel(new CollectionListModel<>(groups));
myProjectTypeList.setSelectionModel(new SingleSelectionModel());
@@ -644,6 +645,8 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
}
ModuleBuilder builder = getSelectedBuilder();
+ LOG.debug("builder=" + builder + "; template=" + template + "; group=" + getSelectedGroup() + "; groupIndex=" + myProjectTypeList.getMinSelectionIndex());
+
myContext.setProjectBuilder(builder);
if (builder != null) {
myWizard.getSequence().setType(builder.getBuilderId());
From ce702dd48cd788db1511288db24b224a79218e37 Mon Sep 17 00:00:00 2001
From: "Anna.Kozlova"
Date: Mon, 10 Apr 2017 12:56:48 +0200
Subject: [PATCH 055/463] redundant cast: process multidimensional arrays
(IDEA-171047)
---
.../com/intellij/psi/util/RedundantCastUtil.java | 13 ++++++++++++-
.../lambda/CastInMultidimensionalArrayIndex.java | 5 +++++
.../codeInspection/RedundantCast18Test.java | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 java/java-tests/testData/inspection/redundantCast/lambda/CastInMultidimensionalArrayIndex.java
diff --git a/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
index c02649b0fa68..b1e85b73ca6b 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
@@ -738,7 +738,18 @@ public class RedundantCastUtil {
PsiExpression lExpression = assignment.getLExpression();
return lExpression instanceof PsiArrayAccessExpression &&
PsiTreeUtil.isAncestor(lExpression, parent, false) &&
- !PsiTreeUtil.isAncestor(((PsiArrayAccessExpression)lExpression).getIndexExpression(), element, false);
+ !isIndexExpression(element, (PsiArrayAccessExpression)lExpression);
+ }
+
+ private static boolean isIndexExpression(PsiElement element, PsiArrayAccessExpression arrayAccessExpression) {
+ if (PsiTreeUtil.isAncestor(arrayAccessExpression.getIndexExpression(), element, false)) {
+ return true;
+ }
+ PsiExpression arrayExpression = arrayAccessExpression.getArrayExpression();
+ if (arrayExpression instanceof PsiArrayAccessExpression) {
+ return isIndexExpression(element, (PsiArrayAccessExpression)arrayExpression);
+ }
+ return false;
}
}
diff --git a/java/java-tests/testData/inspection/redundantCast/lambda/CastInMultidimensionalArrayIndex.java b/java/java-tests/testData/inspection/redundantCast/lambda/CastInMultidimensionalArrayIndex.java
new file mode 100644
index 000000000000..5e6a9c5471c0
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/lambda/CastInMultidimensionalArrayIndex.java
@@ -0,0 +1,5 @@
+class MyTest {
+ void bar(Object[] update, Object[][] grid){
+ grid[(int)update[0]][1] = null;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
index f544cfa44798..d1c48111b910 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
@@ -41,4 +41,5 @@ public class RedundantCast18Test extends LightDaemonAnalyzerTestCase {
public void testConditional() { doTest(); }
public void testInferApplicabilityError() { doTest(); }
public void testCastToRawType() { doTest(); }
+ public void testCastInMultidimensionalArrayIndex() { doTest(); }
}
\ No newline at end of file
From 3b40c576a5ab8ff65882f94b2ce58ba66618eebf Mon Sep 17 00:00:00 2001
From: "Anna.Kozlova"
Date: Mon, 10 Apr 2017 14:24:54 +0200
Subject: [PATCH 056/463] extract method: up/down for visibility for the cases
when there is no name suggestions only (IDEA-171048)
---
.../refactoring/extractMethod/ExtractMethodDialog.java | 4 +++-
.../src/com/intellij/refactoring/ui/NameSuggestionsField.java | 4 ++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java
index e87889a5c136..e69233b24e3e 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java
@@ -219,7 +219,9 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac
myNameField.addDataChangedListener(this::update);
myVisibilityPanel = createVisibilityPanel();
- myVisibilityPanel.registerUpDownActionsFor(myNameField);
+ if (!myNameField.hasSuggestions()) {
+ myVisibilityPanel.registerUpDownActionsFor(myNameField);
+ }
final JPanel visibilityAndReturnType = new JPanel(new BorderLayout(2, 0));
if (!myTargetClass.isInterface()) {
visibilityAndReturnType.add(myVisibilityPanel, BorderLayout.WEST);
diff --git a/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java b/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java
index 66cbfc5a8e3f..f7813e953d0e 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java
@@ -182,6 +182,10 @@ public class NameSuggestionsField extends JPanel {
}
}
+ public boolean hasSuggestions() {
+ return myComponent instanceof JComboBox;
+ }
+
private JComponent createTextFieldForName(String[] nameSuggestions, FileType fileType) {
final String text;
if (nameSuggestions != null && nameSuggestions.length > 0 && nameSuggestions[0] != null) {
From 6d953a8d9e39f50630366375fbc77c51a06f1501 Mon Sep 17 00:00:00 2001
From: "Anna.Kozlova"
Date: Mon, 10 Apr 2017 15:38:49 +0200
Subject: [PATCH 057/463] don't highlight empty ranges (IDEA-171176)
---
.../codeInsight/highlighting/HighlightUsagesHandler.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java
index 3150af69cbbb..e76cceecdc18 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java
@@ -411,6 +411,7 @@ public class HighlightUsagesHandler extends HighlightHandlerBase {
for (TextRange relativeRange : ReferenceRange.getRanges(ref)) {
PsiElement element = ref.getElement();
TextRange range = safeCut(element.getTextRange(), relativeRange);
+ if (range.isEmpty()) continue;
// injection occurs
result.add(InjectedLanguageManager.getInstance(element.getProject()).injectedToHost(element, range));
}
From 45816f0ef4da8cf27ad72c61f2615312ab2534c9 Mon Sep 17 00:00:00 2001
From: nik
Date: Mon, 10 Apr 2017 16:55:02 +0300
Subject: [PATCH 058/463] build scripts: explicitly include JpsGantTool in IDEA
community build scripts instead of using utils.gant
---
.../jetbrains/intellij/build/IdeaCommunityBuilder.groovy | 3 +++
build/scripts/dist.gant | 6 ++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/build/groovy/org/jetbrains/intellij/build/IdeaCommunityBuilder.groovy b/build/groovy/org/jetbrains/intellij/build/IdeaCommunityBuilder.groovy
index 59a7623a7a55..936c9b8266a1 100644
--- a/build/groovy/org/jetbrains/intellij/build/IdeaCommunityBuilder.groovy
+++ b/build/groovy/org/jetbrains/intellij/build/IdeaCommunityBuilder.groovy
@@ -16,6 +16,8 @@
package org.jetbrains.intellij.build
import org.codehaus.gant.GantBinding
+import org.jetbrains.jps.gant.JpsGantTool
+
/**
* @author nik
*/
@@ -25,6 +27,7 @@ class IdeaCommunityBuilder {
IdeaCommunityBuilder(String home, GantBinding binding, BuildOptions options = new BuildOptions(), String projectHome = home) {
this.binding = binding
+ binding.includeTool << JpsGantTool
buildContext = BuildContext.createContext(binding.ant, binding.projectBuilder, binding.project, binding.global, home, projectHome,
new IdeaCommunityProperties(home), ProprietaryBuildTools.DUMMY,
options)
diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant
index adb7c6850840..216821e4bb01 100644
--- a/build/scripts/dist.gant
+++ b/build/scripts/dist.gant
@@ -13,13 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
import org.jetbrains.intellij.build.BuildOptions
import org.jetbrains.intellij.build.IdeaCommunityBuilder
+import org.jetbrains.jps.idea.IdeaProjectLoader
-import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
-
-includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
+String home = IdeaProjectLoader.guessHome(this)
target(compile: "Compile project") {
new IdeaCommunityBuilder(home, binding).compileModules()
From 980ff05ae93f9a6c58ea0882ce26cbce1de29ed2 Mon Sep 17 00:00:00 2001
From: nik
Date: Mon, 10 Apr 2017 16:59:57 +0300
Subject: [PATCH 059/463] build scripts: removed obsolete unused
'build-dist-jars' target
---
build/scripts/dist.gant | 7 -------
build/update.xml | 6 ------
2 files changed, 13 deletions(-)
diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant
index 216821e4bb01..8c0a6545572b 100644
--- a/build/scripts/dist.gant
+++ b/build/scripts/dist.gant
@@ -29,13 +29,6 @@ target('default': 'The default target') {
new IdeaCommunityBuilder(home, binding, options).buildDistributions()
}
-//todo[nik] do we really need this target? update.xml calls layout.gant directly
-target('build-dist-jars' : 'Target to build jars from locally compiled classes') {
- def options = new BuildOptions()
- options.useCompiledClassesFromProjectOutput = true
- new IdeaCommunityBuilder(home, binding, options).buildDistJars()
-}
-
target('build-intellij-core' : 'Build intellij-core.zip') {
def options = new BuildOptions()
new IdeaCommunityBuilder(home, binding, options).buildIntelliJCore()
diff --git a/build/update.xml b/build/update.xml
index 3decc239a398..8f26fc1a1519 100644
--- a/build/update.xml
+++ b/build/update.xml
@@ -58,12 +58,6 @@
deploy="${project.home}/out/deploy"/>
-
-
-
-
Date: Mon, 10 Apr 2017 17:04:00 +0300
Subject: [PATCH 060/463] build scripts: dist.gant renamed to
build_idea_community.gant for clarity
dist.gant is supposed to be used for building IDEA Community edition only, so it's better to rename it to avoid confusion.
---
build.xml | 2 +-
build/scripts/{dist.gant => build_idea_community.gant} | 0
build/update.xml | 4 ++--
.../groovy/org/jetbrains/intellij/build/package.html | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
rename build/scripts/{dist.gant => build_idea_community.gant} (100%)
diff --git a/build.xml b/build.xml
index 40671823724e..fa31737abf7f 100644
--- a/build.xml
+++ b/build.xml
@@ -40,7 +40,7 @@
-
+
diff --git a/build/scripts/dist.gant b/build/scripts/build_idea_community.gant
similarity index 100%
rename from build/scripts/dist.gant
rename to build/scripts/build_idea_community.gant
diff --git a/build/update.xml b/build/update.xml
index 8f26fc1a1519..5fe02d00d804 100644
--- a/build/update.xml
+++ b/build/update.xml
@@ -53,13 +53,13 @@
-
-
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/package.html b/platform/build-scripts/groovy/org/jetbrains/intellij/build/package.html
index 4a4753bc88d1..dd9b420580d9 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/package.html
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/package.html
@@ -3,7 +3,7 @@
This package contains groovy scripts which build distributions of products based on IntelliJ Platform.
-If you want to build a product from sources locally, run the corresponding *.gant file from IntelliJ IDEA (e.g. dist.gant to build IDEA Community).
+If you want to build a product from sources locally, run the corresponding *.gant file from IntelliJ IDEA (e.g. build_idea_community.gant to build IDEA Community).
Do not forget to add 'Build Project' step to 'Before Launch' section of the created Run configuration to ensure that changed groovy scripts are copied to the output.
It makes sense to add {@linkplain org.jetbrains.intellij.build.BuildOptions#USE_COMPILED_CLASSES_PROPERTY '-Dintellij.build.use.compiled.classes=true'} to 'VM Options'
to skip compilation and use the compiled classes from the project output. Also you may use {@linkplain org.jetbrains.intellij.build.BuildOptions#targetOS 'intellij.build.target.os'}
From 6f91705613de243f6419078e08f9eaa22cf06eef Mon Sep 17 00:00:00 2001
From: Roman Shevchenko
Date: Mon, 10 Apr 2017 16:04:42 +0200
Subject: [PATCH 061/463] [java] Maven-compatible compliance option for Java 9
---
java/java-psi-api/src/com/intellij/pom/java/LanguageLevel.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/java/java-psi-api/src/com/intellij/pom/java/LanguageLevel.java b/java/java-psi-api/src/com/intellij/pom/java/LanguageLevel.java
index 66ed4b51a787..ed493cc208b6 100644
--- a/java/java-psi-api/src/com/intellij/pom/java/LanguageLevel.java
+++ b/java/java-psi-api/src/com/intellij/pom/java/LanguageLevel.java
@@ -38,7 +38,7 @@ public enum LanguageLevel {
JDK_1_6("Java 6", JavaCoreBundle.message("jdk.1.6.language.level.description"), "1.6", "6"),
JDK_1_7("Java 7", JavaCoreBundle.message("jdk.1.7.language.level.description"), "1.7", "7"),
JDK_1_8("Java 8", JavaCoreBundle.message("jdk.1.8.language.level.description"), "1.8", "8"),
- JDK_1_9("Java 9", JavaCoreBundle.message("jdk.1.9.language.level.description"), "9"),
+ JDK_1_9("Java 9", JavaCoreBundle.message("jdk.1.9.language.level.description"), "9", "1.9"),
JDK_X("Java X", JavaCoreBundle.message("jdk.X.language.level.description"), "");
public static final LanguageLevel HIGHEST = JDK_1_9;
From 3c68c9910abb05db5cae390e2005400d57a455d7 Mon Sep 17 00:00:00 2001
From: nik
Date: Mon, 10 Apr 2017 17:17:59 +0300
Subject: [PATCH 062/463] build scripts: don't interrupt project loading if
Kotlin Compiler is already in classpath
All glory to statically typed languages!
---
build/scripts/utils.gant | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant
index 974307edc841..c3d7002bf503 100644
--- a/build/scripts/utils.gant
+++ b/build/scripts/utils.gant
@@ -152,7 +152,7 @@ private void setupKotlin() {
private boolean ensureKotlinCompilerAddedToClassPath() {
try {
Class.forName("org.jetbrains.kotlin.jps.build.KotlinBuilder")
- return
+ return true
}
catch (ClassNotFoundException ignored) {
}
From 42324efe82f0d4f265260fdc3e331df6842bff1f Mon Sep 17 00:00:00 2001
From: Rustam Vishnyakov
Date: Mon, 10 Apr 2017 18:07:15 +0300
Subject: [PATCH 063/463] Remove unnecessary code from deprecated classes
---
.../formatter/AbstractXmlTemplateFormattingModelBuilder.java | 1 -
.../com/intellij/xml/template/formatter/TemplateFormatUtil.java | 1 -
.../intellij/xml/template/formatter/TemplateLanguageBlock.java | 1 -
.../com/intellij/xml/template/formatter/TemplateXmlBlock.java | 1 -
4 files changed, 4 deletions(-)
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/AbstractXmlTemplateFormattingModelBuilder.java b/xml/impl/src/com/intellij/xml/template/formatter/AbstractXmlTemplateFormattingModelBuilder.java
index ac14ac3a697f..63c85115df9c 100644
--- a/xml/impl/src/com/intellij/xml/template/formatter/AbstractXmlTemplateFormattingModelBuilder.java
+++ b/xml/impl/src/com/intellij/xml/template/formatter/AbstractXmlTemplateFormattingModelBuilder.java
@@ -41,7 +41,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
-@SuppressWarnings("Duplicates")
public abstract class AbstractXmlTemplateFormattingModelBuilder extends SimpleTemplateLanguageFormattingModelBuilder {
@NotNull
@Override
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/TemplateFormatUtil.java b/xml/impl/src/com/intellij/xml/template/formatter/TemplateFormatUtil.java
index d64c308c24fb..33278429fc79 100644
--- a/xml/impl/src/com/intellij/xml/template/formatter/TemplateFormatUtil.java
+++ b/xml/impl/src/com/intellij/xml/template/formatter/TemplateFormatUtil.java
@@ -38,7 +38,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-@SuppressWarnings("Duplicates")
public class TemplateFormatUtil {
private final static List EMPTY_PSI_ELEMENT_LIST = new ArrayList<>();
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/TemplateLanguageBlock.java b/xml/impl/src/com/intellij/xml/template/formatter/TemplateLanguageBlock.java
index 7c3bea5fbc7a..4b8e7d2885f5 100644
--- a/xml/impl/src/com/intellij/xml/template/formatter/TemplateLanguageBlock.java
+++ b/xml/impl/src/com/intellij/xml/template/formatter/TemplateLanguageBlock.java
@@ -32,7 +32,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
-@SuppressWarnings("Duplicates")
public abstract class TemplateLanguageBlock extends AbstractBlock implements BlockEx, IndentInheritingBlock, BlockWithParent {
protected final ASTNode myNode;
diff --git a/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlBlock.java b/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlBlock.java
index bc1e43cb033c..3183566a1546 100644
--- a/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlBlock.java
+++ b/xml/impl/src/com/intellij/xml/template/formatter/TemplateXmlBlock.java
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
-@SuppressWarnings("Duplicates")
public class TemplateXmlBlock extends XmlBlock implements IndentInheritingBlock {
private AbstractXmlTemplateFormattingModelBuilder myBuilder;
private Indent myIndent;
From a5c26082050f6c38078edb9fa1e86acddf25f991 Mon Sep 17 00:00:00 2001
From: Ekaterina Tuzova
Date: Mon, 10 Apr 2017 18:29:23 +0300
Subject: [PATCH 064/463] add virtual file listener on course creation
---
.../edu/coursecreator/CCProjectComponent.java | 11 +++++++++--
.../coursecreator/CCVirtualFileListener.java | 19 ++++++++++---------
.../coursecreator/PyCCProjectGenerator.java | 3 ++-
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/python/educational-core/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java b/python/educational-core/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java
index d1548a4244fe..a9f5fc3a68f5 100644
--- a/python/educational-core/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java
+++ b/python/educational-core/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java
@@ -26,7 +26,7 @@ import java.util.Map;
public class CCProjectComponent extends AbstractProjectComponent {
private static final Logger LOG = Logger.getInstance(CCProjectComponent.class);
- private final CCVirtualFileListener myTaskFileLifeListener = new CCVirtualFileListener();
+ private CCVirtualFileListener myTaskFileLifeListener;
private final Project myProject;
protected CCProjectComponent(Project project) {
@@ -106,11 +106,18 @@ public class CCProjectComponent extends AbstractProjectComponent {
public void projectOpened() {
migrateIfNeeded();
if (CCUtils.isCourseCreator(myProject)) {
- VirtualFileManager.getInstance().addVirtualFileListener(myTaskFileLifeListener);
+ registerListener();
EduUsagesCollector.projectTypeOpened(CCUtils.COURSE_MODE);
}
}
+ public void registerListener() {
+ if (myTaskFileLifeListener == null) {
+ myTaskFileLifeListener = new CCVirtualFileListener(myProject);
+ VirtualFileManager.getInstance().addVirtualFileListener(myTaskFileLifeListener);
+ }
+ }
+
public void projectClosed() {
VirtualFileManager.getInstance().removeVirtualFileListener(myTaskFileLifeListener);
}
diff --git a/python/educational-core/src/com/jetbrains/edu/coursecreator/CCVirtualFileListener.java b/python/educational-core/src/com/jetbrains/edu/coursecreator/CCVirtualFileListener.java
index 7a2f28b61b4a..d116df72d72b 100644
--- a/python/educational-core/src/com/jetbrains/edu/coursecreator/CCVirtualFileListener.java
+++ b/python/educational-core/src/com/jetbrains/edu/coursecreator/CCVirtualFileListener.java
@@ -17,6 +17,11 @@ import com.jetbrains.edu.learning.courseFormat.tasks.Task;
import org.jetbrains.annotations.NotNull;
public class CCVirtualFileListener implements VirtualFileListener {
+ private final Project myProject;
+
+ public CCVirtualFileListener(Project project) {
+ myProject = project;
+ }
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
@@ -27,18 +32,14 @@ public class CCVirtualFileListener implements VirtualFileListener {
if (createdFile.getPath().contains(CCUtils.GENERATED_FILES_FOLDER)) {
return;
}
- Project project = ProjectUtil.guessProjectForFile(createdFile);
- if (project == null) {
+ if (myProject.getBasePath() !=null && !FileUtil.isAncestor(myProject.getBasePath(), createdFile.getPath(), true)) {
return;
}
- if (project.getBasePath() !=null && !FileUtil.isAncestor(project.getBasePath(), createdFile.getPath(), true)) {
- return;
- }
- Course course = StudyTaskManager.getInstance(project).getCourse();
+ Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course == null) {
return;
}
- TaskFile taskFile = StudyUtils.getTaskFile(project, createdFile);
+ TaskFile taskFile = StudyUtils.getTaskFile(myProject, createdFile);
if (taskFile != null) {
return;
}
@@ -50,7 +51,7 @@ public class CCVirtualFileListener implements VirtualFileListener {
return;
}
- if (CCUtils.isTestsFile(project, createdFile)
+ if (CCUtils.isTestsFile(myProject, createdFile)
|| StudyUtils.isTaskDescriptionFile(createdFile.getName())
|| taskRelativePath.contains(EduNames.WINDOW_POSTFIX)
|| taskRelativePath.contains(EduNames.WINDOWS_POSTFIX)
@@ -61,7 +62,7 @@ public class CCVirtualFileListener implements VirtualFileListener {
if (taskVF == null) {
return;
}
- Task task = StudyUtils.getTask(project, taskVF);
+ Task task = StudyUtils.getTask(myProject, taskVF);
if (task == null) {
return;
}
diff --git a/python/educational-python/Edu-Python/src/com/jetbrains/edu/coursecreator/PyCCProjectGenerator.java b/python/educational-python/Edu-Python/src/com/jetbrains/edu/coursecreator/PyCCProjectGenerator.java
index 558c12db1091..6d8c60deb37b 100644
--- a/python/educational-python/Edu-Python/src/com/jetbrains/edu/coursecreator/PyCCProjectGenerator.java
+++ b/python/educational-python/Edu-Python/src/com/jetbrains/edu/coursecreator/PyCCProjectGenerator.java
@@ -58,7 +58,8 @@ public class PyCCProjectGenerator extends PythonProjectGenerator
Date: Mon, 10 Apr 2017 18:44:17 +0300
Subject: [PATCH 065/463] incompatible NodeJS 172.714
---
platform/platform-resources/src/brokenPlugins.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/platform/platform-resources/src/brokenPlugins.txt b/platform/platform-resources/src/brokenPlugins.txt
index c2a003f5f079..d2bf38e71389 100644
--- a/platform/platform-resources/src/brokenPlugins.txt
+++ b/platform/platform-resources/src/brokenPlugins.txt
@@ -1,7 +1,7 @@
// This file contains list of broken plugins.
// Each line contains plugin ID and list of versions that are broken.
// If plugin name or version contains a space you can quote it like in command line.
-NodeJS 171.1020 171.1281 171.181 171.437 171.860 171.1461 171.1519 163.1699 163.1616 163.1479 163.1374.5 163.1105 163.1059 163.607 163.198 144.2986 144.2925.4 144.2911 144.2562 144.2131 144.988 143.1138 143.1088 143.769 143.751 143.516 143.381.8 143.380.6 143.381.11 143.380.8 143.444 143.379.15 143.21 143.110 143.250 142.4426 142.4100 142.3858 142.3224 142.2650 142.2492 142.2481 142.2064 141.1108 140.2045 140.1669 140.642 139.173 139.105 139.496 139.1 139.8 138.2196 138.2254 138.1684 138.1744 138.1879 138.2051 138.1367 138.1495 138.1189 138.1145 138.937 138.1013 138.921 138.447 138.172 138.317 138.21 138.35 138.96 138.85 136.1205 134.1276 134.1163 134.1145 134.1081 134.1039 134.985 134.680 134.31 134.307 134.262 134.198 134.125 136.1141
+NodeJS 172.714 171.1020 171.1281 171.181 171.437 171.860 171.1461 171.1519
com.jetbrains.php 162.646.18 162.426.10 145.970.40 145.258.2 144.4199.11 144.3891.12 144.3656 144.3168 143.790 143.1770 143.1184.87 143.382.38 143.279 143.381.48 143.129 142.5282 142.2716 142.3969 142.4491 140.2765 141.332 139.732 139.659 139.496 139.173 139.105 138.2502 138.2000.2262 138.1751 138.1806 138.1505 138.1161 138.826 136.1768 136.1672 134.1456 133.982 133.679 133.51 133.326 131.98 131.374 131.332 131.235 131.205 130.1639 130.1481 130.1176 129.91 129.814 129.672 129.362 127.67 127.100 126.334 123.66 122.875 121.62 121.390 121.215 121.12
com.intellij.phing 133.51 131.374 129.672 127.67 124.347 121.62 121.390 121.215 121.12 117.746 117.694 117.501 117.257 117.222 117.132 114.282 114.158
com.intellij.plugins.html.instantEditing 162.5 0.4.1 0.4 0.3.9 0.3.8 0.3.7 0.3.6 0.3.5 0.3.3 0.3.2 0.3.10 0.3.1 0.3 0.2.27 0.2.25 0.2.24 0.2.23
From d85f30a9684119d8d0a51b80a92066a7c51468e6 Mon Sep 17 00:00:00 2001
From: Ekaterina Tuzova
Date: Mon, 10 Apr 2017 18:46:39 +0300
Subject: [PATCH 066/463] remove listener only if it was added previously
---
.../com/jetbrains/edu/coursecreator/CCProjectComponent.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/python/educational-core/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java b/python/educational-core/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java
index a9f5fc3a68f5..4e0e4e7bb726 100644
--- a/python/educational-core/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java
+++ b/python/educational-core/src/com/jetbrains/edu/coursecreator/CCProjectComponent.java
@@ -119,6 +119,8 @@ public class CCProjectComponent extends AbstractProjectComponent {
}
public void projectClosed() {
- VirtualFileManager.getInstance().removeVirtualFileListener(myTaskFileLifeListener);
+ if (myTaskFileLifeListener != null) {
+ VirtualFileManager.getInstance().removeVirtualFileListener(myTaskFileLifeListener);
+ }
}
}
From 64a5cfc5f5a33c740d7b8c6a63d73783e10eae48 Mon Sep 17 00:00:00 2001
From: "Vassiliy.Kudryashov"
Date: Mon, 10 Apr 2017 18:48:09 +0300
Subject: [PATCH 067/463] Rollback platform-wide popups misbehavior (e.g.
Diagram popup appears and disappears immediately); Find In Path: better
traversal policy, checkboxes are not focusable anymore.
Signed-off-by: Vassiliy.Kudryashov
---
.../intellij/find/impl/FindPopupPanel.java | 58 ++++++++++++++++---
.../src/com/intellij/ide/IdePopupManager.java | 3 -
2 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java
index b31aa0ee9a19..8250497e12d8 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java
@@ -31,6 +31,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.help.HelpManager;
+import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.util.ProgressIndicatorBase;
@@ -82,6 +83,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
+import javax.swing.text.JTextComponent;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
@@ -263,7 +265,7 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
myTitleLabel = new JBLabel(FindBundle.message("find.in.path.dialog.title"), UIUtil.ComponentStyle.REGULAR);
myTitleLabel.setFont(myTitleLabel.getFont().deriveFont(Font.BOLD));
myTitleLabel.setBorder(JBUI.Borders.empty(0, 4, 0, 16));
- myCbCaseSensitive = new StateRestoringCheckBox(FindBundle.message("find.popup.case.sensitive"));
+ myCbCaseSensitive = createCheckBox("find.popup.case.sensitive");
ItemListener liveResultsPreviewUpdateListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
@@ -271,14 +273,14 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
}
};
myCbCaseSensitive.addItemListener(liveResultsPreviewUpdateListener);
- myCbPreserveCase = new StateRestoringCheckBox(FindBundle.message("find.options.replace.preserve.case"));
+ myCbPreserveCase = createCheckBox("find.options.replace.preserve.case");
myCbPreserveCase.addItemListener(liveResultsPreviewUpdateListener);
myCbPreserveCase.setVisible(myHelper.getModel().isReplaceState());
- myCbWholeWordsOnly = new StateRestoringCheckBox(FindBundle.message("find.popup.whole.words"));
+ myCbWholeWordsOnly = createCheckBox("find.popup.whole.words");
myCbWholeWordsOnly.addItemListener(liveResultsPreviewUpdateListener);
- myCbRegularExpressions = new StateRestoringCheckBox(FindBundle.message("find.popup.regex"));
+ myCbRegularExpressions = createCheckBox("find.popup.regex");
myCbRegularExpressions.addItemListener(liveResultsPreviewUpdateListener);
- myCbFileFilter = new StateRestoringCheckBox(FindBundle.message("find.popup.filemask"));
+ myCbFileFilter = createCheckBox("find.popup.filemask");
myCbFileFilter.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
@@ -328,7 +330,12 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
}
};
myShowFilterPopupAction.registerCustomShortcutSet(myShowFilterPopupAction.getShortcutSet(), this);
- myFilterContextButton.setFocusable(true);
+ registerPostProcessor(IdeActions.ACTION_EDIT_SOURCE, this, () -> {
+ if (myBalloon != null && !myBalloon.isDisposed()) {
+ myBalloon.cancel();
+ }
+ });
+ //myFilterContextButton.setFocusable(true);
DefaultActionGroup tabResultsContextGroup = new DefaultActionGroup();
tabResultsContextGroup.add(new ToggleAction(FindBundle.message("find.options.skip.results.tab.with.one.usage.checkbox")) {
@@ -578,7 +585,7 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
MnemonicHelper.init(this);
setFocusCycleRoot(true);
- setFocusTraversalPolicy(new ContainerOrderFocusTraversalPolicy() {
+ setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
@Override
public Component getComponentAfter(Container container, Component c) {
return (c == myResultsPreviewTable) ? mySearchComponent : super.getComponentAfter(container, c);
@@ -586,6 +593,13 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
});
}
+ @NotNull
+ private static StateRestoringCheckBox createCheckBox(String message) {
+ StateRestoringCheckBox checkBox = new StateRestoringCheckBox(FindBundle.message(message));
+ checkBox.setFocusable(false);
+ return checkBox;
+ }
+
private void registerCloseAction(JBPopup popup) {
final AnAction escape = ActionManager.getInstance().getAction("EditorEscape");
DumbAwareAction closeAction = new DumbAwareAction() {
@@ -692,8 +706,17 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
private void updateScopeDetailsPanel() {
((CardLayout)myScopeDetailsPanel.getLayout()).show(myScopeDetailsPanel, mySelectedScope.name);
+ Component firstFocusableComponent =
+ UIUtil.uiTraverser(myScopeDetailsPanel).bfsTraversal().find(c -> c.isFocusable() && c.isEnabled() && c.isShowing() &&
+ (c instanceof JComboBox ||
+ c instanceof AbstractButton ||
+ c instanceof JTextComponent));
myScopeDetailsPanel.revalidate();
myScopeDetailsPanel.repaint();
+ if (firstFocusableComponent != null) {
+ ApplicationManager.getApplication().invokeLater(
+ () -> IdeFocusManager.getInstance(myProject).requestFocus(firstFocusableComponent, true));
+ }
}
public void scheduleResultsUpdate() {
@@ -1097,4 +1120,25 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
listPopup.showUnderneathOf(myFilterContextButton);
}
}
+
+ private static boolean registerPostProcessor(@NotNull String actionId,
+ @NotNull JComponent component,
+ @NotNull Runnable postProcessor) {
+ AnAction action = ActionManager.getInstance().getAction(actionId);
+ Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
+ if (action == null || shortcuts.length == 0) return false;
+ AnAction wrapper = new AnAction() {
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ action.beforeActionPerformedUpdate(e);
+ if (e.getPresentation().isEnabled()) {
+ action.actionPerformed(e);
+ postProcessor.run();
+ }
+ }
+ };
+ wrapper.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), component);
+ return true;
+ }
+
}
diff --git a/platform/platform-impl/src/com/intellij/ide/IdePopupManager.java b/platform/platform-impl/src/com/intellij/ide/IdePopupManager.java
index 53951e39b779..b937fcf409b0 100644
--- a/platform/platform-impl/src/com/intellij/ide/IdePopupManager.java
+++ b/platform/platform-impl/src/com/intellij/ide/IdePopupManager.java
@@ -83,9 +83,6 @@ public final class IdePopupManager implements IdeEventQueue.EventDispatcher {
shouldCloseAllPopup = true;
}
}
- if (!shouldCloseAllPopup && isPopupWindow(sourceWindow) && sourceWindow.getParent() == ((WindowEvent)e).getOppositeWindow()) {
- shouldCloseAllPopup = true;
- }
if (shouldCloseAllPopup) {
closeAllPopups();
From f05fadd5e72511c14af76426011dad3465ac611f Mon Sep 17 00:00:00 2001
From: "Maxim.Mossienko"
Date: Mon, 10 Apr 2017 17:53:48 +0200
Subject: [PATCH 068/463] Do not query index under processing of other index
(IDEA-171212)
(cherry picked from commit 0d534b8), IDEA-CR-20178
---
.../codeInsight/completion/JavaModuleCompletion.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaModuleCompletion.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaModuleCompletion.java
index 1f22855ed2d5..f63dea163353 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaModuleCompletion.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaModuleCompletion.java
@@ -30,8 +30,10 @@ import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.Consumer;
+import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
+import java.util.Set;
import java.util.function.Predicate;
import static com.intellij.codeInsight.completion.BasicExpressionCompletionContributor.createKeywordLookupItem;
@@ -110,12 +112,18 @@ class JavaModuleCompletion {
Project project = context.getProject();
JavaModuleNameIndex index = JavaModuleNameIndex.getInstance();
GlobalSearchScope scope = ProjectScope.getAllScope(project);
+ Set candidateNames = new THashSet<>();
index.processAllKeys(project, name -> {
- if (!name.equals(hostName) && index.get(name, project, scope).size() == 1) {
- result.consume(new OverrideableSpace(LookupElementBuilder.create(name), TailType.SEMICOLON));
+ if (!name.equals(hostName)) {
+ candidateNames.add(name);
}
return true;
});
+ for(String candidateName:candidateNames) {
+ if(index.get(candidateName, project, scope).size() == 1) {
+ result.consume(new OverrideableSpace(LookupElementBuilder.create(candidateName), TailType.SEMICOLON));
+ }
+ }
}
}
}
From 561723ced5dc8f77d755a70a2a32658ca44c3871 Mon Sep 17 00:00:00 2001
From: "Egor.Ushakov"
Date: Mon, 10 Apr 2017 15:42:28 +0300
Subject: [PATCH 069/463] cleanup: use ReadAction
---
.../debugger/actions/EditSourceAction.java | 11 +--
.../debugger/actions/JumpToObjectAction.java | 26 +++----
.../intellij/debugger/engine/JVMNameUtil.java | 17 ++---
.../debugger/engine/JavaStackFrame.java | 14 ++--
.../intellij/debugger/engine/JavaValue.java | 37 +++++-----
.../debugger/engine/PositionManagerImpl.java | 69 +++++++++----------
.../intellij/debugger/engine/RequestHint.java | 21 +++---
.../engine/requests/RequestManagerImpl.java | 15 ++--
.../intellij/debugger/impl/PositionUtil.java | 29 ++++----
.../debugger/jdi/LocalVariablesUtil.java | 46 ++++++-------
.../com/intellij/debugger/ui/ValueHint.java | 19 ++---
.../BreakpointWithHighlighter.java | 28 ++------
.../ui/breakpoints/ExceptionBreakpoint.java | 13 ++--
.../JavaExceptionBreakpointType.java | 14 ++--
.../ui/breakpoints/LineBreakpoint.java | 66 ++++++++----------
.../ui/breakpoints/MethodBreakpoint.java | 63 ++++++++---------
16 files changed, 200 insertions(+), 288 deletions(-)
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/EditSourceAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/EditSourceAction.java
index dec60411ee1a..5c644854b043 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/EditSourceAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/EditSourceAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -30,9 +30,8 @@ import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.Presentation;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
public class EditSourceAction extends DebuggerAction{
public void actionPerformed(AnActionEvent e) {
@@ -84,11 +83,7 @@ public class EditSourceAction extends DebuggerAction{
}
final NodeDescriptorImpl nodeDescriptor1 = nodeDescriptor;
- return ApplicationManager.getApplication().runReadAction(new Computable() {
- public SourcePosition compute() {
- return SourcePositionProvider.getSourcePosition(nodeDescriptor1, project, context);
- }
- });
+ return ReadAction.compute(() -> SourcePositionProvider.getSourcePosition(nodeDescriptor1, project, context));
}
public void update(AnActionEvent e) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JumpToObjectAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/JumpToObjectAction.java
index 85f164ec4e0e..84ab2aba6b65 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/JumpToObjectAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/JumpToObjectAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -27,9 +27,8 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
import com.intellij.debugger.ui.tree.ValueDescriptor;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiClass;
import com.intellij.util.containers.ContainerUtil;
import com.sun.jdi.*;
@@ -108,21 +107,18 @@ public class JumpToObjectAction extends DebuggerAction{
if (location != null) {
SourcePosition position = debugProcess.getPositionManager().getSourcePosition(location);
- return ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public SourcePosition compute() {
- // adjust position for non-anonymous classes
- if (clsType.name().indexOf('$') < 0) {
- PsiClass classAt = JVMNameUtil.getClassAt(position);
- if (classAt != null) {
- SourcePosition classPosition = SourcePosition.createFromElement(classAt);
- if (classPosition != null) {
- return classPosition;
- }
+ return ReadAction.compute(() -> {
+ // adjust position for non-anonymous classes
+ if (clsType.name().indexOf('$') < 0) {
+ PsiClass classAt = JVMNameUtil.getClassAt(position);
+ if (classAt != null) {
+ SourcePosition classPosition = SourcePosition.createFromElement(classAt);
+ if (classPosition != null) {
+ return classPosition;
}
}
- return position;
}
+ return position;
});
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java b/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java
index 9a8f2e9651d5..84561dc600e6 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -21,11 +21,10 @@ import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.ide.util.JavaAnonymousClassesHelper;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
@@ -222,11 +221,7 @@ public class JVMNameUtil {
List allClasses = process.getPositionManager().getAllClasses(mySourcePosition);
// If there are more than one available, try to match by name
if (allClasses.size() > 1) {
- String name = ApplicationManager.getApplication().runReadAction(new Computable() {
- public String compute() {
- return getClassVMName(getClassAt(mySourcePosition));
- }
- });
+ String name = ReadAction.compute(() -> getClassVMName(getClassAt(mySourcePosition)));
for (ReferenceType aClass : allClasses) {
if (Comparing.equal(aClass.name(), name)) {
return name;
@@ -241,11 +236,7 @@ public class JVMNameUtil {
}
public String getDisplayName(final DebugProcessImpl debugProcess) {
- return ApplicationManager.getApplication().runReadAction(new Computable() {
- public String compute() {
- return getSourcePositionClassDisplayName(debugProcess, mySourcePosition);
- }
- });
+ return ReadAction.compute(() -> getSourcePositionClassDisplayName(debugProcess, mySourcePosition));
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java
index ee817cd7ef17..fe4d073e93fa 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java
@@ -37,11 +37,14 @@ import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.impl.watch.*;
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener;
import com.intellij.lang.java.JavaLanguage;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
@@ -302,12 +305,7 @@ public class JavaStackFrame extends XStackFrame implements JVMStackFrameInfoProv
Pair, Set> usedVars = EMPTY_USED_VARS;
if (sourcePosition != null) {
- usedVars = ApplicationManager.getApplication().runReadAction(new Computable, Set>>() {
- @Override
- public Pair, Set> compute() {
- return findReferencedVars(ContainerUtil.union(visibleVariables.keySet(), visibleLocals), sourcePosition);
- }
- });
+ usedVars = ReadAction.compute(() -> findReferencedVars(ContainerUtil.union(visibleVariables.keySet(), visibleLocals), sourcePosition));
}
// add locals
if (myAutoWatchMode) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
index 99f91a1ddda6..349cf19bb605 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
@@ -33,9 +33,9 @@ import com.intellij.debugger.ui.tree.*;
import com.intellij.debugger.ui.tree.render.*;
import com.intellij.debugger.ui.tree.render.Renderer;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.CommonClassNames;
@@ -521,29 +521,26 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) throws Exception {
- evaluationExpression = ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public XExpression compute() {
- try {
- PsiElement psiExpression = getDescriptor().getTreeEvaluation(JavaValue.this, getDebuggerContext());
- if (psiExpression != null) {
- XExpression res = TextWithImportsImpl.toXExpression(new TextWithImportsImpl(psiExpression));
- // add runtime imports if any
- Set imports = psiExpression.getUserData(DebuggerTreeNodeExpression.ADDITIONAL_IMPORTS_KEY);
- if (imports != null && res != null) {
- if (res.getCustomInfo() != null) {
- imports.add(res.getCustomInfo());
- }
- res = new XExpressionImpl(res.getExpression(), res.getLanguage(), StringUtil.join(imports, ","), res.getMode());
+ evaluationExpression = ReadAction.compute(() -> {
+ try {
+ PsiElement psiExpression = getDescriptor().getTreeEvaluation(JavaValue.this, getDebuggerContext());
+ if (psiExpression != null) {
+ XExpression res = TextWithImportsImpl.toXExpression(new TextWithImportsImpl(psiExpression));
+ // add runtime imports if any
+ Set imports = psiExpression.getUserData(DebuggerTreeNodeExpression.ADDITIONAL_IMPORTS_KEY);
+ if (imports != null && res != null) {
+ if (res.getCustomInfo() != null) {
+ imports.add(res.getCustomInfo());
}
- return res;
+ res = new XExpressionImpl(res.getExpression(), res.getLanguage(), StringUtil.join(imports, ","), res.getMode());
}
+ return res;
}
- catch (EvaluateException e) {
- LOG.info(e);
- }
- return null;
}
+ catch (EvaluateException e) {
+ LOG.info(e);
+ }
+ return null;
});
res.setResult(evaluationExpression);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
index cc0248b49442..b00533befec7 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
@@ -30,7 +30,6 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
@@ -92,38 +91,35 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
@Override
public List createPrepareRequests(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position)
throws NoDataException {
- return ApplicationManager.getApplication().runReadAction(new Computable>() {
- @Override
- public List compute() {
- List res = new ArrayList<>();
- for (PsiClass psiClass : getLineClasses(position.getFile(), position.getLine())) {
- ClassPrepareRequestor prepareRequestor = requestor;
- String classPattern = JVMNameUtil.getNonAnonymousClassName(psiClass);
- if (classPattern == null) {
- final PsiClass parent = JVMNameUtil.getTopLevelParentClass(psiClass);
- if (parent == null) {
- continue;
- }
- final String parentQName = JVMNameUtil.getNonAnonymousClassName(parent);
- if (parentQName == null) {
- continue;
- }
- classPattern = parentQName + "*";
- prepareRequestor = new ClassPrepareRequestor() {
- public void processClassPrepare(DebugProcess debuggerProcess, ReferenceType referenceType) {
- if (((DebugProcessImpl)debuggerProcess).getPositionManager().getAllClasses(position).contains(referenceType)) {
- requestor.processClassPrepare(debuggerProcess, referenceType);
- }
+ return ReadAction.compute(() -> {
+ List res = new ArrayList<>();
+ for (PsiClass psiClass : getLineClasses(position.getFile(), position.getLine())) {
+ ClassPrepareRequestor prepareRequestor = requestor;
+ String classPattern = JVMNameUtil.getNonAnonymousClassName(psiClass);
+ if (classPattern == null) {
+ final PsiClass parent = JVMNameUtil.getTopLevelParentClass(psiClass);
+ if (parent == null) {
+ continue;
+ }
+ final String parentQName = JVMNameUtil.getNonAnonymousClassName(parent);
+ if (parentQName == null) {
+ continue;
+ }
+ classPattern = parentQName + "*";
+ prepareRequestor = new ClassPrepareRequestor() {
+ public void processClassPrepare(DebugProcess debuggerProcess, ReferenceType referenceType) {
+ if (((DebugProcessImpl)debuggerProcess).getPositionManager().getAllClasses(position).contains(referenceType)) {
+ requestor.processClassPrepare(debuggerProcess, referenceType);
}
- };
- }
- ClassPrepareRequest request = myDebugProcess.getRequestsManager().createClassPrepareRequest(prepareRequestor, classPattern);
- if (request != null) {
- res.add(request);
- }
+ }
+ };
+ }
+ ClassPrepareRequest request = myDebugProcess.getRequestsManager().createClassPrepareRequest(prepareRequestor, classPattern);
+ if (request != null) {
+ res.add(request);
}
- return res;
}
+ return res;
});
}
@@ -444,15 +440,12 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
@NotNull
public List getAllClasses(@NotNull final SourcePosition position) throws NoDataException {
- return ApplicationManager.getApplication().runReadAction(new Computable>() {
- @Override
- public List compute() {
- List res = new ArrayList<>();
- for (PsiClass aClass : getLineClasses(position.getFile(), position.getLine())) {
- res.addAll(getClassReferences(aClass, position));
- }
- return res;
+ return ReadAction.compute(() -> {
+ List res = new ArrayList<>();
+ for (PsiClass aClass : getLineClasses(position.getFile(), position.getLine())) {
+ res.addAll(getClassReferences(aClass, position));
}
+ return res;
});
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java b/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java
index f5adb418da5a..b6ff4f23ff1c 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java
@@ -28,9 +28,8 @@ import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.debugger.settings.DebuggerSettings;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiElement;
import com.intellij.util.Range;
import com.sun.jdi.Location;
@@ -202,13 +201,11 @@ public class RequestHint {
if ((myDepth == StepRequest.STEP_OVER || myDepth == StepRequest.STEP_INTO) && myPosition != null) {
SourcePosition locationPosition = ContextUtil.getSourcePosition(context);
if (locationPosition != null) {
- Integer resultDepth = ApplicationManager.getApplication().runReadAction(new Computable() {
- public Integer compute() {
- if (myPosition.getFile().equals(locationPosition.getFile()) && isTheSameFrame(context) && !mySteppedOut) {
- return isOnTheSameLine(locationPosition) ? myDepth : STOP;
- }
- return null;
+ Integer resultDepth = ReadAction.compute(() -> {
+ if (myPosition.getFile().equals(locationPosition.getFile()) && isTheSameFrame(context) && !mySteppedOut) {
+ return isOnTheSameLine(locationPosition) ? myDepth : STOP;
}
+ return null;
});
if (resultDepth != null) {
return resultDepth.intValue();
@@ -231,11 +228,9 @@ public class RequestHint {
if (!myIgnoreFilters) {
if(settings.SKIP_GETTERS) {
- boolean isGetter = ApplicationManager.getApplication().runReadAction(new Computable(){
- public Boolean compute() {
- PsiElement contextElement = ContextUtil.getContextElement(context);
- return contextElement != null && DebuggerUtils.isInsideSimpleGetter(contextElement);
- }
+ boolean isGetter = ReadAction.compute(() -> {
+ PsiElement contextElement = ContextUtil.getContextElement(context);
+ return contextElement != null && DebuggerUtils.isInsideSimpleGetter(contextElement);
}).booleanValue();
if(isGetter) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java
index 32c2395e5d5d..c5513797d14d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java
@@ -26,9 +26,8 @@ import com.intellij.debugger.requests.Requestor;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.debugger.ui.breakpoints.FilteredRequestor;
import com.intellij.diagnostic.ThreadDumper;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiClass;
@@ -156,14 +155,12 @@ public class RequestManagerImpl extends DebugProcessAdapterImpl implements Reque
if (!filter.isEnabled()) {
continue;
}
- final JVMName jvmClassName = ApplicationManager.getApplication().runReadAction(new Computable() {
- public JVMName compute() {
- PsiClass psiClass = DebuggerUtils.findClass(filter.getPattern(), myDebugProcess.getProject(), myDebugProcess.getSearchScope());
- if (psiClass == null) {
- return null;
- }
- return JVMNameUtil.getJVMQualifiedName(psiClass);
+ final JVMName jvmClassName = ReadAction.compute(() -> {
+ PsiClass psiClass = DebuggerUtils.findClass(filter.getPattern(), myDebugProcess.getProject(), myDebugProcess.getSearchScope());
+ if (psiClass == null) {
+ return null;
}
+ return JVMNameUtil.getJVMQualifiedName(psiClass);
});
String pattern = filter.getPattern();
try {
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java b/java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java
index 47558e8c4da8..012e505791a7 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -18,10 +18,9 @@ package com.intellij.debugger.impl;
import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.ContextUtil;
import com.intellij.debugger.engine.StackFrameContext;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
@@ -50,20 +49,18 @@ public class PositionUtil extends ContextUtil {
@Nullable
public static T getPsiElementAt(final Project project, final Class expectedPsiElementClass, final SourcePosition sourcePosition) {
- return ApplicationManager.getApplication().runReadAction(new Computable() {
- public T compute() {
- final PsiFile psiFile = sourcePosition.getFile();
- final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
- if(document == null) {
- return null;
- }
- final int spOffset = sourcePosition.getOffset();
- if (spOffset < 0) {
- return null;
- }
- final int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), spOffset, " \t");
- return PsiTreeUtil.getParentOfType(psiFile.findElementAt(offset), expectedPsiElementClass, false);
+ return ReadAction.compute(() -> {
+ final PsiFile psiFile = sourcePosition.getFile();
+ final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
+ if(document == null) {
+ return null;
}
+ final int spOffset = sourcePosition.getOffset();
+ if (spOffset < 0) {
+ return null;
+ }
+ final int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), spOffset, " \t");
+ return PsiTreeUtil.getParentOfType(psiFile.findElementAt(offset), expectedPsiElementClass, false);
});
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java
index a736e3c81e02..e2aa62a5fbc0 100644
--- a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java
+++ b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java
@@ -22,9 +22,8 @@ import com.intellij.debugger.engine.StackFrameContext;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.impl.SimpleStackFrameContext;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Computable;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ReflectionUtil;
@@ -331,31 +330,28 @@ public class LocalVariablesUtil {
private static MultiMap calcNames(@NotNull final StackFrameContext context, final int firstLocalsSlot) {
SourcePosition position = ContextUtil.getSourcePosition(context);
if (position != null) {
- return ApplicationManager.getApplication().runReadAction(new Computable>() {
- @Override
- public MultiMap compute() {
- PsiElement element = position.getElementAt();
- PsiElement method = DebuggerUtilsEx.getContainingMethod(element);
- if (method != null) {
- MultiMap res = new MultiMap<>();
- int slot = Math.max(0, firstLocalsSlot - getParametersStackSize(method));
- for (PsiParameter parameter : DebuggerUtilsEx.getParameters(method)) {
- res.putValue(slot, parameter.getName());
- slot += getTypeSlotSize(parameter.getType());
- }
- PsiElement body = DebuggerUtilsEx.getBody(method);
- if (body != null) {
- try {
- body.accept(new LocalVariableNameFinder(firstLocalsSlot, res, element));
- }
- catch (Exception e) {
- LOG.info(e);
- }
- }
- return res;
+ return ReadAction.compute(() -> {
+ PsiElement element = position.getElementAt();
+ PsiElement method = DebuggerUtilsEx.getContainingMethod(element);
+ if (method != null) {
+ MultiMap res = new MultiMap<>();
+ int slot = Math.max(0, firstLocalsSlot - getParametersStackSize(method));
+ for (PsiParameter parameter : DebuggerUtilsEx.getParameters(method)) {
+ res.putValue(slot, parameter.getName());
+ slot += getTypeSlotSize(parameter.getType());
}
- return MultiMap.empty();
+ PsiElement body = DebuggerUtilsEx.getBody(method);
+ if (body != null) {
+ try {
+ body.accept(new LocalVariableNameFinder(firstLocalsSlot, res, element));
+ }
+ catch (Exception e) {
+ LOG.info(e);
+ }
+ }
+ return res;
}
+ return MultiMap.empty();
});
}
return MultiMap.empty();
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/ValueHint.java b/java/debugger/impl/src/com/intellij/debugger/ui/ValueHint.java
index 5e2bdc5aa862..f73e40621738 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/ValueHint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/ValueHint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -123,12 +123,7 @@ public class ValueHint extends AbstractValueHint {
try {
final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
- final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public String compute() {
- return myCurrentExpression.getText();
- }
- });
+ final String expressionText = ReadAction.compute(() -> myCurrentExpression.getText());
final TextWithImports text = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expressionText);
final Value value = myValueToShow != null? myValueToShow : evaluator.evaluate(evaluationContext);
@@ -194,13 +189,7 @@ public class ValueHint extends AbstractValueHint {
@Override
public void threadAction() {
descriptor.setRenderer(debugProcess.getAutoRenderer(descriptor));
- final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable() {
- @Override
- public String compute() {
- return myCurrentExpression.getText();
- }
- });
-
+ final String expressionText = ReadAction.compute(() -> myCurrentExpression.getText());
createAndShowTree(expressionText, descriptor);
}
});
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
index 8ccee6bf428a..075239a3991c 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
@@ -25,11 +25,11 @@ import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
@@ -184,12 +184,7 @@ public abstract class BreakpointWithHighlighter() {
- @Override
- public Boolean compute() {
- return sourcePosition != null && sourcePosition.getFile().isValid();
- }
- }).booleanValue();
+ return ReadAction.compute(() -> sourcePosition != null && sourcePosition.getFile().isValid()).booleanValue();
}
@Nullable
@@ -344,13 +339,7 @@ public abstract class BreakpointWithHighlighter
() {
- @Nullable
- @Override
- public PsiClass compute() {
- return JVMNameUtil.getClassAt(sourcePosition);
- }
- });
+ return ReadAction.compute(() -> JVMNameUtil.getClassAt(sourcePosition));
}
@Override
@@ -403,13 +392,8 @@ public abstract class BreakpointWithHighlighter
() {
- @Override
- public String compute() {
- return CommonXmlStrings.HTML_START + CommonXmlStrings.BODY_START
- + getDescription()
- + CommonXmlStrings.BODY_END + CommonXmlStrings.HTML_END;
- }
- });
+ return ReadAction.compute(() -> CommonXmlStrings.HTML_START + CommonXmlStrings.BODY_START
+ + getDescription()
+ + CommonXmlStrings.BODY_END + CommonXmlStrings.HTML_END);
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
index 956630d0c763..6db976eb4446 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -29,11 +29,9 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.icons.AllIcons;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
@@ -122,12 +120,9 @@ public class ExceptionBreakpoint extends Breakpoint() {
- public SourcePosition compute() {
- PsiClass psiClass = DebuggerUtils.findClass(getQualifiedName(), myProject, debugProcess.getSearchScope());
-
- return psiClass != null ? SourcePosition.createFromElement(psiClass) : null;
- }
+ SourcePosition classPosition = ReadAction.compute(() -> {
+ PsiClass psiClass = DebuggerUtils.findClass(getQualifiedName(), myProject, debugProcess.getSearchScope());
+ return psiClass != null ? SourcePosition.createFromElement(psiClass) : null;
});
if(classPosition == null) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java
index b4883e10f48a..3af57ecf8035 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -21,9 +21,8 @@ import com.intellij.debugger.engine.JVMNameUtil;
import com.intellij.icons.AllIcons;
import com.intellij.ide.util.TreeClassChooser;
import com.intellij.ide.util.TreeClassChooserFactory;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.psi.CommonClassNames;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
@@ -128,13 +127,8 @@ public class JavaExceptionBreakpointType extends JavaBreakpointTypeBase