Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Bas Leijdekkers
2011-12-12 15:40:19 +01:00
70 changed files with 547 additions and 244 deletions
@@ -16,6 +16,7 @@
package com.intellij.lexer;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.StringEscapesTokenTypes;
import com.intellij.psi.tree.IElementType;
@@ -91,10 +92,6 @@ public class StringLiteralLexer extends LexerBase {
return myLastState;
}
private static boolean isHexDigit(char c) {
return c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F';
}
public IElementType getTokenType() {
if (myStart >= myEnd) return null;
@@ -113,14 +110,14 @@ public class StringLiteralLexer extends LexerBase {
}
if (nextChar == 'u') {
for(int i = myStart + 2; i < myStart + 6; i++) {
if (i >= myEnd || !isHexDigit(myBuffer.charAt(i))) return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
if (i >= myEnd || !StringUtil.isHexDigit(myBuffer.charAt(i))) return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
}
return StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN;
}
if (nextChar == 'x' && myAllowHex) {
for(int i = myStart + 2; i < myStart + 4; i++) {
if (i >= myEnd || !isHexDigit(myBuffer.charAt(i))) return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
if (i >= myEnd || !StringUtil.isHexDigit(myBuffer.charAt(i))) return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
}
return StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN;
}
@@ -56,9 +56,8 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
}
String elementMarker = tokenizer.nextToken();
if (TOP_LEVEL_CHILD_MARKER.equals(elementMarker)) {
PsiElement[] children = file.getChildren();
PsiElement result = null;
for (PsiElement child : children) {
for (PsiElement child = file.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child instanceof PsiWhiteSpace) {
continue;
}
@@ -69,7 +68,7 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
if (processingInfoStorage != null) {
processingInfoStorage.append(String.format(
"Stopping '%s' provider because it has top level marker but more than one non white-space child: %s",
getClass().getName(), Arrays.toString(children)
getClass().getName(), Arrays.toString(file.getChildren())
));
}
// More than one top-level non-white space children. Can't match.
@@ -79,7 +78,7 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
if (processingInfoStorage != null) {
processingInfoStorage.append(String.format(
"Finished processing of '%s' provider because all of its top-level children have been processed: %s",
getClass().getName(), Arrays.toString(children)
getClass().getName(), Arrays.toString(file.getChildren())
));
}
return result;
@@ -89,7 +88,7 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
return candidate instanceof PsiComment ? candidate : null;
}
else if (CODE_BLOCK_MARKER.equals(elementMarker)) {
for (PsiElement child : parent.getChildren()) {
for (PsiElement child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
PsiElement firstChild = child.getFirstChild();
PsiElement lastChild = child.getLastChild();
if (firstChild != null && lastChild != null && "{".equals(firstChild.getText()) && "}".equals(lastChild.getText())) {
@@ -145,7 +144,7 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
if (parent == null) {
return false;
}
for (PsiElement child : parent.getChildren()) {
for (PsiElement child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child instanceof PsiWhiteSpace) {
continue;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -681,6 +681,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
// deal with width
final int width = Math.max(editorSize.width, historySize.width);
newEditorSize.width = width + editor.getScrollPane().getHorizontalScrollBar().getHeight();
editor.getSoftWrapModel().forceAdditionalColumnsUsage();
editor.getSettings().setAdditionalColumnsCount(2 + (width - editorSize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, editor));
history.getSettings().setAdditionalColumnsCount(2 + (width - historySize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, history));
@@ -16,6 +16,7 @@
package com.intellij.ide.highlighter.custom.tokens;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.CustomHighlighterTokenType;
/**
@@ -28,15 +29,11 @@ public class HexNumberParser extends PrefixedTokenParser {
protected int getTokenEnd(int position) {
for (; position < myEndOffset; position++) {
if (!isHexDigit(myBuffer.charAt(position))) break;
if (!StringUtil.isHexDigit(myBuffer.charAt(position))) break;
}
return position;
}
public static boolean isHexDigit(char c) {
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
public static HexNumberParser create(String prefix) {
if (prefix == null) return null;
final String trimmedPrefix = prefix.trim();
@@ -118,4 +118,48 @@ public interface SoftWrapModelEx extends SoftWrapModel {
/** Asks the model to completely recalculate soft wraps. */
void recalculate();
/**
* IJ editor defines a notion of {@link EditorSettings#getAdditionalColumnsCount() additional columns}. They define additional
* amount of space to be used during editor component's width calculation (IJ editor perform 'preventive UI component expansion'
* when user types near the right edge).
* <p/>
* The main idea of soft wraps is to avoid horizontal scrolling, however, there is a possible case that particular line
* of text can't be soft-wrapped, i.e. we need to show horizontal scroll bar. So, we have the following use-cases:
* <pre>
* <ol>
* <li>
* <b>Long line is soft-wrapped</b>.
* <p/>
* Example:
* <p/>
* this a long lin[caret] |&lt;-- viewport's edge
* <p/>
* As soon as 'e' is typed, soft wrapping is performed and 'line' word is displayed at the next visual line, we need
* not to consider {@link EditorSettings#getAdditionalColumnsCount() additional columns} during width recalculation;
* </li>
* <li>
* <b>Long line can't be soft-wrapped</b>
* <p/>
* <code>Example:</code>
* thisisaratherlonglin[caret]|&lt;-- viewport's edge
* <p/>
* When 'e' is typed we need to increase component's width and use
* {@link EditorSettings#getAdditionalColumnsCount() additional columns} for its calculation;
* </li>
* </ol>
* </pre>
* This method allows to answer if {@link EditorSettings#getAdditionalColumnsCount() additional columns} should be used
* during editor component's width calculation.
*
* @return <code>true</code> if {@link EditorSettings#getAdditionalColumnsCount() additional columns} should be used
* during editor component's width recalculation;
* <code>false</code> otherwise
*/
boolean isRespectAdditionalColumns();
/**
* Allows to instruct current model to always return <code>'true'</code> from {@link #isRespectAdditionalColumns()}.
*/
void forceAdditionalColumnsUsage();
}
@@ -434,10 +434,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
myScrollingModel = new ScrollingModelImpl(this);
if (mySettings.isUseSoftWraps()) {
mySettings.setAdditionalColumnsCount(0);
}
myGutterComponent.updateSize();
Dimension preferredSize = getPreferredSize();
myEditorComponent.setSize(preferredSize);
@@ -3108,7 +3104,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
final Dimension draft = getSizeWithoutCaret();
final int additionalSpace = mySettings.getAdditionalColumnsCount() * EditorUtil.getSpaceWidth(Font.PLAIN, this);
final int additionalSpace = mySoftWrapModel.isRespectAdditionalColumns()
? mySettings.getAdditionalColumnsCount() * EditorUtil.getSpaceWidth(Font.PLAIN, this)
: 0;
if (!myDocument.isInBulkUpdate() && getCaretModel().isUpToDate()) {
int caretX = visualPositionToXY(getCaretModel().getVisualPosition()).x;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -173,7 +173,7 @@ public class ScrollingModelImpl implements ScrollingModelEx {
hOffset = targetLocation.x - 4 * spaceWidth;
hOffset = hOffset > 0 ? hOffset : 0;
}
else if (targetLocation.x > viewRect.x + viewRect.width) {
else if (targetLocation.x >= viewRect.x + viewRect.width) {
hOffset = targetLocation.x - viewRect.width + xInsets;
}
@@ -98,19 +98,6 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
private boolean myUseSoftWraps;
private int myTabWidth = -1;
/**
* Standard IJ editor starts showing horizontal scroll bar event when text line ends couple of symbols before the right visual
* area edge (exact value of columns to use for such preliminary scrolling is identified by
* {@link EditorSettings#getAdditionalColumnsCount() additionalColumnsCount} value).
* <p/>
* However, we want to avoid using horizontal scrolling within soft wraps whenever possible. Hence, we set that additional
* columns property to zero when soft wraps are used and restore it if soft wraps are turned off.
* <p/>
* Current field holds initial <code>'additional columns count'</code> property value that is to be restored if
* soft wraps are turned off.
*/
private int myAdditionalColumnsCount;
/**
* Soft wraps need to be kept up-to-date on all editor modification (changing text, adding/removing/expanding/collapsing fold
* regions etc). Hence, we need to react to all types of target changes. However, soft wraps processing uses various information
@@ -132,6 +119,8 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
* Current field serves as a flag for that <code>'dirty document, need complete soft wraps cache recalculation'</code> state.
*/
private boolean myDirty;
private boolean myForceAdditionalColumns;
public SoftWrapModelImpl(@NotNull EditorEx editor) {
this(editor, new SoftWrapsStorage(), new CompositeSoftWrapPainter(editor));
@@ -183,7 +172,6 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
}
});
EditorSettings settings = myEditor.getSettings();
myAdditionalColumnsCount = settings.getAdditionalColumnsCount();
myUseSoftWraps = settings.isUseSoftWraps();
editor.addPropertyChangeListener(this);
@@ -200,18 +188,11 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
int tabWidthBefore = myTabWidth;
myTabWidth = getCurrentTabWidth();
if ((myUseSoftWraps && (!softWrapsUsedBefore || settings.getAdditionalColumnsCount() > 0))
|| (tabWidthBefore >= 0 && myTabWidth != tabWidthBefore))
{
if ((myUseSoftWraps ^ softWrapsUsedBefore) || (tabWidthBefore >= 0 && myTabWidth != tabWidthBefore)) {
myApplianceManager.reset();
myDeferredFoldRegions.clear();
myAdditionalColumnsCount = settings.getAdditionalColumnsCount();
settings.setAdditionalColumnsCount(0);
myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
else if (!myUseSoftWraps && softWrapsUsedBefore) {
settings.setAdditionalColumnsCount(myAdditionalColumnsCount);
}
myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
/**
@@ -227,7 +208,17 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
final CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(file.getFileType());
return indentOptions.TAB_SIZE;
}
@Override
public boolean isRespectAdditionalColumns() {
return myForceAdditionalColumns || myApplianceManager.hasLinesWithFailedWrap();
}
@Override
public void forceAdditionalColumnsUsage() {
myForceAdditionalColumns = true;
}
@Override
public boolean isSoftWrappingEnabled() {
if (!myUseSoftWraps || myEditor.isOneLineMode()) {
@@ -97,6 +97,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
private int myCustomIndentValueUsedLastTime;
private int myVisibleAreaWidth;
private boolean myInProgress;
private boolean myHasLinesWithFailedWrap;
public SoftWrapApplianceManager(@NotNull SoftWrapsStorage storage,
@NotNull EditorEx editor,
@@ -111,6 +112,15 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
myWidthProvider = new DefaultVisibleAreaWidthProvider(editor);
}
/**
* @return <code>true</code> if soft wraps processing detected line(s) that exceeds viewport's size but can't be soft-wrapped;
* i.e. part of it lays outside of the screen;
* <code>false</code> otherwise
*/
public boolean hasLinesWithFailedWrap() {
return myHasLinesWithFailedWrap;
}
public void registerSoftWrapIfNecessary() {
recalculateIfNecessary();
}
@@ -163,6 +173,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
myActiveEvents.addAll(events);
myEventsStorage.release();
myInProgress = true;
myHasLinesWithFailedWrap = false;
try {
for (IncrementalCacheUpdateEvent event : events) {
recalculateSoftWraps(event);
@@ -457,6 +468,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
);
if (softWrap == null) {
myContext.tryToShiftToNextLine();
myHasLinesWithFailedWrap = true;
return;
}
@@ -36,7 +36,10 @@ import com.intellij.openapi.ui.Queryable;
import com.intellij.openapi.ui.popup.StackingPopupDispatcher;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.wm.*;
import com.intellij.openapi.wm.FocusCommand;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.KeyEventProcessor;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.ex.LayoutFocusTraversalPolicyExt;
import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
@@ -45,6 +48,9 @@ import com.intellij.ui.AppUIUtil;
import com.intellij.ui.FocusTrackback;
import com.intellij.ui.ScreenUtil;
import com.intellij.ui.SpeedSearchBase;
import com.intellij.ui.mac.foundation.Foundation;
import com.intellij.ui.mac.foundation.ID;
import com.intellij.ui.mac.foundation.MacUtil;
import com.intellij.ui.popup.StackingPopupDispatcherImpl;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
@@ -681,6 +687,25 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
}
}
if (SystemInfo.isMacOSLion) {
final WindowAdapter macFullScreenPatchListener = new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
Window window = e.getWindow();
if (window instanceof Dialog) {
ID _native = MacUtil.findWindowForTitle(((Dialog)window).getTitle());
if (_native != null && _native.intValue() > 0) {
// see MacMainFrameDecorator
// NSCollectionBehaviorFullScreenAuxiliary = 1 << 8
Foundation.invoke(_native, "setCollectionBehavior:", 1 << 8);
}
}
}
};
addWindowListener(macFullScreenPatchListener);
}
super.show();
}
@@ -2213,4 +2213,12 @@ public class StringUtil {
m.appendTail(result);
return result.toString();
}
public static boolean isHexDigit(char c) {
return '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F';
}
public static boolean isOctalDigit(char c) {
return '0' <= c && c <= '7';
}
}
@@ -16,9 +16,14 @@
package org.jetbrains.android;
import com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.*;
import com.intellij.psi.meta.PsiMetaOwner;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlAttributeValue;
import org.jetbrains.android.dom.wrappers.FileResourceElementWrapper;
import org.jetbrains.android.dom.wrappers.ValueResourceElementWrapper;
import org.jetbrains.android.facet.AndroidFacet;
import org.jetbrains.android.util.AndroidResourceUtil;
@@ -55,6 +60,23 @@ public class AndroidGotoDeclarationHandler implements GotoDeclarationHandler {
}
final PsiElement[] resources = AndroidResourceUtil.findResources(resolvedField);
return resources.length > 0 ? resources : null;
final PsiElement[] wrappedResources = new PsiElement[resources.length];
for (int i = 0; i < resources.length; i++) {
final PsiElement resource = resources[i];
if (resource instanceof XmlAttributeValue &&
resource instanceof PsiMetaOwner &&
resource instanceof NavigationItem) {
wrappedResources[i] = new ValueResourceElementWrapper((XmlAttributeValue)resource);
}
else if (resource instanceof PsiFile) {
wrappedResources[i] = new FileResourceElementWrapper((PsiFile)resource);
}
else {
wrappedResources[i] = resource;
}
}
return wrappedResources.length > 0 ? wrappedResources : null;
}
}
@@ -35,14 +35,13 @@ import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.DependencyScope;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleOrderEntry;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.ExternalChangeAction;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiManager;
@@ -91,6 +90,21 @@ public class AndroidModuleBuilder extends JavaModuleBuilder {
rootModel.setSdk(mySdk);
final LanguageLevelModuleExtension moduleExt = rootModel.getModuleExtension(LanguageLevelModuleExtension.class);
if (moduleExt != null) {
LanguageLevel languageLevel = moduleExt.getLanguageLevel();
if (languageLevel == null) {
final LanguageLevelProjectExtension projectExt = LanguageLevelProjectExtension.getInstance(rootModel.getProject());
if (projectExt != null) {
languageLevel = projectExt.getLanguageLevel();
}
}
if (languageLevel == LanguageLevel.JDK_1_3) {
moduleExt.setLanguageLevel(LanguageLevel.JDK_1_5);
}
}
VirtualFile[] files = rootModel.getContentRoots();
if (files.length > 0) {
final VirtualFile contentRoot = files[0];
@@ -65,6 +65,8 @@ public class GradleApiFacadeManager {
private final AtomicReference<Pair<GradleApiFacade, RemoteGradleProcessSettings>> myFacade
= new AtomicReference<Pair<GradleApiFacade, RemoteGradleProcessSettings>>();
private final AtomicReference<RemoteGradleProgressNotificationManager> myExportedProgressManager
= new AtomicReference<RemoteGradleProgressNotificationManager>();
private final GradleLibraryManager myGradleLibraryManager;
private final RemoteGradleProgressNotificationManager myProgressManager;
@@ -110,7 +112,7 @@ public class GradleApiFacadeManager {
Collection<File> gradleLibraries = myGradleLibraryManager.getAllLibraries(null);
GradleLog.LOG.assertTrue(gradleLibraries != null, GradleBundle.message("gradle.generic.text.error.sdk.undefined"));
if (gradleLibraries == null) {
return null;
throw new ExecutionException("Can't find gradle libraries");
}
final SimpleJavaParameters params = new SimpleJavaParameters();
@@ -230,7 +232,16 @@ public class GradleApiFacadeManager {
return myFacade.get().first;
}
result.applySettings(getRemoteSettings());
RemoteGradleProgressNotificationManager exported = (RemoteGradleProgressNotificationManager)UnicastRemoteObject.exportObject(myProgressManager, 0);
RemoteGradleProgressNotificationManager exported = myExportedProgressManager.get();
if (exported == null) {
try {
exported = (RemoteGradleProgressNotificationManager)UnicastRemoteObject.exportObject(myProgressManager, 0);
myExportedProgressManager.set(exported);
}
catch (RemoteException e) {
exported = myExportedProgressManager.get();
}
}
if (exported == null) {
GradleLog.LOG.warn("Can't export progress manager");
}
@@ -261,7 +261,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
PsiElement refNameElement = referenceExpression.getReferenceNameElement();
if (refNameElement != null && referenceExpression.getQualifier() == null) {
final IElementType type = refNameElement.getNode().getElementType();
if (type == GroovyTokenTypes.mGSTRING_LITERAL || type == GroovyTokenTypes.mSTRING_LITERAL) return false;
if (TokenSets.STRING_LITERAL_SET.contains(type)) return false;
}
if (!GroovyUnresolvedHighlightFilter.shouldHighlight(referenceExpression)) return false;
@@ -831,12 +831,21 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
@Override
public void visitLiteralExpression(GrLiteral literal) {
String text = literal.getText();
checkStringLiteral(literal, text);
final IElementType elementType = literal.getFirstChild().getNode().getElementType();
if (elementType == GroovyTokenTypes.mSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_LITERAL) {
checkStringLiteral(literal, literal.getText());
}
else if (elementType == GroovyTokenTypes.mREGEX_LITERAL || elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL) {
checkRegexLiteral(literal.getFirstChild());
}
}
@Override
public void visitRegexExpression(GrRegex regex) {
checkRegexLiteral(regex);
}
private void checkRegexLiteral(PsiElement regex) {
String text = regex.getText();
String quote = GrStringUtil.getStartQuote(text);
@@ -856,7 +865,16 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
}
}
for (String part : regex.getTextParts()) {
String[] parts;
if (regex instanceof GrRegex) {
parts = ((GrRegex)regex).getTextParts();
}
else {
parts = new String[]{regex.getFirstChild().getNextSibling().getText()};
}
for (String part : parts) {
if (!GrStringUtil.parseRegexCharacters(part, new StringBuilder(part.length()), null, regex.getText().startsWith("/"))) {
myHolder.createErrorAnnotation(regex, GroovyBundle.message("illegal.escape.character.in.string.literal"));
return;
@@ -873,13 +891,12 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
}
}
if (regex.getInjections().length > 0) {
if (regex instanceof GrRegex && ((GrRegex)regex).getInjections().length > 0) {
if (!config.isVersionAtLeast(regex, GroovyConfigUtils.GROOVY1_8)) {
myHolder.createErrorAnnotation(regex, GroovyBundle
.message("slashy.strings.with.injections.are.not.allowed.in.groovy.0", config.getSDKVersion(regex)));
}
}
}
@Override
@@ -21,9 +21,9 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrRegex;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
import java.util.List;
@@ -43,13 +43,12 @@ public class GroovyLiteralSelectioner extends GroovyBasicSelectioner {
if (element instanceof GrListOrMap) return true;
if (!(element instanceof GrLiteral)) return false;
if (element instanceof GrRegex && ((GrRegex)element).getInjections().length == 0) return true;
ASTNode node = element.getNode();
if (node == null) return false;
ASTNode firstNode = node.getFirstChildNode();
final IElementType type = firstNode.getElementType();
return firstNode == node.getLastChildNode() && (type == mSTRING_LITERAL || type == mGSTRING_LITERAL);
return firstNode == node.getLastChildNode() && TokenSets.STRING_LITERAL_SET.contains(type);
}
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
@@ -40,6 +40,8 @@ public class GroovyWordSelectionFilter implements Condition<PsiElement> {
type == mSTRING_LITERAL ||
type == mGSTRING_LITERAL ||
type == mGSTRING_CONTENT ||
type == mREGEX_LITERAL ||
type == mDOLLAR_SLASH_REGEX_LITERAL ||
type == mGDOC_COMMENT_DATA ||
type == mGDOC_TAG_NAME ||
type == mGDOC_TAG_PLAIN_VALUE_TOKEN ||
@@ -182,9 +182,11 @@ public abstract class GroovySpacingProcessorBasic extends SpacingTokens implemen
}
// For Gstrings and regexes
if (leftNode.getPsi().getParent() != null &&
leftNode.getPsi().getParent().equals(rightNode.getPsi().getParent()) &&
leftNode.getPsi().getParent() instanceof GrString) {
if (left.getParent() != null &&
left.getParent().equals(right.getParent()) &&
(left.getParent() instanceof GrString ||
leftNode.getTreeParent().getElementType() == mREGEX_LITERAL ||
leftNode.getTreeParent().getElementType() == mDOLLAR_SLASH_REGEX_LITERAL)) {
return NO_SPACING;
}
if (isDollarInGStringInjection(leftNode) || isDollarInGStringInjection(rightNode)) {
@@ -16,6 +16,7 @@
package org.jetbrains.plugins.groovy.highlighter;
import com.intellij.lexer.LexerBase;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.StringEscapesTokenTypes;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.Nullable;
@@ -48,18 +49,30 @@ public class GroovySlashyStringLexer extends LexerBase {
if (myEnd >= myBufferEnd) return null;
myStart = myEnd;
if (checkForEscape(myStart)) {
if (checkForSlashEscape(myStart)) {
myEnd = myStart + 2;
return StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN;
}
else if (checkForHexCodeStart(myStart)) {
for (myEnd = myStart + 2; myEnd < myStart + 6; myEnd++) {
if (myEnd >= myBufferEnd || !StringUtil.isHexDigit(myBuffer.charAt(myEnd))) {
return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
}
}
return StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN;
}
while (myEnd < myBufferEnd && !checkForEscape(myEnd)) myEnd++;
while (myEnd < myBufferEnd && !checkForSlashEscape(myEnd) && !checkForHexCodeStart(myEnd)) myEnd++;
return GroovyTokenTypes.mREGEX_CONTENT;
}
private boolean checkForEscape(int start) {
private boolean checkForSlashEscape(int start) {
return myBuffer.charAt(start) == '\\' && start + 1 < myBufferEnd && myBuffer.charAt(start + 1) == '/';
}
private boolean checkForHexCodeStart(int start) {
return myBuffer.charAt(start) == '\\' && start + 1 < myBufferEnd && myBuffer.charAt(start + 1) == 'u';
}
@Override
public int getState() {
@@ -76,10 +76,13 @@ public interface GroovyTokenTypes extends GroovyDocElementTypes {
IElementType mREGEX_BEGIN = new GroovyElementType("regex begin");
IElementType mREGEX_CONTENT = new GroovyElementType("regex content");
IElementType mREGEX_END = new GroovyElementType("regex end");
IElementType mREGEX_LITERAL = new GroovyElementType("regex literal");
IElementType mDOLLAR_SLASH_REGEX_BEGIN = new GroovyElementType("$/ regex begin");
IElementType mDOLLAR_SLASH_REGEX_CONTENT = new GroovyElementType("$/ regex content");
IElementType mDOLLAR_SLASH_REGEX_END = new GroovyElementType("$/ regex end");
IElementType mDOLLAR_SLASH_REGEX_LITERAL = new GroovyElementType("$/ regex literal");
/* **************************************************************************************************
* Common tokens: operators, braces etc.
@@ -68,7 +68,9 @@ public abstract class TokenSets {
kFALSE,
kNULL,
mSTRING_LITERAL,
mGSTRING_LITERAL
mGSTRING_LITERAL,
mREGEX_LITERAL,
mDOLLAR_SLASH_REGEX_LITERAL
);
public static final TokenSet BUILT_IN_TYPE = TokenSet.create(
@@ -83,7 +85,8 @@ public abstract class TokenSets {
kDOUBLE
);
public static final TokenSet PROPERTY_NAMES = TokenSet.create(mIDENT, mSTRING_LITERAL, mGSTRING_LITERAL);
public static final TokenSet PROPERTY_NAMES =
TokenSet.create(mIDENT, mSTRING_LITERAL, mGSTRING_LITERAL, mREGEX_LITERAL, mDOLLAR_SLASH_REGEX_LITERAL);
public static final TokenSet KEYWORDS = TokenSet.create(kABSTRACT, kAS, kASSERT, kBOOLEAN, kBREAK, kBYTE, kCASE, kCATCH, kCHAR, kCLASS,
kCONTINUE, kDEF, kDEFAULT, kDO, kDOUBLE, kELSE, kEXTENDS, kENUM, kFALSE, kFINAL,
@@ -126,7 +129,9 @@ public abstract class TokenSets {
mGSTRING_LITERAL,
mGSTRING_CONTENT,
mGSTRING_BEGIN,
mGSTRING_END
mGSTRING_END,
mREGEX_LITERAL,
mDOLLAR_SLASH_REGEX_LITERAL
);
public static TokenSet FOR_IN_DELIMITERS = TokenSet.create(kIN, mCOLON);
@@ -142,7 +147,7 @@ public abstract class TokenSets {
public static final TokenSet COMMENT_SET = TokenSet.create(mML_COMMENT, mSH_COMMENT, mSL_COMMENT, GROOVY_DOC_COMMENT);
public static final TokenSet STRING_LITERAL_SET = TokenSet.create(mSTRING_LITERAL, mGSTRING_LITERAL);
public static final TokenSet STRING_LITERAL_SET = TokenSet.create(mSTRING_LITERAL, mGSTRING_LITERAL, mREGEX_LITERAL, mDOLLAR_SLASH_REGEX_LITERAL);
public static final TokenSet BRACES = TokenSet.create(mLBRACK, mRBRACK, mLPAREN, mRPAREN, mLCURLY, mRCURLY);
@@ -101,7 +101,13 @@ public class GroovyParserDefinition implements ParserDefinition {
}
final IElementType parentType = left.getTreeParent().getElementType();
if (parentType == GSTRING || parentType == REGEX || parentType == GSTRING_INJECTION) return MUST_NOT;
if (parentType == GSTRING ||
parentType == REGEX ||
parentType == GSTRING_INJECTION ||
parentType == mREGEX_LITERAL ||
parentType == mDOLLAR_SLASH_REGEX_LITERAL) {
return MUST_NOT;
}
return LanguageUtil.canStickTokensTogetherByLexer(left, right, new GroovyLexer());
}
@@ -24,7 +24,7 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.lexer.IGroovyDocElementType;
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.GroovyDocPsiCreator;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType;
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyASTPsiElementImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.GrLabelImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.GrListOrMapImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.GrThrowsClauseImpl;
@@ -250,7 +250,8 @@ public class GroovyPsiCreator implements GroovyElementTypes {
if (elem == SPREAD_ARGUMENT) return new GrSpreadArgumentImpl(node);
if (elem == ARGUMENT_LABEL) return new GrArgumentLabelImpl(node);
if (elem == BALANCED_BRACKETS) return new GroovyPsiElementImpl(node){};
if (elem == BALANCED_BRACKETS) return new GroovyASTPsiElementImpl(node);
if (elem == mREGEX_LITERAL || elem == mDOLLAR_SLASH_REGEX_LITERAL) return new GroovyASTPsiElementImpl(node);
return new ASTWrapperPsiElement(node);
}
@@ -233,10 +233,10 @@ public class PathExpression implements GroovyElementTypes {
return PATH_PROPERTY_REFERENCE;
}
if (mREGEX_BEGIN.equals(tokenType)) {
return RegexConstructorExpression.parse(builder, parser) ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
return RegexConstructorExpression.parse(builder, parser, true) ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
}
if (mDOLLAR_SLASH_REGEX_BEGIN.equals(tokenType)) {
return DollarSlashRegexConstructorExpression.parse(builder, parser) ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
return DollarSlashRegexConstructorExpression.parse(builder, parser, true) ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
}
if (mLCURLY.equals(tokenType)) {
OpenOrClosableBlock.parseOpenBlock(builder, parser);
@@ -23,9 +23,14 @@ import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.blocks.OpenOr
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arithmetic.PathExpression;
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.GSTRING_INJECTION;
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.REGEX;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR_SLASH_REGEX_BEGIN;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR_SLASH_REGEX_CONTENT;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR_SLASH_REGEX_END;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mIDENT;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mLCURLY;
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.*;
/**
* @author Max Medvedev
@@ -33,8 +38,9 @@ import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.REGEX;
public class DollarSlashRegexConstructorExpression {
private static final Logger LOG = Logger.getInstance(DollarSlashRegexConstructorExpression.class);
public static boolean parse(PsiBuilder builder, GroovyParser parser) {
public static boolean parse(PsiBuilder builder, GroovyParser parser, boolean forRefExpr) {
PsiBuilder.Marker marker = builder.mark();
final PsiBuilder.Marker marker2 = builder.mark();
final boolean result = ParserUtils.getToken(builder, mDOLLAR_SLASH_REGEX_BEGIN);
LOG.assertTrue(result);
@@ -48,7 +54,20 @@ public class DollarSlashRegexConstructorExpression {
if (!ParserUtils.getToken(builder, mDOLLAR_SLASH_REGEX_END)) {
builder.error(GroovyBundle.message("dollar.slash.end.expected"));
}
marker.done(REGEX);
if (inj) {
marker2.drop();
marker.done(REGEX);
}
else {
marker2.done(mDOLLAR_SLASH_REGEX_LITERAL);
if (forRefExpr) {
marker.drop();
}
else {
marker.done(LITERAL);
}
}
return inj;
}
@@ -69,11 +69,11 @@ public class PrimaryExpression implements GroovyElementTypes {
return StringConstructorExpression.parse(builder, parser);
}
if (mREGEX_BEGIN == tokenType) {
RegexConstructorExpression.parse(builder, parser);
RegexConstructorExpression.parse(builder, parser, false);
return REGEX;
}
if (mDOLLAR_SLASH_REGEX_BEGIN == tokenType) {
DollarSlashRegexConstructorExpression.parse(builder, parser);
DollarSlashRegexConstructorExpression.parse(builder, parser, false);
return REGEX;
}
if (mLBRACK == tokenType) {
@@ -34,8 +34,9 @@ public class RegexConstructorExpression implements GroovyElementTypes {
/**
* @return true if there are any injections
*/
public static boolean parse(PsiBuilder builder, GroovyParser parser) {
public static boolean parse(PsiBuilder builder, GroovyParser parser, boolean forRefExpr) {
PsiBuilder.Marker marker = builder.mark();
final PsiBuilder.Marker marker2 = builder.mark();
final boolean result = ParserUtils.getToken(builder, mREGEX_BEGIN);
LOG.assertTrue(result);
@@ -49,7 +50,20 @@ public class RegexConstructorExpression implements GroovyElementTypes {
if (!ParserUtils.getToken(builder, mREGEX_END)) {
builder.error(GroovyBundle.message("regex.end.expected"));
}
marker.done(REGEX);
if (inj) {
marker2.drop();
marker.done(REGEX);
}
else {
marker2.done(mREGEX_LITERAL);
if (forRefExpr) {
marker.drop();
}
else {
marker.done(LITERAL);
}
}
return inj;
}
@@ -0,0 +1,28 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.impl;
import com.intellij.lang.ASTNode;
import org.jetbrains.annotations.NotNull;
/**
* @author Max Medvedev
*/
public class GroovyASTPsiElementImpl extends GroovyPsiElementImpl {
public GroovyASTPsiElementImpl(@NotNull ASTNode node) {
super(node);
}
}
@@ -52,7 +52,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAc
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
import org.jetbrains.plugins.groovy.lang.psi.impl.*;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
@@ -371,8 +371,11 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
PsiElement nameElement = getReferenceNameElement();
if (nameElement != null) {
IElementType nodeType = nameElement.getNode().getElementType();
if (nodeType == mSTRING_LITERAL || nodeType == mGSTRING_LITERAL) {
return GrStringUtil.removeQuotes(nameElement.getText());
if (TokenSets.STRING_LITERAL_SET.contains(nodeType)) {
final Object value = GrLiteralImpl.getLiteralValue(nameElement);
if (value instanceof String) {
return (String)value;
}
}
return nameElement.getText();
@@ -110,6 +110,8 @@ public class TypesUtil {
static {
ourPrimitiveTypesToClassNames.put(mSTRING_LITERAL, JAVA_LANG_STRING);
ourPrimitiveTypesToClassNames.put(mGSTRING_LITERAL, JAVA_LANG_STRING);
ourPrimitiveTypesToClassNames.put(mREGEX_LITERAL, JAVA_LANG_STRING);
ourPrimitiveTypesToClassNames.put(mDOLLAR_SLASH_REGEX_LITERAL, JAVA_LANG_STRING);
ourPrimitiveTypesToClassNames.put(mNUM_INT, JAVA_LANG_INTEGER);
ourPrimitiveTypesToClassNames.put(mNUM_LONG, JAVA_LANG_LONG);
ourPrimitiveTypesToClassNames.put(mNUM_FLOAT, JAVA_LANG_FLOAT);
@@ -19,7 +19,9 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.litera
import com.intellij.openapi.util.ProperTextRange;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.LiteralTextEscaper;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
public class GrLiteralEscaper extends LiteralTextEscaper<GrLiteralImpl> {
@@ -34,7 +36,18 @@ public class GrLiteralEscaper extends LiteralTextEscaper<GrLiteralImpl> {
ProperTextRange.assertProperRange(rangeInsideHost);
String subText = rangeInsideHost.substring(myHost.getText());
outSourceOffsets = new int[subText.length() + 1];
return GrStringUtil.parseStringCharacters(subText, outChars, outSourceOffsets);
final IElementType elementType = myHost.getFirstChild().getNode().getElementType();
if (elementType == GroovyTokenTypes.mSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_LITERAL) {
return GrStringUtil.parseStringCharacters(subText, outChars, outSourceOffsets);
}
else if (elementType == GroovyTokenTypes.mREGEX_LITERAL) {
return GrStringUtil.parseRegexCharacters(subText, outChars, outSourceOffsets, true);
}
else if (elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL) {
return GrStringUtil.parseRegexCharacters(subText, outChars, outSourceOffsets, false);
}
else return false;
}
@Override
@@ -122,6 +122,27 @@ public class GrLiteralImpl extends GrAbstractLiteral implements GrLiteral, PsiLa
boolean result = GrStringUtil.parseStringCharacters(text, chars, null);
return result ? chars.toString() : null;
}
else if (elemType == mREGEX_LITERAL) {
final PsiElement cchild = child.getFirstChild();
if (cchild == null) return null;
final PsiElement sibling = cchild.getNextSibling();
if (sibling == null) return null;
text = sibling.getText();
final StringBuilder chars = new StringBuilder(text.length());
boolean result = GrStringUtil.parseRegexCharacters(text, chars, null, true);
return result ? chars.toString() : null;
}
else if (elemType == mDOLLAR_SLASH_REGEX_LITERAL) {
final PsiElement cchild = child.getFirstChild();
if (cchild == null) return null;
final PsiElement sibling = cchild.getNextSibling();
if (sibling == null) return null;
text = sibling.getText();
final StringBuilder chars = new StringBuilder(text.length());
boolean result = GrStringUtil.parseRegexCharacters(text, chars, null, false);
return result ? chars.toString() : null;
}
return null;
}
@@ -9,12 +9,12 @@ Groovy script
Reference expression
PsiElement(identifier)('a')
PsiElement(.)('.')
Compound regular expression
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('dfg')
PsiElement($/ regex end)('/$')
PsiElement(.)('.')
Compound regular expression
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('fg')
PsiElement(regex end)('/')
@@ -1,8 +1,9 @@
/$1\/
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('$1\/')
PsiErrorElement:Regex ending expected
<empty list>
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('$1\/')
PsiErrorElement:Regex ending expected
<empty list>
@@ -1,7 +1,8 @@
/$1\//
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('$1\/')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('$1\/')
PsiElement(regex end)('/')
@@ -1,7 +1,8 @@
/\//
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('\/')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('\/')
PsiElement(regex end)('/')
@@ -17,10 +17,11 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=~)('=~')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('[;\/\?:@&=\+\$,%-\.]')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('[;\/\?:@&=\+\$,%-\.]')
PsiElement(regex end)('/')
PsiElement())(')')
PsiElement(.)('.')
PsiElement(identifier)('replaceAll')
@@ -10,6 +10,7 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex end)('/$')
@@ -10,7 +10,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('$')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('$')
PsiElement($/ regex end)('/$')
@@ -19,10 +19,11 @@ Groovy script
PsiElement({)('{')
Parameter list
<empty list>
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)(' a ')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)(' a ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
PsiElement($/ regex content)(' ')
GString injection
@@ -31,10 +32,11 @@ Groovy script
PsiElement({)('{')
Parameter list
<empty list>
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)(' b ')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)(' b ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
PsiElement($/ regex content)(' ')
PsiElement($/ regex end)('/$')
@@ -10,7 +10,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiErrorElement:Dollar slash ending expected
<empty list>
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiErrorElement:Dollar slash ending expected
<empty list>
@@ -16,7 +16,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('(?x) # enable whitespace and comments\n((?:19|20)\d\d) # year (group 1) (non-capture alternation for century)\n[- /.] # seperator\n(0[1-9]|1[012]) # month (group 2)\n[- /.] # seperator\n(0[1-9]|[12][0-9]|3[01]) # day (group 3)\n')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('(?x) # enable whitespace and comments\n((?:19|20)\d\d) # year (group 1) (non-capture alternation for century)\n[- /.] # seperator\n(0[1-9]|1[012]) # month (group 2)\n[- /.] # seperator\n(0[1-9]|[12][0-9]|3[01]) # day (group 3)\n')
PsiElement($/ regex end)('/$')
@@ -17,10 +17,11 @@ Groovy script
PsiElement(=)('=')
PsiWhiteSpace(' ')
Multiplicative expression
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('(?x) # enable whitespace and comments\n((?:19|20)\d\d) # year (group 1) (non-capture alternation for century)\n[- /.] # seperator\n(0[1-9]|1[012]) # month (group 2)\n[- /.] # seperator\n(0[1-9]|[12][0-9]|3[01]) # day (group 3)\n')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('(?x) # enable whitespace and comments\n((?:19|20)\d\d) # year (group 1) (non-capture alternation for century)\n[- /.] # seperator\n(0[1-9]|1[012]) # month (group 2)\n[- /.] # seperator\n(0[1-9]|[12][0-9]|3[01]) # day (group 3)\n')
PsiElement($/ regex end)('/$')
PsiElement(/)('/')
Reference expression
PsiElement(identifier)('$')
@@ -15,8 +15,9 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('(?x) # enable whitespace and comments\n((?:19|20)\d\d) # year (group 1) (non-capture alternation for century)\n[- /.] # seperator\n(0[1-9]|1[012]) # month (group 2)\n[- /.] # seperator\n(0[1-9]|[12][0-9]|3[01]) # day (group 3)')
PsiErrorElement:Dollar slash ending expected
<empty list>
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('(?x) # enable whitespace and comments\n((?:19|20)\d\d) # year (group 1) (non-capture alternation for century)\n[- /.] # seperator\n(0[1-9]|1[012]) # month (group 2)\n[- /.] # seperator\n(0[1-9]|[12][0-9]|3[01]) # day (group 3)')
PsiErrorElement:Dollar slash ending expected
<empty list>
@@ -19,10 +19,11 @@ Groovy script
PsiElement({)('{')
Parameter list
<empty list>
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)(' a ')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)(' a ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
PsiElement($/ regex content)(' ')
GString injection
@@ -45,10 +46,11 @@ Groovy script
PsiElement({)('{')
Parameter list
<empty list>
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)(' c ')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)(' c ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
PsiElement($/ regex content)(' ')
PsiElement($/ regex end)('/$')
@@ -10,7 +10,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('C:\temp\')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('C:\temp\')
PsiElement($/ regex end)('/$')
@@ -14,7 +14,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('\nto be\nor\nnot to be\n')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('\nto be\nor\nnot to be\n')
PsiElement(regex end)('/')
@@ -7,7 +7,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('abc')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('abc')
PsiElement(regex end)('/')
@@ -40,7 +40,7 @@ Groovy script
Reference expression
PsiElement(identifier)('frg')
PsiElement(.)('.')
Compound regular expression
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('sdf')
PsiElement(regex end)('/')
@@ -7,10 +7,11 @@ Groovy script
Reference expression
PsiElement(identifier)('i')
PsiElement(=)('=')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('ab \\ncd')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('ab \\ncd')
PsiElement(regex end)('/')
PsiElement(new line)('\n')
Assignment expression
Reference expression
@@ -2,7 +2,8 @@
-----
Groovy script
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('abc')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('abc')
PsiElement(regex end)('/')
@@ -19,10 +19,11 @@ Groovy script
PsiElement({)('{')
Parameter list
<empty list>
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('bugaga')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('bugaga')
PsiElement(regex end)('/')
PsiElement(})('}')
PsiElement(regex content)(' asd')
PsiElement(regex end)('/')
@@ -1,7 +1,8 @@
/$/
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('$')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('$')
PsiElement(regex end)('/')
@@ -1,8 +1,9 @@
/$
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement($)('$')
PsiErrorElement:Regex ending expected
<empty list>
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement($)('$')
PsiErrorElement:Regex ending expected
<empty list>
@@ -1,7 +1,8 @@
/sgfdhj$5dhfg/
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('sgfdhj$5dhfg')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('sgfdhj$5dhfg')
PsiElement(regex end)('/')
@@ -1,7 +1,8 @@
/gsdfjk$ gsdkf$ $/
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('gsdfjk$ gsdkf$ $')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('gsdfjk$ gsdkf$ $')
PsiElement(regex end)('/')
@@ -30,7 +30,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('abc')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('abc')
PsiElement(regex end)('/')
@@ -7,8 +7,9 @@ Groovy script
PsiWhiteSpace(' ')
Arguments
PsiElement(()('(')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('a\${2}')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('a\${2}')
PsiElement(regex end)('/')
PsiElement())(')')
@@ -1,7 +1,8 @@
$/abc/$
-----
Groovy script
Compound regular expression
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('abc')
PsiElement($/ regex end)('/$')
Literal
GroovyASTPsiElementImpl($/ regex literal)
PsiElement($/ regex begin)('$/')
PsiElement($/ regex content)('abc')
PsiElement($/ regex end)('/$')
@@ -1,7 +1,8 @@
/abc/
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('abc')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('abc')
PsiElement(regex end)('/')
@@ -7,7 +7,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('abs$$$')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('abs$$$')
PsiElement(regex end)('/')
@@ -3,10 +3,11 @@
-----
Groovy script
Call expression
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('asd\n')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('asd\n')
PsiElement(regex end)('/')
Command arguments
Reference expression
PsiElement(identifier)('abcdef')
@@ -13,7 +13,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=~)('=~')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('o(b.*r)f')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('o(b.*r)f')
PsiElement(regex end)('/')
@@ -13,7 +13,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=~)('=~')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('\$(.*)\.')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('\$(.*)\.')
PsiElement(regex end)('/')
@@ -56,7 +56,7 @@ Groovy script
Reference expression
PsiElement(identifier)('frg')
PsiElement(.)('.')
Compound regular expression
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('sdf')
PsiElement(regex end)('/')
@@ -57,7 +57,7 @@ Groovy script
Reference expression
PsiElement(identifier)('frg')
PsiElement(.)('.')
Compound regular expression
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('sdf')
PsiElement(regex end)('/')
@@ -1,7 +1,8 @@
/temp_regex/
-----
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('temp_regex')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('temp_regex')
PsiElement(regex end)('/')
@@ -2,7 +2,8 @@
-----
Groovy script
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('temp_regex')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('temp_regex')
PsiElement(regex end)('/')
@@ -10,7 +10,8 @@ Groovy script
PsiWhiteSpace(' ')
PsiElement(=)('=')
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('I cost $$@$@$$')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('I cost $$@$@$$')
PsiElement(regex end)('/')
@@ -18,10 +18,11 @@ Groovy script
PsiWhiteSpace(' ')
Unary expression
PsiElement(~)('~')
Compound regular expression
PsiElement(regex begin)('/')
PsiElement(regex content)('....')
PsiElement(regex end)('/')
Literal
GroovyASTPsiElementImpl(regex literal)
PsiElement(regex begin)('/')
PsiElement(regex content)('....')
PsiElement(regex end)('/')
PsiWhiteSpace(' ')
PsiElement(:)(':')
PsiElement(new line)('\n')