From f7f52af09471824bea872d58104afc0332d78a7d Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 11 May 2012 15:50:53 +0400 Subject: [PATCH 01/45] Update Project optimization: move refresh after update to the background Summary: * Don't refresh each file individually, use RefreshQueue via LFS#refreshIoFiles. * Don't refresh Later, call the async refresh and wait for its completion. Details: 1. collect files to be refreshed. 2. call the old-style refreshDeletedOrReplaced for deleted files. 3. start RefreshQueue for all other files, and wait for completion. 4. release the semaphore if something bad happens. --- .../vcs/update/RefreshVFsSynchronously.java | 107 +++++++----------- 1 file changed, 41 insertions(+), 66 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java index df05f274c5e3..54f330efc034 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java @@ -15,19 +15,20 @@ */ package com.intellij.openapi.vcs.update; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.NewVirtualFile; import com.intellij.util.concurrency.Semaphore; +import gnu.trove.THashSet; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; +import java.util.Collection; import java.util.List; public class RefreshVFsSynchronously { @@ -35,30 +36,28 @@ public class RefreshVFsSynchronously { } public static void updateAllChanged(final UpdatedFiles updatedFiles) { - // approx so ok - final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); - if (progressIndicator != null) { - progressIndicator.setIndeterminate(false); - } - final int num = getFilesNum(updatedFiles); + FilesToRefreshCollector callback = new FilesToRefreshCollector(); + UpdateFilesHelper.iterateFileGroupFilesDeletedOnServerFirst(updatedFiles, callback); - wrapIntoLock(new Runnable() { - public void run() { - UpdateFilesHelper.iterateFileGroupFilesDeletedOnServerFirst(updatedFiles, new MyRefreshCallback(num, progressIndicator)); - } - }); - } - - private static int getFilesNum(final UpdatedFiles files) { - int result = 0; - for (FileGroup group : files.getTopLevelGroups()) { - result += group.getImmediateFilesSize(); - final List children = group.getChildren(); - for (FileGroup child : children) { - result += child.getImmediateFilesSize(); - } + for (File file : callback.getToRefreshDeletedOrReplaced()) { + refreshDeletedOrReplaced(file); } - return result; + + final Semaphore semaphore = new Semaphore(); + semaphore.down(); + try { + LocalFileSystem.getInstance().refreshIoFiles(callback.getToRefresh(), true, false, new Runnable() { + @Override + public void run() { + semaphore.up(); + } + }); + } + catch (Throwable t) { + semaphore.up(); + throw new RuntimeException(t); + } + semaphore.waitFor(); } @Nullable @@ -191,54 +190,30 @@ public class RefreshVFsSynchronously { boolean movedOrRenamedOrReplaced(final Change change); } - private static void wrapIntoLock(final Runnable runnable) { - final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); - if (indicator != null) { - indicator.startNonCancelableSection(); - indicator.setText(VcsBundle.message("progress.text.synchronizing.files")); - indicator.setText2(""); - } - - final Semaphore semaphore = new Semaphore(); - semaphore.down(); - - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - try { - // common lock for all refreshes inside - runnable.run(); - } - finally { - semaphore.up(); - } - } - }); - semaphore.waitFor(); - } - - private static class MyRefreshCallback implements UpdateFilesHelper.Callback { - private int myCnt; - private final double myTotal; - private final ProgressIndicator myProgressIndicator; - - private MyRefreshCallback(final int total, final ProgressIndicator progressIndicator) { - myTotal = total; - myProgressIndicator = progressIndicator; - myCnt = 0; - } + private static class FilesToRefreshCollector implements UpdateFilesHelper.Callback { + private final Collection myToRefresh = new THashSet(); + private final Collection myToRefreshDeletedOrReplaced = new THashSet(); + @Override public void onFile(String filePath, String groupId) { final File file = new File(filePath); if (FileGroup.REMOVED_FROM_REPOSITORY_ID.equals(groupId)) { - refreshDeletedOrReplaced(file); - } else { - refresh(file); + myToRefreshDeletedOrReplaced.add(file); } - if (myProgressIndicator != null) { - ++ myCnt; - myProgressIndicator.setFraction(myCnt/myTotal); - myProgressIndicator.setText2("Refreshing " + filePath); + else { + myToRefresh.add(file); } } + + @NotNull + public Collection getToRefresh() { + return myToRefresh; + } + + @NotNull + public Collection getToRefreshDeletedOrReplaced() { + return myToRefreshDeletedOrReplaced; + } } + } From 13315a238d166f9eee7cbeda09d5ed1afdaa5df1 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 11 May 2012 18:07:47 +0200 Subject: [PATCH 02/45] external merge tool + ExtCompare tools have rewritten --- .../diff/impl/external/BaseExternalTool.java | 94 ++++++------- .../impl/external/ContentExternalizer.java | 26 ++++ .../diff/impl/external/DiffManagerImpl.java | 16 ++- .../diff/impl/external/DiffOptionsForm.form | 123 ++++++++++++++---- .../diff/impl/external/DiffOptionsForm.java | 45 +++++-- .../diff/impl/external/ExtCompareFiles.java | 114 ++++------------ .../diff/impl/external/ExtCompareFolders.java | 35 +++-- .../diff/impl/external/ExtMergeFiles.java | 63 +++++++++ .../ExternalToolContentExternalizer.java | 94 +++++++++++++ .../impl/external/LocalFileExternalizer.java | 52 ++++++++ .../src/messages/DiffBundle.properties | 1 + 11 files changed, 477 insertions(+), 186 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ContentExternalizer.java create mode 100644 platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtMergeFiles.java create mode 100644 platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExternalToolContentExternalizer.java create mode 100644 platform/platform-impl/src/com/intellij/openapi/diff/impl/external/LocalFileExternalizer.java diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/BaseExternalTool.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/BaseExternalTool.java index ec9c2e2b5787..77664086dde9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/BaseExternalTool.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/BaseExternalTool.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -19,7 +19,11 @@ import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.util.ExecutionErrorDialog; import com.intellij.openapi.Disposable; -import com.intellij.openapi.diff.*; +import com.intellij.openapi.diff.DiffBundle; +import com.intellij.openapi.diff.DiffRequest; +import com.intellij.openapi.diff.DiffTool; +import com.intellij.openapi.diff.DiffViewer; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.config.AbstractProperty; import com.intellij.util.config.BooleanProperty; @@ -27,9 +31,12 @@ import com.intellij.util.config.StringProperty; import org.jetbrains.annotations.Nullable; import java.awt.*; -import java.io.File; -import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +/** + * @author Konstantin Bulenkov + */ abstract class BaseExternalTool implements DiffTool { private final BooleanProperty myEnableProperty; private final StringProperty myToolProperty; @@ -39,16 +46,9 @@ abstract class BaseExternalTool implements DiffTool { myToolProperty = toolProperty; } - public boolean canShow(DiffRequest request) { - AbstractProperty.AbstractPropertyContainer config = DiffManagerImpl.getInstanceEx().getProperties(); - if (!myEnableProperty.value(config)) return false; - String path = getToolPath(); - if (path == null || path.length() == 0) return false; - DiffContent[] contents = request.getContents(); - if (contents.length != 2) return false; - if (externalize(request, 0) == null) return false; - if (externalize(request, 1) == null) return false; - return true; + public final boolean canShow(DiffRequest request) { + if (!isEnabled() || StringUtil.isEmpty(getToolPath())) return false; + return isAvailable(request); } @Override @@ -56,18 +56,45 @@ abstract class BaseExternalTool implements DiffTool { return null; } - protected abstract ContentExternalizer externalize(DiffRequest request, int index); + public abstract boolean isAvailable(DiffRequest request); - private String getToolPath() { - return myToolProperty.get(DiffManagerImpl.getInstanceEx().getProperties()); + @Nullable + protected ContentExternalizer externalize(final DiffRequest request, final int index) { + final VirtualFile file = getLocalFile(request.getContents()[index].getFile()); + + if (LocalFileExternalizer.canExternalizeAsFile(file)) { + return LocalFileExternalizer.tryCreate(file); + } + + return new ExternalToolContentExternalizer(request, index); + } + + public static AbstractProperty.AbstractPropertyContainer getProperties() { + return DiffManagerImpl.getInstanceEx().getProperties(); + } + + protected String getToolPath() { + return myToolProperty.get(getProperties()); + } + + protected boolean isEnabled() { + return myEnableProperty.value(getProperties()); + } + + protected List getParameters(DiffRequest request) throws Exception { + final String p1 = convertToPath(request, 0); + final String p2 = convertToPath(request, 1); + final List params = new ArrayList(); + if (p1 != null) params.add(p1); + if (p2 != null) params.add(p2); + return params; } public void show(DiffRequest request) { GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(getToolPath()); try { - commandLine.addParameter(convertToPath(request, 0)); - commandLine.addParameter(convertToPath(request, 1)); + commandLine.addParameters(getParameters(request)); commandLine.createProcess(); } catch (Exception e) { @@ -76,8 +103,10 @@ abstract class BaseExternalTool implements DiffTool { } } - private String convertToPath(DiffRequest request, int index) throws IOException { - return externalize(request, index).getContentFile().getAbsolutePath(); + @Nullable + protected String convertToPath(DiffRequest request, int index) throws Exception { + final ContentExternalizer externalize = externalize(request, index); + return externalize == null ? null : externalize.getContentFile().getAbsolutePath(); } @Nullable @@ -85,27 +114,4 @@ abstract class BaseExternalTool implements DiffTool { if (file != null && file.isInLocalFileSystem()) return file; return null; } - - protected interface ContentExternalizer { - File getContentFile() throws IOException; - } - - protected static class LocalFileExternalizer implements ContentExternalizer { - private final File myFile; - - public LocalFileExternalizer(File file) { - myFile = file; - } - - public File getContentFile() { - return myFile; - } - - @Nullable - public static LocalFileExternalizer tryCreate(VirtualFile file) { - if (file == null || !file.isValid()) return null; - if (!file.isInLocalFileSystem()) return null; - return new LocalFileExternalizer(new File(file.getPath().replace('/', File.separatorChar))); - } - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ContentExternalizer.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ContentExternalizer.java new file mode 100644 index 000000000000..4902fb050300 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ContentExternalizer.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2012 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.diff.impl.external; + +import java.io.File; +import java.io.IOException; + +/** +* @author Konstantin Bulenkov +*/ +interface ContentExternalizer { + File getContentFile() throws IOException; +} diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffManagerImpl.java index 50831f60defc..cc6bd6390640 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -58,10 +58,12 @@ public class DiffManagerImpl extends DiffManager implements JDOMExternalizable { static final StringProperty FOLDERS_TOOL = new StringProperty("foldersTool", ""); static final StringProperty FILES_TOOL = new StringProperty("filesTool", ""); - static final BooleanProperty ENABLE_FOLDERS = new BooleanProperty( - "enableFolders", false); - static final BooleanProperty ENABLE_FILES = new BooleanProperty( - "enableFiles", false); + static final StringProperty MERGE_TOOL = new StringProperty("mergeTool", ""); + static final StringProperty MERGE_TOOL_PARAMETERS = new StringProperty("mergeToolParameters", ""); + static final BooleanProperty ENABLE_FOLDERS = new BooleanProperty("enableFolders", false); + static final BooleanProperty ENABLE_FILES = new BooleanProperty("enableFiles", false); + static final BooleanProperty ENABLE_MERGE = new BooleanProperty("enableMerge", false); + private final ExternalizablePropertyContainer myProperties; private final ArrayList myAdditionTools = new ArrayList(); @@ -89,7 +91,7 @@ public class DiffManagerImpl extends DiffManager implements JDOMExternalizable { public DiffTool getDiffTool() { DiffTool[] standardTools; // there is inner check in multiple tool for external viewers as well - if (! ENABLE_FILES.value(myProperties) || ! ENABLE_FOLDERS.value(myProperties)) { + if (! ENABLE_FILES.value(myProperties) || ! ENABLE_FOLDERS.value(myProperties) || !ENABLE_MERGE.value(myProperties)) { DiffTool[] embeddableTools = { INTERNAL_DIFF, new MergeTool(), @@ -98,6 +100,7 @@ public class DiffManagerImpl extends DiffManager implements JDOMExternalizable { standardTools = new DiffTool[]{ ExtCompareFolders.INSTANCE, ExtCompareFiles.INSTANCE, + ExtMergeFiles.INSTANCE, new MultiLevelDiffTool(Arrays.asList(embeddableTools)), INTERNAL_DIFF, new MergeTool(), @@ -107,6 +110,7 @@ public class DiffManagerImpl extends DiffManager implements JDOMExternalizable { standardTools = new DiffTool[]{ ExtCompareFolders.INSTANCE, ExtCompareFiles.INSTANCE, + ExtMergeFiles.INSTANCE, INTERNAL_DIFF, new MergeTool(), BinaryDiffTool.INSTANCE diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffOptionsForm.form b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffOptionsForm.form index 058759dd972a..332d1b3af224 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffOptionsForm.form +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffOptionsForm.form @@ -1,9 +1,9 @@
- + - + @@ -34,18 +34,6 @@ - - - - - - - - - - - - @@ -54,6 +42,14 @@ + + + + + + + + @@ -64,18 +60,6 @@ - - - - - - - - - - - - @@ -84,13 +68,98 @@ + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffOptionsForm.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffOptionsForm.java index 7e673a38f626..e0f02e272d8a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffOptionsForm.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/DiffOptionsForm.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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,6 +27,7 @@ import com.intellij.util.config.StringProperty; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.event.ActionEvent; @@ -39,14 +40,27 @@ public class DiffOptionsForm implements SearchableConfigurable, Configurable.NoS private JCheckBox myEnableFiles; private TextFieldWithBrowseButton myFoldersTool; private TextFieldWithBrowseButton myFilesTool; + private TextFieldWithBrowseButton myMergeTool; + private JCheckBox myEnableMerge; + private JTextField myMergeParameters; + private JLabel myMergeParamInfo; + private JPanel myMergePanel; - private final ToolPath[] myTools = new ToolPath[2]; + private final ToolPath[] myTools = new ToolPath[3]; public DiffOptionsForm() { - myTools[0] = new ToolPath(myEnableFolders, myFoldersTool, - DiffManagerImpl.FOLDERS_TOOL, DiffManagerImpl.ENABLE_FOLDERS); - myTools[1] = new ToolPath(myEnableFiles, myFilesTool, DiffManagerImpl.FILES_TOOL, - DiffManagerImpl.ENABLE_FILES); + myEnableMerge.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + myMergeParameters.setEditable(myEnableMerge.isEnabled()); + myMergeParameters.setEnabled(myEnableMerge.isEnabled()); + } + }); + myTools[0] = new ToolPath(myEnableFolders, myFoldersTool, null, DiffManagerImpl.FOLDERS_TOOL, DiffManagerImpl.ENABLE_FOLDERS, null); + myTools[1] = new ToolPath(myEnableFiles, myFilesTool, null, DiffManagerImpl.FILES_TOOL, DiffManagerImpl.ENABLE_FILES, null); + myTools[2] = new ToolPath(myEnableMerge, myMergeTool, myMergeParameters, DiffManagerImpl.MERGE_TOOL, DiffManagerImpl.ENABLE_MERGE, DiffManagerImpl.MERGE_TOOL_PARAMETERS); + myMergeParameters.setEditable(myEnableMerge.isEnabled()); + myMergeParameters.setEnabled(myEnableMerge.isEnabled()); } public JComponent createComponent() { @@ -102,13 +116,17 @@ public class DiffOptionsForm implements SearchableConfigurable, Configurable.NoS private final TextFieldWithBrowseButton myTextField; private final StringProperty myPathProperty; private final BooleanProperty myEnabledProperty; + @Nullable private final JTextField myParameters; + @Nullable private final StringProperty myParametersProperty; - public ToolPath(JCheckBox checkBox, TextFieldWithBrowseButton textField, - StringProperty pathProperty, BooleanProperty enabledProperty) { + public ToolPath(JCheckBox checkBox, TextFieldWithBrowseButton textField, @Nullable JTextField parameters, + StringProperty pathProperty, BooleanProperty enabledProperty, @Nullable StringProperty parametersProperty) { myCheckBox = checkBox; myTextField = textField; myPathProperty = pathProperty; myEnabledProperty = enabledProperty; + myParameters = parameters; + myParametersProperty = parametersProperty; final ButtonModel model = myCheckBox.getModel(); model.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -126,8 +144,9 @@ public class DiffOptionsForm implements SearchableConfigurable, Configurable.NoS public boolean isModifier() { AbstractProperty.AbstractPropertyContainer properties = getProperties(); - return !myTextField.getText().equals(myPathProperty.get(properties)) || - isEnabled() != myEnabledProperty.value(properties); + return !myTextField.getText().equals(myPathProperty.get(properties)) + || isEnabled() != myEnabledProperty.value(properties) + || (myParametersProperty != null && myParameters != null && !myParameters.getText().equals(myParametersProperty.get(properties))); } private boolean isEnabled() { @@ -141,11 +160,17 @@ public class DiffOptionsForm implements SearchableConfigurable, Configurable.NoS public void apply() { myPathProperty.set(getProperties(), myTextField.getText()); myEnabledProperty.primSet(getProperties(), isEnabled()); + if (myParameters != null && myParametersProperty != null) { + myParametersProperty.set(getProperties(), myParameters.getText()); + } } public void reset() { myTextField.setText(myPathProperty.get(getProperties())); myCheckBox.getModel().setSelected(myEnabledProperty.value(getProperties())); + if (myParameters != null && myParametersProperty != null) { + myParameters.setText(myParametersProperty.get(getProperties())); + } updateEnabledEffect(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFiles.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFiles.java index 9949ceb1a7c6..0594ab09c0c5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFiles.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFiles.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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,105 +18,37 @@ package com.intellij.openapi.diff.impl.external; import com.intellij.openapi.diff.DiffContent; import com.intellij.openapi.diff.DiffRequest; import com.intellij.openapi.diff.impl.DiffUtil; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypes; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NonNls; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; +/** + * @author Konstantin Bulenkov + */ class ExtCompareFiles extends BaseExternalTool { public static final BaseExternalTool INSTANCE = new ExtCompareFiles(); + private ExtCompareFiles() { super(DiffManagerImpl.ENABLE_FILES, DiffManagerImpl.FILES_TOOL); } - public boolean canShow(DiffRequest request) { - DiffContent[] contents = request.getContents(); - for (int i = 0; i < contents.length; i++) { - DiffContent content = contents[i]; - VirtualFile file = getLocalFile(content.getFile()); - if (file != null && file.isDirectory()) return false; - if (canExternalizeAsFile(file)) continue; - if (DiffUtil.isWritable(content)) return false; + public boolean isAvailable(DiffRequest request) { + final DiffContent[] contents = request.getContents(); + for (DiffContent content : contents) { + final VirtualFile file = getLocalFile(content.getFile()); + if (file != null && file.isDirectory()) { + return false; + } + + if (LocalFileExternalizer.canExternalizeAsFile(file)) { + continue; + } + + if (DiffUtil.isWritable(content)) { + return false; + } } - return super.canShow(request); - } - - protected BaseExternalTool.ContentExternalizer externalize(final DiffRequest request, final int index) { - VirtualFile file = getLocalFile(request.getContents()[index].getFile()); - if (canExternalizeAsFile(file)) return LocalFileExternalizer.tryCreate(file); - return new MyContentExternalizer(request, index); - } - - private boolean canExternalizeAsFile(VirtualFile file) { - if (file == null || file.isDirectory()) return false; - FileType fileType = file.getFileType(); - if (fileType.isBinary() && fileType != FileTypes.UNKNOWN) return false; + if (contents.length != 2) return false; + if (externalize(request, 0) == null) return false; + if (externalize(request, 1) == null) return false; return true; } - - private static class MyContentExternalizer implements BaseExternalTool.ContentExternalizer { - private final DiffRequest myRequest; - private final int myIndex; - @NonNls public static final String STD_PREFIX = "IJDiff"; - - public MyContentExternalizer(DiffRequest request, int index) { - myRequest = request; - myIndex = index; - } - - public File getContentFile() throws IOException { - String extension = chooseExtension(); - String name = chooseName(); - if (name.length() <= 3) name = "___" + name; - File tempFile; - try { - tempFile = FileUtil.createTempFile(name, extension); - } - catch (IOException e) { - tempFile = FileUtil.createTempFile(STD_PREFIX, extension); - } - FileOutputStream stream = null; - try { - stream = new FileOutputStream(tempFile); - stream.write(getContent().getBytes()); - } finally { - if (stream != null) stream.close(); - } - return tempFile; - } - - private String chooseName() { - String title = myRequest.getContentTitles()[myIndex]; - char[] chars = title.toCharArray(); - for (int i = 0; i < chars.length; i++) { - char aChar = chars[i]; - if (!Character.isLetterOrDigit(aChar)) chars[i] = '_'; - } - return new String(chars); - } - - private String chooseExtension() { - DiffContent content = getContent(); - VirtualFile contentFile = content.getFile(); - String extension; - if (contentFile != null) { - extension = "." + contentFile.getExtension(); - } - else { - FileType contentType = content.getContentType(); - if (contentType == null) contentType = DiffUtil.chooseContentTypes(myRequest.getContents())[myIndex]; - extension = contentType != null ? "." + contentType.getDefaultExtension() : null; - } - return extension; - } - - private DiffContent getContent() { - return myRequest.getContents()[myIndex]; - } - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFolders.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFolders.java index 04cfb096b555..14c0a9607293 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFolders.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFolders.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -15,24 +15,43 @@ */ package com.intellij.openapi.diff.impl.external; +import com.intellij.openapi.diff.DiffContent; import com.intellij.openapi.diff.DiffRequest; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.Nullable; +/** + * @author Konstantin Bulenkov + */ class ExtCompareFolders extends BaseExternalTool { public static final BaseExternalTool INSTANCE = new ExtCompareFolders(); + private ExtCompareFolders() { super(DiffManagerImpl.ENABLE_FOLDERS, DiffManagerImpl.FOLDERS_TOOL); } - protected BaseExternalTool.ContentExternalizer externalize(DiffRequest request, int index) { - VirtualFile file = request.getContents()[index].getFile(); - if (!isLocalDirectory(file)) return null; + @Override + public boolean isAvailable(DiffRequest request) { + final DiffContent[] contents = request.getContents(); + if (contents.length != 2) return false; + if (externalize(request, 0) == null) return false; + if (externalize(request, 1) == null) return false; + return true; + } + + @Nullable + protected ContentExternalizer externalize(DiffRequest request, int index) { + final VirtualFile file = request.getContents()[index].getFile(); + + if (!isLocalDirectory(file)) { + return null; + } + return LocalFileExternalizer.tryCreate(file); } - private boolean isLocalDirectory(VirtualFile file) { - file = getLocalFile(file); - return file != null && file.isDirectory(); + private static boolean isLocalDirectory(VirtualFile file) { + final VirtualFile local = getLocalFile(file); + return local != null && local.isDirectory(); } - } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtMergeFiles.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtMergeFiles.java new file mode 100644 index 000000000000..82313a5c9c35 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtMergeFiles.java @@ -0,0 +1,63 @@ +/* + * Copyright 2000-2012 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.diff.impl.external; + +import com.intellij.openapi.diff.DiffContent; +import com.intellij.openapi.diff.DiffRequest; +import com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl; +import com.intellij.openapi.util.text.StringUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Konstantin Bulenkov + */ +public class ExtMergeFiles extends BaseExternalTool { + public static final ExtMergeFiles INSTANCE = new ExtMergeFiles(); + + protected ExtMergeFiles() { + super(DiffManagerImpl.ENABLE_MERGE, DiffManagerImpl.MERGE_TOOL); + } + + @Override + public boolean isAvailable(DiffRequest request) { + DiffContent[] contents = request.getContents(); + if (contents.length != 3) return false; + if (externalize(request, 0) == null) return false; + if (externalize(request, 1) == null) return false; + if (externalize(request, 2) == null) return false; + + return true; + } + + @Override + protected List getParameters(DiffRequest request) throws Exception { + final List params = new ArrayList(); + String result = ((MergeRequestImpl)request).getResultContent().getFile().getPath(); + String left = externalize(request, 0).getContentFile().getPath(); + String base = new ExternalToolContentExternalizer(request, 1).getContentFile().getPath(); + String right = externalize(request, 2).getContentFile().getPath(); + for (String param : StringUtil.split(DiffManagerImpl.MERGE_TOOL_PARAMETERS.get(getProperties()), " ")) { + if ("%1".equals(param)) params.add(left); + else if ("%2".equals(param)) params.add(base); + else if ("%3".equals(param)) params.add(right); + else if ("%4".equals(param)) params.add(result); + else params.add(param); + } + return params; + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExternalToolContentExternalizer.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExternalToolContentExternalizer.java new file mode 100644 index 000000000000..ce28f6c2cd9a --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExternalToolContentExternalizer.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2012 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.diff.impl.external; + +import com.intellij.openapi.diff.DiffContent; +import com.intellij.openapi.diff.DiffRequest; +import com.intellij.openapi.diff.MergeRequest; +import com.intellij.openapi.diff.impl.DiffUtil; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NonNls; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +/** +* @author Konstantin Bulenkov +*/ +class ExternalToolContentExternalizer implements ContentExternalizer { + private final DiffRequest myRequest; + private final int myIndex; + @NonNls public static final String STD_PREFIX = "IJDiff"; + + public ExternalToolContentExternalizer(DiffRequest request, int index) { + myRequest = request; + myIndex = index; + } + + public File getContentFile() throws IOException { + String extension = chooseExtension(); + String name = chooseName(); + if (name.length() <= 3) name = "___" + name; + File tempFile; + try { + tempFile = FileUtil.createTempFile(name, extension); + } + catch (IOException e) { + tempFile = FileUtil.createTempFile(STD_PREFIX, extension); + } + FileOutputStream stream = null; + try { + stream = new FileOutputStream(tempFile); + final DiffContent content = getContent(); + stream.write(myRequest instanceof MergeRequest ? content.getDocument().getText().getBytes() : content.getBytes()); + } finally { + if (stream != null) stream.close(); + } + return tempFile; + } + + private String chooseName() { + String title = myRequest.getContentTitles()[myIndex]; + char[] chars = title.toCharArray(); + for (int i = 0; i < chars.length; i++) { + char aChar = chars[i]; + if (!Character.isLetterOrDigit(aChar)) chars[i] = '_'; + } + return new String(chars); + } + + private String chooseExtension() { + DiffContent content = getContent(); + VirtualFile contentFile = content.getFile(); + String extension; + if (contentFile != null) { + extension = "." + contentFile.getExtension(); + } + else { + FileType contentType = content.getContentType(); + if (contentType == null) contentType = DiffUtil.chooseContentTypes(myRequest.getContents())[myIndex]; + extension = contentType != null ? "." + contentType.getDefaultExtension() : null; + } + return extension; + } + + private DiffContent getContent() { + return myRequest.getContents()[myIndex]; + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/LocalFileExternalizer.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/LocalFileExternalizer.java new file mode 100644 index 000000000000..77068eeb5455 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/LocalFileExternalizer.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2012 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.diff.impl.external; + +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.fileTypes.FileTypes; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.Nullable; + +import java.io.File; + +/** +* @author Konstantin Bulenkov +*/ +class LocalFileExternalizer implements ContentExternalizer { + private final File myFile; + + public LocalFileExternalizer(File file) { + myFile = file; + } + + public File getContentFile() { + return myFile; + } + + @Nullable + public static LocalFileExternalizer tryCreate(VirtualFile file) { + if (file == null || !file.isValid()) return null; + if (!file.isInLocalFileSystem()) return null; + return new LocalFileExternalizer(new File(file.getPath().replace('/', File.separatorChar))); + } + + static boolean canExternalizeAsFile(VirtualFile file) { + if (file == null || file.isDirectory()) return false; + FileType fileType = file.getFileType(); + if (fileType.isBinary() && fileType != FileTypes.UNKNOWN) return false; + return true; + } +} diff --git a/platform/platform-resources-en/src/messages/DiffBundle.properties b/platform/platform-resources-en/src/messages/DiffBundle.properties index 4f47dd7b7101..cc3d2496e947 100644 --- a/platform/platform-resources-en/src/messages/DiffBundle.properties +++ b/platform/platform-resources-en/src/messages/DiffBundle.properties @@ -48,6 +48,7 @@ files.are.different.dialog.title=Files Are Different diff.options.diff.options.border=Diff Options diff.options.use.external.tool.for.files.checkbox=Use external tool to compare files: diff.options.use.external.tool.for.directories.checkbox=Use external tool to compare folders: +diff.options.use.external.merge.tool.for.files.checkbox=Use external merge tool: select.external.diff.program.dialog.title=Select External Diff Program diff.contents.are.identical.message.text=Contents are identical diff.contents.have.differences.only.in.line.separators.message.text=Contents have differences only in line separators From 4bc1be41c0b559e2e6197fcc6aebf78a6d231a43 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 11 May 2012 19:00:59 +0200 Subject: [PATCH 03/45] out-of-process build, cross-compiling: when module's sdk version is lower than the version of compiler's sdk, force lower bytecod target level to match the version of module's sdk. --- .../jps/incremental/java/JavaBuilder.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index 8d8ed4338457..38f7516f288c 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -58,6 +58,7 @@ public class JavaBuilder extends ModuleLevelBuilder { private static final String JAVA_EXTENSION = ".java"; private static final String FORM_EXTENSION = ".form"; public static final boolean USE_EMBEDDED_JAVAC = System.getProperty(GlobalOptions.USE_EXTERNAL_JAVAC_OPTION) == null; + private static final Key JAVA_COMPILER_VERSION_KEY = Key.create("_java_compiler_version_"); public static final FileFilter JAVA_SOURCES_FILTER = new FileFilter() { public boolean accept(File file) { @@ -599,7 +600,17 @@ public class JavaBuilder extends ModuleLevelBuilder { final BytecodeTargetConfiguration targetConfig = context.getProject().getCompilerConfiguration().getBytecodeTarget(); String bytecodeTarget = null; + int chunkSdkVersion = -1; for (Module module : chunk.getModules()) { + final Sdk sdk = module.getSdk(); + if (sdk instanceof JavaSdk) { + final JavaSdk moduleSdk = (JavaSdk)sdk; + final int moduleSdkVersion = convertToNumber(moduleSdk.getVersion()); + if (moduleSdkVersion != 0 /*could determine the version*/&& (chunkSdkVersion < 0 || chunkSdkVersion > moduleSdkVersion)) { + chunkSdkVersion = moduleSdkVersion; + } + } + final String moduleTarget = getModuleTarget(targetConfig, module); if (moduleTarget == null) { continue; @@ -617,10 +628,37 @@ public class JavaBuilder extends ModuleLevelBuilder { options.add("-target"); options.add(bytecodeTarget); } + else { + if (chunkSdkVersion > 0 && getCompilerSdkVersion(context) > chunkSdkVersion) { + // force lower bytecode target level to match the version of sdk assigned to this chunk + options.add("-target"); + options.add("1." + chunkSdkVersion); + } + } return options; } + private static int getCompilerSdkVersion(CompileContext context) { + final Integer cached = JAVA_COMPILER_VERSION_KEY.get(context); + if (cached != null) { + return cached; + } + int javaVersion = convertToNumber(SystemProperties.getJavaVersion()); + if (!USE_EMBEDDED_JAVAC) { + // in case of external javac, run compiler from the newest jdk that is used in the project + for (JavaSdk sdk : context.getProjectDescriptor().getProjectJavaSdks()) { + final String version = sdk.getVersion(); + final int ver = convertToNumber(version); + if (ver > javaVersion) { + javaVersion = ver; + } + } + } + JAVA_COMPILER_VERSION_KEY.set(context, javaVersion); + return javaVersion; + } + @Nullable private static String getModuleTarget(BytecodeTargetConfiguration config, Module module) { final String level = config.getModulesBytecodeTarget().get(module.getName()); From e768be236b38879fc631c84183991ff8dd931a5b Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 11 May 2012 20:30:51 +0400 Subject: [PATCH 04/45] accept all as suppress for all (IDEA-85806) --- .../intellij/codeInspection/RedundantSuppressInspection.java | 2 +- .../src/com/intellij/codeInspection/SuppressionUtil.java | 2 +- .../com/intellij/codeInspection/reference/RefElementImpl.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java index e8cecdcef73c..3ee49d07d7b9 100644 --- a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java @@ -137,7 +137,7 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{ String idsString = SuppressManager.getInstance().getSuppressedInspectionIdsIn(owner); if (idsString != null && idsString.length() != 0) { List ids = StringUtil.split(idsString, ","); - if (IGNORE_ALL && ids.contains(SuppressionUtil.ALL)) return; + if (IGNORE_ALL && (ids.contains(SuppressionUtil.ALL) || ids.contains(SuppressionUtil.ALL.toLowerCase()))) return; Collection suppressed = suppressedScopes.get(owner); if (suppressed == null) { suppressed = ids; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java index 5eceb14e6783..a43bc1259908 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java @@ -58,7 +58,7 @@ public class SuppressionUtil { for (@NonNls String id : ids) { @NonNls String trim = id.trim(); - if (trim.equals(inspectionToolID) || trim.equals(ALL)) return true; + if (trim.equalsIgnoreCase(ALL)) return true; } return false; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java index 9071543e5984..ddfe49cb0d98 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java @@ -255,7 +255,7 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement public boolean isSuppressed(final String toolId) { if (mySuppressions != null) { for (@NonNls String suppression : mySuppressions) { - if (suppression.equals(toolId) || suppression.equals(SuppressionUtil.ALL)){ + if (suppression.equalsIgnoreCase(SuppressionUtil.ALL)){ return true; } } From 4db07b2dedd08e2ba1dea61edefb1aee8641949c Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 11 May 2012 21:07:31 +0400 Subject: [PATCH 05/45] move initial name down in suggestions list (IDEA-85812) --- .../rename/JavaNameSuggestionProvider.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java b/java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java index ca963ae53b93..9719658cca2e 100644 --- a/java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java +++ b/java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java @@ -80,20 +80,10 @@ public class JavaNameSuggestionProvider implements NameSuggestionProvider { } } final String[] strings = info != null ? info.names : ArrayUtil.EMPTY_STRING_ARRAY; - ArrayList list = new ArrayList(Arrays.asList(strings)); + final ArrayList list = new ArrayList(Arrays.asList(strings)); final String[] properlyCased = suggestProperlyCasedName(element); - if (!list.contains(initialName)) { - list.add(0, initialName); - } - else { - int i = list.indexOf(initialName); - list.remove(i); - list.add(0, initialName); - } if (properlyCased != null) { - for (String properlyCasedSuggestion : properlyCased) { - list.add(1, properlyCasedSuggestion); - } + Collections.addAll(list, properlyCased); } if (parameterName != null && !list.contains(parameterName)) { list.add(parameterName); @@ -101,6 +91,14 @@ public class JavaNameSuggestionProvider implements NameSuggestionProvider { if (superMethodName != null && !list.contains(superMethodName)) { list.add(0, superMethodName); } + if (!list.contains(initialName)) { + list.add(initialName); + } + else { + int i = list.indexOf(initialName); + list.remove(i); + list.add(initialName); + } ContainerUtil.removeDuplicates(list); result.addAll(list); return info; From d9ca70c766d4ac2c86050f435fcc17b46b07169c Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 11 May 2012 13:07:25 +0400 Subject: [PATCH 06/45] Language level API cleanup --- .../src/com/intellij/pom/java/LanguageLevel.java | 5 ++++- 1 file changed, 4 insertions(+), 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 9565ee0a8b2e..95691ee0a1ae 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 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -39,14 +39,17 @@ public enum LanguageLevel { myPresentableText = presentableText; } + /** @deprecated (to remove in IDEA 13) */ public int getIndex() { return ordinal() + 3; // solely for backward compatibility } + /** @deprecated (to remove in IDEA 13) */ public boolean hasAssertKeyword() { return isAtLeast(JDK_1_4); } + /** @deprecated use {@linkplain com.intellij.psi.util.PsiUtil#isLanguageLevel5OrHigher(com.intellij.psi.PsiElement)} (to remove in IDEA 13) */ public boolean hasEnumKeywordAndAutoboxing() { return isAtLeast(JDK_1_5); } From 97eb59356dbe35bbef062523f2d5a1c11e79bc6f Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 11 May 2012 13:07:51 +0400 Subject: [PATCH 07/45] Description for Java 8; typos --- java/java-psi-api/src/messages/JavaCoreBundle.properties | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/java/java-psi-api/src/messages/JavaCoreBundle.properties b/java/java-psi-api/src/messages/JavaCoreBundle.properties index 8d0cf5f180d1..31dc1a7440a7 100644 --- a/java/java-psi-api/src/messages/JavaCoreBundle.properties +++ b/java/java-psi-api/src/messages/JavaCoreBundle.properties @@ -1,9 +1,8 @@ psi.error.attempt.to.edit.class.file=Cannot modify compiled element -#language levels jdk.1.3.language.level.description=1.3 - Plain old Java jdk.1.4.language.level.description=1.4 - 'assert' keyword -jdk.1.5.language.level.description=5.0 - 'enum' keyword, autoboxing, etc. +jdk.1.5.language.level.description=5.0 - 'enum' keyword, autoboxing etc. jdk.1.6.language.level.description=6.0 - @Override in interfaces -jdk.1.7.language.level.description=7.0 - Diamonds, ARM, multi-catch, etc. -jdk.1.8.language.level.description=8.0 - Type annotations +jdk.1.7.language.level.description=7.0 - Diamonds, ARM, multi-catch etc. +jdk.1.8.language.level.description=8.0 - Lambdas, type annotations etc. From 7115bb9787b01503973783f05ecb5fa15ee72518 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 11 May 2012 20:58:22 +0400 Subject: [PATCH 08/45] Replace parser conditionals with language level highlighting --- .../impl/analysis/GenericsHighlightUtil.java | 39 ++++---- .../daemon/impl/analysis/HighlightUtil.java | 88 +++++++++++++++++-- .../impl/analysis/HighlightVisitorImpl.java | 55 +++++------- .../lang/java/parser/ExpressionParser.java | 5 +- .../lang/java/parser/JavaParserUtil.java | 11 --- .../lang/java/parser/StatementParser.java | 9 +- .../src/messages/JavaErrorMessages.properties | 17 ++-- .../advHighlighting/UnsupportedFeatures.java | 36 ++++++++ .../psi/parser-partial/expressions/New15.txt | 29 +++--- .../daemon/LightAdvHighlightingTest.java | 33 +++---- .../java/parser/ExpressionParsingTest.java | 12 +-- .../parser/partial/ExpressionParserTest.java | 8 +- .../parser/partial/StatementParserTest.java | 67 ++++++-------- .../statementParsing/TryParsingTest.java | 29 +++--- 14 files changed, 249 insertions(+), 189 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnsupportedFeatures.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java index dc1035ae62d3..3a9857459cdc 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -51,7 +51,6 @@ import java.util.*; */ public class GenericsHighlightUtil { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil"); - private static final String GENERICS_ARE_NOT_SUPPORTED = JavaErrorMessages.message("generics.are.not.supported"); private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance(); private GenericsHighlightUtil() {} @@ -102,6 +101,7 @@ public class GenericsHighlightUtil { return null; } + @Nullable public static HighlightInfo checkParameterizedReferenceTypeArguments(PsiElement resolved, final PsiJavaCodeReferenceElement referenceElement, final PsiSubstitutor substitutor) { @@ -110,17 +110,14 @@ public class GenericsHighlightUtil { return checkReferenceTypeArgumentList(typeParameterListOwner, referenceElement.getParameterList(), substitutor, true); } + @Nullable public static HighlightInfo checkReferenceTypeArgumentList(final PsiTypeParameterListOwner typeParameterListOwner, final PsiReferenceParameterList referenceParameterList, final PsiSubstitutor substitutor, boolean registerIntentions) { - if (referenceParameterList != null && !PsiUtil.isLanguageLevel5OrHigher(referenceParameterList)) { - if (referenceParameterList.getTypeParameterElements().length > 0) { - HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceParameterList, GENERICS_ARE_NOT_SUPPORTED); - QuickFixAction.registerQuickFixAction(info, new ShowModulePropertiesFix(referenceParameterList)); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5)); - return info; - } + if (referenceParameterList != null) { + HighlightInfo info = HighlightUtil.checkGenericsFeature(referenceParameterList, referenceParameterList.getTypeParameterElements().length); + if (info != null) return info; } PsiDiamondType.DiamondInferenceResult inferenceResult = null; @@ -914,15 +911,13 @@ public class GenericsHighlightUtil { return valueOfMethod.equals(methodSignature); } + @Nullable public static HighlightInfo checkTypeParametersList(PsiTypeParameterList parameterList) { PsiTypeParameter[] typeParameters = parameterList.getTypeParameters(); if (typeParameters.length == 0) return null; - if (!PsiUtil.isLanguageLevel5OrHigher(parameterList)) { - HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameterList, GENERICS_ARE_NOT_SUPPORTED); - QuickFixAction.registerQuickFixAction(info, new ShowModulePropertiesFix(parameterList)); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5)); - return info; - } + HighlightInfo info = HighlightUtil.checkGenericsFeature(parameterList, typeParameters.length); + if (info != null) return info; + final PsiElement parent = parameterList.getParent(); if (parent instanceof PsiClass && ((PsiClass)parent).isEnum()) { return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, @@ -1208,21 +1203,18 @@ public class GenericsHighlightUtil { return null; } + @Nullable public static HighlightInfo checkVarArgParameterIsLast(PsiParameter parameter) { PsiElement declarationScope = parameter.getDeclarationScope(); if (declarationScope instanceof PsiMethod) { PsiParameter[] params = ((PsiMethod)declarationScope).getParameterList().getParameters(); if (parameter.isVarArgs()) { - if (!PsiUtil.getLanguageLevel(parameter).hasEnumKeywordAndAutoboxing()) { - HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameter, JavaErrorMessages.message("varargs.prior.15")); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5)); - return info; - } + HighlightInfo info = HighlightUtil.checkVarargFeature(parameter); + if (info != null) return info; if (params[params.length - 1] != parameter) { - HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameter, - JavaErrorMessages.message("vararg.not.last.parameter")); - QuickFixAction.registerQuickFixAction(info, new MakeVarargParameterLastFix(parameter), null); + info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameter, JavaErrorMessages.message("vararg.not.last.parameter")); + QuickFixAction.registerQuickFixAction(info, new MakeVarargParameterLastFix(parameter)); return info; } } @@ -1230,6 +1222,7 @@ public class GenericsHighlightUtil { return null; } + @Nullable public static List checkEnumConstantModifierList(PsiModifierList modifierList) { List list = null; PsiElement[] children = modifierList.getChildren(); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index dc8b8743f524..3a54ada2c167 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -58,6 +58,7 @@ import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.PropertyKey; import java.util.*; @@ -593,6 +594,7 @@ public class HighlightUtil { if (variable instanceof PsiLocalVariable || variable instanceof PsiParameter && ((PsiParameter)variable).getDeclarationScope() instanceof PsiCatchSection || variable instanceof PsiParameter && ((PsiParameter)variable).getDeclarationScope() instanceof PsiForeachStatement) { + @SuppressWarnings("unchecked") PsiElement scope = PsiTreeUtil.getParentOfType(variable, PsiFile.class, PsiMethod.class, PsiClassInitializer.class, PsiResourceList.class); VariablesNotProcessor proc = new VariablesNotProcessor(variable, false) { @Override @@ -602,7 +604,9 @@ public class HighlightUtil { }; PsiScopesUtil.treeWalkUp(proc, identifier, scope); if (scope instanceof PsiResourceList && proc.size() == 0) { - scope = PsiTreeUtil.getParentOfType(variable, PsiFile.class, PsiMethod.class, PsiClassInitializer.class); + @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) + NavigatablePsiElement parent = PsiTreeUtil.getParentOfType(variable, PsiFile.class, PsiMethod.class, PsiClassInitializer.class); + scope = parent; PsiScopesUtil.treeWalkUp(proc, identifier, scope); } if (proc.size() > 0) { @@ -1403,7 +1407,7 @@ public class HighlightUtil { } @Nullable - static HighlightInfo checkValidArrayAccessExpression(PsiExpression arrayExpression, PsiExpression indexExpression, PsiType type) { + static HighlightInfo checkValidArrayAccessExpression(@Nullable PsiExpression arrayExpression, PsiExpression indexExpression, PsiType type) { PsiType arrayExpressionType = arrayExpression == null ? null : arrayExpression.getType(); if (arrayExpressionType != null && !(arrayExpressionType instanceof PsiArrayType)) { String description = JavaErrorMessages.message("array.type.expected", formatType(arrayExpressionType)); @@ -1744,9 +1748,11 @@ public class HighlightUtil { referencedClass = PsiUtil.resolveClassInType(type); } else if (qualifier instanceof PsiThisExpression || qualifier == null) { - resolved = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class); + @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) + PsiMethod parent = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class); + resolved = parent; expression = qualifier == null ? expression : qualifier; - if (resolved instanceof PsiMethod) { + if (resolved != null) { referencedClass = ((PsiMethod)resolved).getContainingClass(); } } @@ -2452,7 +2458,7 @@ public class HighlightUtil { public static void registerChangeVariableTypeFixes(PsiVariable parameter, PsiType itemType, HighlightInfo highlightInfo) { for (ChangeVariableTypeQuickFixProvider fixProvider : Extensions.getExtensions(ChangeVariableTypeQuickFixProvider.EP_NAME)) { for (IntentionAction action : fixProvider.getFixes(parameter, itemType)) { - QuickFixAction.registerQuickFixAction(highlightInfo, action, null); + QuickFixAction.registerQuickFixAction(highlightInfo, action); } } ChangeParameterClassFix.registerQuickFixAction(parameter, itemType, highlightInfo); @@ -2466,4 +2472,76 @@ public class HighlightUtil { } return null; } + + private static enum Feature { + GENERICS(LanguageLevel.JDK_1_5, "feature.generics"), + ANNOTATIONS(LanguageLevel.JDK_1_5, "feature.annotations"), + STATIC_IMPORTS(LanguageLevel.JDK_1_5, "feature.static.imports"), + FOR_EACH(LanguageLevel.JDK_1_5, "feature.for.each"), + VARARGS(LanguageLevel.JDK_1_5, "feature.varargs"), + DIAMOND_TYPES(LanguageLevel.JDK_1_7, "feature.diamond.types"), + MULTI_CATCH(LanguageLevel.JDK_1_7, "feature.multi.catch"), + TRY_WITH_RESOURCES(LanguageLevel.JDK_1_7, "feature.try.with.resources"); + + private final LanguageLevel level; + private final String key; + + private Feature(final LanguageLevel level, @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) final String key) { + this.level = level; + this.key = key; + } + } + + @Nullable + private static HighlightInfo checkFeature(@Nullable final PsiElement element, @NotNull final Feature feature) { + if (element != null && !PsiUtil.getLanguageLevel(element).isAtLeast(feature.level)) { + final String message = JavaErrorMessages.message("insufficient.language.level", JavaErrorMessages.message(feature.key)); + final HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, element, message); + QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(feature.level)); + QuickFixAction.registerQuickFixAction(info, new ShowModulePropertiesFix(element)); + return info; + } + + return null; + } + + @Nullable + public static HighlightInfo checkGenericsFeature(final PsiElement parameterList, final int listSize) { + return listSize > 0 ? checkFeature(parameterList, Feature.GENERICS) : null; + } + + @Nullable + public static HighlightInfo checkAnnotationFeature(final PsiElement element) { + return checkFeature(element, Feature.ANNOTATIONS); + } + + @Nullable + public static HighlightInfo checkForEachFeature(final PsiForeachStatement statement) { + return checkFeature(statement, Feature.FOR_EACH); + } + + @Nullable + public static HighlightInfo checkStaticImportFeature(final PsiImportStaticStatement statement) { + return checkFeature(statement, Feature.STATIC_IMPORTS); + } + + @Nullable + public static HighlightInfo checkVarargFeature(final PsiParameter parameter) { + return checkFeature(parameter, Feature.VARARGS); + } + + @Nullable + public static HighlightInfo checkDiamondFeature(final PsiTypeElement typeElement) { + return typeElement.getType() instanceof PsiDiamondType ? checkFeature(typeElement.getParent(), Feature.DIAMOND_TYPES) : null; + } + + @Nullable + public static HighlightInfo checkMultiCatchFeature(final PsiParameter parameter) { + return parameter.getType() instanceof PsiDisjunctionType ? checkFeature(parameter, Feature.MULTI_CATCH) : null; + } + + @Nullable + public static HighlightInfo checkTryWithResourcesFeature(final PsiResourceVariable resourceVariable) { + return checkFeature(resourceVariable.getParent(), Feature.TRY_WITH_RESOURCES); + } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java index d120ae71f2bf..63d74f914fa3 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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,7 +30,6 @@ import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; -import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.controlFlow.ControlFlowUtil; import com.intellij.psi.impl.source.javadoc.PsiDocMethodOrFieldRef; @@ -170,16 +169,11 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh } } - @Override public void visitAnnotation(PsiAnnotation annotation) { + @Override + public void visitAnnotation(PsiAnnotation annotation) { super.visitAnnotation(annotation); - if (!PsiUtil.isLanguageLevel5OrHigher(annotation)) { - HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, annotation, JavaErrorMessages.message("annotations.prior.15")); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5)); - myHolder.add(info); - return; - } - - myHolder.add(AnnotationsHighlightUtil.checkApplicability(annotation)); + if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkAnnotationFeature(annotation)); + if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkApplicability(annotation)); if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkAnnotationType(annotation)); if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkMissingAttributes(annotation)); if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkTargetAnnotationDuplicates(annotation)); @@ -187,7 +181,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkForeignInnerClassesUsed(annotation)); } - @Override public void visitAnnotationArrayInitializer(PsiArrayInitializerMemberValue initializer) { + @Override + public void visitAnnotationArrayInitializer(PsiArrayInitializerMemberValue initializer) { PsiMethod method = null; PsiElement parent = initializer.getParent(); if (parent instanceof PsiNameValuePair) { @@ -364,28 +359,24 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh } } - @Override public void visitField(PsiField field) { + @Override + public void visitField(PsiField field) { super.visitField(field); if (!myHolder.hasErrorResults()) myHolder.add(HighlightControlFlowUtil.checkFinalFieldInitialized(field)); } - @Override public void visitForeachStatement(PsiForeachStatement statement) { - if (!PsiUtil.isLanguageLevel5OrHigher(statement)) { - HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, statement.getFirstChild(), JavaErrorMessages.message("foreach.prior.15")); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5)); - myHolder.add(info); - } + @Override + public void visitForeachStatement(final PsiForeachStatement statement) { + myHolder.add(HighlightUtil.checkForEachFeature(statement)); } - @Override public void visitImportStaticStatement(PsiImportStaticStatement statement) { - if (!PsiUtil.isLanguageLevel5OrHigher(statement)) { - HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, statement.getFirstChild(), JavaErrorMessages.message("static.imports.prior.15")); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5)); - myHolder.add(info); - } + @Override + public void visitImportStaticStatement(final PsiImportStaticStatement statement) { + myHolder.add(HighlightUtil.checkStaticImportFeature(statement)); } - @Override public void visitIdentifier(PsiIdentifier identifier) { + @Override + public void visitIdentifier(final PsiIdentifier identifier) { PsiElement parent = identifier.getParent(); final EditorColorsScheme colorsScheme = myHolder.getColorsScheme(); if (parent instanceof PsiVariable) { @@ -411,10 +402,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh } else if (parent instanceof PsiClass) { PsiClass aClass = (PsiClass)parent; - if (aClass.isAnnotationType() && !PsiUtil.isLanguageLevel5OrHigher(aClass)) { - HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, identifier, JavaErrorMessages.message("annotations.prior.15")); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5)); - myHolder.add(info); + if (aClass.isAnnotationType()) { + myHolder.add(HighlightUtil.checkAnnotationFeature(identifier)); } myHolder.add(HighlightClassUtil.checkClassAlreadyImported(aClass, identifier)); @@ -742,6 +731,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkForeachLoopParameterType((PsiForeachStatement)parent)); } else if (parent instanceof PsiCatchSection) { + if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkMultiCatchFeature(parameter)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkCatchParameterIsThrowable(parameter)); if (!myHolder.hasErrorResults()) myHolder.addAll(GenericsHighlightUtil.checkCatchParameterIsClass(parameter)); if (!myHolder.hasErrorResults()) myHolder.addAll(HighlightUtil.checkCatchTypeIsDisjoint(parameter)); @@ -987,11 +977,14 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh @Override public void visitResourceVariable(final PsiResourceVariable resourceVariable) { visitVariable(resourceVariable); + if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkTryWithResourcesFeature(resourceVariable)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkTryResourceIsAutoCloseable(resourceVariable)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkUnhandledCloserExceptions(resourceVariable)); } - @Override public void visitTypeElement(PsiTypeElement type) { + @Override + public void visitTypeElement(final PsiTypeElement type) { + if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkDiamondFeature(type)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkIllegalType(type)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkReferenceTypeUsedAsTypeArgument(type)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkWildcardUsage(type)); diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java index 897adbe053a7..1e2cebe67217 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java @@ -671,15 +671,14 @@ public class ExpressionParser { final PsiBuilder.Marker newExpr = (start != null ? start.precede() : builder.mark()); builder.advanceLexer(); - final boolean parseDiamonds = areDiamondsSupported(builder); - myReferenceParser.parseReferenceParameterList(builder, false, parseDiamonds); + myReferenceParser.parseReferenceParameterList(builder, false, true); final PsiBuilder.Marker refOrType; final boolean parseAnnotations = areTypeAnnotationsSupported(builder) && builder.getTokenType() == JavaTokenType.AT; final IElementType tokenType = builder.getTokenType(); if (tokenType == JavaTokenType.IDENTIFIER || parseAnnotations) { - refOrType = myReferenceParser.parseJavaCodeReference(builder, true, true, parseAnnotations, true, parseDiamonds); + refOrType = myReferenceParser.parseJavaCodeReference(builder, true, true, parseAnnotations, true, true); if (refOrType == null) { error(builder, JavaErrorMessages.message("expected.identifier")); newExpr.done(JavaElementType.NEW_EXPRESSION); diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java index f0b086abf5fe..f540b0749b3b 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java @@ -133,17 +133,6 @@ public class JavaParserUtil { builder.putUserDataUnprotected(LANG_LEVEL_KEY, level); } - // todo[r.sh] join all JDK 7 check clauses into single method (IDEA 11) - public static boolean areDiamondsSupported(final PsiBuilder builder) { - return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_7); - } - public static boolean areMultiCatchSupported(final PsiBuilder builder) { - return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_7); - } - public static boolean areTryWithResourcesSupported(final PsiBuilder builder) { - return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_7); - } - public static boolean areTypeAnnotationsSupported(final PsiBuilder builder) { return getLanguageLevel(builder).isAtLeast(LanguageLevel.JDK_1_8); } diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java index 95ad7cfd72a8..95161be3feed 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -622,9 +622,8 @@ public class StatementParser { final PsiBuilder.Marker statement = builder.mark(); builder.advanceLexer(); - boolean hasResourceList = false; - if (areTryWithResourcesSupported(builder) && builder.getTokenType() == JavaTokenType.LPARENTH) { - hasResourceList = true; + final boolean hasResourceList = builder.getTokenType() == JavaTokenType.LPARENTH; + if (hasResourceList) { myDeclarationParser.parseResourceList(builder); } @@ -667,7 +666,7 @@ public class StatementParser { return false; } - final PsiBuilder.Marker param = myDeclarationParser.parseParameter(builder, false, areMultiCatchSupported(builder)); + final PsiBuilder.Marker param = myDeclarationParser.parseParameter(builder, false, true); if (param == null) { error(builder, JavaErrorMessages.message("expected.parameter")); } diff --git a/java/java-psi-impl/src/messages/JavaErrorMessages.properties b/java/java-psi-impl/src/messages/JavaErrorMessages.properties index 3260287f759b..2258f7f8d204 100644 --- a/java/java-psi-impl/src/messages/JavaErrorMessages.properties +++ b/java/java-psi-impl/src/messages/JavaErrorMessages.properties @@ -41,7 +41,6 @@ annotation.target.PACKAGE=package generics.holder.type=Type generics.holder.method=Method -generics.are.not.supported=Generics are not supported at this language level generics.inferred.type.for.type.parameter.is.not.within.its.bound.extend=Inferred type ''{2}'' for type parameter ''{0}'' is not within its bound; should extend ''{1}'' generics.inferred.type.for.type.parameter.is.not.within.its.bound.implement=Inferred type ''{2}'' for type parameter ''{0}'' is not within its bound; should implement ''{1}'' generics.type.parameter.is.not.within.its.bound.extend=Type parameter ''{0}'' is not within its bound; should extend ''{1}'' @@ -83,7 +82,6 @@ generics.type.arguments.on.raw.type=Type arguments given on a raw type generics.type.arguments.on.raw.method=Type arguments given on a raw method classes.extends.enum=Classes cannot directly extend 'java.lang.Enum' unchecked.overriding.incompatible.return.type=Unchecked overriding: return type requires unchecked conversion. Found ''{0}'', required ''{1}'' -unchecked.overriding=Unchecked overriding local.enum=Enum must not be local interface.expected=Interface expected here @@ -237,10 +235,6 @@ static.member.accessed.via.instance.reference=Static member ''{0}.{1}'' accessed unresolved.label=Undefined label: ''{0}'' deprecated.symbol=''{0}'' is deprecated cannot.resolve.symbol=Cannot resolve symbol ''{0}'' -static.imports.prior.15=Static imports are not supported at this language level -varargs.prior.15=Variable arity methods are not supported at this language level -foreach.prior.15=Foreach loops are not supported at this language level -annotations.prior.15=Annotations are not supported at this language level class.is.already.defined.in.single.static.import=Class ''{0}'' is already defined in a single static import class.is.ambiguous.in.single.static.import=Class ''{0}'' is ambiguous in a single static import field.is.already.defined.in.single.static.import=Field ''{0}'' is already defined in a single static import @@ -322,7 +316,6 @@ expected.resource=Resource definition expected expected.type.parameter=Type parameter expected expected.comma=',' expected expected.comma.or.rparen=',' or ')' expected -unexpected.tokens.beyond.the.end.of.expression=Unexpected token(s) beyond the end of expression expected.colon=':' expected expected.type=Type expected expected.lbracket='[' expected @@ -352,3 +345,13 @@ cannot.resolve.package=Cannot resolve package {0} override.not.allowed.in.interfaces=@Override is not allowed when implementing interface method wildcard.not.expected=Unexpected wildcard bound.not.expected=Unexpected bound + +feature.generics=Generics +feature.annotations=Annotations +feature.static.imports=Static imports +feature.for.each=For-each loops +feature.varargs=Variable arity methods +feature.diamond.types=Diamond types +feature.try.with.resources=Try-with-resources +feature.multi.catch=Multi-catches +insufficient.language.level={0} are not supported at this language level diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnsupportedFeatures.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnsupportedFeatures.java new file mode 100644 index 000000000000..1c108b5f9e0e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnsupportedFeatures.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2012 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.io.*; +import java.util.*; + +import static java.lang.Math.*; + +@interface Anno { } + +@Anno +class UnsupportedFeatures { + void m(String... args) throws Exception { + for (String s : args) { System.out.println(s); } + + List list = + new ArrayList<>(); + + try { Reader r = new FileReader("/dev/null"); } + catch (FileNotFoundException | IOException e) { e.printStackTrace(); } + + try (Reader r = new FileReader("/dev/null")) { } + } +} diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New15.txt b/java/java-tests/testData/psi/parser-partial/expressions/New15.txt index 80407edd16b7..2a1cea3f68ea 100644 --- a/java/java-tests/testData/psi/parser-partial/expressions/New15.txt +++ b/java/java-tests/testData/psi/parser-partial/expressions/New15.txt @@ -1,24 +1,21 @@ PsiJavaFile:New15.java - PsiMethodCallExpression:new C.B() - PsiReferenceExpression:new C.B - PsiNewExpression:new C - PsiKeyword:new('new') + PsiNewExpression:new C.B() + PsiKeyword:new('new') + PsiReferenceParameterList + + PsiWhiteSpace(' ') + PsiJavaCodeReferenceElement:C.B + PsiJavaCodeReferenceElement:C + PsiIdentifier:C('C') PsiReferenceParameterList - - PsiWhiteSpace(' ') - PsiJavaCodeReferenceElement:C - PsiIdentifier:C('C') - PsiReferenceParameterList - PsiJavaToken:LT('<') - PsiTypeElement:? - PsiJavaToken:QUEST('?') - PsiJavaToken:GT('>') - PsiErrorElement:'(' or '[' expected - + PsiJavaToken:LT('<') + PsiTypeElement:? + PsiJavaToken:QUEST('?') + PsiJavaToken:GT('>') PsiJavaToken:DOT('.') + PsiIdentifier:B('B') PsiReferenceParameterList - PsiIdentifier:B('B') PsiExpressionList PsiJavaToken:LPARENTH('(') PsiJavaToken:RPARENTH(')') \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java index 082e532a244e..2524776bddac 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java @@ -40,6 +40,7 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.xml.XmlAttribute; @@ -161,7 +162,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { public void testQualifiedNew() throws Exception { doTest(false, false); } public void testEnclosingInstance() throws Exception { doTest(false, false); } - public void testStaticViaInstance() throws Exception { doTest(true, false); } // static via instabnce + public void testStaticViaInstance() throws Exception { doTest(true, false); } // static via instance public void testQualifiedThisSuper() throws Exception { doTest(true, false); } //illegal qualified this or super public void testAmbiguousMethodCall() throws Exception { doTest(false, false); } @@ -230,19 +231,13 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { } @Override - public void setSelected(boolean selected) { - - } + public void setSelected(boolean selected) { } @Override - public void readExternal(Element element) { - - } + public void readExternal(Element element) { } @Override - public void writeExternal(Element element) { - - } + public void writeExternal(Element element) { } }; point.registerExtension(extension); @@ -265,9 +260,13 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { - PsiFile txt = myFile.getParent().createFile("x.txt"); + PsiDirectory directory = myFile.getParent(); + assertNotNull(myFile.toString(), directory); + PsiFile txt = directory.createFile("x.txt"); + VirtualFile vFile = txt.getVirtualFile(); + assertNotNull(txt.toString(), vFile); try { - VfsUtil.saveText(txt.getVirtualFile(), "XXX"); + VfsUtil.saveText(vFile, "XXX"); } catch (IOException e) { throw new RuntimeException(e); @@ -356,11 +355,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { doHighlighting(); } - public void testClassicRethrow() throws Exception { - doTest(false, false); - } - - public void testRegexp() throws Exception { - doTest(false, false); - } + public void testClassicRethrow() throws Exception { doTest(false, false); } + public void testRegexp() throws Exception { doTest(false, false); } + public void testUnsupportedFeatures() throws Exception { doTest(false, false); } } diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/ExpressionParsingTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/ExpressionParsingTest.java index bbb053005b5f..bb07718dd360 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/ExpressionParsingTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/ExpressionParsingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -15,11 +15,7 @@ */ package com.intellij.lang.java.parser; - -import com.intellij.pom.java.LanguageLevel; - public class ExpressionParsingTest extends JavaParsingTestCase { - public ExpressionParsingTest() { super("parser-full/expressionParsing"); } @@ -75,11 +71,7 @@ public class ExpressionParsingTest extends JavaParsingTestCase { public void testNew12() { doTest(true); } public void testNew13() { doTest(true); } public void testNew14() { doTest(true); } - public void testNew15() { - withLevel(LanguageLevel.JDK_1_7, new Runnable() { @Override public void run() { - doTest(true); - }}); - } + public void testNew15() { doTest(true); } public void testExprList0() { doTest(true); } public void testExprList1() { doTest(true); } diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java index 471190ed3179..f43e356abed7 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java @@ -18,10 +18,8 @@ package com.intellij.lang.java.parser.partial; import com.intellij.lang.PsiBuilder; import com.intellij.lang.java.parser.JavaParsers; import com.intellij.lang.java.parser.JavaParsingTestCase; -import com.intellij.pom.java.LanguageLevel; import org.jetbrains.annotations.NonNls; - public class ExpressionParserTest extends JavaParsingTestCase { public ExpressionParserTest() { super("parser-partial/expressions"); @@ -77,11 +75,7 @@ public class ExpressionParserTest extends JavaParsingTestCase { public void testNew13() { doParserTest("new int[1][][2]"); } public void testNew14() { doParserTest("Q.new A()"); } public void testNew15() { doParserTest("new C.B()"); } - public void testNew16() { - withLevel(LanguageLevel.JDK_1_7, - new Runnable() { @Override - public void run() { doParserTest("new C<>()"); } }); - } + public void testNew16() { doParserTest("new C<>()"); } public void testExprList0() { doParserTest("f(1,2)"); } public void testExprList1() { doParserTest("f("); } diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/StatementParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/StatementParserTest.java index 76e99441bba0..714e7c1ad456 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/StatementParserTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/StatementParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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,8 +18,6 @@ package com.intellij.lang.java.parser.partial; import com.intellij.lang.PsiBuilder; import com.intellij.lang.java.parser.JavaParsers; import com.intellij.lang.java.parser.JavaParsingTestCase; -import com.intellij.pom.java.LanguageLevel; - public class StatementParserTest extends JavaParsingTestCase { public StatementParserTest() { @@ -119,10 +117,10 @@ public class StatementParserTest extends JavaParsingTestCase { public void testTryNormal0() { doParserTest("try{}catch(E e){}"); } public void testTryNormal1() { doParserTest("try{}catch(final E e){}finally{}"); } public void testTryNormal2() { doParserTest("try{}finally{}"); } - public void testTryNormal3() { doParserTestJDK7("try{}catch(A|B e){}"); } - public void testTryNormal4() { doParserTestJDK7("try(R r = 0){}"); } - public void testTryNormal5() { doParserTestJDK7("try(R1 r1 = 1; R2 r2 = 2){}"); } - public void testTryNormal6() { doParserTestJDK7("try(R r = 0;){}"); } + public void testTryNormal3() { doParserTest("try{}catch(A|B e){}"); } + public void testTryNormal4() { doParserTest("try(R r = 0){}"); } + public void testTryNormal5() { doParserTest("try(R1 r1 = 1; R2 r2 = 2){}"); } + public void testTryNormal6() { doParserTest("try(R r = 0;){}"); } public void testTryIncomplete0() { doParserTest("try"); } public void testTryIncomplete1() { doParserTest("try{}"); } public void testTryIncomplete2() { doParserTest("try{}catch"); } @@ -131,16 +129,16 @@ public class StatementParserTest extends JavaParsingTestCase { public void testTryIncomplete5() { doParserTest("try{}catch(E e"); } public void testTryIncomplete6() { doParserTest("try{}catch(E e)"); } public void testTryIncomplete7() { doParserTest("try{}finally"); } - public void testTryIncomplete8() { doParserTestJDK7("try{}catch(A|)"); } - public void testTryIncomplete9() { doParserTestJDK7("try{}catch(A|B)"); } - public void testTryIncomplete10() { doParserTestJDK7("try({}"); } - public void testTryIncomplete11() { doParserTestJDK7("try(){}"); } - public void testTryIncomplete12() { doParserTestJDK7("try(;){}"); } - public void testTryIncomplete13() { doParserTestJDK7("try(final ){}"); } - public void testTryIncomplete14() { doParserTestJDK7("try(int){}"); } - public void testTryIncomplete15() { doParserTestJDK7("try(R r){}"); } - public void testTryIncomplete16() { doParserTestJDK7("try(R r =){}"); } - public void testTryIncomplete17() { doParserTestJDK7("try(R r = 0;;){}"); } + public void testTryIncomplete8() { doParserTest("try{}catch(A|)"); } + public void testTryIncomplete9() { doParserTest("try{}catch(A|B)"); } + public void testTryIncomplete10() { doParserTest("try({}"); } + public void testTryIncomplete11() { doParserTest("try(){}"); } + public void testTryIncomplete12() { doParserTest("try(;){}"); } + public void testTryIncomplete13() { doParserTest("try(final ){}"); } + public void testTryIncomplete14() { doParserTest("try(int){}"); } + public void testTryIncomplete15() { doParserTest("try(R r){}"); } + public void testTryIncomplete16() { doParserTest("try(R r =){}"); } + public void testTryIncomplete17() { doParserTest("try(R r = 0;;){}"); } public void testWhileNormal() { doParserTest("while (true) foo();"); } public void testWhileIncomplete0() { doParserTest("while"); } @@ -151,33 +149,22 @@ public class StatementParserTest extends JavaParsingTestCase { public void testWhileIncomplete5() { doParserTest("while() foo();"); } private void doBlockParserTest(final String text) { - doParserTest(text, new MyTestParser1()); + doParserTest(text, new MyBlockTestParser()); } - - private void doParserTest(final String text) { - doParserTest(text, new MyTestParser2()); - } - - private void doParserTestJDK7(final String text) { - withLevel(LanguageLevel.JDK_1_7, new Runnable() { - @Override - public void run() { - doParserTest(text); - } - }); - } - - private static class MyTestParser2 implements TestParser { - @Override - public void parse(final PsiBuilder builder) { - JavaParsers.STATEMENT_PARSER.parseStatements(builder); - } - } - - private static class MyTestParser1 implements TestParser { + private static class MyBlockTestParser implements TestParser { @Override public void parse(final PsiBuilder builder) { JavaParsers.STATEMENT_PARSER.parseCodeBlockDeep(builder, true); } } + + private void doParserTest(final String text) { + doParserTest(text, new MyStatementsTestParser()); + } + private static class MyStatementsTestParser implements TestParser { + @Override + public void parse(final PsiBuilder builder) { + JavaParsers.STATEMENT_PARSER.parseStatements(builder); + } + } } diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/statementParsing/TryParsingTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/statementParsing/TryParsingTest.java index 76fabf2ee387..cb48c248ac30 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/statementParsing/TryParsingTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/statementParsing/TryParsingTest.java @@ -1,8 +1,21 @@ +/* + * Copyright 2000-2012 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.lang.java.parser.statementParsing; import com.intellij.lang.java.parser.JavaParsingTestCase; -import com.intellij.pom.java.LanguageLevel; - public class TryParsingTest extends JavaParsingTestCase { public TryParsingTest() { @@ -12,11 +25,7 @@ public class TryParsingTest extends JavaParsingTestCase { public void testNormal1() { doTest(true); } public void testNormal2() { doTest(true); } public void testNormal3() { doTest(true); } - public void testNormal4() { - withLevel(LanguageLevel.JDK_1_7, new Runnable() { @Override public void run() { - doTest(true); - }}); - } + public void testNormal4() { doTest(true); } public void testIncomplete1() { doTest(true); } public void testIncomplete2() { doTest(true); } @@ -26,9 +35,5 @@ public class TryParsingTest extends JavaParsingTestCase { public void testIncomplete6() { doTest(true); } public void testIncomplete7() { doTest(true); } public void testIncomplete8() { doTest(true); } - public void testIncomplete9() { - withLevel(LanguageLevel.JDK_1_7, new Runnable() { @Override public void run() { - doTest(true); - }}); - } + public void testIncomplete9() { doTest(true); } } \ No newline at end of file From 0e08b571642eb68a87aa75d541096f872d550948 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 11 May 2012 21:08:23 +0400 Subject: [PATCH 09/45] Cleanup (move messages to corresponding bundle) --- .../src/messages/JavaErrorMessages.properties | 2 -- .../uiDesigner/binding/FormClassAnnotator.java | 15 ++++++--------- .../src/messages/UIDesignerBundle.properties | 2 ++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/java/java-psi-impl/src/messages/JavaErrorMessages.properties b/java/java-psi-impl/src/messages/JavaErrorMessages.properties index 2258f7f8d204..79ee2846632c 100644 --- a/java/java-psi-impl/src/messages/JavaErrorMessages.properties +++ b/java/java-psi-impl/src/messages/JavaErrorMessages.properties @@ -258,8 +258,6 @@ private.inner.interface.is.not.used=Private inner interface ''{0}'' is never use type.parameter.is.not.used=Type parameter ''{0}'' is never used local.class.is.not.used=Local class ''{0}'' is never used class.is.not.used=Class ''{0}'' is never used -uidesigned.field.is.overwritten.by.generated.code=Field ''{0}'' is overwritten by generated code -uidesigner.bound.field.type.mismatch=Types of GUI component (''{0}'') and bound field (''{1}'') do not match hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit=Hexadecimal numbers must contain at least one hexadecimal digit binary.numbers.must.contain.at.least.one.hexadecimal.digit=Binary numbers must contain at least one binary digit diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java index 0830d5d886b8..191bd651a949 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -15,9 +15,8 @@ */ package com.intellij.uiDesigner.binding; -import com.intellij.codeInsight.daemon.JavaErrorMessages; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.CodeInsightUtilBase; +import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.lang.annotation.Annotation; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.Annotator; @@ -26,10 +25,10 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.ui.UIBundle; +import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; -import java.text.MessageFormat; import java.util.List; /** @@ -38,9 +37,6 @@ import java.util.List; public class FormClassAnnotator implements Annotator { private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.binding.FormClassAnnotator"); - private static final String FIELD_IS_OVERWRITTEN = JavaErrorMessages.message("uidesigned.field.is.overwritten.by.generated.code"); - private static final String BOUND_FIELD_TYPE_MISMATCH = JavaErrorMessages.message("uidesigner.bound.field.type.mismatch"); - public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) { if (psiElement instanceof PsiField) { PsiField field = (PsiField) psiElement; @@ -68,7 +64,8 @@ public class FormClassAnnotator implements Annotator { if (guiComponentType != null) { final PsiType fieldType = field.getType(); if (!fieldType.isAssignableFrom(guiComponentType)) { - String message = MessageFormat.format(BOUND_FIELD_TYPE_MISMATCH, guiComponentType.getCanonicalText(), fieldType.getCanonicalText()); + String message = UIDesignerBundle.message("bound.field.type.mismatch", guiComponentType.getCanonicalText(), + fieldType.getCanonicalText()); Annotation annotation = holder.createErrorAnnotation(field.getTypeElement(), message); annotation.registerFix(new ChangeFormComponentTypeFix((PsiPlainTextFile)boundForm, field.getName(), field.getType()), null, null); annotation.registerFix(new ChangeBoundFieldTypeFix(field, guiComponentType), null, null); @@ -76,7 +73,7 @@ public class FormClassAnnotator implements Annotator { } if (field.hasInitializer()) { - final String message = MessageFormat.format(FIELD_IS_OVERWRITTEN, field.getName()); + final String message = UIDesignerBundle.message("field.is.overwritten.by.generated.code", field.getName()); Annotation annotation = holder.createWarningAnnotation(field.getInitializer(), message); annotation.registerFix(new IntentionAction() { @NotNull diff --git a/plugins/ui-designer/src/messages/UIDesignerBundle.properties b/plugins/ui-designer/src/messages/UIDesignerBundle.properties index 883a27e82812..c330d3e58673 100644 --- a/plugins/ui-designer/src/messages/UIDesignerBundle.properties +++ b/plugins/ui-designer/src/messages/UIDesignerBundle.properties @@ -480,6 +480,8 @@ add.component.error.qualified.name.required=Please enter a qualified class name add.component.error.component.required=Please select a class derived from JComponent form.usage.type=Usage in GUI form unsupported.component.class.version=Unsupported component class version +field.is.overwritten.by.generated.code=Field ''{0}'' is overwritten by generated code +bound.field.type.mismatch=Types of GUI component (''{0}'') and bound field (''{1}'') do not match action.GuiDesigner.PreviewForm.text=Preview action.GuiDesigner.PreviewForm.description=Preview form action.GuiDesigner.DataBindingWizard.text=Data Binding Wizard... From 066c6584104141ea170d650e710390c1bff3818a Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 11 May 2012 21:20:18 +0400 Subject: [PATCH 10/45] do not try to detect copyright by empty string (IDEA-85674) --- .../copyright/psi/UpdatePsiFileCopyright.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java index 152a130dd74f..c8f51ffa58df 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java @@ -111,15 +111,19 @@ public abstract class UpdatePsiFileCopyright extends AbstractUpdateCopyright { protected void checkComments(PsiElement last, boolean commentHere, List comments) { try { - LinkedHashSet found = new LinkedHashSet(); - Pattern pattern = Pattern.compile(myOptions.getKeyword(), Pattern.CASE_INSENSITIVE); - Document doc = FileDocumentManager.getInstance().getDocument(getFile().getVirtualFile()); - for (int i = 0; i < comments.size(); i++) { - PsiComment comment = comments.get(i); - String text = comment.getText(); - Matcher match = pattern.matcher(text); - if (match.find()) { - found.add(getLineCopyrightComments(comments, doc, i, comment)); + final String keyword = myOptions.getKeyword(); + final LinkedHashSet found = new LinkedHashSet(); + Document doc = null; + if (!StringUtil.isEmpty(keyword)) { + Pattern pattern = Pattern.compile(keyword, Pattern.CASE_INSENSITIVE); + doc = FileDocumentManager.getInstance().getDocument(getFile().getVirtualFile()); + for (int i = 0; i < comments.size(); i++) { + PsiComment comment = comments.get(i); + String text = comment.getText(); + Matcher match = pattern.matcher(text); + if (match.find()) { + found.add(getLineCopyrightComments(comments, doc, i, comment)); + } } } From c6c028883b7f959c9a2b04b4c12a1042c59c2059 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 11 May 2012 21:46:40 +0400 Subject: [PATCH 11/45] Java 8 tokens --- .../src/com/intellij/psi/JavaTokenType.java | 6 +- .../src/com/intellij/lexer/JavaLexer.java | 65 +- .../src/com/intellij/lexer/_JavaLexer.flex | 25 +- .../src/com/intellij/lexer/_JavaLexer.java | 1236 +++++++++-------- .../lang/java/lexer/JavaLexerTest.java | 5 + 5 files changed, 695 insertions(+), 642 deletions(-) rename java/{java-impl => java-psi-impl}/src/com/intellij/lexer/_JavaLexer.flex (91%) diff --git a/java/java-psi-api/src/com/intellij/psi/JavaTokenType.java b/java/java-psi-api/src/com/intellij/psi/JavaTokenType.java index 7b868633a938..81db31947f2b 100644 --- a/java/java-psi-api/src/com/intellij/psi/JavaTokenType.java +++ b/java/java-psi-api/src/com/intellij/psi/JavaTokenType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -87,6 +87,7 @@ public interface JavaTokenType extends TokenType{ IElementType TRY_KEYWORD = new IKeywordElementType("TRY_KEYWORD"); IElementType VOLATILE_KEYWORD = new IKeywordElementType("VOLATILE_KEYWORD"); IElementType THROWS_KEYWORD = new IKeywordElementType("THROWS_KEYWORD"); + IElementType NONE_KEYWORD = new IKeywordElementType("NONE_KEYWORD"); IElementType LPARENTH = new IJavaElementType("LPARENTH"); IElementType RPARENTH = new IJavaElementType("RPARENTH"); @@ -139,6 +140,9 @@ public interface JavaTokenType extends TokenType{ IElementType GTGTEQ = new IJavaElementType("GTGTEQ"); IElementType GTGTGTEQ = new IJavaElementType("GTGTGTEQ"); + IElementType DOUBLE_COLON = new IJavaElementType("DOUBLE_COLON"); + IElementType ARROW = new IJavaElementType("ARROW"); + TokenSet OPERATION_BIT_SET = TokenSet.create( EQ, GT, LT, EXCL, TILDE, QUEST, COLON, PLUS, MINUS, ASTERISK, DIV, AND, OR, XOR, PERC, EQEQ, LE, GE, NE, ANDAND, OROR, PLUSPLUS, MINUSMINUS, LTLT, GTGT, GTGTGT, diff --git a/java/java-psi-impl/src/com/intellij/lexer/JavaLexer.java b/java/java-psi-impl/src/com/intellij/lexer/JavaLexer.java index cee9feac4a2d..cf47bdcb772c 100644 --- a/java/java-psi-impl/src/com/intellij/lexer/JavaLexer.java +++ b/java/java-psi-impl/src/com/intellij/lexer/JavaLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -23,50 +23,51 @@ import com.intellij.psi.impl.source.tree.JavaDocElementType; import com.intellij.psi.tree.IElementType; import com.intellij.util.text.CharArrayUtil; import gnu.trove.THashSet; +import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.util.Set; public class JavaLexer extends LexerBase { - private JavaLexer(boolean isAssertKeywordEnabled, boolean isJDK15) { - myTable = getTable(isAssertKeywordEnabled, isJDK15); - myFlexLexer = new _JavaLexer(isAssertKeywordEnabled, isJDK15); - } + private static final HashTable[] TABLES = new HashTable[]{ + new HashTable(LanguageLevel.JDK_1_8), + new HashTable(LanguageLevel.JDK_1_5), + new HashTable(LanguageLevel.JDK_1_4), + new HashTable(LanguageLevel.JDK_1_3) + }; - public JavaLexer(LanguageLevel level) { - this(level.hasAssertKeyword(), level.hasEnumKeywordAndAutoboxing()); + private static HashTable getTable(final LanguageLevel level) { + for (HashTable table : TABLES) { + if (level.isAtLeast(table.myLevel)) { + return table; + } + } + throw new IllegalArgumentException("Unsupported level: " + level); } - private static HashTable getTable(boolean isAssertKeywordEnabled, boolean isJDK15) { - return isAssertKeywordEnabled - ? isJDK15 ? ourTableWithAssertAndJDK15 : ourTableWithAssert - : isJDK15 ? ourTableWithJDK15 : ourTableWithoutAssert; - } - - private static HashTable getTable(LanguageLevel level) { - return getTable(level.hasAssertKeyword(), level.hasEnumKeywordAndAutoboxing()); - } - - public static boolean isKeyword(String id, LanguageLevel level) { return getTable(level).contains(id); } + private final _JavaLexer myFlexLexer; + private final HashTable myTable; private CharSequence myBuffer; private char[] myBufferArray; private int myBufferIndex; private int myBufferEndOffset; - + private int myTokenEndOffset; // positioned after the last symbol of the current token private IElementType myTokenType; - private _JavaLexer myFlexLexer; - //Positioned after the last symbol of the current token - private int myTokenEndOffset; + public JavaLexer(@NotNull final LanguageLevel level) { + myFlexLexer = new _JavaLexer(level); + myTable = getTable(level); + } private static final class HashTable { private static final int NUM_ENTRIES = 999; private static final Logger LOG = Logger.getInstance("com.intellij.Lexer.JavaLexer"); + private final LanguageLevel myLevel; private final char[][] myTable = new char[NUM_ENTRIES][]; private final IElementType[] myKeywords = new IElementType[NUM_ENTRIES]; private final Set myKeywordsInSet = new THashSet(); @@ -111,12 +112,16 @@ public class JavaLexer extends LexerBase { } @SuppressWarnings({"HardCodedStringLiteral"}) - private HashTable(boolean isAssertKeywordEnabled, boolean isJDK15) { - if (isAssertKeywordEnabled) { + private HashTable(final LanguageLevel level) { + myLevel = level; + if (level.isAtLeast(LanguageLevel.JDK_1_4)) { add("assert", JavaTokenType.ASSERT_KEYWORD); - } - if (isJDK15) { - add("enum", JavaTokenType.ENUM_KEYWORD); + if (level.isAtLeast(LanguageLevel.JDK_1_5)) { + add("enum", JavaTokenType.ENUM_KEYWORD); + if (level.isAtLeast(LanguageLevel.JDK_1_8)) { + add("none", JavaTokenType.NONE_KEYWORD); + } + } } add("abstract", JavaTokenType.ABSTRACT_KEYWORD); add("default", JavaTokenType.DEFAULT_KEYWORD); @@ -172,12 +177,6 @@ public class JavaLexer extends LexerBase { } } - private final HashTable myTable; - private static final HashTable ourTableWithoutAssert = new HashTable(false, false); - private static final HashTable ourTableWithAssert = new HashTable(true, false); - private static final HashTable ourTableWithAssertAndJDK15 = new HashTable(true, true); - private static final HashTable ourTableWithJDK15 = new HashTable(false, true); - @Override public final void start(CharSequence buffer, int startOffset, int endOffset, int initialState) { myBuffer = buffer; diff --git a/java/java-impl/src/com/intellij/lexer/_JavaLexer.flex b/java/java-psi-impl/src/com/intellij/lexer/_JavaLexer.flex similarity index 91% rename from java/java-impl/src/com/intellij/lexer/_JavaLexer.flex rename to java/java-psi-impl/src/com/intellij/lexer/_JavaLexer.flex index ee395afce51e..a1335e5ba747 100644 --- a/java/java-impl/src/com/intellij/lexer/_JavaLexer.flex +++ b/java/java-psi-impl/src/com/intellij/lexer/_JavaLexer.flex @@ -1,6 +1,8 @@ /* It's an automatically generated code. Do not modify it. */ package com.intellij.lexer; -import com.intellij.psi.*; + +import com.intellij.pom.java.LanguageLevel; +import com.intellij.psi.JavaTokenType; import com.intellij.psi.impl.source.tree.JavaDocElementType; import com.intellij.psi.tree.IElementType; @@ -8,13 +10,15 @@ import com.intellij.psi.tree.IElementType; %% %{ - private boolean myAssertKeywordEnabled; - private boolean myJdk15Enabled; + private boolean myAssertKeyword; + private boolean myEnumKeyword; + private boolean myNoneKeyword; - public _JavaLexer(boolean isAssertKeywordEnabled, boolean jdk15Enabled){ + public _JavaLexer(LanguageLevel level) { this((java.io.Reader)null); - myAssertKeywordEnabled = isAssertKeywordEnabled; - myJdk15Enabled = jdk15Enabled; + myAssertKeyword = level.isAtLeast(LanguageLevel.JDK_1_4); + myEnumKeyword = level.isAtLeast(LanguageLevel.JDK_1_5); + myNoneKeyword = level.isAtLeast(LanguageLevel.JDK_1_8); } public void goTo(int offset) { @@ -101,7 +105,7 @@ ESCAPE_SEQUENCE=\\[^\r\n] "null" { return JavaTokenType.NULL_KEYWORD; } "abstract" { return JavaTokenType.ABSTRACT_KEYWORD; } - "assert" { return myAssertKeywordEnabled ? JavaTokenType.ASSERT_KEYWORD : JavaTokenType.IDENTIFIER; } + "assert" { return myAssertKeyword ? JavaTokenType.ASSERT_KEYWORD : JavaTokenType.IDENTIFIER; } "boolean" { return JavaTokenType.BOOLEAN_KEYWORD; } "break" { return JavaTokenType.BREAK_KEYWORD; } "byte" { return JavaTokenType.BYTE_KEYWORD; } @@ -115,7 +119,7 @@ ESCAPE_SEQUENCE=\\[^\r\n] "do" { return JavaTokenType.DO_KEYWORD; } "double" { return JavaTokenType.DOUBLE_KEYWORD; } "else" { return JavaTokenType.ELSE_KEYWORD; } - "enum" { return myJdk15Enabled ? JavaTokenType.ENUM_KEYWORD : JavaTokenType.IDENTIFIER; } + "enum" { return myEnumKeyword ? JavaTokenType.ENUM_KEYWORD : JavaTokenType.IDENTIFIER; } "extends" { return JavaTokenType.EXTENDS_KEYWORD; } "final" { return JavaTokenType.FINAL_KEYWORD; } "finally" { return JavaTokenType.FINALLY_KEYWORD; } @@ -150,6 +154,7 @@ ESCAPE_SEQUENCE=\\[^\r\n] "try" { return JavaTokenType.TRY_KEYWORD; } "volatile" { return JavaTokenType.VOLATILE_KEYWORD; } "throws" { return JavaTokenType.THROWS_KEYWORD; } + "none" { return myNoneKeyword ? JavaTokenType.NONE_KEYWORD : JavaTokenType.IDENTIFIER; } {IDENTIFIER} { return JavaTokenType.IDENTIFIER; } @@ -201,5 +206,7 @@ ESCAPE_SEQUENCE=\\[^\r\n] "%" { return JavaTokenType.PERC; } "@" { return JavaTokenType.AT; } - . { return JavaTokenType.BAD_CHARACTER; } + "::" { return JavaTokenType.DOUBLE_COLON; } + "->" { return JavaTokenType.ARROW; } + . { return JavaTokenType.BAD_CHARACTER; } diff --git a/java/java-psi-impl/src/com/intellij/lexer/_JavaLexer.java b/java/java-psi-impl/src/com/intellij/lexer/_JavaLexer.java index 25b809b8a7ba..6f9733947fd3 100644 --- a/java/java-psi-impl/src/com/intellij/lexer/_JavaLexer.java +++ b/java/java-psi-impl/src/com/intellij/lexer/_JavaLexer.java @@ -1,8 +1,26 @@ -/* The following code was generated by JFlex 1.4.3 on 2/3/11 8:56 PM */ +/* + * Copyright 2000-2012 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. + */ + +/* The following code was generated by JFlex 1.4.3 on 5/11/12 9:41 PM */ /* It's an automatically generated code. Do not modify it. */ package com.intellij.lexer; -import com.intellij.psi.*; + +import com.intellij.pom.java.LanguageLevel; +import com.intellij.psi.JavaTokenType; import com.intellij.psi.impl.source.tree.JavaDocElementType; import com.intellij.psi.tree.IElementType; @@ -11,8 +29,8 @@ import com.intellij.psi.tree.IElementType; /** * This class is a scanner generated by * JFlex 1.4.3 - * on 2/3/11 8:56 PM from the specification file - * /home/sher/Projects/IDEA/tools/lexer/../../community/java/java-impl/src/com/intellij/lexer/_JavaLexer.flex + * on 5/11/12 9:41 PM from the specification file + * /home/sher/Projects/IDEA/tools/lexer/../../community/java/java-psi-impl/src/com/intellij/lexer/_JavaLexer.flex */ class _JavaLexer implements FlexLexer { /** initial size of the lookahead buffer */ @@ -142,27 +160,27 @@ class _JavaLexer implements FlexLexer { "\1\17\1\20\1\21\1\22\1\23\1\24\1\25\1\26"+ "\1\27\1\30\1\31\1\32\1\33\1\34\1\35\1\36"+ "\1\37\1\40\1\41\1\42\1\43\1\0\1\44\1\45"+ - "\3\46\2\0\3\6\1\46\1\0\1\47\1\50\2\11"+ - "\2\12\34\3\1\51\3\3\1\52\6\3\1\53\1\54"+ + "\3\46\2\0\3\6\1\46\1\0\1\47\1\50\1\51"+ + "\2\11\2\12\35\3\1\52\3\3\1\53\6\3\1\54"+ "\1\55\1\56\1\57\1\60\1\61\1\62\1\63\1\64"+ - "\1\65\1\66\1\41\1\67\2\46\2\0\1\6\1\44"+ - "\1\0\1\6\1\0\1\70\2\3\1\71\10\3\1\72"+ - "\13\3\1\73\11\3\1\74\14\3\1\75\1\0\2\67"+ - "\4\0\1\46\2\0\1\76\2\3\1\77\1\3\1\100"+ - "\1\101\6\3\1\102\6\3\1\103\3\3\1\104\1\3"+ - "\1\105\3\3\1\106\6\3\1\107\5\3\1\110\1\3"+ - "\1\41\4\0\1\45\1\46\1\3\1\111\2\3\1\112"+ - "\1\113\1\114\4\3\1\115\1\3\1\116\2\3\1\117"+ - "\1\3\1\120\1\121\1\3\1\122\13\3\1\123\1\3"+ - "\1\124\1\125\2\3\1\126\2\3\1\127\1\3\1\130"+ - "\1\131\5\3\1\132\1\3\1\133\2\3\1\134\3\3"+ - "\1\135\1\136\3\3\1\137\4\3\1\140\1\3\1\141"+ - "\1\142\2\3\1\143\1\144\1\3\1\145\4\3\1\146"+ - "\1\147\1\3\1\150\2\3\1\151\1\3\1\152\1\153"+ - "\1\3\1\154"; + "\1\65\1\66\1\67\1\70\1\41\1\71\2\46\2\0"+ + "\1\6\1\44\1\0\1\6\1\0\1\72\2\3\1\73"+ + "\10\3\1\74\13\3\1\75\12\3\1\76\14\3\1\77"+ + "\1\0\2\71\4\0\1\46\2\0\1\100\2\3\1\101"+ + "\1\3\1\102\1\103\6\3\1\104\6\3\1\105\1\3"+ + "\1\106\2\3\1\107\1\3\1\110\3\3\1\111\6\3"+ + "\1\112\5\3\1\113\1\3\1\41\4\0\1\45\1\46"+ + "\1\3\1\114\2\3\1\115\1\116\1\117\4\3\1\120"+ + "\1\3\1\121\2\3\1\122\1\3\1\123\1\124\1\3"+ + "\1\125\13\3\1\126\1\3\1\127\1\130\2\3\1\131"+ + "\2\3\1\132\1\3\1\133\1\134\5\3\1\135\1\3"+ + "\1\136\2\3\1\137\3\3\1\140\1\141\3\3\1\142"+ + "\4\3\1\143\1\3\1\144\1\145\2\3\1\146\1\147"+ + "\1\3\1\150\4\3\1\151\1\152\1\3\1\153\2\3"+ + "\1\154\1\3\1\155\1\156\1\3\1\157"; private static int [] zzUnpackAction() { - int [] result = new int[340]; + int [] result = new int[345]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -192,47 +210,48 @@ class _JavaLexer implements FlexLexer { "\0\u0470\0\u04b7\0\u04fe\0\u0545\0\u058c\0\u05d3\0\u061a\0\u0661"+ "\0\u06a8\0\u06ef\0\u0736\0\u077d\0\u07c4\0\u080b\0\u0852\0\u0899"+ "\0\u08e0\0\107\0\u0927\0\u096e\0\u09b5\0\107\0\107\0\107"+ - "\0\107\0\107\0\107\0\107\0\107\0\107\0\107\0\107"+ - "\0\107\0\u09fc\0\u0a43\0\107\0\107\0\u0a8a\0\107\0\107"+ - "\0\107\0\u0ad1\0\u0b18\0\u0b5f\0\u0ba6\0\u0bed\0\u0c34\0\u0c7b"+ - "\0\u0cc2\0\u0d09\0\107\0\107\0\107\0\u0d50\0\u0d97\0\107"+ - "\0\u0dde\0\u0e25\0\u0e6c\0\u0eb3\0\u0efa\0\u0f41\0\u0f88\0\u0fcf"+ + "\0\107\0\107\0\107\0\107\0\107\0\107\0\107\0\u09fc"+ + "\0\107\0\u0a43\0\u0a8a\0\107\0\107\0\u0ad1\0\107\0\107"+ + "\0\107\0\u0b18\0\u0b5f\0\u0ba6\0\u0bed\0\u0c34\0\u0c7b\0\u0cc2"+ + "\0\u0d09\0\u0d50\0\107\0\107\0\107\0\107\0\u0d97\0\u0dde"+ + "\0\107\0\u0e25\0\u0e6c\0\u0eb3\0\u0efa\0\u0f41\0\u0f88\0\u0fcf"+ "\0\u1016\0\u105d\0\u10a4\0\u10eb\0\u1132\0\u1179\0\u11c0\0\u1207"+ "\0\u124e\0\u1295\0\u12dc\0\u1323\0\u136a\0\u13b1\0\u13f8\0\u143f"+ - "\0\u1486\0\u14cd\0\u1514\0\u155b\0\325\0\u15a2\0\u15e9\0\u1630"+ - "\0\u1677\0\u16be\0\u1705\0\u174c\0\u1793\0\u17da\0\u1821\0\107"+ - "\0\107\0\107\0\107\0\107\0\107\0\107\0\u1868\0\107"+ - "\0\107\0\107\0\107\0\u18af\0\u18f6\0\u193d\0\u1984\0\u19cb"+ - "\0\u1a12\0\u1a59\0\u1a12\0\u1aa0\0\u1ae7\0\u1b2e\0\107\0\u1b75"+ - "\0\u1bbc\0\325\0\u1c03\0\u1c4a\0\u1c91\0\u1cd8\0\u1d1f\0\u1d66"+ - "\0\u1dad\0\u1df4\0\325\0\u1e3b\0\u1e82\0\u1ec9\0\u1f10\0\u1f57"+ - "\0\u1f9e\0\u1fe5\0\u202c\0\u2073\0\u20ba\0\u2101\0\325\0\u2148"+ - "\0\u218f\0\u21d6\0\u221d\0\u2264\0\u22ab\0\u22f2\0\u2339\0\u2380"+ - "\0\u23c7\0\u240e\0\u2455\0\u249c\0\u24e3\0\u252a\0\u2571\0\u25b8"+ - "\0\u25ff\0\u2646\0\u268d\0\u26d4\0\u271b\0\107\0\u2762\0\u27a9"+ - "\0\107\0\u27f0\0\u2837\0\u287e\0\u28c5\0\u290c\0\u2953\0\u299a"+ - "\0\325\0\u29e1\0\u2a28\0\325\0\u2a6f\0\325\0\325\0\u2ab6"+ - "\0\u2afd\0\u2b44\0\u2b8b\0\u2bd2\0\u2c19\0\325\0\u2c60\0\u2ca7"+ - "\0\u2cee\0\u2d35\0\u2d7c\0\u2dc3\0\325\0\u2e0a\0\u2e51\0\u2e98"+ - "\0\325\0\u2edf\0\325\0\u2f26\0\u2f6d\0\u2fb4\0\325\0\u2ffb"+ - "\0\u3042\0\u3089\0\u30d0\0\u3117\0\u315e\0\325\0\u31a5\0\u31ec"+ - "\0\u3233\0\u327a\0\u32c1\0\325\0\u3308\0\107\0\u334f\0\u3396"+ - "\0\u33dd\0\u3424\0\u2837\0\u2837\0\u346b\0\u34b2\0\u34f9\0\u3540"+ - "\0\325\0\325\0\u3587\0\u35ce\0\u3615\0\u365c\0\u36a3\0\325"+ - "\0\u36ea\0\325\0\u3731\0\u3778\0\325\0\u37bf\0\325\0\325"+ - "\0\u3806\0\325\0\u384d\0\u3894\0\u38db\0\u3922\0\u3969\0\u39b0"+ - "\0\u39f7\0\u3a3e\0\u3a85\0\u3acc\0\u3b13\0\325\0\u3b5a\0\325"+ - "\0\325\0\u3ba1\0\u3be8\0\325\0\u3c2f\0\u3c76\0\325\0\u3cbd"+ - "\0\325\0\325\0\u3d04\0\u3d4b\0\u3d92\0\u3dd9\0\u3e20\0\325"+ - "\0\u3e67\0\325\0\u3eae\0\u3ef5\0\325\0\u3f3c\0\u3f83\0\u3fca"+ - "\0\325\0\325\0\u4011\0\u4058\0\u409f\0\325\0\u40e6\0\u412d"+ - "\0\u4174\0\u41bb\0\325\0\u4202\0\325\0\325\0\u4249\0\u4290"+ - "\0\325\0\325\0\u42d7\0\325\0\u431e\0\u4365\0\u43ac\0\u43f3"+ - "\0\325\0\325\0\u443a\0\325\0\u4481\0\u44c8\0\325\0\u450f"+ - "\0\325\0\325\0\u4556\0\325"; + "\0\u1486\0\u14cd\0\u1514\0\u155b\0\u15a2\0\u15e9\0\325\0\u1630"+ + "\0\u1677\0\u16be\0\u1705\0\u174c\0\u1793\0\u17da\0\u1821\0\u1868"+ + "\0\u18af\0\107\0\107\0\107\0\107\0\107\0\107\0\107"+ + "\0\u18f6\0\107\0\107\0\107\0\107\0\107\0\u193d\0\u1984"+ + "\0\u19cb\0\u1a12\0\u1a59\0\u1aa0\0\u1ae7\0\u1aa0\0\u1b2e\0\u1b75"+ + "\0\u1bbc\0\107\0\u1c03\0\u1c4a\0\325\0\u1c91\0\u1cd8\0\u1d1f"+ + "\0\u1d66\0\u1dad\0\u1df4\0\u1e3b\0\u1e82\0\325\0\u1ec9\0\u1f10"+ + "\0\u1f57\0\u1f9e\0\u1fe5\0\u202c\0\u2073\0\u20ba\0\u2101\0\u2148"+ + "\0\u218f\0\325\0\u21d6\0\u221d\0\u2264\0\u22ab\0\u22f2\0\u2339"+ + "\0\u2380\0\u23c7\0\u240e\0\u2455\0\u249c\0\u24e3\0\u252a\0\u2571"+ + "\0\u25b8\0\u25ff\0\u2646\0\u268d\0\u26d4\0\u271b\0\u2762\0\u27a9"+ + "\0\u27f0\0\107\0\u2837\0\u287e\0\107\0\u28c5\0\u290c\0\u2953"+ + "\0\u299a\0\u29e1\0\u2a28\0\u2a6f\0\325\0\u2ab6\0\u2afd\0\325"+ + "\0\u2b44\0\325\0\325\0\u2b8b\0\u2bd2\0\u2c19\0\u2c60\0\u2ca7"+ + "\0\u2cee\0\325\0\u2d35\0\u2d7c\0\u2dc3\0\u2e0a\0\u2e51\0\u2e98"+ + "\0\325\0\u2edf\0\325\0\u2f26\0\u2f6d\0\325\0\u2fb4\0\325"+ + "\0\u2ffb\0\u3042\0\u3089\0\325\0\u30d0\0\u3117\0\u315e\0\u31a5"+ + "\0\u31ec\0\u3233\0\325\0\u327a\0\u32c1\0\u3308\0\u334f\0\u3396"+ + "\0\325\0\u33dd\0\107\0\u3424\0\u346b\0\u34b2\0\u34f9\0\u290c"+ + "\0\u290c\0\u3540\0\u3587\0\u35ce\0\u3615\0\325\0\325\0\u365c"+ + "\0\u36a3\0\u36ea\0\u3731\0\u3778\0\325\0\u37bf\0\325\0\u3806"+ + "\0\u384d\0\325\0\u3894\0\325\0\325\0\u38db\0\325\0\u3922"+ + "\0\u3969\0\u39b0\0\u39f7\0\u3a3e\0\u3a85\0\u3acc\0\u3b13\0\u3b5a"+ + "\0\u3ba1\0\u3be8\0\325\0\u3c2f\0\325\0\325\0\u3c76\0\u3cbd"+ + "\0\325\0\u3d04\0\u3d4b\0\325\0\u3d92\0\325\0\325\0\u3dd9"+ + "\0\u3e20\0\u3e67\0\u3eae\0\u3ef5\0\325\0\u3f3c\0\325\0\u3f83"+ + "\0\u3fca\0\325\0\u4011\0\u4058\0\u409f\0\325\0\325\0\u40e6"+ + "\0\u412d\0\u4174\0\325\0\u41bb\0\u4202\0\u4249\0\u4290\0\325"+ + "\0\u42d7\0\325\0\325\0\u431e\0\u4365\0\325\0\325\0\u43ac"+ + "\0\325\0\u43f3\0\u443a\0\u4481\0\u44c8\0\325\0\325\0\u450f"+ + "\0\325\0\u4556\0\u459d\0\325\0\u45e4\0\325\0\325\0\u462b"+ + "\0\325"; private static int [] zzUnpackRowMap() { - int [] result = new int[340]; + int [] result = new int[345]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -272,362 +291,366 @@ class _JavaLexer implements FlexLexer { "\1\100\1\67\1\70\1\71\1\72\1\73\11\0\1\73"+ "\1\70\1\0\1\67\2\0\1\100\6\0\1\71\1\0"+ "\1\77\41\0\1\101\1\0\1\101\1\0\2\101\5\0"+ - "\1\102\110\0\1\103\35\0\1\104\24\0\6\13\1\0"+ - "\17\13\1\0\1\105\1\106\56\13\6\14\1\0\17\14"+ - "\1\0\1\14\1\107\1\110\55\14\2\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\1\4\1\111"+ - "\14\4\1\112\11\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\3\4\1\113\24\4\27\0"+ + "\1\102\110\0\1\103\35\0\1\104\4\0\1\105\17\0"+ + "\6\13\1\0\17\13\1\0\1\106\1\107\56\13\6\14"+ + "\1\0\17\14\1\0\1\14\1\110\1\111\55\14\2\0"+ "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\6\4\1\114\1\4\1\115\11\4\1\116\5\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\5\4\1\117\1\120\4\4\1\121\3\4\1\122\10\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\7\4\1\123\1\4\1\124\16\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\13\4"+ - "\1\125\14\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\1\126\1\4\1\127\12\4\1\130"+ - "\1\131\7\4\1\132\1\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\2\4\1\133\1\134"+ - "\1\4\1\135\22\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\1\4\1\136\11\4\1\137"+ - "\1\4\1\140\12\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\5\4\1\141\1\142\4\4"+ - "\1\143\2\4\1\144\11\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\4\4\1\145\3\4"+ - "\1\146\10\4\1\147\6\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\3\4\1\150\7\4"+ - "\1\151\14\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\13\4\1\152\14\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\4"+ - "\1\153\1\154\2\4\1\155\22\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\13\4\1\156"+ - "\14\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\16\4\1\157\11\4\107\0\1\160\106\0"+ - "\1\161\106\0\1\162\1\0\1\163\104\0\1\164\2\0"+ - "\1\165\103\0\1\166\3\0\1\167\102\0\1\170\5\0"+ - "\1\171\100\0\1\172\106\0\1\173\24\0\6\62\1\0"+ - "\17\62\1\0\60\62\5\174\1\175\101\174\7\0\1\7"+ - "\1\66\1\7\1\0\2\7\101\0\1\101\1\0\1\101"+ - "\1\0\2\101\3\0\1\70\1\71\1\0\1\73\11\0"+ - "\1\73\1\70\13\0\1\71\43\0\1\176\1\0\1\176"+ - "\1\0\2\176\3\0\1\70\1\71\2\0\1\177\11\0"+ - "\1\70\13\0\1\71\12\0\1\177\30\0\1\74\1\200"+ - "\1\74\1\0\2\74\3\0\1\70\1\71\1\72\1\73"+ - "\11\0\1\73\1\70\13\0\1\71\43\0\1\74\1\75"+ - "\1\76\1\0\2\76\101\0\1\74\1\75\1\76\1\0"+ - "\2\76\2\0\1\67\1\70\1\71\1\72\1\73\11\0"+ - "\1\73\1\70\1\0\1\67\11\0\1\71\34\0\7\201"+ - "\1\202\1\201\4\202\1\201\1\202\1\203\2\202\1\201"+ - "\1\202\1\201\1\204\1\0\6\201\3\202\1\203\2\201"+ - "\2\202\5\201\1\202\3\201\1\204\30\201\13\0\2\205"+ - "\2\0\1\67\20\0\1\67\55\0\1\101\1\206\1\101"+ - "\1\0\2\101\3\0\1\70\1\71\1\0\1\73\11\0"+ - "\1\73\1\70\13\0\1\71\56\0\1\207\64\0\6\13"+ - "\1\0\17\13\1\0\60\13\6\14\1\0\17\14\1\0"+ - "\60\14\2\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\2\4\1\210\2\4\1\211\7\4\1\212"+ - "\12\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\1\4\1\213\15\4\1\214\10\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\1\215\27\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\7\4\1\216\20\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\2\4"+ - "\1\217\25\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\1\220\27\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\6\4\1\221"+ - "\21\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\13\4\1\222\14\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\1\4\1\223"+ - "\26\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\10\4\1\224\17\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\7\4\1\225"+ - "\20\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\7\4\1\226\20\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\10\4\1\227"+ - "\17\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\1\4\1\230\3\4\1\231\22\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\24\4\1\232\3\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\10\4\1\233\17\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\13\4\1\234\14\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\17\4\1\235\10\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\6\4\1\236\21\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\26\4\1\237\1\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\1\240\27\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\3\4\1\241\24\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\13\4"+ - "\1\242\14\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\1\243\27\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\1\244\6\4"+ - "\1\245\20\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\5\4\1\246\22\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\10\4"+ - "\1\247\17\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\5\4\1\250\22\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\251"+ - "\6\4\1\252\20\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\24\4\1\253\3\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\4\4\1\254\23\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\2\4\1\255\25\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\1\256\27\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\13\4\1\257\3\4\1\260\10\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\11\4\1\261\16\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\12\4\1\262\15\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\6\4\1\263\10\4\1\264\10\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\17\4"+ - "\1\265\10\4\107\0\1\266\24\0\5\174\1\267\101\174"+ - "\4\270\1\271\1\175\101\270\7\0\1\176\1\272\1\176"+ - "\1\0\2\176\3\0\1\70\1\71\14\0\1\70\13\0"+ - "\1\71\43\0\1\176\1\0\1\176\1\0\2\176\3\0"+ - "\1\70\1\71\14\0\1\70\13\0\1\71\43\0\1\74"+ - "\1\200\1\74\1\0\2\74\101\0\1\273\1\0\4\273"+ - "\1\0\1\273\1\0\2\273\1\0\1\273\1\0\1\274"+ - "\7\0\3\273\3\0\2\273\5\0\1\273\3\0\1\274"+ - "\30\0\7\201\1\202\1\275\4\202\1\201\1\202\1\203"+ - "\2\202\1\201\1\202\1\201\1\204\1\0\6\201\3\202"+ - "\1\203\2\201\2\202\5\201\1\202\3\201\1\204\30\201"+ - "\7\0\1\276\1\0\1\276\1\273\2\276\1\0\1\273"+ - "\1\0\2\273\1\0\1\273\1\277\1\274\7\0\3\273"+ - "\3\0\2\273\5\0\1\273\3\0\1\274\6\0\1\277"+ - "\31\0\1\300\2\0\2\205\2\0\1\67\20\0\1\67"+ - "\55\0\1\101\1\206\1\101\1\0\2\101\74\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\3\4"+ - "\1\301\24\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\10\4\1\302\17\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\13\4"+ - "\1\303\14\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\7\4\1\304\20\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\2\4"+ - "\1\305\25\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\3\4\1\306\24\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\21\4"+ - "\1\307\6\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\3\4\1\310\24\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\7\4"+ - "\1\311\20\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\5\4\1\312\22\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\5\4"+ - "\1\313\22\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\3\4\1\314\24\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\315"+ - "\27\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\23\4\1\316\4\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\17\4\1\317"+ - "\10\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\1\320\27\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\3\4\1\321\24\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\12\4\1\322\15\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\1\4\1\323\26\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\1\324\27\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\6\4\1\325\21\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\17\4\1\326\10\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\5\4\1\327\22\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\6\4\1\330\21\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\3\4\1\331\24\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\12\4\1\332\15\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\3\4\1\333\24\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\7\4\1\334\20\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\1\335\6\4\1\336\20\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\1\4\1\337\26\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\3\4\1\340\24\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\1\341\27\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\6\4\1\342\4\4\1\343"+ - "\14\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\5\4\1\344\22\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\11\4\1\345"+ - "\16\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\13\4\1\346\14\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\1\347\27\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\25\4\1\350\2\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\6\4\1\351\21\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\14\4\1\352\13\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\5\4\1\353\22\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\20\4\1\354\7\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\6\4\1\355\21\4"+ - "\25\0\4\174\1\356\1\267\101\174\5\270\1\357\101\270"+ - "\7\0\1\176\1\272\1\176\1\0\2\176\101\0\1\273"+ - "\1\360\4\273\1\0\1\273\1\0\2\273\1\0\1\273"+ - "\1\0\1\274\7\0\3\273\3\0\2\273\5\0\1\273"+ - "\3\0\1\274\37\0\1\176\1\0\1\176\1\0\2\176"+ - "\7\0\1\277\40\0\1\277\30\0\1\202\1\361\4\202"+ - "\1\0\1\202\1\0\2\202\1\0\1\202\1\0\1\274"+ - "\7\0\3\202\3\0\2\202\5\0\1\202\3\0\1\274"+ - "\37\0\1\276\1\362\1\276\1\273\2\276\1\0\1\273"+ - "\1\0\1\363\1\364\1\0\1\273\1\0\1\274\7\0"+ - "\1\273\1\363\1\273\3\0\2\273\5\0\1\364\3\0"+ - "\1\274\37\0\1\176\1\0\1\176\1\0\2\176\102\0"+ - "\1\300\2\0\2\205\74\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\7\4\1\365\20\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\26\4\1\366\1\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\1\4\1\367\26\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\10\4\1\370\17\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\3\4\1\371\24\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\1\372\27\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\6\4\1\373\21\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\4"+ - "\1\374\26\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\1\4\1\375\26\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\12\4"+ - "\1\376\15\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\17\4\1\377\10\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\4"+ - "\1\u0100\26\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\16\4\1\u0101\11\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\u0102"+ - "\27\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\12\4\1\u0103\15\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\25\4\1\u0104"+ - "\2\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\14\4\1\u0105\13\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\3\4\1\u0106"+ + "\1\4\1\112\14\4\1\113\11\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\3\4\1\114"+ "\24\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\16\4\1\u0107\11\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\7\4\1\u0108"+ - "\20\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\17\4\1\u0109\10\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\1\u010a\27\4"+ + "\1\4\4\0\6\4\1\115\1\4\1\116\11\4\1\117"+ + "\5\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\5\4\1\120\1\121\4\4\1\122\3\4"+ + "\1\123\10\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\7\4\1\124\1\4\1\125\16\4"+ "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\1\4\1\u010b\26\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\5\4\1\u010c\22\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\3\4\1\u010d\24\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\1\4\1\u010e\26\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\2\4\1\u010f\25\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\6\4\1\u0110\21\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\3\4\1\u0111\24\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\5\4\1\u0112\22\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\17\4\1\u0113\10\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\5\4\1\u0114\22\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\1\u0115\27\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\3\4\1\u0116\24\4\25\0"+ - "\4\270\1\271\1\357\101\270\7\0\1\273\1\360\4\273"+ - "\1\0\1\273\1\0\2\273\1\0\1\273\11\0\3\273"+ - "\3\0\2\273\5\0\1\273\43\0\1\202\1\361\4\202"+ - "\1\0\1\202\1\0\2\202\1\0\1\202\11\0\3\202"+ - "\3\0\2\202\5\0\1\202\43\0\1\276\1\362\1\276"+ - "\1\273\2\276\1\0\1\273\1\0\2\273\1\0\1\273"+ - "\11\0\3\273\3\0\2\273\5\0\1\273\36\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\17\4"+ - "\1\u0117\10\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\7\4\1\u0118\20\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\10\4"+ - "\1\u0119\17\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\20\4\1\u011a\7\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\6\4"+ - "\1\u011b\21\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\1\u011c\27\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\5\4\1\u011d"+ - "\22\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\1\u011e\27\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\12\4\1\u011f\15\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\1\4\1\u0120\26\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\16\4\1\u0121\11\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\3\4\1\u0122\24\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\5\4\1\u0123\22\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\10\4\1\u0124\17\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\4\4\1\u0125\23\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\10\4\1\u0126\17\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\21\4\1\u0127\6\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\1\u0128\27\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\6\4\1\u0129\21\4\27\0"+ + "\4\0\13\4\1\126\14\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\1\127\1\4\1\130"+ + "\12\4\1\131\1\132\7\4\1\133\1\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\2\4"+ + "\1\134\1\135\1\4\1\136\5\4\1\137\14\4\27\0"+ "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\3\4\1\u012a\24\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\12\4\1\u012b\15\4\27\0"+ + "\1\4\1\140\11\4\1\141\1\4\1\142\12\4\27\0"+ "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\1\u012c\27\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\12\4\1\u012d\15\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\23\4"+ - "\1\u012e\4\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\17\4\1\u012f\10\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\3\4"+ - "\1\u0130\24\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\7\4\1\u0131\20\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\15\4"+ - "\1\u0132\12\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\12\4\1\u0133\15\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\4\4"+ - "\1\u0134\23\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\13\4\1\u0135\14\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\10\4"+ - "\1\u0136\17\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\2\4\1\u0137\25\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\5\4"+ - "\1\u0138\22\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\12\4\1\u0139\15\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\3\4"+ - "\1\u013a\24\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\1\u013b\27\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\1\u013c\27\4"+ + "\5\4\1\143\1\144\4\4\1\145\2\4\1\146\11\4"+ "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\3\4\1\u013d\24\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\3\4\1\u013e\24\4"+ + "\4\0\4\4\1\147\3\4\1\150\10\4\1\151\6\4"+ "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\6\4\1\u013f\21\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\10\4\1\u0140\17\4"+ - "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\1\u0141\27\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\24\4\1\u0142\3\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\10\4\1\u0143\17\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\3\4\1\u0144\24\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\12\4\1\u0145\15\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\3\4\1\u0146\24\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\10\4\1\u0147\17\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\3\4\1\u0148\24\4\27\0"+ - "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ - "\3\4\1\u0149\24\4\27\0\2\4\3\0\13\4\1\0"+ - "\1\4\1\0\1\4\4\0\1\u014a\27\4\27\0\2\4"+ - "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\17\4"+ - "\1\u014b\10\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\3\4\1\u014c\24\4\27\0\2\4"+ + "\4\0\3\4\1\152\7\4\1\153\14\4\27\0\2\4"+ "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\13\4"+ - "\1\u014d\14\4\27\0\2\4\3\0\13\4\1\0\1\4"+ - "\1\0\1\4\4\0\1\u014e\27\4\27\0\2\4\3\0"+ - "\13\4\1\0\1\4\1\0\1\4\4\0\20\4\1\u014f"+ - "\7\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ - "\1\4\4\0\27\4\1\u0150\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\4\4\1\u0151\23\4"+ + "\1\154\14\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\1\4\1\155\1\156\2\4\1\157"+ + "\22\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\13\4\1\160\14\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\16\4\1\161"+ + "\11\4\107\0\1\162\106\0\1\163\106\0\1\164\1\0"+ + "\1\165\104\0\1\166\2\0\1\167\103\0\1\170\3\0"+ + "\1\171\102\0\1\172\5\0\1\173\100\0\1\174\106\0"+ + "\1\175\131\0\1\176\1\0\6\62\1\0\17\62\1\0"+ + "\60\62\5\177\1\200\101\177\7\0\1\7\1\66\1\7"+ + "\1\0\2\7\101\0\1\101\1\0\1\101\1\0\2\101"+ + "\3\0\1\70\1\71\1\0\1\73\11\0\1\73\1\70"+ + "\13\0\1\71\43\0\1\201\1\0\1\201\1\0\2\201"+ + "\3\0\1\70\1\71\2\0\1\202\11\0\1\70\13\0"+ + "\1\71\12\0\1\202\30\0\1\74\1\203\1\74\1\0"+ + "\2\74\3\0\1\70\1\71\1\72\1\73\11\0\1\73"+ + "\1\70\13\0\1\71\43\0\1\74\1\75\1\76\1\0"+ + "\2\76\101\0\1\74\1\75\1\76\1\0\2\76\2\0"+ + "\1\67\1\70\1\71\1\72\1\73\11\0\1\73\1\70"+ + "\1\0\1\67\11\0\1\71\34\0\7\204\1\205\1\204"+ + "\4\205\1\204\1\205\1\206\2\205\1\204\1\205\1\204"+ + "\1\207\1\0\6\204\3\205\1\206\2\204\2\205\5\204"+ + "\1\205\3\204\1\207\30\204\13\0\2\210\2\0\1\67"+ + "\20\0\1\67\55\0\1\101\1\211\1\101\1\0\2\101"+ + "\3\0\1\70\1\71\1\0\1\73\11\0\1\73\1\70"+ + "\13\0\1\71\56\0\1\212\64\0\6\13\1\0\17\13"+ + "\1\0\60\13\6\14\1\0\17\14\1\0\60\14\2\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\2\4\1\213\2\4\1\214\7\4\1\215\12\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\1\4\1\216\15\4\1\217\10\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\1\220\27\4"+ "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\7\4\1\u0152\20\4\27\0\2\4\3\0\13\4"+ - "\1\0\1\4\1\0\1\4\4\0\3\4\1\u0153\24\4"+ + "\4\0\7\4\1\221\20\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\2\4\1\222\25\4"+ "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ - "\4\0\20\4\1\u0154\7\4\25\0"; + "\4\0\1\223\27\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\6\4\1\224\21\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\13\4\1\225\14\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\1\4\1\226\26\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\10\4\1\227\17\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\7\4\1\230\20\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\7\4\1\231\20\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\10\4\1\232\17\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\1\4\1\233\3\4\1\234\22\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\24\4\1\235"+ + "\3\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\10\4\1\236\17\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\13\4\1\237"+ + "\14\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\17\4\1\240\10\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\6\4\1\241"+ + "\21\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\26\4\1\242\1\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\1\243\27\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\10\4\1\244\17\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\3\4\1\245\24\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\13\4\1\246\14\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\1\247\27\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\1\250\6\4\1\251\20\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\5\4\1\252\22\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\10\4\1\253\17\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\5\4\1\254\22\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\1\255\6\4\1\256\20\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\24\4\1\257"+ + "\3\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\4\4\1\260\23\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\2\4\1\261"+ + "\25\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\1\262\27\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\13\4\1\263\3\4"+ + "\1\264\10\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\11\4\1\265\16\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\12\4"+ + "\1\266\15\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\6\4\1\267\10\4\1\270\10\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\17\4\1\271\10\4\107\0\1\272\24\0\5\177"+ + "\1\273\101\177\4\274\1\275\1\200\101\274\7\0\1\201"+ + "\1\276\1\201\1\0\2\201\3\0\1\70\1\71\14\0"+ + "\1\70\13\0\1\71\43\0\1\201\1\0\1\201\1\0"+ + "\2\201\3\0\1\70\1\71\14\0\1\70\13\0\1\71"+ + "\43\0\1\74\1\203\1\74\1\0\2\74\101\0\1\277"+ + "\1\0\4\277\1\0\1\277\1\0\2\277\1\0\1\277"+ + "\1\0\1\300\7\0\3\277\3\0\2\277\5\0\1\277"+ + "\3\0\1\300\30\0\7\204\1\205\1\301\4\205\1\204"+ + "\1\205\1\206\2\205\1\204\1\205\1\204\1\207\1\0"+ + "\6\204\3\205\1\206\2\204\2\205\5\204\1\205\3\204"+ + "\1\207\30\204\7\0\1\302\1\0\1\302\1\277\2\302"+ + "\1\0\1\277\1\0\2\277\1\0\1\277\1\303\1\300"+ + "\7\0\3\277\3\0\2\277\5\0\1\277\3\0\1\300"+ + "\6\0\1\303\31\0\1\304\2\0\2\210\2\0\1\67"+ + "\20\0\1\67\55\0\1\101\1\211\1\101\1\0\2\101"+ + "\74\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\3\4\1\305\24\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\10\4\1\306\17\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\13\4\1\307\14\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\7\4\1\310\20\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\2\4\1\311\25\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\3\4\1\312\24\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\21\4\1\313\6\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\3\4\1\314\24\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\7\4\1\315\20\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\5\4\1\316\22\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\5\4\1\317\22\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\3\4\1\320\24\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\1\321\27\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\23\4\1\322\4\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\17\4\1\323\10\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\1\324\27\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\3\4"+ + "\1\325\24\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\12\4\1\326\15\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\4"+ + "\1\327\26\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\1\330\27\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\6\4\1\331"+ + "\21\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\17\4\1\332\10\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\3\4\1\333"+ + "\24\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\5\4\1\334\22\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\6\4\1\335"+ + "\21\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\3\4\1\336\24\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\12\4\1\337"+ + "\15\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\3\4\1\340\24\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\7\4\1\341"+ + "\20\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\1\342\6\4\1\343\20\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\4"+ + "\1\344\26\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\3\4\1\345\24\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\346"+ + "\27\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\6\4\1\347\4\4\1\350\14\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\5\4\1\351\22\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\11\4\1\352\16\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\13\4\1\353\14\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\1\354\27\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\25\4"+ + "\1\355\2\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\6\4\1\356\21\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\14\4"+ + "\1\357\13\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\5\4\1\360\22\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\20\4"+ + "\1\361\7\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\6\4\1\362\21\4\25\0\4\177"+ + "\1\363\1\273\101\177\5\274\1\364\101\274\7\0\1\201"+ + "\1\276\1\201\1\0\2\201\101\0\1\277\1\365\4\277"+ + "\1\0\1\277\1\0\2\277\1\0\1\277\1\0\1\300"+ + "\7\0\3\277\3\0\2\277\5\0\1\277\3\0\1\300"+ + "\37\0\1\201\1\0\1\201\1\0\2\201\7\0\1\303"+ + "\40\0\1\303\30\0\1\205\1\366\4\205\1\0\1\205"+ + "\1\0\2\205\1\0\1\205\1\0\1\300\7\0\3\205"+ + "\3\0\2\205\5\0\1\205\3\0\1\300\37\0\1\302"+ + "\1\367\1\302\1\277\2\302\1\0\1\277\1\0\1\370"+ + "\1\371\1\0\1\277\1\0\1\300\7\0\1\277\1\370"+ + "\1\277\3\0\2\277\5\0\1\371\3\0\1\300\37\0"+ + "\1\201\1\0\1\201\1\0\2\201\102\0\1\304\2\0"+ + "\2\210\74\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\7\4\1\372\20\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\26\4\1\373"+ + "\1\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\1\4\1\374\26\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\10\4\1\375"+ + "\17\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\3\4\1\376\24\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\1\377\27\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\6\4\1\u0100\21\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\1\4\1\u0101\26\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\1\4\1\u0102\26\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\12\4\1\u0103\15\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\17\4\1\u0104\10\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\1\4\1\u0105\26\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\16\4\1\u0106\11\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\1\u0107\27\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\12\4\1\u0108\15\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\25\4\1\u0109\2\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\14\4\1\u010a\13\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\3\4\1\u010b\24\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\16\4\1\u010c\11\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\7\4\1\u010d\20\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\17\4\1\u010e\10\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\1\u010f\27\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\4"+ + "\1\u0110\26\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\5\4\1\u0111\22\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\3\4"+ + "\1\u0112\24\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\1\4\1\u0113\26\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\2\4"+ + "\1\u0114\25\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\6\4\1\u0115\21\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\3\4"+ + "\1\u0116\24\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\5\4\1\u0117\22\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\17\4"+ + "\1\u0118\10\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\5\4\1\u0119\22\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\u011a"+ + "\27\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\3\4\1\u011b\24\4\25\0\4\274\1\275"+ + "\1\364\101\274\7\0\1\277\1\365\4\277\1\0\1\277"+ + "\1\0\2\277\1\0\1\277\11\0\3\277\3\0\2\277"+ + "\5\0\1\277\43\0\1\205\1\366\4\205\1\0\1\205"+ + "\1\0\2\205\1\0\1\205\11\0\3\205\3\0\2\205"+ + "\5\0\1\205\43\0\1\302\1\367\1\302\1\277\2\302"+ + "\1\0\1\277\1\0\2\277\1\0\1\277\11\0\3\277"+ + "\3\0\2\277\5\0\1\277\36\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\17\4\1\u011c\10\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\7\4\1\u011d\20\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\10\4\1\u011e\17\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\20\4\1\u011f\7\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\6\4\1\u0120\21\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\1\u0121\27\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\5\4\1\u0122\22\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\1\u0123\27\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\12\4\1\u0124\15\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\4"+ + "\1\u0125\26\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\16\4\1\u0126\11\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\3\4"+ + "\1\u0127\24\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\5\4\1\u0128\22\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\10\4"+ + "\1\u0129\17\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\4\4\1\u012a\23\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\10\4"+ + "\1\u012b\17\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\21\4\1\u012c\6\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\u012d"+ + "\27\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\6\4\1\u012e\21\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\3\4\1\u012f"+ + "\24\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\12\4\1\u0130\15\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\1\u0131\27\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\12\4\1\u0132\15\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\23\4\1\u0133\4\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\17\4\1\u0134\10\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\3\4\1\u0135\24\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\7\4\1\u0136\20\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\15\4\1\u0137\12\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\12\4\1\u0138\15\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\4\4\1\u0139\23\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\13\4\1\u013a\14\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\10\4\1\u013b\17\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\2\4\1\u013c\25\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\5\4\1\u013d\22\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\12\4\1\u013e\15\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\3\4\1\u013f\24\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\1\u0140\27\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\1\u0141\27\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\3\4"+ + "\1\u0142\24\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\3\4\1\u0143\24\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\6\4"+ + "\1\u0144\21\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\10\4\1\u0145\17\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\1\u0146"+ + "\27\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\24\4\1\u0147\3\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\10\4\1\u0148"+ + "\17\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\3\4\1\u0149\24\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\12\4\1\u014a"+ + "\15\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\3\4\1\u014b\24\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\10\4\1\u014c"+ + "\17\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\3\4\1\u014d\24\4\27\0\2\4\3\0"+ + "\13\4\1\0\1\4\1\0\1\4\4\0\3\4\1\u014e"+ + "\24\4\27\0\2\4\3\0\13\4\1\0\1\4\1\0"+ + "\1\4\4\0\1\u014f\27\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\17\4\1\u0150\10\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\3\4\1\u0151\24\4\27\0\2\4\3\0\13\4"+ + "\1\0\1\4\1\0\1\4\4\0\13\4\1\u0152\14\4"+ + "\27\0\2\4\3\0\13\4\1\0\1\4\1\0\1\4"+ + "\4\0\1\u0153\27\4\27\0\2\4\3\0\13\4\1\0"+ + "\1\4\1\0\1\4\4\0\20\4\1\u0154\7\4\27\0"+ + "\2\4\3\0\13\4\1\0\1\4\1\0\1\4\4\0"+ + "\27\4\1\u0155\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\4\4\1\u0156\23\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\7\4"+ + "\1\u0157\20\4\27\0\2\4\3\0\13\4\1\0\1\4"+ + "\1\0\1\4\4\0\3\4\1\u0158\24\4\27\0\2\4"+ + "\3\0\13\4\1\0\1\4\1\0\1\4\4\0\20\4"+ + "\1\u0159\7\4\25\0"; private static int [] zzUnpackTrans() { - int [] result = new int[17821]; + int [] result = new int[18034]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -668,14 +691,15 @@ class _JavaLexer implements FlexLexer { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\1\0\1\11\37\1\1\11\3\1\14\11\2\1\2\11"+ - "\1\0\3\11\2\1\2\0\4\1\1\0\3\11\2\1"+ - "\1\11\47\1\7\11\1\1\4\11\4\1\2\0\2\1"+ - "\1\0\1\1\1\0\1\11\56\1\1\11\1\0\1\1"+ - "\1\11\4\0\1\1\2\0\55\1\1\11\4\0\142\1"; + "\1\0\1\11\37\1\1\11\3\1\12\11\1\1\1\11"+ + "\2\1\2\11\1\0\3\11\2\1\2\0\4\1\1\0"+ + "\4\11\2\1\1\11\50\1\7\11\1\1\5\11\4\1"+ + "\2\0\2\1\1\0\1\1\1\0\1\11\57\1\1\11"+ + "\1\0\1\1\1\11\4\0\1\1\2\0\56\1\1\11"+ + "\4\0\142\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[340]; + int [] result = new int[345]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -734,13 +758,15 @@ class _JavaLexer implements FlexLexer { private boolean zzEOFDone; /* user code: */ - private boolean myAssertKeywordEnabled; - private boolean myJdk15Enabled; + private boolean myAssertKeyword; + private boolean myEnumKeyword; + private boolean myNoneKeyword; - public _JavaLexer(boolean isAssertKeywordEnabled, boolean jdk15Enabled){ + public _JavaLexer(LanguageLevel level) { this((java.io.Reader)null); - myAssertKeywordEnabled = isAssertKeywordEnabled; - myJdk15Enabled = jdk15Enabled; + myAssertKeyword = level.isAtLeast(LanguageLevel.JDK_1_4); + myEnumKeyword = level.isAtLeast(LanguageLevel.JDK_1_5); + myNoneKeyword = level.isAtLeast(LanguageLevel.JDK_1_8); } public void goTo(int offset) { @@ -996,438 +1022,450 @@ class _JavaLexer implements FlexLexer { zzMarkedPos = zzMarkedPosL; switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 66: + case 68: { return JavaTokenType.LONG_KEYWORD; } - case 109: break; - case 97: + case 112: break; + case 100: { return JavaTokenType.PRIVATE_KEYWORD; } - case 110: break; + case 113: break; case 27: { return JavaTokenType.COMMA; } - case 111: break; + case 114: break; case 23: { return JavaTokenType.RBRACE; } - case 112: break; + case 115: break; case 22: { return JavaTokenType.LBRACE; } - case 113: break; + case 116: break; case 65: - { return myJdk15Enabled ? JavaTokenType.ENUM_KEYWORD : JavaTokenType.IDENTIFIER; - } - case 114: break; - case 63: { return JavaTokenType.THIS_KEYWORD; } - case 115: break; - case 81: + case 117: break; + case 84: { return JavaTokenType.CLASS_KEYWORD; } - case 116: break; + case 118: break; case 14: { return JavaTokenType.PLUS; } - case 117: break; - case 53: + case 119: break; + case 54: { return JavaTokenType.XOREQ; } - case 118: break; - case 60: + case 120: break; + case 62: { return JavaTokenType.INT_KEYWORD; } - case 119: break; - case 78: + case 121: break; + case 81: { return JavaTokenType.SHORT_KEYWORD; } - case 120: break; - case 43: + case 122: break; + case 44: { return JavaTokenType.EQEQ; } - case 121: break; - case 99: - { return JavaTokenType.ABSTRACT_KEYWORD; - } - case 122: break; - case 67: - { return JavaTokenType.NULL_KEYWORD; - } case 123: break; - case 93: - { return JavaTokenType.EXTENDS_KEYWORD; + case 67: + { return myEnumKeyword ? JavaTokenType.ENUM_KEYWORD : JavaTokenType.IDENTIFIER; } case 124: break; - case 50: - { return JavaTokenType.LTLT; + case 102: + { return JavaTokenType.ABSTRACT_KEYWORD; } case 125: break; + case 69: + { return JavaTokenType.NULL_KEYWORD; + } + case 126: break; + case 96: + { return JavaTokenType.EXTENDS_KEYWORD; + } + case 127: break; + case 51: + { return JavaTokenType.LTLT; + } + case 128: break; case 20: { return JavaTokenType.LPARENTH; } - case 126: break; + case 129: break; case 12: { return JavaTokenType.EXCL; } - case 127: break; - case 100: + case 130: break; + case 103: { return JavaTokenType.STRICTFP_KEYWORD; } - case 128: break; + case 131: break; case 34: { return JavaTokenType.DIVEQ; } - case 129: break; - case 87: + case 132: break; + case 90: { return JavaTokenType.STATIC_KEYWORD; } - case 130: break; + case 133: break; case 39: { return JavaTokenType.MINUSMINUS; } - case 131: break; - case 74: + case 134: break; + case 77: { return JavaTokenType.FALSE_KEYWORD; } - case 132: break; + case 135: break; case 1: { return JavaTokenType.BAD_CHARACTER; } - case 133: break; - case 88: + case 136: break; + case 91: { return JavaTokenType.SWITCH_KEYWORD; } - case 134: break; + case 137: break; case 26: { return JavaTokenType.SEMICOLON; } - case 135: break; + case 138: break; case 18: { return JavaTokenType.XOR; } - case 136: break; + case 139: break; case 38: { return JavaTokenType.DOUBLE_LITERAL; } - case 137: break; - case 45: + case 140: break; + case 46: { return JavaTokenType.OREQ; } - case 138: break; + case 141: break; case 11: { return JavaTokenType.EQ; } - case 139: break; + case 142: break; case 4: { return JavaTokenType.DIV; } - case 140: break; - case 64: + case 143: break; + case 66: { return JavaTokenType.ELSE_KEYWORD; } - case 141: break; - case 59: + case 144: break; + case 61: { return JavaTokenType.NEW_KEYWORD; } - case 142: break; - case 56: + case 145: break; + case 58: { return JavaTokenType.ELLIPSIS; } - case 143: break; - case 52: + case 146: break; + case 53: { return JavaTokenType.ANDAND; } - case 144: break; - case 79: + case 147: break; + case 82: { return JavaTokenType.BREAK_KEYWORD; } - case 145: break; + case 148: break; case 9: { return JavaTokenType.CHARACTER_LITERAL; } - case 146: break; - case 51: + case 149: break; + case 52: { return JavaTokenType.ANDEQ; } - case 147: break; + case 150: break; case 6: { return JavaTokenType.INTEGER_LITERAL; } - case 148: break; - case 75: + case 151: break; + case 78: { return JavaTokenType.FLOAT_KEYWORD; } - case 149: break; + case 152: break; case 10: { return JavaTokenType.STRING_LITERAL; } - case 150: break; - case 70: + case 153: break; + case 73: { return JavaTokenType.CHAR_KEYWORD; } - case 151: break; - case 89: + case 154: break; + case 92: { return JavaTokenType.NATIVE_KEYWORD; } - case 152: break; - case 42: + case 155: break; + case 43: { return JavaTokenType.DO_KEYWORD; } - case 153: break; + case 156: break; case 7: { return JavaTokenType.DOT; } - case 154: break; + case 157: break; case 28: { return JavaTokenType.TILDE; } - case 155: break; - case 108: + case 158: break; + case 111: { return JavaTokenType.SYNCHRONIZED_KEYWORD; } - case 156: break; + case 159: break; case 32: { return JavaTokenType.END_OF_LINE_COMMENT; } - case 157: break; + case 160: break; case 35: { return JavaTokenType.ASTERISKEQ; } - case 158: break; - case 77: + case 161: break; + case 80: { return JavaTokenType.SUPER_KEYWORD; } - case 159: break; + case 162: break; case 40: { return JavaTokenType.MINUSEQ; } - case 160: break; - case 61: + case 163: break; + case 63: { return JavaTokenType.LTLTEQ; } - case 161: break; - case 71: + case 164: break; + case 74: { return JavaTokenType.GOTO_KEYWORD; } - case 162: break; + case 165: break; case 25: { return JavaTokenType.RBRACKET; } - case 163: break; - case 86: - { return myAssertKeywordEnabled ? JavaTokenType.ASSERT_KEYWORD : JavaTokenType.IDENTIFIER; - } - case 164: break; + case 166: break; case 33: { return JavaTokenType.C_STYLE_COMMENT; } - case 165: break; + case 167: break; case 15: { return JavaTokenType.LT; } - case 166: break; - case 41: + case 168: break; + case 42: { return JavaTokenType.IF_KEYWORD; } - case 167: break; + case 169: break; case 8: { return JavaTokenType.MINUS; } - case 168: break; - case 83: + case 170: break; + case 86: { return JavaTokenType.WHILE_KEYWORD; } - case 169: break; - case 68: + case 171: break; + case 71: { return JavaTokenType.BYTE_KEYWORD; } - case 170: break; - case 94: + case 172: break; + case 97: { return JavaTokenType.FINALLY_KEYWORD; } - case 171: break; - case 72: + case 173: break; + case 75: { return JavaTokenType.VOID_KEYWORD; } - case 172: break; + case 174: break; case 29: { return JavaTokenType.QUEST; } - case 173: break; + case 175: break; case 19: { return JavaTokenType.PERC; } - case 174: break; - case 107: + case 176: break; + case 110: { return JavaTokenType.IMPLEMENTS_KEYWORD; } - case 175: break; - case 84: + case 177: break; + case 87: { return JavaTokenType.THROWS_KEYWORD; } - case 176: break; - case 76: - { return JavaTokenType.FINAL_KEYWORD; - } - case 177: break; - case 91: - { return JavaTokenType.DOUBLE_KEYWORD; - } case 178: break; - case 105: - { return JavaTokenType.PROTECTED_KEYWORD; + case 41: + { return JavaTokenType.ARROW; } case 179: break; - case 101: - { return JavaTokenType.CONTINUE_KEYWORD; + case 79: + { return JavaTokenType.FINAL_KEYWORD; } case 180: break; - case 98: - { return JavaTokenType.PACKAGE_KEYWORD; + case 94: + { return JavaTokenType.DOUBLE_KEYWORD; } case 181: break; + case 89: + { return myAssertKeyword ? JavaTokenType.ASSERT_KEYWORD : JavaTokenType.IDENTIFIER; + } + case 182: break; + case 108: + { return JavaTokenType.PROTECTED_KEYWORD; + } + case 183: break; + case 104: + { return JavaTokenType.CONTINUE_KEYWORD; + } + case 184: break; + case 101: + { return JavaTokenType.PACKAGE_KEYWORD; + } + case 185: break; + case 70: + { return myNoneKeyword ? JavaTokenType.NONE_KEYWORD : JavaTokenType.IDENTIFIER; + } + case 186: break; case 16: { return JavaTokenType.GT; } - case 182: break; + case 187: break; case 24: { return JavaTokenType.LBRACKET; } - case 183: break; + case 188: break; case 36: { return JavaTokenType.LONG_LITERAL; } - case 184: break; - case 58: + case 189: break; + case 60: { return JavaTokenType.FOR_KEYWORD; } - case 185: break; - case 96: + case 190: break; + case 99: { return JavaTokenType.DEFAULT_KEYWORD; } - case 186: break; - case 47: + case 191: break; + case 48: { return JavaTokenType.PLUSEQ; } - case 187: break; - case 85: + case 192: break; + case 88: { return JavaTokenType.RETURN_KEYWORD; } - case 188: break; - case 62: + case 193: break; + case 64: { return JavaTokenType.TRUE_KEYWORD; } - case 189: break; - case 48: + case 194: break; + case 49: { return JavaTokenType.PLUSPLUS; } - case 190: break; - case 46: + case 195: break; + case 47: { return JavaTokenType.OROR; } - case 191: break; + case 196: break; case 13: { return JavaTokenType.OR; } - case 192: break; + case 197: break; case 3: { return JavaTokenType.IDENTIFIER; } - case 193: break; - case 54: + case 198: break; + case 55: { return JavaTokenType.PERCEQ; } - case 194: break; + case 199: break; case 30: { return JavaTokenType.COLON; } - case 195: break; - case 102: + case 200: break; + case 105: { return JavaTokenType.VOLATILE_KEYWORD; } - case 196: break; - case 104: + case 201: break; + case 107: { return JavaTokenType.INTERFACE_KEYWORD; } - case 197: break; - case 106: + case 202: break; + case 109: { return JavaTokenType.INSTANCEOF_KEYWORD; } - case 198: break; - case 103: + case 203: break; + case 106: { return JavaTokenType.TRANSIENT_KEYWORD; } - case 199: break; - case 95: + case 204: break; + case 98: { return JavaTokenType.BOOLEAN_KEYWORD; } - case 200: break; - case 69: + case 205: break; + case 72: { return JavaTokenType.CASE_KEYWORD; } - case 201: break; + case 206: break; case 5: { return JavaTokenType.ASTERISK; } - case 202: break; - case 90: + case 207: break; + case 93: { return JavaTokenType.IMPORT_KEYWORD; } - case 203: break; + case 208: break; case 31: { return JavaTokenType.AT; } - case 204: break; - case 44: + case 209: break; + case 45: { return JavaTokenType.NE; } - case 205: break; - case 57: + case 210: break; + case 59: { return JavaTokenType.TRY_KEYWORD; } - case 206: break; - case 80: + case 211: break; + case 83: { return JavaTokenType.CATCH_KEYWORD; } - case 207: break; + case 212: break; case 37: { return JavaTokenType.FLOAT_LITERAL; } - case 208: break; + case 213: break; case 17: { return JavaTokenType.AND; } - case 209: break; - case 73: + case 214: break; + case 76: { return JavaTokenType.THROW_KEYWORD; } - case 210: break; - case 55: + case 215: break; + case 57: { return JavaDocElementType.DOC_COMMENT; } - case 211: break; + case 216: break; + case 56: + { return JavaTokenType.DOUBLE_COLON; + } + case 217: break; case 21: { return JavaTokenType.RPARENTH; } - case 212: break; + case 218: break; case 2: { return JavaTokenType.WHITE_SPACE; } - case 213: break; - case 92: + case 219: break; + case 95: { return JavaTokenType.PUBLIC_KEYWORD; } - case 214: break; - case 49: + case 220: break; + case 50: { return JavaTokenType.LE; } - case 215: break; - case 82: + case 221: break; + case 85: { return JavaTokenType.CONST_KEYWORD; } - case 216: break; + case 222: break; default: if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { zzAtEOF = true; diff --git a/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java b/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java index b4e835b2a079..0f5080857a4f 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java @@ -134,6 +134,11 @@ public class JavaLexerTest extends LexerTestCase { "WHITE_SPACE (' ')\nINTEGER_LITERAL ('0')\nRPARENTH (')')\n"); } + public void testJava8Tokens() { + doTest("none :: ->", + "NONE_KEYWORD ('none')\nWHITE_SPACE (' ')\nDOUBLE_COLON ('::')\nWHITE_SPACE (' ')\nARROW ('->')"); + } + @Override protected Lexer createLexer() { return new JavaLexer(LanguageLevel.HIGHEST); From 73f8db9d5f5ae5541a637d076b12c3fb6725ce97 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 11 May 2012 22:03:34 +0400 Subject: [PATCH 12/45] Fix deprecated API usages --- .../codeInspection/dataFlow/DataFlowInspection.java | 5 +++-- .../src/com/intellij/lexer/JavaHighlightingLexer.java | 6 ++---- .../intellij/psi/impl/source/javadoc/ValueDocTagInfo.java | 4 ++-- .../reference/impl/providers/JavaClassReferenceSet.java | 4 ++-- .../refactoring/introduceField/IntroduceConstantDialog.java | 5 +++-- .../src/com/intellij/pom/java/LanguageLevel.java | 3 +++ .../java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java | 6 +++--- .../src/com/intellij/psi/util/TypeConversionUtil.java | 4 ++-- .../inject/java/JavaLanguageInjectionSupport.java | 4 ++-- .../com/intellij/codeInspection/i18n/I18nInspection.java | 4 ++-- .../testng/inspection/JUnitConvertTool.java | 5 +++-- 11 files changed, 27 insertions(+), 23 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java index f2f650ba843d..94e67278a58f 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -39,6 +39,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.Pair; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.util.PsiUtil; import com.intellij.util.ArrayUtil; @@ -118,7 +119,7 @@ public class DataFlowInspection extends BaseLocalInspectionTool { binary.getLOperand().replace(qualifier); List fixes = new SmartList(); - if (PsiUtil.getLanguageLevel(qualifier).hasAssertKeyword()) { + if (PsiUtil.getLanguageLevel(qualifier).isAtLeast(LanguageLevel.JDK_1_4)) { fixes.add(new AddAssertStatementFix(binary)); } SurroundWithIfFix ifFix = new SurroundWithIfFix(qualifier); diff --git a/java/java-impl/src/com/intellij/lexer/JavaHighlightingLexer.java b/java/java-impl/src/com/intellij/lexer/JavaHighlightingLexer.java index e47b804fbd0d..316420c953fd 100644 --- a/java/java-impl/src/com/intellij/lexer/JavaHighlightingLexer.java +++ b/java/java-impl/src/com/intellij/lexer/JavaHighlightingLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -34,9 +34,7 @@ public class JavaHighlightingLexer extends LayeredLexer { registerSelfStoppingLayer(new StringLiteralLexer('\'', JavaTokenType.STRING_LITERAL), new IElementType[]{JavaTokenType.CHARACTER_LITERAL}, IElementType.EMPTY_ARRAY); - - - LayeredLexer docLexer = new LayeredLexer(new JavaDocLexer(languageLevel.hasEnumKeywordAndAutoboxing())); + LayeredLexer docLexer = new LayeredLexer(new JavaDocLexer(languageLevel.isAtLeast(LanguageLevel.JDK_1_5))); HtmlHighlightingLexer lexer = new HtmlHighlightingLexer(); lexer.setHasNoEmbeddments(true); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java index 4b48b1802543..76b350b1a2db 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -53,7 +53,7 @@ public class ValueDocTagInfo implements JavadocTagInfo { public String checkTagValue(PsiDocTagValue value) { boolean hasReference = (value != null && value.getFirstChild() != null); if (hasReference) { - if (!PsiUtil.getLanguageLevel(value).hasEnumKeywordAndAutoboxing()) { + if (!PsiUtil.isLanguageLevel5OrHigher(value)) { return JavaErrorMessages.message("javadoc.value.tag.jdk15.required"); } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java index 9dec07075f40..0b212aa49494 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -82,7 +82,7 @@ public class JavaClassReferenceSet { if (ch == LT || ch == COMMA) { if (!allowGenericsCalculated) { - allowGenerics = !isStaticImport && PsiUtil.getLanguageLevel(element).hasEnumKeywordAndAutoboxing(); + allowGenerics = !isStaticImport && PsiUtil.isLanguageLevel5OrHigher(element); allowGenericsCalculated = true; } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java index c7415007fe83..5a847e91cb92 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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,6 +30,7 @@ import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Comparing; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.codeStyle.SuggestedNameInfo; @@ -265,7 +266,7 @@ class IntroduceConstantDialog extends DialogWrapper { final PsiManager psiManager = PsiManager.getInstance(myProject); if ((myTypeSelectorManager.isSuggestedType("java.lang.String") || (myLocalVariable != null && AnnotationUtil.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, false)))&& - LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel().hasEnumKeywordAndAutoboxing() && + LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5) && JavaPsiFacade.getInstance(psiManager.getProject()).findClass(AnnotationUtil.NON_NLS, myParentClass.getResolveScope()) != null) { final PropertiesComponent component = PropertiesComponent.getInstance(myProject); myCbNonNls.setSelected(component.isTrueValue(NONNLS_SELECTED_PROPERTY)); 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 95691ee0a1ae..9774133bad24 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 @@ -40,16 +40,19 @@ public enum LanguageLevel { } /** @deprecated (to remove in IDEA 13) */ + @SuppressWarnings("UnusedDeclaration") public int getIndex() { return ordinal() + 3; // solely for backward compatibility } /** @deprecated (to remove in IDEA 13) */ + @SuppressWarnings("UnusedDeclaration") public boolean hasAssertKeyword() { return isAtLeast(JDK_1_4); } /** @deprecated use {@linkplain com.intellij.psi.util.PsiUtil#isLanguageLevel5OrHigher(com.intellij.psi.PsiElement)} (to remove in IDEA 13) */ + @SuppressWarnings("UnusedDeclaration") public boolean hasEnumKeywordAndAutoboxing() { return isAtLeast(JDK_1_5); } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java b/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java index 84499cf87411..5e2d80fd6e0d 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -104,7 +104,7 @@ public class PsiPrimitiveType extends PsiType { @Nullable public static PsiPrimitiveType getUnboxedType(PsiType type) { if (!(type instanceof PsiClassType)) return null; - if (!((PsiClassType)type).getLanguageLevel().hasEnumKeywordAndAutoboxing()) return null; + if (!((PsiClassType)type).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) return null; final PsiClass psiClass = ((PsiClassType)type).resolve(); if (psiClass == null) return null; return ourQNameToUnboxed.get(psiClass.getQualifiedName()); @@ -124,7 +124,7 @@ public class PsiPrimitiveType extends PsiType { @Nullable public PsiClassType getBoxedType(PsiElement context) { LanguageLevel languageLevel = PsiUtil.getLanguageLevel(context); - if (!languageLevel.hasEnumKeywordAndAutoboxing()) return null; + if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return null; final String boxedQName = getBoxedTypeName(); //[ven]previous call returns null for NULL, VOID diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java index f1a4bf511e3a..f3755f9edf20 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -780,7 +780,7 @@ public class TypeConversionUtil { private static final Key>> POSSIBLE_BOXED_HOLDER_TYPES = Key.create("Types that may be possibly assigned from primitive ones"); private static boolean isBoxable(final PsiClassType left, final PsiPrimitiveType right) { - if (!left.getLanguageLevel().hasEnumKeywordAndAutoboxing()) return false; + if (!left.getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) return false; final PsiClass psiClass = left.resolve(); if (psiClass == null) return false; diff --git a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java index 22a84364d416..bb5556d2bba2 100644 --- a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java +++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -202,7 +202,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo static boolean doAddLanguageAnnotation(final Project project, final PsiModifierListOwner modifierListOwner, final String languageId) { - if (modifierListOwner.getModifierList() == null || !PsiUtil.getLanguageLevel(modifierListOwner).hasEnumKeywordAndAutoboxing()) return false; + if (modifierListOwner.getModifierList() == null || !PsiUtil.isLanguageLevel5OrHigher(modifierListOwner)) return false; if (!OrderEntryFix.ensureAnnotationsJarInPath(ModuleUtil.findModuleForPsiElement(modifierListOwner), AnnotationUtil.LANGUAGE)) return false; new WriteCommandAction(project, modifierListOwner.getContainingFile()) { protected void run(final Result result) throws Throwable { diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java index 49a7a1610579..84ab55e7a705 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -449,7 +449,7 @@ public class I18nInspection extends BaseLocalInspectionTool { final Project project = expression.getManager().getProject(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(project); - if (PsiUtil.getLanguageLevel(expression).hasEnumKeywordAndAutoboxing()) { + if (PsiUtil.isLanguageLevel5OrHigher(expression)) { for (PsiModifierListOwner element : nonNlsTargets) { if (!AnnotationUtil.isAnnotated(element, AnnotationUtil.NLS, true)) { if (!element.getManager().isInProject(element) || facade.findClass(AnnotationUtil.NON_NLS, element.getResolveScope()) != null) { diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java index 8717dd343e04..db9271544b12 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/JUnitConvertTool.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -19,6 +19,7 @@ import com.intellij.codeInsight.CodeInsightUtilBase; import com.intellij.codeInspection.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.util.PsiElementFilter; @@ -95,7 +96,7 @@ public class JUnitConvertTool extends BaseJavaLocalInspectionTool { convertJUnitConstructor(method); } else { - if (!javaFile.getLanguageLevel().hasEnumKeywordAndAutoboxing()) { + if (!javaFile.getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) { addMethodJavadoc(factory, method); } else { From 7c6cf7dcf84e51ba6e4771e9f00e451c5103a255 Mon Sep 17 00:00:00 2001 From: Alexander Kirillin Date: Fri, 11 May 2012 20:59:22 +0400 Subject: [PATCH 13/45] OC-3951 Command+B from protocol/protocol's method should show possible implementations to jump to (currently it shows error) --- .../actions/GotoDeclarationAction.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java index 0c9369abd945..41d6355ddcda 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java @@ -147,11 +147,19 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code return true; } if (elements.length > 1) { - final TextRange range = reference.getRangeInElement(); - final String elementText = reference.getElement().getText(); - LOG.assertTrue(range.getStartOffset() >= 0 && range.getEndOffset() <= elementText.length(), Arrays.toString(elements)); - final String refText = range.substring(elementText); - String title = MessageFormat.format(titlePattern, refText); + String title; + + if (reference != null) { + final TextRange range = reference.getRangeInElement(); + final String elementText = reference.getElement().getText(); + LOG.assertTrue(range.getStartOffset() >= 0 && range.getEndOffset() <= elementText.length(), Arrays.toString(elements)); + final String refText = range.substring(elementText); + title = MessageFormat.format(titlePattern, refText); + } + else { + title = titlePattern; + } + NavigationUtil.getPsiElementPopup(elements, new DefaultPsiElementCellRenderer(), title, processor).showInBestPositionFor(editor); return true; } From c3553b567864dfedcb00a8ad15da04e391dce492 Mon Sep 17 00:00:00 2001 From: Shaverdova Elena Date: Thu, 3 May 2012 22:01:13 +0400 Subject: [PATCH 14/45] WI-10804 ftp mass select needs a 'do nothing' option --- .../src/idea/PlatformActions.xml | 2 + .../dir/actions/popup/SetNoOperation.java | 56 +++++++++++++++++++ .../dir/actions/popup/SetOperationToBase.java | 2 +- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetNoOperation.java diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 371afc7d3b2a..26e2812f9500 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -540,6 +540,8 @@ + + diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetNoOperation.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetNoOperation.java new file mode 100644 index 000000000000..f893ac644389 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetNoOperation.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2012 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.diff.impl.dir.actions.popup; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.diff.impl.dir.DirDiffElement; +import com.intellij.openapi.diff.impl.dir.DirDiffOperation; +import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; + +import javax.swing.*; + +/** + * @author lene + * Date: 23.04.12 + */ +public class SetNoOperation extends AnAction { + @Override + public void actionPerformed(AnActionEvent e) { + final DirDiffTableModel model = SetOperationToBase.getModel(e); + final JTable table = SetOperationToBase.getTable(e); + assert model != null && table != null; + for (DirDiffElement element : model.getSelectedElements()) { + element.setOperation(DirDiffOperation.NONE); + } + table.repaint(); + } + + @Override + public final void update(AnActionEvent e) { + final DirDiffTableModel model = SetOperationToBase.getModel(e); + final JTable table = SetOperationToBase.getTable(e); + if (table != null && model != null) { + for (DirDiffElement element : model.getSelectedElements()) { + if (element.getOperation() != DirDiffOperation.NONE) { + e.getPresentation().setEnabled(true); + return; + } + } + } + e.getPresentation().setEnabled(false); + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetOperationToBase.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetOperationToBase.java index 27aca25a9961..a2b361464fd9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetOperationToBase.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetOperationToBase.java @@ -68,7 +68,7 @@ public abstract class SetOperationToBase extends AnAction { protected abstract boolean isEnabledFor(DirDiffElement element); @Nullable - private static JTable getTable(AnActionEvent e) { + static JTable getTable(AnActionEvent e) { return e.getData(DirDiffPanel.DIR_DIFF_TABLE); } From 874afc0153038d4e30fa6cf9917f35e5521f76fc Mon Sep 17 00:00:00 2001 From: Shaverdova Elena Date: Fri, 4 May 2012 19:08:31 +0400 Subject: [PATCH 15/45] WI-10885 Recursive Compare: add action "Set overwrite older" --- .../intellij/ide/diff/DirDiffSettings.java | 6 ++++ .../openapi/diff/impl/dir/DirDiffElement.java | 36 ++++++++++++++----- .../diff/impl/dir/DirDiffTableModel.java | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ide/diff/DirDiffSettings.java b/platform/platform-api/src/com/intellij/ide/diff/DirDiffSettings.java index 4876fd3c2aa2..034d30e7195d 100644 --- a/platform/platform-api/src/com/intellij/ide/diff/DirDiffSettings.java +++ b/platform/platform-api/src/com/intellij/ide/diff/DirDiffSettings.java @@ -41,6 +41,7 @@ public class DirDiffSettings { public boolean enableChoosers = true; public CompareMode compareMode = CompareMode.CONTENT; public double compareTimestampAccuracy = 0; + public CustomSourceChooser customSourceChooser; public boolean showInFrame = true; // in dialog otherwise @@ -103,4 +104,9 @@ public class DirDiffSettings { @Nullable String getName(CompareMode mode); } + + public interface CustomSourceChooser { + @Nullable + DiffElement chooseSource(@NotNull DiffElement first, @NotNull DiffElement second); + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffElement.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffElement.java index 9f20c24c356a..16341103141a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffElement.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffElement.java @@ -16,6 +16,7 @@ package com.intellij.openapi.diff.impl.dir; import com.intellij.ide.diff.DiffElement; +import com.intellij.ide.diff.DirDiffSettings; import com.intellij.util.text.DateFormatUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,7 +40,8 @@ public class DirDiffElement { private DirDiffOperation myDefaultOperation; private DTree myNode; - private DirDiffElement(DTree parent, @Nullable DiffElement source, @Nullable DiffElement target, DType type, String name) { + private DirDiffElement(DTree parent, @Nullable DiffElement source, @Nullable DiffElement target, DType type, String name, + @Nullable DirDiffOperation defaultOperation) { myParent = parent.getParent(); myNode = parent; myType = type; @@ -48,7 +50,10 @@ public class DirDiffElement { myTarget = target; myTargetLength = target == null || target.isContainer() ? -1 : target.getSize(); myName = name; - if (type == DType.ERROR) { + if(defaultOperation != null){ + myDefaultOperation = defaultOperation; + } + else if (type == DType.ERROR) { myDefaultOperation = NONE; } else if (isSource()) { @@ -87,28 +92,41 @@ public class DirDiffElement { return timeStamp < 0 ? "" : DateFormatUtil.formatDateTime(timeStamp); } - public static DirDiffElement createChange(DTree parent, @NotNull DiffElement source, @NotNull DiffElement target) { - return new DirDiffElement(parent, source, target, DType.CHANGED, source.getName()); + public static DirDiffElement createChange(DTree parent, + @NotNull DiffElement source, + @NotNull DiffElement target, + @Nullable DirDiffSettings.CustomSourceChooser customSourceChooser) { + DirDiffOperation defaultOperation = null; + if (customSourceChooser != null) { + DiffElement chosenSource = customSourceChooser.chooseSource(source, target); + if (chosenSource == source) { // chosenSource might be null + defaultOperation = COPY_TO; + } + else if (chosenSource == target) { + defaultOperation = COPY_FROM; + } + } + return new DirDiffElement(parent, source, target, DType.CHANGED, source.getName(), defaultOperation); } public static DirDiffElement createError(DTree parent, @Nullable DiffElement source, @Nullable DiffElement target) { - return new DirDiffElement(parent, source, target, DType.ERROR, source == null ? target.getName() : source.getName()); + return new DirDiffElement(parent, source, target, DType.ERROR, source == null ? target.getName() : source.getName(), null); } public static DirDiffElement createSourceOnly(DTree parent, @NotNull DiffElement source) { - return new DirDiffElement(parent, source, null, DType.SOURCE, null); + return new DirDiffElement(parent, source, null, DType.SOURCE, null, null); } public static DirDiffElement createTargetOnly(DTree parent, @NotNull DiffElement target) { - return new DirDiffElement(parent, null, target, DType.TARGET, null); + return new DirDiffElement(parent, null, target, DType.TARGET, null, null); } public static DirDiffElement createDirElement(DTree parent, DiffElement src, DiffElement trg, String name) { - return new DirDiffElement(parent, src, trg, DType.SEPARATOR, name); + return new DirDiffElement(parent, src, trg, DType.SEPARATOR, name, null); } public static DirDiffElement createEqual(DTree parent, @NotNull DiffElement source, @NotNull DiffElement target) { - return new DirDiffElement(parent, source, target, DType.EQUAL, source.getName()); + return new DirDiffElement(parent, source, target, DType.EQUAL, source.getName(), null); } public DType getType() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java index 1964b1c72218..47c36d1233ea 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java @@ -323,7 +323,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode elements.add(DirDiffElement.createTargetOnly(child, child.getTarget())); break; case CHANGED: - elements.add(DirDiffElement.createChange(child, child.getSource(), child.getTarget())); + elements.add(DirDiffElement.createChange(child, child.getSource(), child.getTarget(), mySettings.customSourceChooser)); break; case EQUAL: elements.add(DirDiffElement.createEqual(child, child.getSource(), child.getTarget())); From 652bcb9b66dd4c81f1c73ab0ad79a6dc6131e566 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 11 May 2012 23:16:09 +0400 Subject: [PATCH 16/45] fix one-tool suppressions --- .../src/com/intellij/codeInspection/SuppressionUtil.java | 2 +- .../com/intellij/codeInspection/reference/RefElementImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java index a43bc1259908..e2e1bf030593 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java @@ -58,7 +58,7 @@ public class SuppressionUtil { for (@NonNls String id : ids) { @NonNls String trim = id.trim(); - if (trim.equalsIgnoreCase(ALL)) return true; + if (trim.equals(inspectionToolID) || trim.equalsIgnoreCase(ALL)) return true; } return false; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java index ddfe49cb0d98..3899fd5a402c 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java @@ -255,7 +255,7 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement public boolean isSuppressed(final String toolId) { if (mySuppressions != null) { for (@NonNls String suppression : mySuppressions) { - if (suppression.equalsIgnoreCase(SuppressionUtil.ALL)){ + if (suppression.equals(toolId) || suppression.equalsIgnoreCase(SuppressionUtil.ALL)){ return true; } } From f98638a52054fb51bbc826fbe7608799395ccca2 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 11 May 2012 23:30:32 +0400 Subject: [PATCH 17/45] Cleanup --- java/java-tests/testSrc/Anonymous.java | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 java/java-tests/testSrc/Anonymous.java diff --git a/java/java-tests/testSrc/Anonymous.java b/java/java-tests/testSrc/Anonymous.java deleted file mode 100644 index e72d2fb65789..000000000000 --- a/java/java-tests/testSrc/Anonymous.java +++ /dev/null @@ -1,10 +0,0 @@ -class Anonymous { - int num1; - int num2; - Object o = new Object(){ - int num = 1; - }; - - Anonymous() {} - void foo() {} -} \ No newline at end of file From fedd867f1972ff76b38b5bbe4d5c84dcbc5cb5e6 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 11 May 2012 23:42:55 +0400 Subject: [PATCH 18/45] Two heavyweight tests replaced --- .../advHighlighting/UnsupportedFeatures.java | 5 +++ .../advHighlighting7/AllJava15Features.java | 37 +++++++++++++++++++ .../daemon/LightAdvHighlightingJdk7Test.java | 6 ++- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/AllJava15Features.java diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnsupportedFeatures.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnsupportedFeatures.java index 1c108b5f9e0e..9701b4b373b2 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnsupportedFeatures.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnsupportedFeatures.java @@ -28,6 +28,11 @@ class UnsupportedFeatures { List list = new ArrayList<>(); + for (String s : list) {} + Arrays.asList(""); + Boolean b = true; + boolean b1 = Boolean.TRUE; + try { Reader r = new FileReader("/dev/null"); } catch (FileNotFoundException | IOException e) { e.printStackTrace(); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/AllJava15Features.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/AllJava15Features.java new file mode 100644 index 000000000000..e4bd0a89b587 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/AllJava15Features.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2012 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.List; +import static java.lang.Math.min; + +class a { + List l; + + private void asList(Object... objects) {} + + void foo() { + for (String s : l) {} + + for (Object o : l) {} + + asList(""); + + Boolean b = true; + + boolean b1 = Boolean.TRUE; + } + + enum e {} +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java index 5ce544d5c852..8165329c5130 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -57,6 +57,10 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { }; } + public void testAllJava15Features() throws Exception { + doTest(false, false); + } + public void testEnumSyntheticMethods() throws Exception { doTest(false, false); } From 8ffa203245102608161efc0a0429073f59af0dd1 Mon Sep 17 00:00:00 2001 From: Dmitry Boulytchev Date: Fri, 11 May 2012 23:58:00 +0400 Subject: [PATCH 19/45] Improved log (compile server). --- .../incremental/annotations/classAsArgument/src/Annotated.java | 2 +- jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/java/java-tests/testData/compileServer/incremental/annotations/classAsArgument/src/Annotated.java b/java/java-tests/testData/compileServer/incremental/annotations/classAsArgument/src/Annotated.java index 5c49f5d0ba47..09fafb546747 100644 --- a/java/java-tests/testData/compileServer/incremental/annotations/classAsArgument/src/Annotated.java +++ b/java/java-tests/testData/compileServer/incremental/annotations/classAsArgument/src/Annotated.java @@ -5,6 +5,6 @@ * Time: 17:43 * To change this template use File | Settings | File Templates. */ -@Ann({A.class}) +@Ann(A.class) public class Annotated { } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java index 06cdd47625a5..a08c05de8cc3 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java @@ -930,6 +930,7 @@ public class Mappings { if (classes != null) { for (ClassRepr c : classes) { + debug("Affecting usages of removed class ", c.name); u.affectAll(c.name, affectedFiles); } } @@ -1226,8 +1227,10 @@ public class Mappings { } final Collection> overriding = u.findOverridingMethods(m, it, false); + for (final Pair p : overriding) { final int fName = myClassToSourceFile.get(p.second.name); + debug("Affecting file by overriding: ", fName); affectedFiles.add(new File(myContext.getValue(fName))); } From d85b0bbf3bc17f2c66640ad4f24122d5cc92372d Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 12 May 2012 12:22:41 +0400 Subject: [PATCH 20/45] [git] optimize branch operations: save all documents only before checkout & merge. Don't save them before creating new branch, new tag, deleting a local or a remote branch, comparing branches. --- .../src/git4idea/branch/GitBranchOperation.java | 10 ++++++++++ .../git4idea/branch/GitBranchOperationsProcessor.java | 11 ----------- .../src/git4idea/branch/GitCheckoutOperation.java | 1 + .../src/git4idea/branch/GitMergeOperation.java | 1 + 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchOperation.java b/plugins/git4idea/src/git4idea/branch/GitBranchOperation.java index 144ae4320ce5..a2da87a7265d 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchOperation.java @@ -20,6 +20,7 @@ import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; @@ -172,6 +173,15 @@ abstract class GitBranchOperation { notifySuccess(getSuccessMessage()); } + protected static void saveAllDocuments() { + UIUtil.invokeAndWaitIfNeeded(new Runnable() { + @Override + public void run() { + FileDocumentManager.getInstance().saveAllDocuments(); + } + }); + } + /** * Show fatal error as a notification or as a dialog with rollback proposal. */ diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java b/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java index 56560add2f86..b683b94decf4 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java @@ -18,7 +18,6 @@ package git4idea.branch; import com.intellij.notification.NotificationType; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; @@ -28,7 +27,6 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.Change; -import com.intellij.util.ui.UIUtil; import git4idea.GitBranch; import git4idea.GitExecutionException; import git4idea.GitVcs; @@ -471,7 +469,6 @@ public final class GitBranchOperationsProcessor { @Override public final void run(@NotNull ProgressIndicator indicator) { - saveAllDocuments(); execute(indicator); if (myCallInAwtAfterExecution != null) { SwingUtilities.invokeLater(myCallInAwtAfterExecution); @@ -484,14 +481,6 @@ public final class GitBranchOperationsProcessor { GitVcs.runInBackground(this); } - private static void saveAllDocuments() { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - FileDocumentManager.getInstance().saveAllDocuments(); - } - }); - } } } diff --git a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java index 47169747ef0f..e610e59ba28a 100644 --- a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java @@ -65,6 +65,7 @@ class GitCheckoutOperation extends GitBranchOperation { @Override protected void execute() { + saveAllDocuments(); boolean fatalErrorHappened = false; while (hasMoreRepositories() && !fatalErrorHappened) { final GitRepository repository = next(); diff --git a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java index afc13e1eb852..c4e5f89b8e3d 100644 --- a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java @@ -79,6 +79,7 @@ class GitMergeOperation extends GitBranchOperation { @Override protected void execute() { LOG.info("starting"); + saveAllDocuments(); boolean fatalErrorHappened = false; int alreadyUpToDateRepositories = 0; while (hasMoreRepositories() && !fatalErrorHappened) { From 4ef34abb9b996ad2b076b94f5316462d5340b6a1 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 12 May 2012 12:58:57 +0400 Subject: [PATCH 21/45] [git] don't log diff & rev-list to the console on update --- plugins/git4idea/src/git4idea/GitUtil.java | 1 + plugins/git4idea/src/git4idea/update/GitMergeUpdater.java | 1 + plugins/git4idea/src/git4idea/update/GitUpdater.java | 1 + 3 files changed, 3 insertions(+) diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index f4be63494bea..fcc925257d81 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -719,6 +719,7 @@ public class GitUtil { diff.setNoSSH(true); diff.setStdoutSuppressed(true); diff.setStderrSuppressed(true); + diff.setSilent(true); final String output = diff.run(); final Collection remoteChanges = new HashSet(); diff --git a/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java b/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java index 1c6a940ec92b..905f520fadb0 100644 --- a/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java @@ -189,6 +189,7 @@ public class GitMergeUpdater extends GitUpdater { diff.setNoSSH(true); diff.setStdoutSuppressed(true); diff.setStderrSuppressed(true); + diff.setSilent(true); final String output = diff.run(); return !output.trim().isEmpty(); } diff --git a/plugins/git4idea/src/git4idea/update/GitUpdater.java b/plugins/git4idea/src/git4idea/update/GitUpdater.java index 1735a3c58376..cbf2d7805474 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdater.java @@ -166,6 +166,7 @@ public abstract class GitUpdater { protected boolean hasRemoteChanges(@NotNull String currentBranch, @NotNull String remoteBranch) throws VcsException { GitSimpleHandler handler = new GitSimpleHandler(myProject, myRoot, GitCommand.REV_LIST); + handler.setSilent(true); handler.setNoSSH(true); handler.addParameters("-1"); handler.addParameters(currentBranch + ".." + remoteBranch); From 5767f834ef17dd5d8c054c9a1d84c714b60f6bf1 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 12 May 2012 14:40:08 +0400 Subject: [PATCH 22/45] [git] refactoring: root -> GitRepository * Use GitRepository instead of root VirtualFile for GitUpdateProcess and GitFetcher. * Introduce getRepositoriesFromRoots and getRootsFromRepositories (rename) in GitUtil. --- plugins/git4idea/src/git4idea/GitUtil.java | 20 +++++++- .../src/git4idea/actions/GitFetch.java | 6 ++- .../src/git4idea/actions/GitPull.java | 9 ++-- .../git4idea/branch/GitBranchOperation.java | 3 +- .../git4idea/branch/GitMergeOperation.java | 2 +- .../git4idea/src/git4idea/push/GitPusher.java | 20 +++----- .../src/git4idea/update/GitFetcher.java | 20 ++++---- .../git4idea/update/GitUpdateEnvironment.java | 12 +++-- .../src/git4idea/update/GitUpdateProcess.java | 50 +++++++++---------- .../git4idea/util/GitPreservingProcess.java | 2 +- 10 files changed, 77 insertions(+), 67 deletions(-) diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index fcc925257d81..db0de52d46dd 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -698,7 +698,7 @@ public class GitUtil { } @NotNull - public static Collection getRoots(@NotNull Collection repositories) { + public static Collection getRootsFromRepositories(@NotNull Collection repositories) { Collection roots = new ArrayList(repositories.size()); for (GitRepository repository : repositories) { roots.add(repository.getRoot()); @@ -706,6 +706,22 @@ public class GitUtil { return roots; } + @NotNull + public static Collection getRepositoriesFromRoots(@NotNull GitRepositoryManager repositoryManager, + @NotNull Collection roots) { + Collection repositories = new ArrayList(roots.size()); + for (VirtualFile root : roots) { + GitRepository repo = repositoryManager.getRepositoryForRoot(root); + if (repo == null) { + LOG.error("Repository not found for root " + root); + } + else { + repositories.add(repo); + } + } + return repositories; + } + /** * Returns absolute paths which have changed remotely comparing to the current branch, i.e. performs * git diff --name-only master..origin/master @@ -764,7 +780,7 @@ public class GitUtil { return affectedChanges; } - @Nullable + @NotNull public static GitRepositoryManager getRepositoryManager(@NotNull Project project) { return ServiceManager.getService(project, GitRepositoryManager.class); } diff --git a/plugins/git4idea/src/git4idea/actions/GitFetch.java b/plugins/git4idea/src/git4idea/actions/GitFetch.java index b761aecac34a..ac33e9721ba8 100644 --- a/plugins/git4idea/src/git4idea/actions/GitFetch.java +++ b/plugins/git4idea/src/git4idea/actions/GitFetch.java @@ -20,8 +20,10 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; +import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.i18n.GitBundle; +import git4idea.repo.GitRepositoryManager; import git4idea.update.GitFetcher; import org.jetbrains.annotations.NotNull; @@ -46,7 +48,9 @@ public class GitFetch extends GitRepositoryAction { GitVcs.runInBackground(new Task.Backgroundable(project, "Fetching...", false) { @Override public void run(@NotNull ProgressIndicator indicator) { - new GitFetcher(project, indicator, true).fetchRootsAndNotify(gitRoots, null, true); + GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(project); + new GitFetcher(project, indicator, true).fetchRootsAndNotify(GitUtil.getRepositoriesFromRoots(repositoryManager, gitRoots), + null, true); } }); } diff --git a/plugins/git4idea/src/git4idea/actions/GitPull.java b/plugins/git4idea/src/git4idea/actions/GitPull.java index 874e7e2d0fc4..a5ff0dd5b875 100644 --- a/plugins/git4idea/src/git4idea/actions/GitPull.java +++ b/plugins/git4idea/src/git4idea/actions/GitPull.java @@ -37,10 +37,11 @@ import git4idea.merge.GitPullDialog; import git4idea.repo.GitRemote; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; -import git4idea.util.GitUIUtil; import git4idea.update.GitFetcher; +import git4idea.util.GitUIUtil; import org.jetbrains.annotations.NotNull; +import java.util.Collections; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; @@ -73,9 +74,6 @@ public class GitPull extends GitRepositoryAction { @Override public void run(@NotNull ProgressIndicator indicator) { final GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(myProject); - if (repositoryManager == null) { - return; - } GitRepository repository = repositoryManager.getRepositoryForRoot(dialog.gitRoot()); assert repository != null : "Repository can't be null for root " + dialog.gitRoot(); @@ -89,7 +87,8 @@ public class GitPull extends GitRepositoryAction { } if (GitHttpAdapter.shouldUseJGit(url)) { - boolean fetchSuccessful = new GitFetcher(project, indicator, true).fetchRootsAndNotify(gitRoots, "Pull failed", false); + boolean fetchSuccessful = new GitFetcher(project, indicator, true).fetchRootsAndNotify(Collections.singleton(repository), + "Pull failed", false); if (!fetchSuccessful) { return; } diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchOperation.java b/plugins/git4idea/src/git4idea/branch/GitBranchOperation.java index a2da87a7265d..31baab85c6b9 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchOperation.java @@ -307,7 +307,8 @@ abstract class GitBranchOperation { setMergeDescription("The following files have unresolved conflicts. You need to resolve them before " + getOperationName() + "."). setErrorNotificationTitle("Unresolved files remain."); - new GitConflictResolver(myProject, myGit, ServiceManager.getService(PlatformFacade.class), GitUtil.getRoots(getRepositories()), params).merge(); + new GitConflictResolver(myProject, myGit, ServiceManager.getService(PlatformFacade.class), GitUtil.getRootsFromRepositories( + getRepositories()), params).merge(); } } }); diff --git a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java index c4e5f89b8e3d..8235466851b9 100644 --- a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java @@ -364,7 +364,7 @@ class GitMergeOperation extends GitBranchOperation { private class MyMergeConflictResolver extends GitMergeCommittingConflictResolver { public MyMergeConflictResolver() { super(GitMergeOperation.this.myProject, myGit, new GitMerger(GitMergeOperation.this.myProject), - GitUtil.getRoots(GitMergeOperation.this.myConflictedRepositories.keySet()), new Params(), true); + GitUtil.getRootsFromRepositories(GitMergeOperation.this.myConflictedRepositories.keySet()), new Params(), true); } @Override diff --git a/plugins/git4idea/src/git4idea/push/GitPusher.java b/plugins/git4idea/src/git4idea/push/GitPusher.java index e8907f052130..ebb558aec8fe 100644 --- a/plugins/git4idea/src/git4idea/push/GitPusher.java +++ b/plugins/git4idea/src/git4idea/push/GitPusher.java @@ -484,7 +484,7 @@ public final class GitPusher { Collection repositoriesToUpdate = getRootsToUpdate(rejectedPushesForCurrentBranch, updateSettings.shouldUpdateAllRoots()); GitPushResult adjustedPushResult = result.remove(rejectedPushesForCurrentBranch); adjustedPushResult.markUpdateStartIfNotMarked(repositoriesToUpdate); - boolean updateResult = update(getRootsFromRepositories(repositoriesToUpdate), updateSettings.getUpdateMethod()); + boolean updateResult = update(repositoriesToUpdate, updateSettings.getUpdateMethod()); if (updateResult) { myProgressIndicator.setText(INDICATOR_TEXT); GitPushInfo newPushInfo = pushInfo.retain(rejectedPushesForCurrentBranch); @@ -544,20 +544,12 @@ public final class GitPusher { return updateAllRoots ? myRepositories : rejectedPushesForCurrentBranch.keySet(); } - @NotNull - private static Collection getRootsFromRepositories(@NotNull Collection repositories) { - Collection roots = new ArrayList(); - for (GitRepository repository : repositories) { - roots.add(repository.getRoot()); - } - return roots; - } - - private boolean update(@NotNull Collection rootsToUpdate, @NotNull UpdateMethod updateMethod) { + private boolean update(@NotNull Collection rootsToUpdate, @NotNull UpdateMethod updateMethod) { GitUpdateProcess.UpdateMethod um = updateMethod == UpdateMethod.MERGE ? GitUpdateProcess.UpdateMethod.MERGE : GitUpdateProcess.UpdateMethod.REBASE; - boolean updateResult = new GitUpdateProcess(myProject, myProgressIndicator, new HashSet(rootsToUpdate), UpdatedFiles.create()).update(um); - for (VirtualFile virtualFile : rootsToUpdate) { - virtualFile.refresh(true, true); + boolean updateResult = new GitUpdateProcess(myProject, myProgressIndicator, new HashSet(rootsToUpdate), + UpdatedFiles.create()).update(um); + for (GitRepository repository : rootsToUpdate) { + repository.getRoot().refresh(true, true); } return updateResult; } diff --git a/plugins/git4idea/src/git4idea/update/GitFetcher.java b/plugins/git4idea/src/git4idea/update/GitFetcher.java index e7628d655175..23a9dbd90539 100644 --- a/plugins/git4idea/src/git4idea/update/GitFetcher.java +++ b/plugins/git4idea/src/git4idea/update/GitFetcher.java @@ -81,14 +81,11 @@ public class GitFetcher { * Invokes 'git fetch'. * @return true if fetch was successful, false in the case of error. */ - public GitFetchResult fetch(@NotNull VirtualFile root) { - GitRepository repository = myRepositoryManager.getRepositoryForRoot(root); - assert repository != null : "Repository can't be null for " + root + "\n" + myRepositoryManager; - + public GitFetchResult fetch(@NotNull GitRepository repository) { // TODO need to have a fair compound result here GitFetchResult fetchResult = GitFetchResult.success(); if (myFetchAll) { - fetchResult = fetchAll(root, repository, fetchResult); + fetchResult = fetchAll(repository, fetchResult); } else { return fetchCurrentRemote(repository); @@ -187,7 +184,7 @@ public class GitFetcher { } @NotNull - private GitFetchResult fetchAll(@NotNull VirtualFile root, @NotNull GitRepository repository, @NotNull GitFetchResult fetchResult) { + private GitFetchResult fetchAll(@NotNull GitRepository repository, @NotNull GitFetchResult fetchResult) { for (GitRemote remote : repository.getRemotes()) { String url = remote.getFirstUrl(); if (url == null) { @@ -204,7 +201,7 @@ public class GitFetcher { } } else { - GitFetchResult res = fetchNatively(root, remote, null); + GitFetchResult res = fetchNatively(repository.getRoot(), remote, null); res.addPruneInfo(fetchResult.getPrunedRefs()); fetchResult = res; if (!fetchResult.isSuccess()) { @@ -318,13 +315,14 @@ public class GitFetcher { * @param notifySuccess if set to {@code true} successful notification will be displayed. * @return true if all fetches were successful, false if at least one fetch failed. */ - public boolean fetchRootsAndNotify(@NotNull Collection roots, @Nullable String errorNotificationTitle, boolean notifySuccess) { + public boolean fetchRootsAndNotify(@NotNull Collection roots, + @Nullable String errorNotificationTitle, boolean notifySuccess) { Map additionalInfo = new HashMap(); - for (VirtualFile root : roots) { - GitFetchResult result = fetch(root); + for (GitRepository repository : roots) { + GitFetchResult result = fetch(repository); String ai = result.getAdditionalInfo(); if (!StringUtil.isEmptyOrSpaces(ai)) { - additionalInfo.put(root, ai); + additionalInfo.put(repository.getRoot(), ai); } if (!result.isSuccess()) { Collection errors = new ArrayList(getErrors()); diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java b/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java index b3a662ee9f33..1ef496047022 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java @@ -27,9 +27,9 @@ import com.intellij.openapi.vcs.update.UpdateEnvironment; import com.intellij.openapi.vcs.update.UpdateSession; import com.intellij.openapi.vcs.update.UpdatedFiles; import com.intellij.openapi.vfs.VirtualFile; -import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.config.GitVcsSettings; +import git4idea.repo.GitRepositoryManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,6 +37,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.Set; +import static git4idea.GitUtil.*; + /** * Git update environment implementation. The environment does * {@code git pull -v} for each vcs root. Rebase variant is detected @@ -60,8 +62,10 @@ public class GitUpdateEnvironment implements UpdateEnvironment { @NotNull public UpdateSession updateDirectories(@NotNull FilePath[] filePaths, UpdatedFiles updatedFiles, ProgressIndicator progressIndicator, @NotNull Ref sequentialUpdatesContextRef) throws ProcessCanceledException { - Set roots = GitUtil.gitRoots(Arrays.asList(filePaths)); - final GitUpdateProcess gitUpdateProcess = new GitUpdateProcess(myProject, progressIndicator, roots, updatedFiles); + Set roots = gitRoots(Arrays.asList(filePaths)); + GitRepositoryManager repositoryManager = getRepositoryManager(myProject); + final GitUpdateProcess gitUpdateProcess = new GitUpdateProcess(myProject, progressIndicator, + getRepositoriesFromRoots(repositoryManager, roots), updatedFiles); boolean result = gitUpdateProcess.update(GitUpdateProcess.UpdateMethod.READ_FROM_SETTINGS); return new GitUpdateSession(result); } @@ -69,7 +73,7 @@ public class GitUpdateEnvironment implements UpdateEnvironment { public boolean validateOptions(Collection filePaths) { for (FilePath p : filePaths) { - if (!GitUtil.isUnderGit(p)) { + if (!isUnderGit(p)) { return false; } } diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index e1390c294642..a434e58dfbd1 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -29,18 +29,22 @@ import com.intellij.util.continuation.ContinuationContext; import com.intellij.util.continuation.ContinuationFinalTasksInserter; import com.intellij.util.text.DateFormatUtil; import git4idea.GitBranch; -import git4idea.GitVcs; +import git4idea.GitUtil; +import git4idea.PlatformFacade; import git4idea.branch.GitBranchPair; import git4idea.commands.Git; import git4idea.merge.GitConflictResolver; import git4idea.merge.GitMergeCommittingConflictResolver; import git4idea.merge.GitMerger; import git4idea.rebase.GitRebaser; +import git4idea.repo.GitRepository; import git4idea.stash.GitChangesSaver; -import git4idea.util.GitUIUtil; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; import static git4idea.util.GitUIUtil.*; @@ -52,10 +56,9 @@ import static git4idea.util.GitUIUtil.*; public class GitUpdateProcess { private static final Logger LOG = Logger.getInstance(GitUpdateProcess.class); - private final Project myProject; - private final GitVcs myVcs; + @NotNull private final Project myProject; @NotNull private final Git myGit; - private final Set myRoots; + @NotNull private final Collection myRepositories; private final UpdatedFiles myUpdatedFiles; private final ProgressIndicator myProgressIndicator; private final GitMerger myMerger; @@ -72,12 +75,10 @@ public class GitUpdateProcess { READ_FROM_SETTINGS } - public GitUpdateProcess(@NotNull Project project, - @NotNull ProgressIndicator progressIndicator, - @NotNull Set roots, @NotNull UpdatedFiles updatedFiles) { + public GitUpdateProcess(@NotNull Project project, @NotNull ProgressIndicator progressIndicator, + @NotNull Collection repositories, @NotNull UpdatedFiles updatedFiles) { myProject = project; - myRoots = roots; - myVcs = GitVcs.getInstance(project); + myRepositories = repositories; myGit = ServiceManager.getService(Git.class); myUpdatedFiles = updatedFiles; myProgressIndicator = progressIndicator; @@ -135,7 +136,8 @@ public class GitUpdateProcess { private boolean updateImpl(UpdateMethod updateMethod, ContinuationContext context) { // define updaters for roots try { - for (VirtualFile root : myRoots) { + for (GitRepository repository : myRepositories) { + VirtualFile root = repository.getRoot(); final GitUpdater updater; if (updateMethod == UpdateMethod.MERGE) { updater = new GitMergeUpdater(myProject, myGit, root, myTrackedBranches, myProgressIndicator, myUpdatedFiles); @@ -227,15 +229,7 @@ public class GitUpdateProcess { // fetch all roots. If an error happens, return false and notify about errors. private boolean fetchAndNotify() { - return new GitFetcher(myProject, myProgressIndicator, false).fetchRootsAndNotify(myRoots, "Update failed", false); - } - - public Map getTrackedBranches() { - return myTrackedBranches; - } - - public GitChangesSaver getSaver() { - return mySaver; + return new GitFetcher(myProject, myProgressIndicator, false).fetchRootsAndNotify(myRepositories, "Update failed", false); } /** @@ -245,7 +239,8 @@ public class GitUpdateProcess { * If branch configuration is OK for all roots, return true. */ private boolean checkTrackedBranchesConfigured() { - for (VirtualFile root : myRoots) { + for (GitRepository repository : myRepositories) { + VirtualFile root = repository.getRoot(); try { final GitBranch branch = GitBranch.current(myProject, root); if (branch == null) { @@ -261,7 +256,7 @@ public class GitUpdateProcess { final String branchName = branch.getName(); LOG.info("checkTrackedBranchesConfigured tracked branch is null for current branch " + branch); notifyImportantError(myProject, "Can't update: no tracked branch", - "No tracked branch configured for branch " + GitUIUtil.code(branchName) + + "No tracked branch configured for branch " + code(branchName) + rootStringIfNeeded(root) + "To make your branch track a remote branch call, for example,
" + "git branch --set-upstream " + branchName + " origin/" + branchName + ""); @@ -287,10 +282,10 @@ public class GitUpdateProcess { } private String rootStringIfNeeded(@NotNull VirtualFile root) { - if (myRoots.size() < 2) { + if (myRepositories.size() < 2) { return ".
"; } - return "
in Git repository " + GitUIUtil.code(root.getPresentableUrl()) + "
"; + return "
in Git repository " + code(root.getPresentableUrl()) + "
"; } /** @@ -316,7 +311,8 @@ public class GitUpdateProcess { GitConflictResolver.Params params = new GitConflictResolver.Params(); params.setErrorNotificationTitle("Can't update"); params.setMergeDescription("Unmerged files detected. These conflicts must be resolved before update."); - return !new GitMergeCommittingConflictResolver(myProject, myGit, myMerger, myRoots, params, false).merge(); + return !new GitMergeCommittingConflictResolver(myProject, myGit, myMerger, GitUtil.getRootsFromRepositories(myRepositories), + params, false).merge(); } /** @@ -336,7 +332,7 @@ public class GitUpdateProcess { params.setMergeDescription("You have unfinished rebase process. These conflicts must be resolved before update."); params.setErrorNotificationAdditionalDescription("Then you may continue rebase.
You also may abort rebase to restore the original branch and stop rebasing."); params.setReverse(true); - return !new GitConflictResolver(myProject, myGit, ServiceManager.getService(git4idea.PlatformFacade.class), rebasingRoots, params) { + return !new GitConflictResolver(myProject, myGit, ServiceManager.getService(PlatformFacade.class), rebasingRoots, params) { @Override protected boolean proceedIfNothingToMerge() { return rebaser.continueRebase(rebasingRoots); } diff --git a/plugins/git4idea/src/git4idea/util/GitPreservingProcess.java b/plugins/git4idea/src/git4idea/util/GitPreservingProcess.java index 73981378561b..2f0463065066 100644 --- a/plugins/git4idea/src/git4idea/util/GitPreservingProcess.java +++ b/plugins/git4idea/src/git4idea/util/GitPreservingProcess.java @@ -147,7 +147,7 @@ public class GitPreservingProcess { */ private boolean save() { try { - mySaver.saveLocalChanges(GitUtil.getRoots(myRepositories)); + mySaver.saveLocalChanges(GitUtil.getRootsFromRepositories(myRepositories)); return true; } catch (VcsException e) { LOG.info("Couldn't save local changes", e); From 0b96eda9bcabc1fc64dc01b00a8d017a6faf4b32 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Sat, 12 May 2012 12:44:23 +0200 Subject: [PATCH 23/45] correctly determine the path to compiler when starting build process --- .../compiler/CompileServerManager.java | 3 +- .../compiler/server/BuildManager.java | 28 ++++++++++++++----- .../jetbrains/jps/cmdline/BuildSession.java | 5 ++-- .../jps/server/ClasspathBootstrap.java | 10 +------ 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java b/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java index 519e55bd9cf9..7ac97854bead 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java @@ -643,7 +643,8 @@ public class CompileServerManager implements ApplicationComponent{ cmdLine.addParameter("-classpath"); - final List cp = ClasspathBootstrap.getCompileServerApplicationClasspath(); + final List cp = ClasspathBootstrap.getBuildProcessApplicationClasspath(); + cp.add(ClasspathBootstrap.getResourcePath(systemCompiler.getClass())); // tools.jar cp.addAll(myClasspathManager.getCompileServerPluginsClasspath()); cmdLine.addParameter(classpathToString(cp)); diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index 00206e02133a..694e701848f5 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -565,14 +565,10 @@ public class BuildManager implements ApplicationComponent{ } private Process launchBuildProcess(Project project, final int port, final UUID sessionId) throws ExecutionException { - // validate tools.jar presence - final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler(); - if (systemCompiler == null) { - throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath."); - } // choosing sdk with which the build process should be run - Sdk projectJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); + final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); + Sdk projectJdk = internalJdk; final String versionString = projectJdk.getVersionString(); if (versionString != null) { JavaSdkVersion sdkVersion = ((JavaSdk)projectJdk.getSdkType()).getVersion(versionString); @@ -600,6 +596,23 @@ public class BuildManager implements ApplicationComponent{ } } + // validate tools.jar presence + final File compilerPath; + if (projectJdk.equals(internalJdk)) { + final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler(); + if (systemCompiler == null) { + throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath."); + } + compilerPath = ClasspathBootstrap.getResourcePath(systemCompiler.getClass()); + } + else { + final String path = ((JavaSdk)projectJdk.getSdkType()).getToolsPath(projectJdk); + if (path == null) { + throw new ExecutionException("Cannot determine path to 'tools.jar' library for " + projectJdk.getName() + " (" + projectJdk.getHomePath() + ")"); + } + compilerPath = new File(path); + } + final GeneralCommandLine cmdLine = new GeneralCommandLine(); final String vmExecutablePath = ((JavaSdkType)projectJdk.getSdkType()).getVMExecutablePath(projectJdk); cmdLine.setExePath(vmExecutablePath); @@ -667,7 +680,8 @@ public class BuildManager implements ApplicationComponent{ cmdLine.addParameter("-classpath"); - final List cp = ClasspathBootstrap.getCompileServerApplicationClasspath(); + final List cp = ClasspathBootstrap.getBuildProcessApplicationClasspath(); + cp.add(compilerPath); cp.addAll(myClasspathManager.getCompileServerPluginsClasspath()); cmdLine.addParameter(classpathToString(cp)); diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java index 423decc28335..fc1b17756ee8 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java @@ -168,11 +168,12 @@ final class BuildSession implements Runnable, CanceledStatus { final Project project = loadProject(projectPath); final File dataStorageRoot = Utils.getDataStorageRoot(project); + final boolean inMemoryMappingsDelta = System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null; ProjectTimestamps projectTimestamps = null; BuildDataManager dataManager = null; try { projectTimestamps = new ProjectTimestamps(dataStorageRoot); - dataManager = new BuildDataManager(dataStorageRoot, true); + dataManager = new BuildDataManager(dataStorageRoot, inMemoryMappingsDelta); if (dataManager.versionDiffers()) { forceCleanCaches = true; msgHandler.processMessage(new CompilerMessage("build", BuildMessage.Kind.INFO, "Dependency data format has changed, project rebuild required")); @@ -190,7 +191,7 @@ final class BuildSession implements Runnable, CanceledStatus { forceCleanCaches = true; FileUtil.delete(dataStorageRoot); projectTimestamps = new ProjectTimestamps(dataStorageRoot); - dataManager = new BuildDataManager(dataStorageRoot, true); + dataManager = new BuildDataManager(dataStorageRoot, inMemoryMappingsDelta); // second attempt succeded msgHandler.processMessage(new CompilerMessage("build", BuildMessage.Kind.INFO, "Project rebuild forced: " + e.getMessage())); } diff --git a/jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java b/jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java index 1279c09b17b2..59627572644e 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java +++ b/jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java @@ -86,7 +86,7 @@ public class ClasspathBootstrap { private ClasspathBootstrap() { } - public static List getCompileServerApplicationClasspath() { + public static List getBuildProcessApplicationClasspath() { final Set cp = new LinkedHashSet(); cp.add(getResourcePath(Server.class)); for (String path : PathManager.getUtilClassPath()) { cp.add(new File(path)); } // util @@ -114,14 +114,6 @@ public class ClasspathBootstrap { catch (Throwable ignored) { } - final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler(); - if (systemCompiler != null) { - try { - cp.add(getResourcePath(systemCompiler.getClass())); // tools.jar - } - catch (Throwable ignored) { - } - } return new ArrayList(cp); } From 1eca2a7f5809c2a52cc67107c905f84f7332a587 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 12 May 2012 15:09:45 +0400 Subject: [PATCH 24/45] GitUpdateProcess optimization: use available cached info for current and tracked branches, instead of querying Git for this information. --- .../src/git4idea/branch/GitBranchUtil.java | 24 +++++++ .../src/git4idea/push/GitPushDialog.java | 23 +------ .../src/git4idea/repo/GitBranchTrackInfo.java | 6 ++ .../src/git4idea/update/GitUpdateProcess.java | 65 +++++++++---------- 4 files changed, 64 insertions(+), 54 deletions(-) diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java b/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java index d93c65550e76..c53303f318a8 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java @@ -17,6 +17,7 @@ package git4idea.branch; import git4idea.GitBranch; import git4idea.repo.GitBranchTrackInfo; +import git4idea.repo.GitRemote; import git4idea.repo.GitRepository; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,4 +42,27 @@ public class GitBranchUtil { } return null; } + + /** + * Looks through the remote branches in the given repository and tries to find the one from the given remote, + * which the given name. + * @return remote branch or null if such branch couldn't be found. + */ + @Nullable + public static GitBranch findRemoteBranchByName(@NotNull GitRepository repository, @Nullable GitRemote remote, @Nullable String name) { + if (name == null || remote == null) { + return null; + } + final String BRANCH_PREFIX = "refs/heads/"; + if (name.startsWith(BRANCH_PREFIX)) { + name = name.substring(BRANCH_PREFIX.length()); + } + + for (GitBranch branch : repository.getBranches().getRemoteBranches()) { + if (branch.getName().equals(remote.getName() + "/" + name)) { + return branch; + } + } + return null; + } } diff --git a/plugins/git4idea/src/git4idea/push/GitPushDialog.java b/plugins/git4idea/src/git4idea/push/GitPushDialog.java index 0cb4bcc04733..bb460d6c0d70 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushDialog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushDialog.java @@ -27,6 +27,7 @@ import com.intellij.util.Consumer; import com.intellij.util.ui.UIUtil; import git4idea.GitBranch; import git4idea.GitUtil; +import git4idea.branch.GitBranchUtil; import git4idea.history.browser.GitCommit; import git4idea.repo.GitRemote; import git4idea.repo.GitRepository; @@ -211,7 +212,7 @@ public class GitPushDialog extends DialogWrapper { String remoteName = currentBranch.getTrackedRemoteName(repository.getProject(), repository.getRoot()); String trackedBranchName = currentBranch.getTrackedBranchName(repository.getProject(), repository.getRoot()); GitRemote remote = GitUtil.findRemoteByName(repository, remoteName); - GitBranch tracked = findRemoteBranchByName(repository, remote, trackedBranchName); + GitBranch tracked = GitBranchUtil.findRemoteBranchByName(repository, remote, trackedBranchName); if (remote == null || tracked == null) { Pair remoteAndBranch = GitUtil.findMatchingRemoteBranch(repository, currentBranch); if (remoteAndBranch == null) { @@ -226,7 +227,7 @@ public class GitPushDialog extends DialogWrapper { if (myRefspecPanel.turnedOn()) { String manualBranchName = myRefspecPanel.getBranchToPush(); remote = myRefspecPanel.getSelectedRemote(); - GitBranch manualBranch = findRemoteBranchByName(repository, remote, manualBranchName); + GitBranch manualBranch = GitBranchUtil.findRemoteBranchByName(repository, remote, manualBranchName); if (manualBranch == null) { if (!manualBranchName.startsWith("refs/remotes/")) { manualBranchName = myRefspecPanel.getSelectedRemote().getName() + "/" + manualBranchName; @@ -242,24 +243,6 @@ public class GitPushDialog extends DialogWrapper { return defaultSpecs; } - @Nullable - private static GitBranch findRemoteBranchByName(@NotNull GitRepository repository, @Nullable GitRemote remote, @Nullable String name) { - if (name == null || remote == null) { - return null; - } - final String BRANCH_PREFIX = "refs/heads/"; - if (name.startsWith(BRANCH_PREFIX)) { - name = name.substring(BRANCH_PREFIX.length()); - } - - for (GitBranch branch : repository.getBranches().getRemoteBranches()) { - if (branch.getName().equals(remote.getName() + "/" + name)) { - return branch; - } - } - return null; - } - @Override public JComponent getPreferredFocusedComponent() { return myListPanel.getPreferredFocusComponent(); diff --git a/plugins/git4idea/src/git4idea/repo/GitBranchTrackInfo.java b/plugins/git4idea/src/git4idea/repo/GitBranchTrackInfo.java index bc70772c27e5..2f96b0acb607 100644 --- a/plugins/git4idea/src/git4idea/repo/GitBranchTrackInfo.java +++ b/plugins/git4idea/src/git4idea/repo/GitBranchTrackInfo.java @@ -50,6 +50,12 @@ public class GitBranchTrackInfo { return myRemote; } + /** + * Returns the name of the remote branch.
+ * The name is local for that remote (i.e. without the remote prefix), + * and the name is simplified (i.e. without the {@code refs/heads/} prefix).
+ * For example, returns {@code master}, and not {@code origin/master} or {@code refs/heads/master} or {@code refs/remotes/origin/master}. + */ @NotNull public String getRemoteBranch() { return myRemoteBranch; diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index a434e58dfbd1..2b2b41c8b812 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -32,11 +32,13 @@ import git4idea.GitBranch; import git4idea.GitUtil; import git4idea.PlatformFacade; import git4idea.branch.GitBranchPair; +import git4idea.branch.GitBranchUtil; import git4idea.commands.Git; import git4idea.merge.GitConflictResolver; import git4idea.merge.GitMergeCommittingConflictResolver; import git4idea.merge.GitMerger; import git4idea.rebase.GitRebaser; +import git4idea.repo.GitBranchTrackInfo; import git4idea.repo.GitRepository; import git4idea.stash.GitChangesSaver; import org.jetbrains.annotations.NotNull; @@ -241,42 +243,37 @@ public class GitUpdateProcess { private boolean checkTrackedBranchesConfigured() { for (GitRepository repository : myRepositories) { VirtualFile root = repository.getRoot(); - try { - final GitBranch branch = GitBranch.current(myProject, root); - if (branch == null) { - LOG.info("checkTrackedBranchesConfigured current branch is null"); - notifyImportantError(myProject, "Can't update: no current branch", - "You are in 'detached HEAD' state, which means that you're not on any branch" + - rootStringIfNeeded(root) + - "Checkout a branch to make update possible."); - return false; - } - final GitBranch tracked = branch.tracked(myProject, root); - if (tracked == null) { - final String branchName = branch.getName(); - LOG.info("checkTrackedBranchesConfigured tracked branch is null for current branch " + branch); - notifyImportantError(myProject, "Can't update: no tracked branch", - "No tracked branch configured for branch " + code(branchName) + - rootStringIfNeeded(root) + - "To make your branch track a remote branch call, for example,
" + - "git branch --set-upstream " + branchName + " origin/" + branchName + ""); - return false; - } - if (!tracked.exists(root)) { - LOG.info("checkTrackedBranchesConfigured tracked branch " + tracked + " doesn't exist."); - notifyMessage(myProject, "Can't update: tracked branch doesn't exist.", - "Tracked branch " + tracked.getName() + " doesn't exist, so there is nothing to update" + - rootStringIfNeeded(root) + - "The branch will be automatically created when you push to it.", - NotificationType.WARNING, true, null); - return false; - } - myTrackedBranches.put(root, new GitBranchPair(branch, tracked)); - } catch (VcsException e) { - LOG.info("checkTrackedBranchesConfigured ", e); - notifyImportantError(myProject, "Can't update: error identifying tracked branch", e.getLocalizedMessage()); + final GitBranch branch = repository.getCurrentBranch(); + if (branch == null) { + LOG.info("checkTrackedBranchesConfigured: current branch is null in " + repository); + notifyImportantError(myProject, "Can't update: no current branch", + "You are in 'detached HEAD' state, which means that you're not on any branch" + + rootStringIfNeeded(root) + + "Checkout a branch to make update possible."); return false; } + GitBranchTrackInfo trackInfo = GitBranchUtil.getTrackInfoForBranch(repository, branch); + if (trackInfo == null) { + final String branchName = branch.getName(); + LOG.info(String.format("checkTrackedBranchesConfigured: no track info for current branch %s in %s", branch, repository)); + notifyImportantError(myProject, "Can't update: no tracked branch", + "No tracked branch configured for branch " + code(branchName) + + rootStringIfNeeded(root) + + "To make your branch track a remote branch call, for example,
" + + "git branch --set-upstream " + branchName + " origin/" + branchName + ""); + return false; + } + GitBranch tracked = GitBranchUtil.findRemoteBranchByName(repository, trackInfo.getRemote(), trackInfo.getRemoteBranch()); + if (tracked == null) { + LOG.info(String.format("checkTrackedBranchesConfigured: tracked branch %s not found in %s", tracked, repository)); + notifyMessage(myProject, "Can't update: tracked branch doesn't exist.", + "Tracked branch " + trackInfo.getRemoteBranch() + " doesn't exist" + + rootStringIfNeeded(root) + + "The branch will be automatically created when you push to it.", + NotificationType.WARNING, true, null); + return false; + } + myTrackedBranches.put(root, new GitBranchPair(branch, tracked)); } return true; } From ebfc7d5b48a96ac9ae60da4459a51c243a086fe3 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 12 May 2012 14:32:38 +0200 Subject: [PATCH 25/45] IDEA-85422 Mappings confuguration table is not editable --- platform/platform-api/src/com/intellij/ui/table/JBTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/ui/table/JBTable.java b/platform/platform-api/src/com/intellij/ui/table/JBTable.java index f8265bea7c4b..2f67b1bfefe8 100644 --- a/platform/platform-api/src/com/intellij/ui/table/JBTable.java +++ b/platform/platform-api/src/com/intellij/ui/table/JBTable.java @@ -519,7 +519,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component if (!isEditing()) { return; } - Component c = myFocusManager.getFocusOwner(); + Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); while (c != null) { if (c instanceof JPopupMenu) { c = ((JPopupMenu)c).getInvoker(); From be819b666ce8cc9cb33137262004c5d3caea56b8 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 12 May 2012 14:34:36 +0200 Subject: [PATCH 26/45] 1st + 2nd columns width was 54px less than table width --- .../codeStyle/OptionTableWithPreviewPanel.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTableWithPreviewPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTableWithPreviewPanel.java index 68f75c8e100e..12cc00f51182 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTableWithPreviewPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTableWithPreviewPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -263,13 +263,13 @@ public abstract class OptionTableWithPreviewPanel extends MultilanguageCodeStyle final TableColumn levelColumn = treeTable.getColumnModel().getColumn(1); //TODO[max]: better preffered size... - JLabel value = new JLabel(ApplicationBundle.message("option.table.sizing.text")); - final Dimension valueSize = value.getPreferredSize(); - levelColumn.setPreferredWidth(valueSize.width); - levelColumn.setMaxWidth(valueSize.width); - levelColumn.setMinWidth(valueSize.width); - levelColumn.setResizable(false); + //TODO[kb]: Did I fixed it by making the last column floating? + //levelColumn.setPreferredWidth(valueSize.width); + //levelColumn.setMaxWidth(valueSize.width); + //levelColumn.setMinWidth(valueSize.width); + //levelColumn.setResizable(false); + final Dimension valueSize = new JLabel(ApplicationBundle.message("option.table.sizing.text")).getPreferredSize(); treeTable.setPreferredScrollableViewportSize(new Dimension(maxWidth + valueSize.width + 10, 20)); return treeTable; From 4fc387547e6ed9085cdd2e9b5045a1ee5b02d51b Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 12 May 2012 16:57:19 +0400 Subject: [PATCH 27/45] Add logging to GitUpdateProcess --- .../git4idea/src/git4idea/update/GitFetcher.java | 1 + .../src/git4idea/update/GitUpdateProcess.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/update/GitFetcher.java b/plugins/git4idea/src/git4idea/update/GitFetcher.java index 23a9dbd90539..8278ccbc879b 100644 --- a/plugins/git4idea/src/git4idea/update/GitFetcher.java +++ b/plugins/git4idea/src/git4idea/update/GitFetcher.java @@ -319,6 +319,7 @@ public class GitFetcher { @Nullable String errorNotificationTitle, boolean notifySuccess) { Map additionalInfo = new HashMap(); for (GitRepository repository : roots) { + LOG.info("fetching " + repository); GitFetchResult result = fetch(repository); String ai = result.getAdditionalInfo(); if (!StringUtil.isEmptyOrSpaces(ai)) { diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index 2b2b41c8b812..4a7ac4604fbd 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -137,6 +137,7 @@ public class GitUpdateProcess { private boolean updateImpl(UpdateMethod updateMethod, ContinuationContext context) { // define updaters for roots + LOG.info("updateImpl: defining updaters..."); try { for (GitRepository repository : myRepositories) { VirtualFile root = repository.getRoot(); @@ -161,7 +162,9 @@ public class GitUpdateProcess { } if (myUpdaters.isEmpty()) return true; + // save local changes if needed (update via merge may perform without saving). + LOG.info("updateImpl: identifying if save is needed..."); for (Map.Entry entry : myUpdaters.entrySet()) { VirtualFile root = entry.getKey(); GitUpdater updater = entry.getValue(); @@ -171,6 +174,7 @@ public class GitUpdateProcess { } } + LOG.info("updateImpl: saving local changes..."); try { mySaver.saveLocalChanges(myRootsToSave); } catch (VcsException e) { @@ -182,6 +186,7 @@ public class GitUpdateProcess { } // update each root + LOG.info("updateImpl: updating..."); boolean incomplete = false; boolean success = true; VirtualFile currentlyUpdatedRoot = null; @@ -206,6 +211,7 @@ public class GitUpdateProcess { mySaver.notifyLocalChangesAreNotRestored(); } else { + LOG.info("updateImpl: restoring local changes..."); restoreLocalChanges(context); } } @@ -241,6 +247,7 @@ public class GitUpdateProcess { * If branch configuration is OK for all roots, return true. */ private boolean checkTrackedBranchesConfigured() { + LOG.info("checking tracked branch configuration..."); for (GitRepository repository : myRepositories) { VirtualFile root = repository.getRoot(); final GitBranch branch = repository.getCurrentBranch(); @@ -290,10 +297,12 @@ public class GitUpdateProcess { * @return true if merge is in progress, which means that update can't continue. */ private boolean isMergeInProgress() { + LOG.info("isMergeInProgress: checking if there is an unfinished merge process..."); final Collection mergingRoots = myMerger.getMergingRoots(); if (mergingRoots.isEmpty()) { return false; } + LOG.info("isMergeInProgress: roots with unfinished merge: " + mergingRoots); GitConflictResolver.Params params = new GitConflictResolver.Params(); params.setErrorNotificationTitle("Can't update"); params.setMergeDescription("You have unfinished merge. These conflicts must be resolved before update."); @@ -305,6 +314,7 @@ public class GitUpdateProcess { * @return true if there are unmerged files at */ private boolean areUnmergedFiles() { + LOG.info("areUnmergedFiles: checking if there are unmerged files..."); GitConflictResolver.Params params = new GitConflictResolver.Params(); params.setErrorNotificationTitle("Can't update"); params.setMergeDescription("Unmerged files detected. These conflicts must be resolved before update."); @@ -317,12 +327,13 @@ public class GitUpdateProcess { * @return true if rebase is in progress, which means that update can't continue. */ private boolean checkRebaseInProgress() { + LOG.info("checkRebaseInProgress: checking if there is an unfinished rebase process..."); final GitRebaser rebaser = new GitRebaser(myProject, myGit, myProgressIndicator); final Collection rebasingRoots = rebaser.getRebasingRoots(); if (rebasingRoots.isEmpty()) { return false; } - LOG.info("checkRebaseInProgress rebasingRoots: " + rebasingRoots); + LOG.info("checkRebaseInProgress: roots with unfinished rebase: " + rebasingRoots); GitConflictResolver.Params params = new GitConflictResolver.Params(); params.setErrorNotificationTitle("Can't update"); From a31597886cafb03acb285a4983a16dc7f2e3c918 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Sat, 12 May 2012 16:50:58 +0400 Subject: [PATCH 28/45] drop SQL supports --- .../openapi/extensions/AbstractExtensionPointBean.java | 4 ++++ .../intelliLang/inject/LanguageInjectionConfigBean.java | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/extensions/src/com/intellij/openapi/extensions/AbstractExtensionPointBean.java b/platform/extensions/src/com/intellij/openapi/extensions/AbstractExtensionPointBean.java index 0f9b3f49b3cc..54b3cd7fda03 100644 --- a/platform/extensions/src/com/intellij/openapi/extensions/AbstractExtensionPointBean.java +++ b/platform/extensions/src/com/intellij/openapi/extensions/AbstractExtensionPointBean.java @@ -33,6 +33,10 @@ public abstract class AbstractExtensionPointBean implements PluginAware { myPluginDescriptor = pluginDescriptor; } + public PluginDescriptor getPluginDescriptor() { + return myPluginDescriptor; + } + @NotNull public final Class findClass(final String className) throws ClassNotFoundException { return (Class)Class.forName(className, true, getLoaderForClass()); diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/LanguageInjectionConfigBean.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/LanguageInjectionConfigBean.java index e1874a75f797..f6eff1434052 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/LanguageInjectionConfigBean.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/LanguageInjectionConfigBean.java @@ -30,8 +30,5 @@ public class LanguageInjectionConfigBean extends AbstractExtensionPointBean { return myConfigUrl; } - public PluginDescriptor getPluginDescriptor() { - return myPluginDescriptor; - } } From a0c3574f3e6b1210a4d15dec96c00ac3a143dc1d Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Sat, 12 May 2012 16:56:12 +0400 Subject: [PATCH 29/45] per-plugin statistics --- .../intellij/psi/tree/IElementTypeTest.java | 65 +++++++++++++++++-- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/psi/tree/IElementTypeTest.java b/platform/platform-tests/testSrc/com/intellij/psi/tree/IElementTypeTest.java index d5915a9f253b..2922cefb6110 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/tree/IElementTypeTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/tree/IElementTypeTest.java @@ -3,13 +3,20 @@ */ package com.intellij.psi.tree; +import com.intellij.lang.Language; import com.intellij.lang.LanguageExtensionPoint; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import gnu.trove.THashMap; +import gnu.trove.TObjectIntHashMap; + +import java.util.Arrays; +import java.util.Comparator; /** * @author gregsh @@ -20,28 +27,74 @@ public class IElementTypeTest extends LightPlatformCodeInsightFixtureTestCase { @SuppressWarnings("UnusedDeclaration") public void testCount() throws Exception { int count = IElementType.getAllocatedTypesCount(); - System.out.println("Before: " + count +" types"); + System.out.println("Preloaded: " + count +" element types"); LanguageExtensionPoint[] extensions = Extensions.getExtensions(new ExtensionPointName("com.intellij.lang.parserDefinition")); - System.out.println(extensions.length +" definitions"); + System.out.println("ParserDefinitions: " + extensions.length); + THashMap languageMap = new THashMap(); + languageMap.put(Language.ANY, "platform"); + final TObjectIntHashMap map = new TObjectIntHashMap(); for (LanguageExtensionPoint e : extensions) { + String key = e.getPluginDescriptor().getPluginId().getIdString(); + int curCount = IElementType.getAllocatedTypesCount(); ParserDefinition definition = (ParserDefinition)e.getInstance(); + IFileElementType type = definition.getFileNodeType(); + Language language = type.getLanguage(); + languageMap.put(language, key); + if (language.getBaseLanguage() != null && !languageMap.containsKey(language.getBaseLanguage())) { + languageMap.put(language.getBaseLanguage(), key); + } try { - IFileElementType type = definition.getFileNodeType(); Lexer lexer = definition.createLexer(getProject()); PsiParser parser = definition.createParser(getProject()); } catch (UnsupportedOperationException e1) { } + + // language-based calculation: per-class-loading stuff commented + //int diff = IElementType.getAllocatedTypesCount() - curCount; + //map.put(key, map.get(key) + diff); } - System.out.println("After: " + IElementType.getAllocatedTypesCount() +" types"); + // language-based calculation + count = IElementType.getAllocatedTypesCount(); + + for (short i = 0; i < count; i ++ ) { + IElementType type = IElementType.find(i); + Language language = type.getLanguage(); + String key = null; + for (Language cur = language; cur != null && key == null; cur = cur.getBaseLanguage()) { + key = languageMap.get(cur); + } + key = StringUtil.notNullize(key, "unknown"); + map.put(key, map.get(key) + 1); + //if (key.equals("unknown")) System.out.println(type +" " + language); + } + System.out.println("Total: " + IElementType.getAllocatedTypesCount() +" element types"); + + // Show per-plugin statistics + Object[] keys = map.keys(); + Arrays.sort(keys, new Comparator() { + @Override + public int compare(Object o1, Object o2) { + return map.get((String)o2) - map.get((String)o1); + } + }); + int sum = 0; + for (Object key : keys) { + int value = map.get((String)key); + if (value == 0) continue; + sum += value; + System.out.println(" " + key + ": " + value); + } + // leave some index-space for plugin developers assertTrue(IElementType.getAllocatedTypesCount() < 10000); + assertEquals(IElementType.getAllocatedTypesCount(), sum); // output on 11.05.2012 - // Before: 3485 types + // Preloaded: 3485 types // 95 definitions - // After: 7694 types + // Total: 7694 types } } From 32b538eae57135133484f4f54ea83fe7125415fd Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Sat, 12 May 2012 17:06:24 +0400 Subject: [PATCH 30/45] IDEA-73251 Mark recursive method calls on gutter partially implemented. Multiple calls on the same line generate multiple icons to be fixed. --- build/order.txt | 1 + .../daemon/impl/JavaLineMarkerProvider.java | 45 ++++++++++++++++++ platform/icons/src/gutter/recursiveMethod.png | Bin 0 -> 490 bytes 3 files changed, 46 insertions(+) create mode 100644 platform/icons/src/gutter/recursiveMethod.png diff --git a/build/order.txt b/build/order.txt index dc0069234894..9fdc720edae0 100644 --- a/build/order.txt +++ b/build/order.txt @@ -10602,6 +10602,7 @@ gutter/overridingMethod.png:/lib/icons.jar gutter/implementingMethod.png:/lib/icons.jar gutter/overridenMethod.png:/lib/icons.jar gutter/implementedMethod.png:/lib/icons.jar +gutter/recursiveMethod.png:/lib/icons.jar com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl$1.class:/lib/idea.jar com/intellij/codeInsight/daemon/impl/IconLineMarkerProvider.class:/lib/idea.jar com/intellij/codeInsight/daemon/impl/IconLineMarkerProvider$1.class:/lib/idea.jar diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java index 4a26b2c25866..90c6fbb7ee13 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java @@ -60,6 +60,8 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware { private static final Icon IMPLEMENTED_INTERFACE_MARKER_RENDERER = IMPLEMENTED_METHOD_MARKER_RENDERER; private static final Icon SUBCLASSED_CLASS_MARKER_RENDERER = OVERRIDEN_METHOD_MARKER_RENDERER; + private static final Icon RECURSIVE_METHOD_ICON = IconLoader.getIcon("/gutter/recursiveMethod.png"); + protected final DaemonCodeAnalyzerSettings myDaemonSettings; protected final EditorColorsManager myColorsManager; @@ -164,6 +166,11 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware { } else if (element instanceof PsiClass && !(element instanceof PsiTypeParameter)) { collectInheritingClasses((PsiClass)element, result); + } else if(element instanceof PsiMethodCallExpression){ + final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element; + if (isRecursiveMethodCall(methodCall)){ + result.add(new RecursiveMethodCallMarkerInfo(methodCall)); + } } } if (!methods.isEmpty()) { @@ -171,6 +178,12 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware { } } + private static boolean isRecursiveMethodCall(@NotNull PsiMethodCallExpression methodCall){ + final PsiMethod referencedMethod = (PsiMethod)methodCall.getMethodExpression().resolve(); + + return referencedMethod.getTextRange().contains(methodCall.getTextRange()); + } + private static void collectInheritingClasses(PsiClass aClass, Collection result) { if (aClass.hasModifierProperty(PsiModifier.FINAL)) { return; @@ -276,4 +289,36 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware { }; } } + + private static class RecursiveMethodCallMarkerInfo extends MergeableLineMarkerInfo { + private RecursiveMethodCallMarkerInfo(@NotNull PsiMethodCallExpression methodCall) { + super(methodCall, + methodCall.getTextRange(), + RECURSIVE_METHOD_ICON, + Pass.UPDATE_OVERRIDEN_MARKERS, + FunctionUtil.constant("Recursive call"), + null, + GutterIconRenderer.Alignment.RIGHT + ); + } + + @Override + public boolean canMergeWith(@NotNull MergeableLineMarkerInfo info) { + if (!(info instanceof RecursiveMethodCallMarkerInfo)) return false; + PsiElement otherElement = info.getElement(); + PsiElement myElement = getElement(); + return otherElement != null && myElement != null; + } + + + @Override + public Icon getCommonIcon(@NotNull List infos) { + return myIcon; + } + + @Override + public Function getCommonTooltip(@NotNull List infos) { + return FunctionUtil.constant("Multiple recursive calls"); + } + } } diff --git a/platform/icons/src/gutter/recursiveMethod.png b/platform/icons/src/gutter/recursiveMethod.png new file mode 100644 index 0000000000000000000000000000000000000000..f74592556633f3f11567b0d865f7092e7bed4701 GIT binary patch literal 490 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iye< z4QB4jel#NZ%5ETT1(Ap9; ziAYnn6*jggLg@3o@4L6be1+kKyByB%{yAV~bnED5&g|3# zy438}#b~vdFLdfI5ME7-NIVn$F`H!9A4oM2iDzQr)wJu=m>Hq@4FTP|uKSE+-)JaQ zE#?bGz_e(Bv04PM(_VXjxK=R+hbGyv+R~23YU%d}qA883^!K@k7&sA{utkqIDLmd%%h(K()7&MdUJY1zy*(w3nE?Rf(@O%tuF&;4;qjV3K$(=f g29PY=oe= Date: Sat, 12 May 2012 17:20:40 +0400 Subject: [PATCH 31/45] IDEA-73251 npe fix --- .../codeInsight/daemon/impl/JavaLineMarkerProvider.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java index 90c6fbb7ee13..df86eee27b19 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java @@ -32,6 +32,7 @@ import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.search.searches.AllOverridingMethodsSearch; import com.intellij.psi.search.searches.ClassInheritorsSearch; @@ -181,6 +182,10 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware { private static boolean isRecursiveMethodCall(@NotNull PsiMethodCallExpression methodCall){ final PsiMethod referencedMethod = (PsiMethod)methodCall.getMethodExpression().resolve(); + if (referencedMethod == null){ + return false; + } + return referencedMethod.getTextRange().contains(methodCall.getTextRange()); } From dfae39c99a264baad66876cce21196aac6d29dde Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 12 May 2012 17:25:12 +0400 Subject: [PATCH 32/45] Add toString to GitMerge/RebaseUpdater for nicer logging. --- plugins/git4idea/src/git4idea/update/GitMergeUpdater.java | 5 +++++ plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java b/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java index 905f520fadb0..1360c937e990 100644 --- a/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java @@ -245,6 +245,11 @@ public class GitMergeUpdater extends GitUpdater { return changes; } + @Override + public String toString() { + return "Merge updater"; + } + private enum MergeError { CONFLICT, LOCAL_CHANGES, diff --git a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java index 32f0418fa0f2..74b7df43e02b 100644 --- a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java @@ -154,6 +154,11 @@ public class GitRebaseUpdater extends GitUpdater { return !cancelled.get(); } + @Override + public String toString() { + return "Rebase updater"; + } + private static class MyConflictResolver extends GitConflictResolver { private final GitRebaser myRebaser; private final VirtualFile myRoot; From b2535b83f67af4fe56036a1169c84a629b98b2a9 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Sat, 12 May 2012 18:31:44 +0400 Subject: [PATCH 33/45] DSGN-113 JPA console toolwindow --- .../src/general/toolWindowDatabaseConsole.png | Bin 570 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 platform/icons/src/general/toolWindowDatabaseConsole.png diff --git a/platform/icons/src/general/toolWindowDatabaseConsole.png b/platform/icons/src/general/toolWindowDatabaseConsole.png deleted file mode 100644 index afe7957df8ed9372b5e8079cf943c127929d4423..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 570 zcmV-A0>%A_P);)0b$)J8Flh#-*^7AXV^o1`${4=6%F2vO1rf`5tU z?d@%{`+m=PZ!bj9!jB!^?C`#sZ)P4ld-?u{q21NKLlusu02&35n7TQEuRnibAPVtd<|!s8YFKNw zac}wwChIkU%&r`moMhf6EHBwaQ)6B62rWt((lSs+Coz=PR8ib z3ij_gw^gbBS0&6ZyajKy8tU-K>F@phJC)0FF2w@l^9vs~ADeg)51B`K87>mJq;CpiY1e}*XePIy%gG2+k zHP?f6+P Date: Sat, 12 May 2012 17:14:44 +0200 Subject: [PATCH 34/45] there is no point in collecting data if fs rescan is needed --- .../com/intellij/compiler/server/BuildManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index 694e701848f5..f6d50ba7fc91 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -834,13 +834,17 @@ public class BuildManager implements ApplicationComponent{ } public void addChanged(Collection paths) { - myDeleted.removeAll(paths); - myChanged.addAll(paths); + if (!myNeedRescan) { + myDeleted.removeAll(paths); + myChanged.addAll(paths); + } } public void addDeleted(Collection paths) { - myChanged.removeAll(paths); - myDeleted.addAll(paths); + if (!myNeedRescan) { + myChanged.removeAll(paths); + myDeleted.addAll(paths); + } } public CmdlineRemoteProto.Message.ControllerMessage.FSEvent createNextEvent() { From fe7611e1298afddd3df67124fc172ccea5f9c45c Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 10 May 2012 13:49:34 +0400 Subject: [PATCH 35/45] highlighting for caught exceptions --- .../plugins/groovy/GroovyBundle.properties | 3 + .../groovy/annotator/GroovyAnnotator.java | 65 +++++++++++++++++++ .../groovy/lang/GroovyHighlightingTest.groovy | 48 ++++++++++++++ 3 files changed, 116 insertions(+) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties index 7aa4e6d9fdc7..8e7de64218df 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties @@ -308,3 +308,6 @@ closure.is.too.complex.to.analyze=Closure is complex to analyze.\nTypes of local create.parameter.from.usage=Create Parameter ''{0}'' wrong.number.of.type.arguments=Wrong number of type arguments\: {0}; required\: {1} type.argument.0.is.not.in.its.bound.should.extend.1=Type parameter ''{0}'' is not in its bound; should extend ''{1}'' +catch.statement.parameter.type.should.be.a.subclass.of.throwable=Catch statement parameter type should be a subclass of Throwable +exception.0.has.already.been.caught=Exception ''{0}'' has already been caught +unnecessary.type=Unnecessary exception ''{0}''. ''{1}'' is already declared diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index ca1e094f3b91..af683cbe996c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -227,6 +227,71 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { } } + @Override + public void visitTryStatement(GrTryCatchStatement statement) { + final GrCatchClause[] clauses = statement.getCatchClauses(); + List usedExceptions = new ArrayList(); + + final PsiClassType throwable = PsiType.getJavaLangThrowable(statement.getManager(), statement.getResolveScope()); + + for (GrCatchClause clause : clauses) { + final GrParameter parameter = clause.getParameter(); + if (parameter == null) continue; + + final GrTypeElement typeElement = parameter.getTypeElementGroovy(); + + PsiType type = typeElement != null ? typeElement.getType() : null; + if (type == null) { + type = throwable; + } + + if (!throwable.isAssignableFrom(type)) { + LOG.assertTrue(typeElement != null); + myHolder.createErrorAnnotation(typeElement, + GroovyBundle.message("catch.statement.parameter.type.should.be.a.subclass.of.throwable")); + continue; + } + + if (typeElement instanceof GrDisjunctionTypeElement) { + final GrTypeElement[] elements = ((GrDisjunctionTypeElement)typeElement).getTypeElements(); + PsiType[] types = new PsiType[elements.length]; + for (int i = 0; i < elements.length; i++) { + types[i] = elements[i].getType(); + } + + List usedInsideDisjunction = new ArrayList(); + for (int i = 0; i < types.length; i++) { + if (checkExceptionUsed(usedExceptions, parameter, elements[i], types[i])) { + usedInsideDisjunction.add(types[i]); + for (int j = 0; j < types.length; j++) { + if (i != j && types[j].isAssignableFrom(types[i])) { + myHolder.createWarningAnnotation(elements[i], GroovyBundle.message("unnecessary.type", types[i].getCanonicalText(), + types[j].getCanonicalText())); + } + } + } + } + + usedExceptions.addAll(usedInsideDisjunction); + } + else { + if (checkExceptionUsed(usedExceptions, parameter, typeElement, type)) { + usedExceptions.add(type); + } + } + } + } + + private boolean checkExceptionUsed(List usedExceptions, GrParameter parameter, GrTypeElement typeElement, PsiType type) { + for (PsiType exception : usedExceptions) { + if (exception.isAssignableFrom(type)) { + myHolder.createWarningAnnotation(typeElement != null ? typeElement : parameter.getNameIdentifierGroovy(), GroovyBundle.message("exception.0.has.already.been.caught", type.getCanonicalText())); + return false; + } + } + return true; + } + @Override public void visitReferenceExpression(final GrReferenceExpression referenceExpression) { checkStringNameIdentifier(referenceExpression); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy index 2e24f7a14738..ec7ff165c658 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy @@ -936,4 +936,52 @@ def test() { } ''', GroovyAssignabilityCheckInspection) } + + void testTryCatch1() { + testHighlighting('''\ +try {} +catch (Exception e){} +catch (IOException e){} +''') + } + + void testTryCatch2() { + testHighlighting('''\ +try {} +catch (e){} +catch (e){} +''') + } + + void testTryCatch3() { + testHighlighting('''\ +try {} +catch (e){} +catch (IOException e){} +''') + } + + void testTryCatch4() { + testHighlighting('''\ +try {} +catch (Exception | IOException e){} +''') + } + + void testTryCatch5() { + testHighlighting('''\ +try {} +catch (RuntimeException | IOException e){} +catch (NullPointerException e){} +''') + } + + void testTryCatch6() { + testHighlighting('''\ +try {} +catch (NullPointerException | IOException e){} +catch (ClassNotFoundException | NullPointerException e){} +''') + } + } \ No newline at end of file From 1b2f0ba825b0c5802e42fcc93ae0423528d104c8 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 10 May 2012 15:04:03 +0400 Subject: [PATCH 36/45] 'rename to ignored' fix for unused catch parameters --- .../GroovyUnusedCatchParameterInspection.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/exception/GroovyUnusedCatchParameterInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/exception/GroovyUnusedCatchParameterInspection.java index 7c6165eaeeab..9747d550e422 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/exception/GroovyUnusedCatchParameterInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/exception/GroovyUnusedCatchParameterInspection.java @@ -15,9 +15,12 @@ */ package org.jetbrains.plugins.groovy.codeInspection.exception; +import com.intellij.codeInsight.daemon.impl.quickfix.RenameElementFix; +import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemHighlightType; +import com.intellij.psi.PsiElement; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.codeInspection.BaseInspection; import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrCatchClause; @@ -42,12 +45,6 @@ public class GroovyUnusedCatchParameterInspection extends BaseInspection { return "Unused catch parameter"; } - @Nullable - protected String buildErrorString(Object... args) { - return "Unused catch parameter '#ref' #loc"; - - } - public BaseInspectionVisitor buildVisitor() { return new Visitor(); } @@ -71,7 +68,9 @@ public class GroovyUnusedCatchParameterInspection extends BaseInspection { final CatchParameterUsedVisitor visitor = new CatchParameterUsedVisitor(parameter); block.accept(visitor); if (!visitor.isUsed()) { - registerVariableError(parameter); + final PsiElement nameIdentifier = parameter.getNameIdentifierGroovy(); + registerError(nameIdentifier, "Unused catch parameter '#ref' #loc", new LocalQuickFix[]{new RenameElementFix(parameter, "ignored")}, + ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } } From ff3be16d675a86aa29bc6850ed5930c8b8ef08ca Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 10 May 2012 15:07:48 +0400 Subject: [PATCH 37/45] 'remove catch block' fix for groovy --- .../groovy/annotator/GroovyAnnotator.java | 5 +- .../intentions/GrRemoveExceptionFix.java | 108 ++++++++++++++++++ .../GroovyIntentionsBundle.properties | 5 +- .../types/GrDisjunctionTypeElementImpl.java | 26 +++++ 4 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrRemoveExceptionFix.java diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index af683cbe996c..0ce3941bd63d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -266,7 +266,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { for (int j = 0; j < types.length; j++) { if (i != j && types[j].isAssignableFrom(types[i])) { myHolder.createWarningAnnotation(elements[i], GroovyBundle.message("unnecessary.type", types[i].getCanonicalText(), - types[j].getCanonicalText())); + types[j].getCanonicalText())).registerFix(new GrRemoveExceptionFix(true)); } } } @@ -285,7 +285,8 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { private boolean checkExceptionUsed(List usedExceptions, GrParameter parameter, GrTypeElement typeElement, PsiType type) { for (PsiType exception : usedExceptions) { if (exception.isAssignableFrom(type)) { - myHolder.createWarningAnnotation(typeElement != null ? typeElement : parameter.getNameIdentifierGroovy(), GroovyBundle.message("exception.0.has.already.been.caught", type.getCanonicalText())); + myHolder.createWarningAnnotation(typeElement != null ? typeElement : parameter.getNameIdentifierGroovy(),GroovyBundle.message("exception.0.has.already.been.caught", type.getCanonicalText())) + .registerFix(new GrRemoveExceptionFix(parameter.getTypeElementGroovy() instanceof GrDisjunctionTypeElement)); return false; } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrRemoveExceptionFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrRemoveExceptionFix.java new file mode 100644 index 000000000000..9402f682e1e3 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrRemoveExceptionFix.java @@ -0,0 +1,108 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.annotator.intentions; + +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrCatchClause; +import org.jetbrains.plugins.groovy.lang.psi.api.types.GrDisjunctionTypeElement; +import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement; + +/** + * @author Max Medvedev + */ +public class GrRemoveExceptionFix implements IntentionAction { + private String myText; + private final boolean myDisjunction; + + public GrRemoveExceptionFix(boolean isDisjunction) { + myDisjunction = isDisjunction; + if (isDisjunction) { + myText = GroovyIntentionsBundle.message("remove.exception"); + } + else { + myText = GroovyIntentionsBundle.message("remove.catch.block"); + } + } + + @NotNull + @Override + public String getText() { + return myText; + } + + @NotNull + @Override + public String getFamilyName() { + return GroovyIntentionsBundle.message("try.catch.fix"); + } + + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + return myDisjunction && findTypeElementInDisjunction(editor, file) != null || !myDisjunction && findCatch(editor, file) != null; + } + + @Nullable + private static GrTypeElement findTypeElementInDisjunction(Editor editor, PsiFile file) { + final int offset = editor.getCaretModel().getOffset(); + final PsiElement at = file.findElementAt(offset); + final GrDisjunctionTypeElement disjunction = PsiTreeUtil.getParentOfType(at, GrDisjunctionTypeElement.class); + if (disjunction == null) return null; + for (GrTypeElement element : disjunction.getTypeElements()) { + if (element.getTextRange().contains(offset)) { + return element; + } + } + return null; + } + + @Nullable + private static GrCatchClause findCatch(Editor editor, PsiFile file) { + final int offset = editor.getCaretModel().getOffset(); + final PsiElement at = file.findElementAt(offset); + return PsiTreeUtil.getParentOfType(at, GrCatchClause.class); + } + + + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + if (myDisjunction) { + final GrTypeElement element = findTypeElementInDisjunction(editor, file); + if (element != null) { + element.delete(); + } + } + else { + final GrCatchClause aCatch = findCatch(editor, file); + if (aCatch != null) { + aCatch.delete(); + } + } + } + + @Override + public boolean startInWriteAction() { + return true; + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties index 7e388d2f9f6d..00d90c07f79d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties @@ -149,4 +149,7 @@ split.into.declaration.and.assignment=Split into declaration and assignment split.into.separate.declaration=Split into separate declaration gr.split.declaration.family.name=Split Variable Declaration remove.parameter.0=Remove parameter ''{0}'' -remove.unused.parameter=Remove unused parameter \ No newline at end of file +remove.unused.parameter=Remove unused parameter +remove.exception=Remove exception +remove.catch.block=Remove catch block +try.catch.fix=Try-catch fix \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrDisjunctionTypeElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrDisjunctionTypeElementImpl.java index e6cdd85cf07f..1c79f9fbf112 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrDisjunctionTypeElementImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrDisjunctionTypeElementImpl.java @@ -17,11 +17,14 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.types; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiDisjunctionType; +import com.intellij.psi.PsiElement; import com.intellij.psi.PsiType; import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrDisjunctionTypeElement; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement; import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl; +import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; import java.util.ArrayList; @@ -69,4 +72,27 @@ public class GrDisjunctionTypeElementImpl extends GroovyPsiElementImpl implement public String toString() { return "disjunction type element"; } + + @Override + public void deleteChildInternal(@NotNull ASTNode child) { + final PsiElement psi = child.getPsi(); + if (psi instanceof GrTypeElement) { + PsiElement next = PsiUtil.skipWhitespaces(psi.getNextSibling(), true); + if (next != null) { + if (next.getNode().getElementType() == GroovyTokenTypes.mBOR) { + super.deleteChildInternal(next.getNode()); + } + } + else { + PsiElement prev = PsiUtil.skipWhitespaces(psi.getPrevSibling(), false); + if (prev != null) { + if (prev.getNode().getElementType() == GroovyTokenTypes.mBOR) { + super.deleteChildInternal(prev.getNode()); + } + } + } + } + + super.deleteChildInternal(child); + } } From c7b955e67df34912b349abf15a97d90f95d73753 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 10 May 2012 17:22:25 +0400 Subject: [PATCH 38/45] IDEA-48857 The property "class" is shown as reserved word --- .../groovy/lang/lexer/GroovyLexer.java | 28 +++++++++++++++++-- .../groovy/annotations/classLiteral.test | 2 +- .../expressions/path/method/clazz1.test | 2 +- .../expressions/path/method/clazz2.test | 2 +- .../groovy/expressions/path/path10.test | 2 +- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java index 1a812794adfc..7d705c9f8db3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java @@ -47,15 +47,23 @@ public class GroovyLexer extends LookAheadLexer { @Override protected void lookAhead(Lexer baseLexer) { final IElementType type = baseLexer.getTokenType(); - if (type == mDOT || type == kIMPORT || type == kPACKAGE) { + if (TokenSets.DOTS.contains(type) || type == kIMPORT || type == kPACKAGE) { addToken(type); baseLexer.advance(); while (baseLexer.getTokenType() == WHITE_SPACE) { addToken(WHITE_SPACE); baseLexer.advance(); } + if (TokenSets.DOTS.contains(type) && baseLexer.getTokenType()==mAT) { + addToken(mAT); + baseLexer.advance(); + while (baseLexer.getTokenType() == WHITE_SPACE) { + addToken(WHITE_SPACE); + baseLexer.advance(); + } + } final IElementType token = baseLexer.getTokenType(); - if (token == kDEF || token == kAS || token == kIN) { + if (shouldBeIdent(type, token)) { addToken(mIDENT); baseLexer.advance(); } @@ -68,4 +76,20 @@ public class GroovyLexer extends LookAheadLexer { super.lookAhead(baseLexer); } } + + private static boolean shouldBeIdent(IElementType type, IElementType token) { + if (!TokenSets.KEYWORDS.contains(token)) return false; + + if (TokenSets.DOTS.contains(type)) { + return token != kTHIS && token != kSUPER && token != kNEW; + } + else if (type == kIMPORT) { + return token != kSTATIC; + } + else if (type == kPACKAGE) { + return true; + } + + return false; + } } diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test b/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test index f9f1701d9a4f..15a582580489 100644 --- a/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test +++ b/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test @@ -16,7 +16,7 @@ Groovy script Reference expression PsiElement(identifier)('foo') PsiElement(.)('.') - PsiElement(class)('class') + PsiElement(identifier)('class') PsiElement())(')') PsiElement(new line)('\n') PsiElement(def)('def') diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz1.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz1.test index e2d193357273..7b00da6d057f 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz1.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz1.test @@ -12,4 +12,4 @@ Groovy script PsiElement(Integer)('2') PsiElement())(')') PsiElement(?.)('?.') - PsiElement(class)('class') \ No newline at end of file + PsiElement(identifier)('class') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz2.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz2.test index c805f981a0f0..6053265a1f4e 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz2.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz2.test @@ -13,7 +13,7 @@ Groovy script PsiElement(Integer)('2') PsiElement())(')') PsiElement(?.)('?.') - PsiElement(class)('class') + PsiElement(identifier)('class') Arguments PsiElement(()('(') Literal diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/path10.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/path10.test index 995e8b373e89..2d6b507182f2 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/path/path10.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/path10.test @@ -10,4 +10,4 @@ Groovy script 'this' reference expression PsiElement(this)('this') PsiElement(.)('.') - PsiElement(final)('final') \ No newline at end of file + PsiElement(identifier)('final') \ No newline at end of file From 86fe64c310e4ab959f87ce525b3b96ca27bbd343 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Fri, 11 May 2012 12:08:28 +0400 Subject: [PATCH 39/45] gdsl 'delegatesTo' should process non code members too (IDEA-63554) --- .../dsl/dsltop/GroovyDslDefaultMembers.java | 35 ++++++++++++++----- .../findUsages/GDKSuperMethodSearcher.java | 24 +++++++------ .../lang/resolve/ResolveMethodTest.groovy | 27 ++++++++++++++ 3 files changed, 67 insertions(+), 19 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/dsltop/GroovyDslDefaultMembers.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/dsltop/GroovyDslDefaultMembers.java index 2356aa7fc8c3..431242407143 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/dsltop/GroovyDslDefaultMembers.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/dsltop/GroovyDslDefaultMembers.java @@ -22,6 +22,8 @@ import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.dsl.GdslMembersHolderConsumer; import org.jetbrains.plugins.groovy.dsl.holders.DelegatedMembersHolder; +import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; +import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall; @@ -29,6 +31,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; +import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; +import org.jetbrains.plugins.groovy.lang.resolve.processors.CompletionProcessor; +import org.jetbrains.plugins.groovy.lang.resolve.processors.ResolverProcessor; /** * @author ilyas @@ -37,7 +43,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrM public class GroovyDslDefaultMembers implements GdslMembersProvider { /** - * Find a class by its full-qulified name + * Find a class by its full-qualified name * * @param fqn * @return @@ -45,8 +51,7 @@ public class GroovyDslDefaultMembers implements GdslMembersProvider { @Nullable public PsiClass findClass(String fqn, GdslMembersHolderConsumer consumer) { final JavaPsiFacade facade = JavaPsiFacade.getInstance(consumer.getProject()); - final PsiClass clazz = facade.findClass(fqn, GlobalSearchScope.allScope(consumer.getProject())); - return clazz; + return facade.findClass(fqn, GlobalSearchScope.allScope(consumer.getProject())); } /** @@ -59,11 +64,26 @@ public class GroovyDslDefaultMembers implements GdslMembersProvider { if (elem instanceof PsiClass) { final PsiClass clazz = (PsiClass)elem; final DelegatedMembersHolder holder = new DelegatedMembersHolder(); - for (PsiMethod method : clazz.getAllMethods()) { - if (!method.isConstructor()) holder.addMember(method); + + if (clazz instanceof GrTypeDefinition) { + final PsiClassType type = JavaPsiFacade.getElementFactory(consumer.getProject()).createType(clazz); + final ResolverProcessor processor = CompletionProcessor.createPropertyCompletionProcessor(clazz); + final GroovyPsiElement context = (GroovyPsiElement)clazz; + ResolveUtil.processAllDeclarations(type, processor, ResolveState.initial(), context); + for (GroovyResolveResult result : processor.getCandidates()) { + final PsiElement element = result.getElement(); + if (element instanceof PsiMethod && !((PsiMethod)element).isConstructor() || element instanceof PsiField) { + holder.addMember((PsiMember)element); + } + } } - for (PsiField field : clazz.getAllFields()) { - holder.addMember(field); + else { + for (PsiMethod method : clazz.getAllMethods()) { + if (!method.isConstructor()) holder.addMember(method); + } + for (PsiField field : clazz.getAllFields()) { + holder.addMember(field); + } } consumer.addMemberHolder(holder); } @@ -155,5 +175,4 @@ public class GroovyDslDefaultMembers implements GdslMembersProvider { } return null; } - } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GDKSuperMethodSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GDKSuperMethodSearcher.java index d01a30372ffa..3e604a744937 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GDKSuperMethodSearcher.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GDKSuperMethodSearcher.java @@ -65,25 +65,23 @@ public class GDKSuperMethodSearcher implements QueryExecutor allMethods = new ArrayList(); + final PsiManager psiManager = PsiManager.getInstance(project); + + final MethodSignature signature = method.getHierarchicalMethodSignature(); + List goodSupers = new ArrayList(); + for (GroovyResolveResult candidate : candidates) { final PsiElement element = candidate.getElement(); if (element instanceof PsiMethod) { - allMethods.add((PsiMethod)element); + final PsiMethod m = (PsiMethod)element; + if (!isTheSameMethod(method, psiManager, m) && PsiImplUtil.isExtendsSignature(m.getHierarchicalMethodSignature(), signature)) { + goodSupers.add(m); + } } } - final MethodSignature signature = method.getHierarchicalMethodSignature(); - - List goodSupers = new ArrayList(); - for (PsiMethod m : allMethods) { - if (PsiImplUtil.isExtendsSignature(m.getHierarchicalMethodSignature(), signature)) { - goodSupers.add(m); - } - } if (goodSupers.size() == 0) return true; - final PsiManager psiManager = PsiManager.getInstance(project); final GlobalSearchScope searchScope = GlobalSearchScope.allScope(project); List result = new ArrayList(goodSupers.size()); @@ -125,6 +123,10 @@ public class GDKSuperMethodSearcher implements QueryExecutor 0) { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy index 4229d595fd73..36e275396735 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy @@ -1026,4 +1026,31 @@ foo() assertNotNull(ref.resolve()) } + + public void testMixin() { + def ref = configureByText('''\ +@Mixin([Category1, Category2]) +class A { + def test1(){} +} + + +@Category(A) +class Category1 { + boolean foo() { + true + + } +} + +@Category(A) +class Category2 { + void bar() { + foo() + } +} +''') + assertNotNull(ref.resolve()) + } + } From 359b946d21f55535a1f077b8acefd7fc0ee7d86e Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Sat, 12 May 2012 14:58:07 +0400 Subject: [PATCH 40/45] highlighting for keyword in Groovy via annotator --- .../groovy/annotator/GroovyAnnotator.java | 25 +++++++- .../highlighter/GroovySyntaxHighlighter.java | 4 +- .../groovy/lang/lexer/GroovyLexer.java | 53 +--------------- .../plugins/groovy/lang/lexer/TokenSets.java | 3 +- .../primary/PrimaryExpression.java | 4 +- .../statements/imports/ImportReference.java | 5 +- .../typeDefinitions/ReferenceElement.java | 7 ++- .../toplevel/packaging/PackageDefinition.java | 9 ++- .../lang/psi/impl/GrReferenceElementImpl.java | 8 +-- .../types/GrCodeReferenceElementImpl.java | 10 ++- .../lang/parser/ExpressionsParsingTest.groovy | 62 ++++++++++++++++++- .../lang/parser/StatementsParsingTest.groovy | 16 ++++- .../InnerClassConstructorThis.groovy | 25 ++++++-- .../ReassignedHighlighting.groovy | 39 ++++++++---- .../groovy/annotations/classLiteral.test | 2 +- .../expressions/path/method/clazz1.test | 2 +- .../expressions/path/method/clazz2.test | 2 +- .../groovy/expressions/path/path10.test | 2 +- .../parsing/groovy/packaging/pack4.test | 2 +- .../parsing/groovy/packaging/pack5.test | 2 +- .../parsing/groovy/packaging/pack6.test | 2 +- .../parsing/groovy/packaging/pack7.test | 2 +- .../parsing/groovy/packaging/pack8.test | 4 +- .../statements/typedef/classes/class9.test | 40 ++++++++++++ 24 files changed, 226 insertions(+), 104 deletions(-) create mode 100644 plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class9.test diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index 0ce3941bd63d..d0f4e3966024 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -130,6 +130,29 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { ((GroovyPsiElement)element).accept(this); myHolder = null; } + else { + final IElementType token = element.getNode().getElementType(); + if (TokenSets.KEYWORDS.contains(token)) { + highlightKeyword(element, holder, token); + } + } + } + + private static void highlightKeyword(PsiElement element, AnnotationHolder holder, IElementType token) { + final PsiElement parent = element.getParent(); + if (parent instanceof GrArgumentLabel) return; //don't highlight: print (void:'foo') + + if (PsiTreeUtil.getParentOfType(element, GrCodeReferenceElement.class) != null) { + if (token == GroovyTokenTypes.kDEF || token == GroovyTokenTypes.kIN || token == GroovyTokenTypes.kAS) { + return; //It is allowed to name packages 'as', 'in' or 'def' + } + } + else if (parent instanceof GrReferenceExpression && element == ((GrReferenceExpression)parent).getReferenceNameElement()) { + return; //don't highlight foo.def + } + + final Annotation annotation = holder.createInfoAnnotation(element, null); + annotation.setTextAttributes(DefaultHighlighter.KEYWORD); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySyntaxHighlighter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySyntaxHighlighter.java index 98c94e263715..04c3ee54f85a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySyntaxHighlighter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovySyntaxHighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -193,7 +193,7 @@ public class GroovySyntaxHighlighter extends SyntaxHighlighterBase implements Gr fillMap(ATTRIBUTES, tLINE_COMMENTS, DefaultHighlighter.LINE_COMMENT); fillMap(ATTRIBUTES, tBLOCK_COMMENTS, DefaultHighlighter.BLOCK_COMMENT); fillMap(ATTRIBUTES, tBAD_CHARACTERS, DefaultHighlighter.BAD_CHARACTER); - fillMap(ATTRIBUTES, tKEYWORDS, DefaultHighlighter.KEYWORD); + //fillMap(ATTRIBUTES, tKEYWORDS, DefaultHighlighter.KEYWORD); fillMap(ATTRIBUTES, tNUMBERS, DefaultHighlighter.NUMBER); fillMap(ATTRIBUTES, tGSTRINGS, DefaultHighlighter.GSTRING); fillMap(ATTRIBUTES, tSTRINGS, DefaultHighlighter.STRING); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java index 7d705c9f8db3..78120390859a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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,10 +16,8 @@ package org.jetbrains.plugins.groovy.lang.lexer; -import com.intellij.lexer.Lexer; import com.intellij.lexer.LookAheadLexer; import com.intellij.lexer.MergingLexerAdapter; -import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; import static com.intellij.psi.TokenType.WHITE_SPACE; @@ -43,53 +41,4 @@ public class GroovyLexer extends LookAheadLexer { public GroovyLexer() { super(new MergingLexerAdapter(new GroovyFlexLexer(), tokensToMerge)); } - - @Override - protected void lookAhead(Lexer baseLexer) { - final IElementType type = baseLexer.getTokenType(); - if (TokenSets.DOTS.contains(type) || type == kIMPORT || type == kPACKAGE) { - addToken(type); - baseLexer.advance(); - while (baseLexer.getTokenType() == WHITE_SPACE) { - addToken(WHITE_SPACE); - baseLexer.advance(); - } - if (TokenSets.DOTS.contains(type) && baseLexer.getTokenType()==mAT) { - addToken(mAT); - baseLexer.advance(); - while (baseLexer.getTokenType() == WHITE_SPACE) { - addToken(WHITE_SPACE); - baseLexer.advance(); - } - } - final IElementType token = baseLexer.getTokenType(); - if (shouldBeIdent(type, token)) { - addToken(mIDENT); - baseLexer.advance(); - } - else { - addToken(token); - baseLexer.advance(); - } - } - else { - super.lookAhead(baseLexer); - } - } - - private static boolean shouldBeIdent(IElementType type, IElementType token) { - if (!TokenSets.KEYWORDS.contains(token)) return false; - - if (TokenSets.DOTS.contains(type)) { - return token != kTHIS && token != kSUPER && token != kNEW; - } - else if (type == kIMPORT) { - return token != kSTATIC; - } - else if (type == kPACKAGE) { - return true; - } - - return false; - } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java index d09ec7ff336d..8fa25ca33ef9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -201,4 +201,5 @@ public abstract class TokenSets { ); public static final TokenSet SHIFT_SIGNS = TokenSet.create(COMPOSITE_LSHIFT_SIGN, COMPOSITE_RSHIFT_SIGN, COMPOSITE_TRIPLE_SHIFT_SIGN); + public static TokenSet CODE_REFERENCE_ELEMENT_NAME_TOKENS = TokenSet.create(mIDENT, kDEF, kIN, kAS); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java index 9fdf7265f8c4..8d284aa997b9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -124,7 +124,7 @@ public class PrimaryExpression implements GroovyElementTypes { if (TokenSets.BUILT_IN_TYPE.contains(builder.getTokenType())) { ParserUtils.eatElement(builder, BUILT_IN_TYPE); } - else if (mIDENT == builder.getTokenType()) { + else if (TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(builder.getTokenType())) { name = builder.getTokenText(); ReferenceElement.parse(builder, false, true, false, true, true); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/imports/ImportReference.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/imports/ImportReference.java index 33fd0beb7821..62381a57c72f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/imports/ImportReference.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/imports/ImportReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.imports; import com.intellij.lang.PsiBuilder; import org.jetbrains.plugins.groovy.GroovyBundle; +import org.jetbrains.plugins.groovy.lang.lexer.TokenSets; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement; import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils; @@ -31,7 +32,7 @@ public class ImportReference implements GroovyElementTypes { public static boolean parse(PsiBuilder builder) { - if (!mIDENT.equals(builder.getTokenType())) { + if (!TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(builder.getTokenType())) { return false; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/ReferenceElement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/ReferenceElement.java index ddfd759b31a3..44cfb76bf8d5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/ReferenceElement.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/ReferenceElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefiniti import com.intellij.codeInsight.completion.CompletionInitializationContext; import com.intellij.lang.PsiBuilder; import com.intellij.psi.tree.IElementType; +import org.jetbrains.plugins.groovy.lang.lexer.TokenSets; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeArguments; import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils; @@ -97,7 +98,7 @@ public class ReferenceElement implements GroovyElementTypes { String lastIdentifier = builder.getTokenText(); - if (!ParserUtils.getToken(builder, mIDENT)) { + if (!ParserUtils.getToken(builder, TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS)) { internalTypeMarker.rollbackTo(); return fail; } @@ -127,7 +128,7 @@ public class ReferenceElement implements GroovyElementTypes { lastIdentifier = builder.getTokenText(); - if (!ParserUtils.getToken(builder, mIDENT)) { + if (!ParserUtils.getToken(builder, TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS)) { internalTypeMarker.rollbackTo(); return fail; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/toplevel/packaging/PackageDefinition.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/toplevel/packaging/PackageDefinition.java index fa6a13e07264..48d539bfd359 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/toplevel/packaging/PackageDefinition.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/toplevel/packaging/PackageDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.lang.parser.parsing.toplevel.packaging; import com.intellij.lang.PsiBuilder; import com.intellij.lang.PsiBuilder.Marker; import org.jetbrains.plugins.groovy.GroovyBundle; +import org.jetbrains.plugins.groovy.lang.lexer.TokenSets; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.modifiers.Modifiers; @@ -40,9 +41,11 @@ public class PackageDefinition implements GroovyElementTypes { pMarker.rollbackTo(); return false; } - if (builder.getTokenType() == mIDENT) { + + if (TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(builder.getTokenType())) { ReferenceElement.parseForPackage(builder); - } else { + } + else { builder.error(GroovyBundle.message("identifier.expected")); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java index 6ae074d56866..e4ec3da4068e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -23,7 +23,6 @@ import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster; -import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; @@ -60,11 +59,6 @@ public abstract class GrReferenceElementImpl extends Groov return null; } - @Nullable - public PsiElement getReferenceNameElement() { - return findChildByType(GroovyTokenTypes.mIDENT); - } - public PsiElement getElement() { return this; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java index baea0b8eb846..239e24f42bc7 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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,6 +30,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.completion.GroovyCompletionUtil; import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement; +import org.jetbrains.plugins.groovy.lang.lexer.TokenSets; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; @@ -92,6 +93,11 @@ public class GrCodeReferenceElementImpl extends GrReferenceElementImplA { - static private class B { - int i - B () { this.i = 42 } - } +class A { +static private class B { +int i +/* + * Copyright 2000-2012 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. + */ +B () { this.i = 42 } +} } \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/ReassignedHighlighting.groovy b/plugins/groovy/testdata/highlighting/ReassignedHighlighting.groovy index 22ba7339ab32..13e1a4495afa 100644 --- a/plugins/groovy/testdata/highlighting/ReassignedHighlighting.groovy +++ b/plugins/groovy/testdata/highlighting/ReassignedHighlighting.groovy @@ -1,15 +1,30 @@ -def method(int param1, int param2) { - int var1 = 0 - int var2 = 1 - int var3 = 1 - if (param1 == 1) { - param2 = var2 = 2 - var3++ +/* + * Copyright 2000-2012 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. + */ +def method(int param1, int param2) { +int var1 = 0 +int var2 = 1 +int var3 = 1 +if (param1 == 1) { +param2 = var2 = 2 +var3++ } - println var1 + - var2 + - param1 + - param2 + println var1 + + var2 + +param1 + + param2 } -method(239, 42) \ No newline at end of file +method(239, 42) \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test b/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test index 15a582580489..f9f1701d9a4f 100644 --- a/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test +++ b/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test @@ -16,7 +16,7 @@ Groovy script Reference expression PsiElement(identifier)('foo') PsiElement(.)('.') - PsiElement(identifier)('class') + PsiElement(class)('class') PsiElement())(')') PsiElement(new line)('\n') PsiElement(def)('def') diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz1.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz1.test index 7b00da6d057f..e2d193357273 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz1.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz1.test @@ -12,4 +12,4 @@ Groovy script PsiElement(Integer)('2') PsiElement())(')') PsiElement(?.)('?.') - PsiElement(identifier)('class') \ No newline at end of file + PsiElement(class)('class') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz2.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz2.test index 6053265a1f4e..c805f981a0f0 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz2.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/clazz2.test @@ -13,7 +13,7 @@ Groovy script PsiElement(Integer)('2') PsiElement())(')') PsiElement(?.)('?.') - PsiElement(identifier)('class') + PsiElement(class)('class') Arguments PsiElement(()('(') Literal diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/path10.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/path10.test index 2d6b507182f2..995e8b373e89 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/path/path10.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/path10.test @@ -10,4 +10,4 @@ Groovy script 'this' reference expression PsiElement(this)('this') PsiElement(.)('.') - PsiElement(identifier)('final') \ No newline at end of file + PsiElement(final)('final') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/packaging/pack4.test b/plugins/groovy/testdata/parsing/groovy/packaging/pack4.test index dc9bb96feabe..e640b0a94ed6 100644 --- a/plugins/groovy/testdata/parsing/groovy/packaging/pack4.test +++ b/plugins/groovy/testdata/parsing/groovy/packaging/pack4.test @@ -11,6 +11,6 @@ Groovy script Reference element PsiElement(identifier)('a') PsiElement(.)('.') - PsiElement(identifier)('def') + PsiElement(def)('def') PsiElement(.)('.') PsiElement(identifier)('b') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/packaging/pack5.test b/plugins/groovy/testdata/parsing/groovy/packaging/pack5.test index b8ba7afd5001..6d065ed18809 100644 --- a/plugins/groovy/testdata/parsing/groovy/packaging/pack5.test +++ b/plugins/groovy/testdata/parsing/groovy/packaging/pack5.test @@ -10,4 +10,4 @@ Groovy script Reference element PsiElement(identifier)('a') PsiElement(.)('.') - PsiElement(identifier)('def') \ No newline at end of file + PsiElement(def)('def') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/packaging/pack6.test b/plugins/groovy/testdata/parsing/groovy/packaging/pack6.test index 8b00b126b0d7..03a5a7f5796c 100644 --- a/plugins/groovy/testdata/parsing/groovy/packaging/pack6.test +++ b/plugins/groovy/testdata/parsing/groovy/packaging/pack6.test @@ -10,4 +10,4 @@ Groovy script Reference element PsiElement(identifier)('a') PsiElement(.)('.') - PsiElement(identifier)('as') \ No newline at end of file + PsiElement(as)('as') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/packaging/pack7.test b/plugins/groovy/testdata/parsing/groovy/packaging/pack7.test index 573511ec8c5a..d7b5200d0f06 100644 --- a/plugins/groovy/testdata/parsing/groovy/packaging/pack7.test +++ b/plugins/groovy/testdata/parsing/groovy/packaging/pack7.test @@ -7,4 +7,4 @@ Groovy script PsiElement(package)('package') PsiWhiteSpace(' ') Reference element - PsiElement(identifier)('as') \ No newline at end of file + PsiElement(as)('as') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/packaging/pack8.test b/plugins/groovy/testdata/parsing/groovy/packaging/pack8.test index eea087b608bc..23e8c664d534 100644 --- a/plugins/groovy/testdata/parsing/groovy/packaging/pack8.test +++ b/plugins/groovy/testdata/parsing/groovy/packaging/pack8.test @@ -8,6 +8,6 @@ Groovy script PsiWhiteSpace(' ') Reference element Reference element - PsiElement(identifier)('def') + PsiElement(def)('def') PsiElement(.)('.') - PsiElement(identifier)('as') \ No newline at end of file + PsiElement(as)('as') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class9.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class9.test new file mode 100644 index 000000000000..50d2ad66cc95 --- /dev/null +++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class9.test @@ -0,0 +1,40 @@ +class a extends def.b implements as.foo.def.in.c {} +----- +Groovy script + Class definition + Modifiers + + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(identifier)('a') + PsiWhiteSpace(' ') + Extends clause + PsiElement(extends)('extends') + PsiWhiteSpace(' ') + Reference element + Reference element + PsiElement(def)('def') + PsiElement(.)('.') + PsiElement(identifier)('b') + PsiWhiteSpace(' ') + Implements clause + PsiElement(implements)('implements') + PsiWhiteSpace(' ') + Reference element + Reference element + Reference element + Reference element + Reference element + PsiElement(as)('as') + PsiElement(.)('.') + PsiElement(identifier)('foo') + PsiElement(.)('.') + PsiElement(def)('def') + PsiElement(.)('.') + PsiElement(in)('in') + PsiElement(.)('.') + PsiElement(identifier)('c') + PsiWhiteSpace(' ') + Type definition body + PsiElement({)('{') + PsiElement(})('}') \ No newline at end of file From b8034b8c3e157e0af8de8137679cbc52fb3a6698 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Sat, 12 May 2012 16:11:48 +0400 Subject: [PATCH 41/45] IDEA-80592 Groovy: 'Assignment is not used' inspection should mark right part of assignment statement instead of variable name. --- .../unusedDef/UnusedDefInspection.java | 4 +-- .../DefinitionUsedInSwitchCase.groovy | 20 +++++++++-- .../highlighting/IfIncrementElseReturn.groovy | 35 ++++++++++++------- .../highlighting/SwitchControlFlow.groovy | 17 ++++++++- .../highlighting/UnusedVariable.groovy | 17 ++++++++- .../highlighting/UsageInInjection.groovy | 17 ++++++++- .../VeryLongDfaWithComplexGenerics.groovy | 17 ++++++++- 7 files changed, 106 insertions(+), 21 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java index 4bb6ad43dfae..8cd3b620ca1e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -147,7 +147,7 @@ public class UnusedDefInspection extends GroovyLocalInspectionBase { } } else if (element instanceof GrVariable) { - toHighlight = ((GrVariable)element).getNameIdentifierGroovy(); + toHighlight = ((GrVariable)element).getInitializerGroovy(); } if (toHighlight == null) toHighlight = element; return toHighlight; diff --git a/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy b/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy index e864e59f0b8e..13e53c057995 100644 --- a/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy +++ b/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy @@ -1,9 +1,23 @@ +/* + * Copyright 2000-2012 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. + */ def m = [a: 1, b: 2] -def m1 = [a: 1, b: 2] +def m1 = [a: 1, b: 2] def val = 'a' switch (val) { case m: "key in map"; break // equivalent to case { val in m }: ... - default: "not in map" -} \ No newline at end of file +default: "not in map" diff --git a/plugins/groovy/testdata/highlighting/IfIncrementElseReturn.groovy b/plugins/groovy/testdata/highlighting/IfIncrementElseReturn.groovy index 04e1d86bc2e5..db5b2008f5c6 100644 --- a/plugins/groovy/testdata/highlighting/IfIncrementElseReturn.groovy +++ b/plugins/groovy/testdata/highlighting/IfIncrementElseReturn.groovy @@ -1,13 +1,24 @@ -int numPermutationsPrinted = 1; - for ( int pos_right = 2; pos_right <= n; pos_right++ ) { +/* + * Copyright 2000-2012 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. + */ +def m = [a: 1, b: 2] +def m1 = [a: 1, b: 2] +def val = 'a' - if (numPermutationsPrinted++ < 30) - { - println "a" - } - else - return - - } - -def x = 2 \ No newline at end of file +switch (val) { + case m: "key in map"; break +// equivalent to case { val in m }: ... +default: "not in map" +} \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/SwitchControlFlow.groovy b/plugins/groovy/testdata/highlighting/SwitchControlFlow.groovy index 29ae1c4cb2d2..bd45c16a39d4 100644 --- a/plugins/groovy/testdata/highlighting/SwitchControlFlow.groovy +++ b/plugins/groovy/testdata/highlighting/SwitchControlFlow.groovy @@ -1,7 +1,22 @@ +/* + * Copyright 2000-2012 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. + */ def testV(def variable) { def v = "s" def m="10" - def x="10" + def x="10" try { switch (variable) { case 1: diff --git a/plugins/groovy/testdata/highlighting/UnusedVariable.groovy b/plugins/groovy/testdata/highlighting/UnusedVariable.groovy index 0ea69f992bde..d4b0eb0364cb 100644 --- a/plugins/groovy/testdata/highlighting/UnusedVariable.groovy +++ b/plugins/groovy/testdata/highlighting/UnusedVariable.groovy @@ -1 +1,16 @@ -Class clazz = null \ No newline at end of file +/* + * Copyright 2000-2012 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 clazz = null \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/UsageInInjection.groovy b/plugins/groovy/testdata/highlighting/UsageInInjection.groovy index 2d222f6d5511..5840ca40e0e8 100644 --- a/plugins/groovy/testdata/highlighting/UsageInInjection.groovy +++ b/plugins/groovy/testdata/highlighting/UsageInInjection.groovy @@ -1,5 +1,20 @@ +/* + * Copyright 2000-2012 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. + */ def x = new Date() def y = new Date() -def z = new Date() +def z = new Date() assert false : "should have thrown exception, but returned $x" assert false : "should have thrown exception, but returned ${y}" \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/VeryLongDfaWithComplexGenerics.groovy b/plugins/groovy/testdata/highlighting/VeryLongDfaWithComplexGenerics.groovy index cebbb202aab5..1d67e40d8e71 100644 --- a/plugins/groovy/testdata/highlighting/VeryLongDfaWithComplexGenerics.groovy +++ b/plugins/groovy/testdata/highlighting/VeryLongDfaWithComplexGenerics.groovy @@ -1,10 +1,25 @@ +/* + * Copyright 2000-2012 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 TroubleCase { private Foo fooBar; private Foo fooBaz; private void troubleMethod(boolean b) { - def icDao = (b?fooBaz:fooBar); + def icDao = (b?fooBaz:fooBar); for(Object x: new ArrayList()) { } From 7d8bc987a161d5f1f36ad5277908308b5647fc8b Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Sat, 12 May 2012 16:31:30 +0400 Subject: [PATCH 42/45] IDEA-80592 Groovy: 'Assignment is not used' inspection should mark right part of assignment statement instead of variable name. --- .../testdata/highlighting/DefinitionUsedInSwitchCase.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy b/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy index 13e53c057995..db5b2008f5c6 100644 --- a/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy +++ b/plugins/groovy/testdata/highlighting/DefinitionUsedInSwitchCase.groovy @@ -21,3 +21,4 @@ switch (val) { case m: "key in map"; break // equivalent to case { val in m }: ... default: "not in map" +} \ No newline at end of file From aa27329967970bc6e32019ba254c4b83bd762fb2 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Sat, 12 May 2012 17:32:10 +0400 Subject: [PATCH 43/45] fix minimum size for 'Generate GroovyDoc' dialog --- .../plugins/groovy/doc/GroovyDocGenerationPanel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocGenerationPanel.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocGenerationPanel.java index ed9137abe44e..194d2165e3d1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocGenerationPanel.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocGenerationPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -75,7 +75,7 @@ public final class GroovyDocGenerationPanel extends JPanel { actionToolbar.updateActionsImmediately(); - myPanel.setMinimumSize(new Dimension(-1, 350)); + myPanel.setMinimumSize(new Dimension(275, 350)); } private ActionGroup getActionGroup() { From a0f2dfb96e247443f43400a3a5634ee5e2d0ffbd Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Sat, 12 May 2012 19:04:36 +0400 Subject: [PATCH 44/45] formatting --- .../groovy/lang/groovydoc/lexer/gdoc.flex | 93 +++++++++++-------- 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/lexer/gdoc.flex b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/lexer/gdoc.flex index d587bed073fe..80f95491eb07 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/lexer/gdoc.flex +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/lexer/gdoc.flex @@ -77,48 +77,63 @@ IDENTIFIER={ALPHA}({ALPHA}|{DIGIT}|[":.-"])* %% - "/**" { yybegin(COMMENT_DATA_START); return mGDOC_COMMENT_START; } - {WHITE_DOC_SPACE_CHAR}+ { return WHITE_SPACE; } - {WHITE_DOC_SPACE_NO_NL}+ { return mGDOC_COMMENT_DATA; } - [\n\r]+{WHITE_DOC_SPACE_CHAR}* { return WHITE_SPACE; } + "/**" { yybegin(COMMENT_DATA_START); + return mGDOC_COMMENT_START; } + {WHITE_DOC_SPACE_CHAR}+ { return WHITE_SPACE; } + {WHITE_DOC_SPACE_NO_NL}+ { return mGDOC_COMMENT_DATA; } + [\n\r]+{WHITE_DOC_SPACE_CHAR}* { return WHITE_SPACE; } - {WHITE_DOC_SPACE_CHAR}+ { yybegin(COMMENT_DATA); return WHITE_SPACE; } - ({ALPHA}|[_0-9\."$"\[\]])+ { return mGDOC_TAG_VALUE_TOKEN; } - [\(] { yybegin(DOC_TAG_VALUE_IN_PAREN); return mGDOC_TAG_VALUE_LPAREN; } - [\)] { yybegin(DOC_TAG_VALUE); return mGDOC_TAG_VALUE_RPAREN; } - [#] { return mGDOC_TAG_VALUE_SHARP_TOKEN; } - [,] { return mGDOC_TAG_VALUE_COMMA; } - {WHITE_DOC_SPACE_CHAR}+ { return WHITE_SPACE; } + {WHITE_DOC_SPACE_CHAR}+ { yybegin(COMMENT_DATA); + return WHITE_SPACE; } + ({ALPHA}|[_0-9\."$"\[\]])+ { return mGDOC_TAG_VALUE_TOKEN; } + [\(] { yybegin(DOC_TAG_VALUE_IN_PAREN); + return mGDOC_TAG_VALUE_LPAREN; } + [\)] { yybegin(DOC_TAG_VALUE); + return mGDOC_TAG_VALUE_RPAREN; } + [#] { return mGDOC_TAG_VALUE_SHARP_TOKEN; } + [,] { return mGDOC_TAG_VALUE_COMMA; } + {WHITE_DOC_SPACE_CHAR}+ { return WHITE_SPACE; } - "@param" { yybegin(PARAM_TAG_SPACE); return mGDOC_TAG_NAME; } - {WHITE_DOC_SPACE_CHAR}+ {yybegin(DOC_TAG_VALUE); return WHITE_SPACE;} - [\<] { yybegin(DOC_TAG_VALUE_IN_LTGT); return mGDOC_TAG_VALUE_LT; } - {IDENTIFIER} { return mGDOC_TAG_VALUE_TOKEN; } - [\>] { yybegin(COMMENT_DATA); return mGDOC_TAG_VALUE_GT; } + "@param" { yybegin(PARAM_TAG_SPACE); + return mGDOC_TAG_NAME; } + {WHITE_DOC_SPACE_CHAR}+ { yybegin(DOC_TAG_VALUE); + return WHITE_SPACE;} + [\<] { yybegin(DOC_TAG_VALUE_IN_LTGT); + return mGDOC_TAG_VALUE_LT; } + {IDENTIFIER} { return mGDOC_TAG_VALUE_TOKEN; } + [\>] { yybegin(COMMENT_DATA); + return mGDOC_TAG_VALUE_GT; } - "{" { - if (checkAhead('@')){ - yybegin(INLINE_TAG_NAME); - } - else{ - yybegin(COMMENT_DATA); - } - return mGDOC_INLINE_TAG_START; -} - "@"{IDENTIFIER} { yybegin(TAG_DOC_SPACE); return mGDOC_TAG_NAME; } - "}" { yybegin(COMMENT_DATA); return mGDOC_INLINE_TAG_END; } + "{" { if (checkAhead('@')){ + yybegin(INLINE_TAG_NAME); + } + else{ + yybegin(COMMENT_DATA); + } + return mGDOC_INLINE_TAG_START; + } + + "@"{IDENTIFIER} { yybegin(TAG_DOC_SPACE); + return mGDOC_TAG_NAME; } + "}" { yybegin(COMMENT_DATA); + return mGDOC_INLINE_TAG_END; } - . { yybegin(COMMENT_DATA); return mGDOC_COMMENT_DATA; } - "@"{IDENTIFIER} { yybegin(TAG_DOC_SPACE); return mGDOC_TAG_NAME; } - {WHITE_DOC_SPACE_CHAR}+ { + . { yybegin(COMMENT_DATA); + return mGDOC_COMMENT_DATA; } + "@"{IDENTIFIER} { yybegin(TAG_DOC_SPACE); + return mGDOC_TAG_NAME; } + {WHITE_DOC_SPACE_CHAR}+ { if (checkAhead('<') || checkAhead('\"')) { + yybegin(COMMENT_DATA); + } + else if (checkAhead('\u007b') ) { + yybegin(COMMENT_DATA); //lbrace - there's some error in JLex when typing lbrace directly + } + else { + yybegin(DOC_TAG_VALUE); + } + return WHITE_SPACE; + } - if (checkAhead('<') || checkAhead('\"')) yybegin(COMMENT_DATA); - else if (checkAhead('\u007b') ) yybegin(COMMENT_DATA); //lbrace - there's some error in JLex when typing lbrace directly - else yybegin(DOC_TAG_VALUE); - - return WHITE_SPACE; -} - -"*"+"/" { return mGDOC_COMMENT_END; } -[^] { return mGDOC_COMMENT_BAD_CHARACTER; } \ No newline at end of file +"*"+"/" { return mGDOC_COMMENT_END; } +[^] { return mGDOC_COMMENT_BAD_CHARACTER; } \ No newline at end of file From 384f74039e32c3a9953dbd42238763256facc654 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Sat, 12 May 2012 19:50:54 +0400 Subject: [PATCH 45/45] IDEA-85594 Groovy: Javadoc @link makes no use of method arguments --- .../GroovyCompletionContributor.java | 3 +- .../GroovyDocCompletionProvider.java | 85 +++++++++++++ .../GroovyMethodSignatureInsertHandler.java | 120 ++++++++++++++++++ .../psi/api/GrDocMemberReference.java | 8 +- .../psi/impl/GrDocFieldReferenceImpl.java | 5 +- .../psi/impl/GrDocMemberReferenceImpl.java | 62 +-------- .../psi/impl/GrDocMethodReferenceImpl.java | 7 +- .../lang/groovydoc/psi/impl/GrDocTagImpl.java | 6 +- .../completion/GrDocCompletionTest.groovy | 30 +++++ .../completion/gdoc/LinkCompletion.groovy | 26 ++++ .../gdoc/LinkCompletion_after.groovy | 26 ++++ 11 files changed, 305 insertions(+), 73 deletions(-) create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyDocCompletionProvider.java create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/handlers/GroovyMethodSignatureInsertHandler.java create mode 100644 plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GrDocCompletionTest.groovy create mode 100644 plugins/groovy/testdata/groovy/completion/gdoc/LinkCompletion.groovy create mode 100644 plugins/groovy/testdata/groovy/completion/gdoc/LinkCompletion_after.groovy diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java index b9c66f060cbe..280c5b08decc 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -248,6 +248,7 @@ public class GroovyCompletionContributor extends CompletionContributor { MapArgumentCompletionProvider.register(this); GroovyConfigSlurperCompletionProvider.register(this); MapKeysCompletionProvider.register(this); + GroovyDocCompletionProvider.register(this); // class name stuff diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyDocCompletionProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyDocCompletionProvider.java new file mode 100644 index 000000000000..ee03b9d85586 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyDocCompletionProvider.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.lang.completion; + +import com.intellij.codeInsight.completion.*; +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.codeInsight.lookup.LookupElementBuilder; +import com.intellij.patterns.PsiJavaPatterns; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.ResolveState; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.ArrayUtil; +import com.intellij.util.ProcessingContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.lang.completion.handlers.GroovyMethodSignatureInsertHandler; +import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference; +import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement; +import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTagValueToken; +import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; +import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; +import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; +import org.jetbrains.plugins.groovy.lang.resolve.processors.CompletionProcessor; +import org.jetbrains.plugins.groovy.lang.resolve.processors.ResolverProcessor; + +/** + * @author Max Medvedev + */ +public class GroovyDocCompletionProvider extends CompletionProvider { + public static void register(CompletionContributor contributor) { + final GroovyDocCompletionProvider provider = new GroovyDocCompletionProvider(); + contributor.extend(CompletionType.BASIC, PsiJavaPatterns.psiElement().inside(GrDocTagValueToken.class), provider); + } + + @Override + protected void addCompletions(@NotNull CompletionParameters parameters, + ProcessingContext context, + @NotNull CompletionResultSet result) { + final PsiElement position = parameters.getPosition(); + GrDocMemberReference reference = PsiTreeUtil.getParentOfType(position, GrDocMemberReference.class); + GrDocReferenceElement holder = reference.getReferenceHolder(); + PsiElement resolved; + if (holder != null) { + GrCodeReferenceElement referenceElement = holder.getReferenceElement(); + resolved = referenceElement != null ? referenceElement.resolve() : null; + } + else { + resolved = PsiUtil.getContextClass(reference); + } + if (resolved instanceof PsiClass) { + ResolverProcessor propertyProcessor = CompletionProcessor.createPropertyCompletionProcessor(reference); + resolved.processDeclarations(propertyProcessor, ResolveState.initial(), null, reference); + PsiElement[] propertyCandidates = ResolveUtil.mapToElements(propertyProcessor.getCandidates()); + ResolverProcessor methodProcessor = CompletionProcessor.createPropertyCompletionProcessor(reference); + + resolved.processDeclarations(methodProcessor, ResolveState.initial(), null, reference); + + PsiElement[] methodCandidates = ResolveUtil.mapToElements(methodProcessor.getCandidates()); + + PsiElement[] elements = ArrayUtil.mergeArrays(propertyCandidates, methodCandidates); + + for (PsiElement psiElement : elements) { + LookupElement element = GroovyCompletionUtil.getLookupElement(psiElement); + if (psiElement instanceof PsiMethod) { + element = ((LookupElementBuilder)element).setInsertHandler(new GroovyMethodSignatureInsertHandler()); + } + result.addElement(element); + } + } + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/handlers/GroovyMethodSignatureInsertHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/handlers/GroovyMethodSignatureInsertHandler.java new file mode 100644 index 000000000000..41e1642c9ab6 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/handlers/GroovyMethodSignatureInsertHandler.java @@ -0,0 +1,120 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.lang.completion.handlers; + +import com.intellij.codeInsight.completion.InsertHandler; +import com.intellij.codeInsight.completion.InsertionContext; +import com.intellij.codeInsight.lookup.Lookup; +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.EditorModificationUtil; +import com.intellij.openapi.editor.ScrollType; +import com.intellij.openapi.project.Project; +import com.intellij.psi.*; +import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.codeStyle.CodeStyleSettingsManager; +import com.intellij.psi.javadoc.PsiDocTag; +import com.intellij.psi.javadoc.PsiDocTagValue; +import com.intellij.psi.javadoc.PsiInlineDocTag; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.TypeConversionUtil; +import com.intellij.util.IncorrectOperationException; +import com.intellij.util.text.CharArrayUtil; +import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference; + +/** + * @author Max Medvedev + */ +public class GroovyMethodSignatureInsertHandler implements InsertHandler { + private static final Logger LOG = Logger.getInstance(GroovyMethodSignatureInsertHandler.class); + + public void handleInsert(InsertionContext context, LookupElement item) { + if (!(item.getObject() instanceof PsiMethod)) { + return; + } + PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getEditor().getDocument()); + final Editor editor = context.getEditor(); + final PsiMethod method = (PsiMethod)item.getObject(); + + final PsiParameter[] parameters = method.getParameterList().getParameters(); + final StringBuilder buffer = new StringBuilder(); + + final CharSequence chars = editor.getDocument().getCharsSequence(); + int endOffset = editor.getCaretModel().getOffset(); + final Project project = context.getProject(); + int afterSharp = CharArrayUtil.shiftBackwardUntil(chars, endOffset - 1, "#") + 1; + int signatureOffset = afterSharp; + + PsiElement element = context.getFile().findElementAt(signatureOffset - 1); + final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(element.getProject()); + PsiDocTag tag = PsiTreeUtil.getParentOfType(element, PsiDocTag.class); + if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) { + final PsiDocTagValue value = tag.getValueElement(); + endOffset = value.getTextRange().getEndOffset(); + } + editor.getDocument().deleteString(afterSharp, endOffset); + editor.getCaretModel().moveToOffset(signatureOffset); + editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); + editor.getSelectionModel().removeSelection(); + buffer.append(method.getName()).append("("); + final int afterParenth = afterSharp + buffer.length(); + for (int i = 0; i < parameters.length; i++) { + final PsiType type = TypeConversionUtil.erasure(parameters[i].getType()); + buffer.append(type.getCanonicalText()); + + if (i < parameters.length - 1) { + buffer.append(","); + if (styleSettings.SPACE_AFTER_COMMA) buffer.append(" "); + } + } + buffer.append(")"); + if (!(tag instanceof PsiInlineDocTag)) { + buffer.append(" "); + } + else { + final int currentOffset = editor.getCaretModel().getOffset(); + if (chars.charAt(currentOffset) == '}') { + afterSharp++; + } + else { + buffer.append("} "); + } + } + String insertString = buffer.toString(); + EditorModificationUtil.insertStringAtCaret(editor, insertString); + editor.getCaretModel().moveToOffset(afterSharp + buffer.length()); + editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); + PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); + + shortenReferences(project, editor, context, afterParenth); + } + + private static void shortenReferences(final Project project, final Editor editor, InsertionContext context, int offset) { + PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); + final PsiElement element = context.getFile().findElementAt(offset); + final GrDocMemberReference tagValue = PsiTreeUtil.getParentOfType(element, GrDocMemberReference.class); + if (tagValue != null) { + try { + //GrReferenceAdjuster.shortenReferences(tagValue); + } + catch (IncorrectOperationException e) { + LOG.error(e); + } + } + PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments(); + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/api/GrDocMemberReference.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/api/GrDocMemberReference.java index 7027d7f4170d..6f89e02175e0 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/api/GrDocMemberReference.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/api/GrDocMemberReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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,15 +16,15 @@ package org.jetbrains.plugins.groovy.lang.groovydoc.psi.api; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import com.intellij.psi.PsiPolyVariantReference; import com.intellij.psi.PsiQualifiedReference; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author ilyas */ -public interface GrDocMemberReference extends GroovyDocPsiElement, PsiPolyVariantReference, PsiQualifiedReference { +public interface GrDocMemberReference extends GroovyDocPsiElement, PsiPolyVariantReference, PsiQualifiedReference, GrDocTagValueToken { @Nullable GrDocReferenceElement getReferenceHolder(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocFieldReferenceImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocFieldReferenceImpl.java index a6273928fb37..b6289d5a14f8 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocFieldReferenceImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocFieldReferenceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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,6 +29,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; +import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; import org.jetbrains.plugins.groovy.lang.resolve.processors.MethodResolverProcessor; import org.jetbrains.plugins.groovy.lang.resolve.processors.PropertyResolverProcessor; @@ -85,7 +86,7 @@ public class GrDocFieldReferenceImpl extends GrDocMemberReferenceImpl implements GrCodeReferenceElement referenceElement = holder.getReferenceElement(); resolved = referenceElement != null ? referenceElement.resolve() : null; } else { - resolved = getEnclosingClass(this); + resolved = PsiUtil.getContextClass(this); } if (resolved instanceof PsiClass) { PropertyResolverProcessor processor = new PropertyResolverProcessor(name, this); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMemberReferenceImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMemberReferenceImpl.java index 41936f988321..de6d9af50850 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMemberReferenceImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMemberReferenceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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,28 +16,17 @@ package org.jetbrains.plugins.groovy.lang.groovydoc.psi.impl; -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.lookup.LookupItem; import com.intellij.lang.ASTNode; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; -import com.intellij.util.ArrayUtil; -import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference; import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement; import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTagValueToken; -import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; -import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; -import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.CompletionProcessor; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ResolverProcessor; /** * @author ilyas @@ -166,55 +155,8 @@ public abstract class GrDocMemberReferenceImpl extends GroovyDocPsiElementImpl i @NotNull public Object[] getVariants() { - GrDocReferenceElement holder = getReferenceHolder(); - PsiElement resolved; - if (holder != null) { - GrCodeReferenceElement referenceElement = holder.getReferenceElement(); - resolved = referenceElement != null ? referenceElement.resolve() : null; - } else { - resolved = getEnclosingClass(this); - } - if (resolved instanceof PsiClass) { - ResolverProcessor propertyProcessor = CompletionProcessor.createPropertyCompletionProcessor(this); - resolved.processDeclarations(propertyProcessor, ResolveState.initial(), null, this); - PsiElement[] propertyCandidates = ResolveUtil.mapToElements(propertyProcessor.getCandidates()); - ResolverProcessor methodProcessor = CompletionProcessor.createPropertyCompletionProcessor(this); - - resolved.processDeclarations(methodProcessor, ResolveState.initial(), null, this); - - PsiElement[] methodCandidates = ResolveUtil.mapToElements(methodProcessor.getCandidates()); - - PsiElement[] elements = ArrayUtil.mergeArrays(propertyCandidates, methodCandidates); - - return ContainerUtil.map2Array(elements, new Function() { - public Object fun(PsiElement psiElement) { - LookupElement lookupItem = null; - if (psiElement instanceof PsiNamedElement) { - if (psiElement instanceof PsiMethod) { - lookupItem = new LookupItem(psiElement, ((PsiMethod) psiElement).getName()); - } else { - String string = ((PsiNamedElement) psiElement).getName(); - lookupItem = new LookupItem(psiElement, string == null ? "" : string); - } - lookupItem.putUserData(LookupItem.FORCE_SHOW_SIGNATURE_ATTR, true); - } - return lookupItem != null ? lookupItem : psiElement; - } - }); - } - return ArrayUtil.EMPTY_OBJECT_ARRAY; - } - - protected static PsiClass getEnclosingClass(PsiElement element) { - PsiElement parent = element.getParent(); - while (parent != null) { - if (parent instanceof GrTypeDefinition) return (PsiClass) parent; - if (parent instanceof GroovyFile) return ((GroovyFile) parent).getScriptClass(); - parent = parent.getParent(); - } - return null; + return PsiElement.EMPTY_ARRAY; } protected abstract ResolveResult[] multiResolveImpl(); - } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMethodReferenceImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMethodReferenceImpl.java index a37c295e4641..8fa7aee0e1d0 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMethodReferenceImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMethodReferenceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -28,6 +28,7 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodReference; import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; +import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; import org.jetbrains.plugins.groovy.lang.resolve.processors.MethodResolverProcessor; /** @@ -63,7 +64,7 @@ public class GrDocMethodReferenceImpl extends GrDocMemberReferenceImpl implement GrCodeReferenceElement referenceElement = holder.getReferenceElement(); resolved = referenceElement != null ? referenceElement.resolve() : null; } else { - resolved = getEnclosingClass(this); + resolved = PsiUtil.getContextClass(this); } if (resolved instanceof PsiClass) { PsiType[] parameterTypes = getParameterList().getParameterTypes(); @@ -93,7 +94,7 @@ public class GrDocMethodReferenceImpl extends GrDocMemberReferenceImpl implement GrCodeReferenceElement referenceElement = holder.getReferenceElement(); resolved = referenceElement != null ? referenceElement.resolve() : null; } else { - resolved = getEnclosingClass(this); + resolved = PsiUtil.getContextClass(this); } if (resolved instanceof PsiClass) { PsiType[] parameterTypes = getParameterList().getParameterTypes(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocTagImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocTagImpl.java index c6cf6c3cf6d2..ce8904b6cdb1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocTagImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocTagImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -19,7 +19,7 @@ package org.jetbrains.plugins.groovy.lang.groovydoc.psi.impl; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.tree.TokenSet; -import com.intellij.psi.util.PsiUtilBase; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -87,7 +87,7 @@ public class GrDocTagImpl extends GroovyDocPsiElementImpl implements GrDocTag { public PsiElement[] getDataElements() { final List list = findChildrenByType(VALUE_BIT_SET); - return PsiUtilBase.toPsiElementArray(list); + return PsiUtilCore.toPsiElementArray(list); } public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GrDocCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GrDocCompletionTest.groovy new file mode 100644 index 000000000000..acc2bb1dcb98 --- /dev/null +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GrDocCompletionTest.groovy @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.completion + +import org.jetbrains.plugins.groovy.util.TestUtils + +/** + * @author Max Medvedev + */ +class GrDocCompletionTest extends GroovyCompletionTestBase { + @Override + protected String getBasePath() { + "${TestUtils.testDataPath}groovy/completion/gdoc"; + } + + void testLinkCompletion() { doBasicTest() } +} diff --git a/plugins/groovy/testdata/groovy/completion/gdoc/LinkCompletion.groovy b/plugins/groovy/testdata/groovy/completion/gdoc/LinkCompletion.groovy new file mode 100644 index 000000000000..6e9dd32a94a8 --- /dev/null +++ b/plugins/groovy/testdata/groovy/completion/gdoc/LinkCompletion.groovy @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2012 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 { + def foo(String x) {} + + /** + * {@link A#fo + */ + def bar() { + + } +} \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/completion/gdoc/LinkCompletion_after.groovy b/plugins/groovy/testdata/groovy/completion/gdoc/LinkCompletion_after.groovy new file mode 100644 index 000000000000..6285dc37c24d --- /dev/null +++ b/plugins/groovy/testdata/groovy/completion/gdoc/LinkCompletion_after.groovy @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2012 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 { + def foo(String x) {} + + /** + * {@link A#foo(java.lang.String)} + */ + def bar() { + + } +} \ No newline at end of file