Commit eeb8feb4 authored by irengrig's avatar irengrig
Browse files

Merge remote branch 'origin/117' into 117

parents ff7b0366 50da56c4
Branches unavailable Tags unavailable
No related merge requests found
Showing with 60 additions and 9 deletions
+60 -9
......@@ -659,6 +659,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) {
if (refEntity instanceof RefImplicitConstructor) refEntity = ((RefImplicitConstructor)refEntity).getOwnerClass();
Element element = refEntity.getRefManager().export(refEntity, parentNode, -1);
if (element == null) return;
@NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
if (refEntity instanceof RefElement) {
......
......@@ -286,6 +286,7 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
@NonNls String problemText = StringUtil.replace(StringUtil.replace(template, "#ref", psiElement != null ? ProblemDescriptionNode.extractHighlightedText(description, psiElement): "") , " #loc ", " ");
Element element = refEntity.getRefManager().export(refEntity, parentNode, line);
if (element == null) return;
@NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
problemClassElement.addContent(getDisplayName());
if (refEntity instanceof RefElement){
......
......@@ -208,6 +208,7 @@ public class RefManagerImpl extends RefManager {
final RefElement refElement = (RefElement)refEntity;
PsiElement psiElement = refElement.getElement();
PsiFile psiFile = psiElement.getContainingFile();
if (psiFile == null) return null;
Element fileElement = new Element("file");
Element lineElement = new Element("line");
......
......@@ -43,6 +43,7 @@ import java.util.*;
public class NotificationsConfigurationImpl extends NotificationsConfiguration implements ApplicationComponent,
PersistentStateComponent<Element> {
private static final Logger LOG = Logger.getInstance("#com.intellij.notification.impl.NotificationsConfiguration");
private static final String SHOW_BALLOONS_ATTRIBUTE = "showBalloons";
private final Map<String, NotificationSettings> myIdToSettingsMap = new LinkedHashMap<String, NotificationSettings>();
private final Map<String, String> myToolWindowCapable = new java.util.LinkedHashMap<String, String>();
......@@ -167,6 +168,10 @@ public class NotificationsConfigurationImpl extends NotificationsConfiguration i
for (String entry: myToolWindowCapable.keySet()) {
element.addContent(new Element("toolWindow").setAttribute("group", entry));
}
//noinspection NonPrivateFieldAccessedInSynchronizedContext
if (!SHOW_BALLOONS) {
element.setAttribute(SHOW_BALLOONS_ATTRIBUTE, "false");
}
return element;
}
......@@ -187,5 +192,9 @@ public class NotificationsConfigurationImpl extends NotificationsConfiguration i
}
}
_remove("Log Only");
if ("false".equals(state.getAttributeValue(SHOW_BALLOONS_ATTRIBUTE))) {
//noinspection NonPrivateFieldAccessedInSynchronizedContext
SHOW_BALLOONS = false;
}
}
}
......@@ -337,7 +337,11 @@ public class GroovyParser implements PsiParser {
return true;
}
if (GroovyTokenTypes.kIMPORT.equals(builder.getTokenType())) {
if (isBlockStatementNeeded && mSEMI == builder.getTokenType()) {
return true;
}
if (GroovyTokenTypes.kIMPORT.equals(builder.getTokenType())) {
PsiBuilder.Marker marker = builder.mark();
ImportStatement.parse(builder, this);
marker.error(GroovyBundle.message("import.not.allowed"));
......
......@@ -34,8 +34,7 @@ import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub;
* @author Maxim.Medvedev
*/
public class GrEnumConstantInitializerImpl extends GrAnonymousClassDefinitionImpl implements GrEnumConstantInitializer {
private static final Logger LOG =
Logger.getInstance("#org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.GrEnumConstantInitializerImpl");
private static final Logger LOG = Logger.getInstance(GrEnumConstantInitializerImpl.class);
public GrEnumConstantInitializerImpl(@NotNull ASTNode node) {
super(node);
......
......@@ -38,6 +38,7 @@ import org.jetbrains.plugins.groovy.GroovyFileType;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumConstantInitializer;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
......@@ -361,14 +362,16 @@ public class GrClassImplUtil {
return true;
}
private static boolean isSameDeclaration(PsiElement place, PsiElement element) {
public static boolean isSameDeclaration(PsiElement place, PsiElement element) {
if (element instanceof GrAccessorMethod) element = ((GrAccessorMethod)element).getProperty();
if (!(element instanceof GrField)) return false;
while (place != null) {
place = place.getParent();
if (place == element) return true;
place = place.getParent();
if (place instanceof GrClosableBlock) return false;
if (place instanceof GrEnumConstantInitializer) return false;
}
return false;
}
......
......@@ -61,6 +61,7 @@ public class StatementsParsingTest extends GroovyParsingTestCase {
public void testFor$for1() throws Throwable { doTest(); }
public void testFor$for10() throws Throwable { doTest(); }
public void testFor$for11() throws Throwable { doTest(); }
public void testFor$for12() throws Throwable { doTest(); }
public void testFor$for2() throws Throwable { doTest(); }
public void testFor$for3() throws Throwable { doTest(); }
public void testFor$for4() throws Throwable { doTest(); }
......
......@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.resolve;
package org.jetbrains.plugins.groovy.lang.resolve
import com.intellij.psi.*
import com.intellij.psi.util.PropertyUtil
import org.jetbrains.plugins.groovy.GroovyFileType
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement
......@@ -32,8 +32,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMe
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.GrTopStatement
import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil
import org.jetbrains.plugins.groovy.util.TestUtils
import com.intellij.psi.*
/**
* @author ven
*/
......@@ -731,6 +729,20 @@ print map.cla<caret>ss''')
assertInstanceOf( resolved , GrField)
assertEquals(resolved.containingClass.name, 'B')
}
void testResolveEnumConstantInsideItsInitializer() {
def ref = configureByText('''\
enum MyEnum {
CONST {
void get() {
C<caret>ONST
}
}
}
''')
assertNotNull(ref)
}
}
for (i in []);
-----
Groovy script
For statement
PsiElement(for)('for')
PsiWhiteSpace(' ')
PsiElement(()('(')
In clause
Parameter
Modifiers
<empty list>
PsiElement(identifier)('i')
PsiWhiteSpace(' ')
PsiElement(in)('in')
PsiWhiteSpace(' ')
Generalized list
PsiElement([)('[')
PsiElement(])(']')
PsiElement())(')')
PsiElement(;)(';')
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment