mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
Use SuppressWarnings[..] rather than Suppress[..]
This commit is contained in:
parent
dc67c9e3d5
commit
653aa74bc5
34 changed files with 170 additions and 111 deletions
|
@ -97,7 +97,7 @@ import org.junit.Assert
|
|||
logger.level = level
|
||||
action.run
|
||||
val events = appender.events.toList.sortWith(TEMPORAL_ORDER)
|
||||
new LogCapture(events)
|
||||
return new LogCapture(events)
|
||||
} finally {
|
||||
logger.removeAppender(appender)
|
||||
allAppenders.forEach[removeFilter(filter)]
|
||||
|
@ -114,10 +114,16 @@ import org.junit.Assert
|
|||
}
|
||||
|
||||
private static def removeFilter(Appender appender, Filter filter) {
|
||||
for (var current = appender.filter; current != null; current = current.getNext) {
|
||||
if (current.getNext == filter) {
|
||||
current.setNext(null)
|
||||
}
|
||||
if (appender.filter == filter) {
|
||||
appender.clearFilters
|
||||
appender.addFilter(filter.getNext)
|
||||
} else {
|
||||
for (var current = appender.filter; current != null; current = current.getNext) {
|
||||
if (current.getNext == filter) {
|
||||
current.setNext(filter.getNext)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ AbstractToken returns AbstractElement:
|
|||
Action
|
||||
;
|
||||
|
||||
/* Suppress[potentialOverride]: Handled in CardinalityAwareEcoreFactory */
|
||||
/* SuppressWarnings[potentialOverride]: Handled in CardinalityAwareEcoreFactory */
|
||||
AbstractTokenWithCardinality returns AbstractElement:
|
||||
(Assignment | AbstractTerminal) (cardinality=('?'|'*'|'+'))?
|
||||
;
|
||||
|
@ -149,7 +149,7 @@ TerminalGroup returns AbstractElement:
|
|||
TerminalToken ({Group.elements+=current} (elements+=TerminalToken)+)?
|
||||
;
|
||||
|
||||
/* Suppress[potentialOverride]: Handled in CardinalityAwareEcoreFactory */
|
||||
/* SuppressWarnings[potentialOverride]: Handled in CardinalityAwareEcoreFactory */
|
||||
TerminalToken returns AbstractElement:
|
||||
TerminalTokenElement (cardinality=('?'|'*'|'+'))?
|
||||
;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -15,6 +16,7 @@ import org.eclipse.emf.ecore.EObject;
|
|||
import org.eclipse.emf.ecore.EStructuralFeature;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.xtext.AbstractRule;
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.GrammarUtil;
|
||||
import org.eclipse.xtext.diagnostics.Severity;
|
||||
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;
|
||||
|
@ -22,9 +24,12 @@ import org.eclipse.xtext.nodemodel.ICompositeNode;
|
|||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
import org.eclipse.xtext.resource.ILocationInFileProvider;
|
||||
import org.eclipse.xtext.util.IAcceptor;
|
||||
import org.eclipse.xtext.util.ITextRegion;
|
||||
import org.eclipse.xtext.validation.DiagnosticConverterImpl;
|
||||
import org.eclipse.xtext.validation.Issue;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
|
@ -72,21 +77,46 @@ public class XtextDiagnosticConverter extends DiagnosticConverterImpl{
|
|||
return null;
|
||||
}
|
||||
}
|
||||
Grammar grammar = GrammarUtil.getGrammar(causer);
|
||||
if (grammar != null && isMarkedAsIgnored(grammar, issueCode)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// group 1 matches the suffix in an issue code e.g. someCode from org.eclipse.xtext.Xtext.someCode
|
||||
private final Pattern afterLastDot = Pattern.compile(".*\\W(\\w+)$");
|
||||
// group 1 matches the codes given in SuppressWarnings[code1, code2], e.g. "code1, code2" is returned
|
||||
private final Pattern suppressWarnings = Pattern.compile("SuppressWarnings\\[([^]]*)\\]", Pattern.CASE_INSENSITIVE);
|
||||
private final Splitter splitter = Splitter.on(',').trimResults().omitEmptyStrings();
|
||||
private static final String ALL = "all";
|
||||
|
||||
protected boolean isMarkedAsIgnored(EObject object, String code) {
|
||||
String documentation = documentationProvider.getDocumentation(object);
|
||||
if (documentation != null) {
|
||||
Matcher matcher = afterLastDot.matcher(code);
|
||||
if (matcher.matches()) {
|
||||
String suffix = matcher.group(1);
|
||||
if (documentation.contains("Suppress[" + suffix + "]")) {
|
||||
return true;
|
||||
Matcher suppressWarningsMatcher = suppressWarnings.matcher(documentation);
|
||||
while (suppressWarningsMatcher.find()) {
|
||||
String suffix = null;
|
||||
String suppressed = suppressWarningsMatcher.group(1);
|
||||
Iterator<String> iter = splitter.split(suppressed).iterator();
|
||||
while(iter.hasNext()) {
|
||||
String next = iter.next();
|
||||
if (ALL.equalsIgnoreCase(next)) {
|
||||
return true;
|
||||
}
|
||||
if (suffix == null) {
|
||||
Matcher matcher = afterLastDot.matcher(code);
|
||||
if (matcher.matches()) {
|
||||
suffix = matcher.group(1);
|
||||
} else {
|
||||
suffix = "";
|
||||
}
|
||||
}
|
||||
if (suffix.equalsIgnoreCase(next)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ AbstractToken returns AbstractElement:
|
|||
Action
|
||||
;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
AbstractTokenWithCardinality returns AbstractElement:
|
||||
(Assignment |
|
||||
AbstractTerminal) (cardinality=('?'|'*'|'+'))?
|
||||
|
@ -130,7 +130,7 @@ TerminalGroup returns AbstractElement:
|
|||
TerminalToken ({Group.tokens+=current} (tokens+=TerminalToken)+)?
|
||||
;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
TerminalToken returns AbstractElement:
|
||||
TerminalTokenElement (cardinality=('?'|'*'|'+'))?
|
||||
;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*******************************************************************************/
|
||||
grammar org.eclipse.xtext.enumrules.EnumRulesTestLanguage with org.eclipse.xtext.common.Terminals
|
||||
|
||||
/* Suppress[external] */
|
||||
/* SuppressWarnings[external] */
|
||||
import "classpath:/org/eclipse/xtext/enumrules/enums.ecore"
|
||||
generate enumRulesTestLanguage "http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest"
|
||||
|
||||
|
|
|
@ -11,9 +11,11 @@ import java.io.FileNotFoundException;
|
|||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.eclipse.emf.common.util.WrappedException;
|
||||
import org.eclipse.xpand2.XpandExecutionContext;
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.junit4.logging.LoggingTester;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -26,7 +28,7 @@ public class CompositeGeneratorFragmentTest extends Assert {
|
|||
|
||||
@Test
|
||||
public void testFinalBindingsPersist() throws Exception {
|
||||
CompositeGeneratorFragment fragment = new CompositeGeneratorFragment();
|
||||
final CompositeGeneratorFragment fragment = new CompositeGeneratorFragment();
|
||||
fragment.addFragment(new DefaultGeneratorFragment() {
|
||||
@Override
|
||||
public Set<Binding> getGuiceBindingsRt(Grammar grammar) {
|
||||
|
@ -43,9 +45,16 @@ public class CompositeGeneratorFragmentTest extends Assert {
|
|||
return bindFactory.getBindings();
|
||||
}
|
||||
});
|
||||
Set<Binding> bindings = fragment.getGuiceBindingsRt(null);
|
||||
assertEquals(1, bindings.size());
|
||||
assertEquals("BAR", bindings.iterator().next().getValue().getTypeName());
|
||||
LoggingTester.captureLogging(Level.WARN, CompositeGeneratorFragment.class, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Set<Binding> bindings = fragment.getGuiceBindingsRt(null);
|
||||
assertEquals(1, bindings.size());
|
||||
assertEquals("BAR", bindings.iterator().next().getValue().getTypeName());
|
||||
}
|
||||
|
||||
}).assertLogEntry("Cannot override final binding 'final FOO -> BAR (contributed by org.eclipse.xtext.generator.CompositeGeneratorFragmentTest$1)'. Ignoring binding from fragment 'org.eclipse.xtext.generator.CompositeGeneratorFragmentTest$2'");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -95,7 +104,6 @@ public class CompositeGeneratorFragmentTest extends Assert {
|
|||
fragment.getGuiceBindingsRt(null);
|
||||
fail("exception expected");
|
||||
} catch (IllegalStateException e) {
|
||||
System.out.println(e);
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
grammar org.eclipse.xtext.generator.ecore.EcoreFragmentTestLanguage with org.eclipse.xtext.common.Terminals
|
||||
|
||||
/* Suppress[external] */
|
||||
/* SuppressWarnings[external] */
|
||||
import "classpath:/org/eclipse/xtext/generator/ecore/First.ecore" as first
|
||||
generate second "http://www.eclipse.org/2009/tmf/xtext/EcoreFragmentTestLanguage" as second
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ AType:
|
|||
AnotherType:
|
||||
'bar' {AnotherType};
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
FinderKeywords:
|
||||
'myKeyword' name=ID? 'myKeyword' 'lala';
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
FinderKeywordPairs:
|
||||
'begin' 'whatever' name=ID ('begin' nested=ID 'end')* 'end' 'begin' second=ID 'end';
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
grammar org.eclipse.xtext.generator.grammarAccess.GrammarAccessTestLanguage with org.eclipse.xtext.common.Terminals
|
||||
|
||||
/* Suppress[external] */
|
||||
/* SuppressWarnings[external] */
|
||||
import "classpath:/org/eclipse/xtext/generator/grammarAccess/ametamodel.ecore#//asubpackage" as root
|
||||
/* Suppress[external] */
|
||||
/* SuppressWarnings[external] */
|
||||
import "classpath:/org/eclipse/xtext/generator/grammarAccess/ametamodel.ecore#//asubpackage/emptyPackage/subsubpackage" as sub
|
||||
|
||||
Root returns root::AModel:
|
||||
|
|
|
@ -14,7 +14,7 @@ import "http://www.eclipse.org/emf/2002/Ecore" as ecore
|
|||
InheritedParserRule returns mm::AType:
|
||||
'element' name=ID;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
AbstractCallOverridenParserRule returns mm::AModel:
|
||||
'overridemodel' (elements+=OverridableParserRule)*;
|
||||
|
||||
|
@ -24,7 +24,7 @@ OverridableParserRule returns mm::AType :
|
|||
OverridableParserRule2 returns mm::AType :
|
||||
'other element' name=STRING;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
AbstractCallExtendedParserRule returns mm::AModel:
|
||||
'extendedmodel' (elements+=ExtendableParserRule)*;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ grammar org.eclipse.xtext.linking.Bug287988TestLanguage with org.eclipse.xtext.c
|
|||
|
||||
generate bug287988Test "http://eclipse.org/xtext/Bug287988TestLanguage"
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Model:
|
||||
('actions' attributes+=BaseAttribute*)
|
||||
| ('simple' attributes+=SimpleAttribute*)
|
||||
|
|
|
@ -13,8 +13,8 @@ Model :
|
|||
types+=Type*;
|
||||
|
||||
/*
|
||||
* Suppress[BidirectionalReference]
|
||||
* Suppress[potentialOverride]
|
||||
* SuppressWarnings[BidirectionalReference]
|
||||
* SuppressWarnings[potentialOverride]
|
||||
*/
|
||||
Type :
|
||||
'type' name=ID ('extends' ^extends=[Type] '.' parentId=[Property])? ('for' parentId=[Property] 'in' ^extends=[Type])? '{'
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*******************************************************************************/
|
||||
grammar org.eclipse.xtext.metamodelreferencing.tests.EcoreReferenceTestLanguage with org.eclipse.xtext.common.Terminals
|
||||
|
||||
/* Suppress[external] */
|
||||
/* SuppressWarnings[external] */
|
||||
import "http://www.eclipse.org/2011/tmf/xtext/ecorePerNsURI"
|
||||
import "http://www.eclipse.org/2011/tmf/xtext/ecorePerPlatformPlugin"
|
||||
import "http://www.eclipse.org/2011/tmf/xtext/ecorePerPlatformResource"
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.net.URL;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.mwe.core.WorkflowContext;
|
||||
import org.eclipse.emf.mwe.core.WorkflowContextDefaultImpl;
|
||||
|
@ -25,6 +26,7 @@ import org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup;
|
|||
import org.eclipse.xtext.index.indexTestLanguage.Entity;
|
||||
import org.eclipse.xtext.index.indexTestLanguage.IndexTestLanguagePackage;
|
||||
import org.eclipse.xtext.junit4.AbstractXtextTests;
|
||||
import org.eclipse.xtext.junit4.logging.LoggingTester;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +35,7 @@ import org.junit.Test;
|
|||
public abstract class AbstractReaderTest extends AbstractXtextTests {
|
||||
|
||||
@Test public void testLoadMatchNone() throws Exception {
|
||||
Reader reader = getReader();
|
||||
final Reader reader = getReader();
|
||||
reader.addPath(pathTo("emptyFolder"));
|
||||
reader.addPath(pathTo("nonemptyFolder"));
|
||||
reader.addRegister(new IndexTestLanguageStandaloneSetup());
|
||||
|
@ -48,8 +50,15 @@ public abstract class AbstractReaderTest extends AbstractXtextTests {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
WorkflowContext ctx = ctx();
|
||||
reader.invoke(ctx, monitor(), issues());
|
||||
final WorkflowContext ctx = ctx();
|
||||
LoggingTester.captureLogging(Level.WARN, SlotEntry.class, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
reader.invoke(ctx, monitor(), issues());
|
||||
}
|
||||
|
||||
}).assertLogEntry("Could not find any exported element of type 'Type' -> Slot 'model' is empty.");
|
||||
Collection<?> slotContent = (Collection<?>) ctx.get("model");
|
||||
assertNotNull(slotContent);
|
||||
assertTrue(slotContent.isEmpty());
|
||||
|
|
|
@ -9,7 +9,7 @@ grammar org.eclipse.xtext.parser.antlr.Bug296889ExTestLanguage with org.eclipse.
|
|||
|
||||
generate bug296889ExTest "http://eclipse.org/xtext/Bug296889ExTestLanguage"
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Model: "Model" expressions += Expression* | "DataType" values += DataTypeExpression* ;
|
||||
|
||||
Expression: Postop | Preop ;
|
||||
|
|
|
@ -9,7 +9,7 @@ grammar org.eclipse.xtext.parser.antlr.Bug296889TestLanguage with org.eclipse.xt
|
|||
|
||||
generate bug296889Test "http://eclipse.org/xtext/Bug296889TestLanguage"
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Model: "Model" expressions += Expression* | "DataType" values += DataTypeExpression* ;
|
||||
|
||||
Expression: Postop | Preop ;
|
||||
|
|
|
@ -57,7 +57,7 @@ AbstractToken returns AbstractElement:
|
|||
Action
|
||||
;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
AbstractTokenWithCardinality returns AbstractElement:
|
||||
(Assignment |
|
||||
AbstractTerminal) (cardinality=('?'|'*'|'+'))?
|
||||
|
@ -121,7 +121,7 @@ TerminalGroup returns AbstractElement:
|
|||
TerminalToken ({Group.tokens+=current} (tokens+=TerminalToken)+)?
|
||||
;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
TerminalToken returns AbstractElement:
|
||||
TerminalTokenElement (cardinality=('?'|'*'|'+'))?
|
||||
;
|
||||
|
|
|
@ -54,7 +54,7 @@ UnorderedDatatype:
|
|||
| '14' (('a' & 'b') & ('c' & 'd'))+
|
||||
;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
UnorderedSerialization: {UnorderedSerialization} (
|
||||
'1' first?='a'? & second?='b'? & third?='c'? & forth?='d'?
|
||||
| '2' (firstAsList+='a' & secondAsList+='b')*
|
||||
|
|
|
@ -15,11 +15,11 @@ import "http://www.eclipse.org/2008/Xtext" as xtext
|
|||
Root:
|
||||
"test" (TestLinewrap | TestIndentation);
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TestLinewrap:
|
||||
"linewrap" items+=STRING*;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TestIndentation:
|
||||
"indentation" "{"
|
||||
(sub+=TestIndentation |
|
||||
|
|
|
@ -17,11 +17,11 @@ import "http://www.eclipse.org/2008/Xtext" as xtext
|
|||
Root:
|
||||
"test" (TestLinewrap | TestIndentation);
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TestLinewrap:
|
||||
"linewrap" items+=STRING*;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TestIndentation:
|
||||
"indentation" "{"
|
||||
(sub+=TestIndentation |
|
||||
|
|
|
@ -21,7 +21,7 @@ Term returns Expression:
|
|||
Atom:
|
||||
name=ID;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
Parens returns Expression:
|
||||
'(' Op ')' em='!'?;
|
||||
|
||||
|
@ -34,23 +34,23 @@ StrangeStuff :
|
|||
//TrickyA returns TypeA1: 'TA' TrickyA1 (name += ID)* ({TypeB.x=current} 'x' | {TypeC.x=current} 'y')? name+=STRING;
|
||||
//TrickyA1 returns TypeD: name+=ID;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TrickyB : 'TB' (name = ID type += INT)? (type += INT)*;
|
||||
|
||||
TrickyC : 'TC' name = ID ({C1.x=current} 'x')? ({C2.y=current} 'y')? ({C3.z=current} 'z')?;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TrickyD: 'TD' (name += INT foo = STRING type += ID)? (name += INT type += ID)? (type += ID)*;
|
||||
|
||||
// 34 "abc" XX 123 "de" YY x 34 DD 45 CC
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TrickyE: 'TE' (name+=INT foo+=STRING type+=ID)* 'x' (name+=INT type+=ID)*;
|
||||
|
||||
//
|
||||
TrickyF: 'TF' (name+=ID type+=INT)* (name+=ID | type+=INT);
|
||||
|
||||
TrickyG: 'TG' tree=TrickyG1;
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TrickyG1: '[' (vals+=TrickyG2 (',' vals+=TrickyG2)*)? ']';
|
||||
TrickyG2: TrickyG1 | val=INT;
|
||||
|
||||
|
|
|
@ -23,18 +23,18 @@ EnumBug:
|
|||
|
||||
enum EnumBugEnum: array="array" | object="object" | resultSet="resultSet" | iterator="iterator";
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Commentable:
|
||||
'#3' item+=CommentableItem*;
|
||||
|
||||
CommentableItem:
|
||||
'item' id=ID;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
ValueList:
|
||||
'#4' ids+=FQN*;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
RefList:
|
||||
'#5' objs+=RefObj* 'refs' refs+=[RefObj|FQN]*;
|
||||
|
||||
|
@ -45,7 +45,7 @@ SingleRef:
|
|||
'#6' obj=RefObj 'ref' ref=[RefObj|FQN];
|
||||
|
||||
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=297938
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
AppendToFileEnd:
|
||||
'#7' items+=AppendToFileEndItem*;
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ TwoRequired:
|
|||
TwoOptions:
|
||||
"twooptions" ("one" one=ID | "two" two=ID);
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Indent:
|
||||
"{" req=TwoRequired? opt=TwoOptions? indent+=Indent* "}";
|
|
@ -24,7 +24,7 @@ Term returns Expression:
|
|||
Atom:
|
||||
name=ID;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
Parens returns Expression:
|
||||
'(' Op ')' em='!'?;
|
||||
|
||||
|
@ -70,14 +70,14 @@ Loop4:
|
|||
LoopBug285452:
|
||||
'#12' (interface?="interface"|"class") name=ID;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
DuplicateBug284491:
|
||||
'#13' (static?='static' | final?='final' | transient?='transient')*;
|
||||
|
||||
EmptyObjectBug284850:
|
||||
'#14' items=EmptyObjectItems;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
EmptyObjectItems:
|
||||
list+=EmptyObjectItem*;
|
||||
|
||||
|
@ -115,11 +115,11 @@ TypeBug2B: {TypeBug2B} "kb" name=ID;
|
|||
Bug305171:
|
||||
"#19" (('kx' x+=ID (',' x+=ID)*)? (('ky' y+=ID (',' y+=ID)*)? ('kz' z+=ID (',' z+=ID)*)?)) name=ID;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Bug310435Enum:
|
||||
"#20" ('kw1' lits+=EnumBug310435Lit1 | 'kw2' lits+=EnumBug310435Lit2)*;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Bug310435Val:
|
||||
"#21" ('kw1' lits+=ID | 'kw2' lits+=STRING)*;
|
||||
|
||||
|
@ -129,7 +129,7 @@ enum EnumBug310435Lit1 returns EnumBug310435Enum:
|
|||
enum EnumBug310435Lit2 returns EnumBug310435Enum:
|
||||
lit2='lit2';
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
CrossRefNameTest:
|
||||
"#22" named+=CrossRefNamed* "kw1" ("kw2" ref+=[CrossRefNamed|ID1] | "kw3" ref+=[CrossRefNamed|ID2])*;
|
||||
|
||||
|
|
|
@ -8,13 +8,16 @@
|
|||
package org.eclipse.xtext.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.EAnnotation;
|
||||
import org.eclipse.emf.ecore.EClass;
|
||||
import org.eclipse.emf.ecore.EClassifier;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.EPackage;
|
||||
import org.eclipse.emf.ecore.EcoreFactory;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
|
@ -65,13 +68,13 @@ public class ConcurrentAccessTest extends Assert {
|
|||
ePackage.setNsURI("http://www.test.me/" + i);
|
||||
toBeProxified.getContents().add(ePackage);
|
||||
for (int j = 0; j < 100; j++) {
|
||||
EClass subClass = EcoreFactory.eINSTANCE.createEClass();
|
||||
subClass.setName("SubClass" + j);
|
||||
start.getEClassifiers().add(subClass);
|
||||
EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
|
||||
annotation.setSource("Source" + j);
|
||||
start.getEAnnotations().add(annotation);
|
||||
EClass superClass = EcoreFactory.eINSTANCE.createEClass();
|
||||
superClass.setName("SuperClass" + j);
|
||||
ePackage.getEClassifiers().add(superClass);
|
||||
subClass.getESuperTypes().add(superClass);
|
||||
annotation.getReferences().add(superClass);
|
||||
}
|
||||
toBeProxified.save(null);
|
||||
}
|
||||
|
@ -99,23 +102,14 @@ public class ConcurrentAccessTest extends Assert {
|
|||
resourceSet.getResources().add(resource);
|
||||
assertEquals(1, resourceSet.getResources().size());
|
||||
EPackage pack = (EPackage) resource.getContents().get(0);
|
||||
for(EClassifier classifier: pack.getEClassifiers()) {
|
||||
EClass clazz = (EClass) classifier;
|
||||
EList<EClass> superTypes = clazz.getESuperTypes();
|
||||
for(EClass superType: superTypes) {
|
||||
if (superType == null)
|
||||
throw new NullPointerException("No supertype");
|
||||
if (superType.eIsProxy())
|
||||
throw new NullPointerException("Unresolved Proxy");
|
||||
}
|
||||
}
|
||||
doResolveAllReferences(pack);
|
||||
assertEquals(101, resourceSet.getResources().size());
|
||||
}
|
||||
|
||||
@Ignore @Test public void testMultiThreaded() throws InterruptedException {
|
||||
ResourceSet resourceSet = new XtextResourceSet();
|
||||
resourceSet.getResources().add(resource);
|
||||
boolean wasOk = resolveAllSupertypesMultithreaded((EPackage) resource.getContents().get(0));
|
||||
boolean wasOk = resolveAllReferencesMultithreaded((EPackage) resource.getContents().get(0));
|
||||
if (wasOk)
|
||||
assertFalse(101 == resourceSet.getResources().size());
|
||||
assertFalse("unresolvedProxy", wasOk);
|
||||
|
@ -124,7 +118,7 @@ public class ConcurrentAccessTest extends Assert {
|
|||
@Test public void testMultiThreadedSynchronized() throws InterruptedException {
|
||||
ResourceSet resourceSet = new SynchronizedXtextResourceSet();
|
||||
resourceSet.getResources().add(resource);
|
||||
boolean wasOk = resolveAllSupertypesMultithreaded((EPackage) resource.getContents().get(0));
|
||||
boolean wasOk = resolveAllReferencesMultithreaded((EPackage) resource.getContents().get(0));
|
||||
assertEquals(101, resourceSet.getResources().size());
|
||||
assertTrue("unresolvedProxy", wasOk);
|
||||
}
|
||||
|
@ -132,7 +126,7 @@ public class ConcurrentAccessTest extends Assert {
|
|||
@Ignore @Test public void testMultiThreadedUnitOfWork() throws InterruptedException {
|
||||
ResourceSet resourceSet = new XtextResourceSet();
|
||||
resourceSet.getResources().add(resource);
|
||||
boolean wasOk = resolveAllSupertypesStateAccess((EPackage) resource.getContents().get(0));
|
||||
boolean wasOk = resolveAllReferencesStateAccess((EPackage) resource.getContents().get(0));
|
||||
if (wasOk)
|
||||
assertFalse(101 == resourceSet.getResources().size());
|
||||
assertFalse("unresolvedProxy", wasOk);
|
||||
|
@ -141,9 +135,9 @@ public class ConcurrentAccessTest extends Assert {
|
|||
@Test public void testMultiThreadedSynchronizedUnitOfWork() throws InterruptedException {
|
||||
ResourceSet resourceSet = new SynchronizedXtextResourceSet();
|
||||
resourceSet.getResources().add(resource);
|
||||
boolean wasOk = resolveAllSupertypesStateAccess((EPackage) resource.getContents().get(0));
|
||||
boolean wasOk = resolveAllReferencesStateAccess((EPackage) resource.getContents().get(0));
|
||||
assertEquals(101, resourceSet.getResources().size());
|
||||
assertTrue("unresolvedProxy", wasOk);
|
||||
assertTrue("unresolvedProxy or concurrent modification or no such element", wasOk);
|
||||
}
|
||||
|
||||
@Ignore @Test public void testMultiThreadedListAccess() throws InterruptedException {
|
||||
|
@ -217,14 +211,14 @@ public class ConcurrentAccessTest extends Assert {
|
|||
/**
|
||||
* @return <code>true</code> if everything was ok.
|
||||
*/
|
||||
protected boolean resolveAllSupertypesMultithreaded(final EPackage pack) throws InterruptedException {
|
||||
protected boolean resolveAllReferencesMultithreaded(final EPackage pack) throws InterruptedException {
|
||||
final AtomicBoolean wasExceptionOrProxy = new AtomicBoolean(false);
|
||||
List<Thread> threads = Lists.newArrayList();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
threads.add(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean failed = doResolveAllSupertypes(pack);
|
||||
boolean failed = doResolveAllReferences(pack);
|
||||
if (failed)
|
||||
wasExceptionOrProxy.set(failed);
|
||||
}
|
||||
|
@ -243,7 +237,7 @@ public class ConcurrentAccessTest extends Assert {
|
|||
/**
|
||||
* @return <code>true</code> if everything was ok.
|
||||
*/
|
||||
protected boolean resolveAllSupertypesStateAccess(final EPackage pack) throws InterruptedException {
|
||||
protected boolean resolveAllReferencesStateAccess(final EPackage pack) throws InterruptedException {
|
||||
final IReadAccess<EPackage> stateAccess = new AbstractReadWriteAcces<EPackage>() {
|
||||
@Override
|
||||
protected EPackage getState() {
|
||||
|
@ -256,14 +250,14 @@ public class ConcurrentAccessTest extends Assert {
|
|||
threads.add(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean failed = stateAccess.readOnly(new IUnitOfWork<Boolean, EPackage>() {
|
||||
Boolean failed = stateAccess.readOnly(new IUnitOfWork<Boolean, EPackage>() {
|
||||
@Override
|
||||
public Boolean exec(EPackage state) throws Exception {
|
||||
return doResolveAllSupertypes(pack);
|
||||
return doResolveAllReferences(pack);
|
||||
}
|
||||
});
|
||||
if (failed)
|
||||
wasExceptionOrProxy.set(failed);
|
||||
if (failed == null || failed)
|
||||
wasExceptionOrProxy.set(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -277,17 +271,22 @@ public class ConcurrentAccessTest extends Assert {
|
|||
return !wasExceptionOrProxy.get();
|
||||
}
|
||||
|
||||
protected boolean doResolveAllSupertypes(final EPackage pack) {
|
||||
protected boolean doResolveAllReferences(final EPackage pack) {
|
||||
boolean failed = false;
|
||||
for(EClassifier classifier: pack.getEClassifiers()) {
|
||||
EClass clazz = (EClass) classifier;
|
||||
EList<EClass> superTypes = clazz.getESuperTypes();
|
||||
for(EClass superType: superTypes) {
|
||||
if (superType == null)
|
||||
failed = true;
|
||||
else if (superType.eIsProxy())
|
||||
failed = true;
|
||||
try {
|
||||
for(EAnnotation annotation: pack.getEAnnotations()) {
|
||||
EList<EObject> references = annotation.getReferences();
|
||||
for(EObject reference: references) {
|
||||
if (reference == null)
|
||||
failed = true;
|
||||
else if (reference.eIsProxy())
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
} catch(ConcurrentModificationException e) {
|
||||
failed = true;
|
||||
} catch(NoSuchElementException e) {
|
||||
failed = true;
|
||||
}
|
||||
return failed;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ package org.eclipse.xtext.resource;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.xtext.junit4.logging.LoggingTester;
|
||||
import org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -27,11 +29,17 @@ public class ResourceServiceProvideRegistryTest {
|
|||
}
|
||||
};
|
||||
|
||||
IResourceServiceProvider.Registry reg = new ResourceServiceProviderRegistryImpl();
|
||||
final IResourceServiceProvider.Registry reg = new ResourceServiceProviderRegistryImpl();
|
||||
reg.getExtensionToFactoryMap().put("foo", provider);
|
||||
|
||||
assertEquals(1, reg.getExtensionToFactoryMap().size());
|
||||
assertNull(reg.getResourceServiceProvider(URI.createURI("hubba.foo")));
|
||||
LoggingTester.captureLogging(Level.ERROR, ResourceServiceProviderRegistryImpl.class, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
assertNull(reg.getResourceServiceProvider(URI.createURI("hubba.foo")));
|
||||
}
|
||||
}).assertLogEntry("Errorneous resource service provider registered for 'hubba.foo'. Removing it from the registry.");
|
||||
|
||||
assertEquals(0, reg.getExtensionToFactoryMap().size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,6 @@ public class SrcSegmentsInUrisAreNotRemovedTests {
|
|||
writer.flush();
|
||||
String fileContent = writer.toString();
|
||||
|
||||
System.out.println(fileContent);
|
||||
assertTrue(
|
||||
"We should have a src/ in the serialization as we are refering to a.ecore which is in a src folder.",
|
||||
fileContent.indexOf("src") > -1);
|
||||
|
|
|
@ -14,7 +14,7 @@ Model:
|
|||
domainModel = DomainModel
|
||||
;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
DomainModel:
|
||||
'entities'
|
||||
(entities+=Entity)*
|
||||
|
|
|
@ -10,7 +10,7 @@ grammar org.eclipse.xtext.testlanguages.FowlerDslTestLanguage with org.eclipse.x
|
|||
|
||||
generate fowlerdsl "http://example.xtext.org/FowlerDslTestLanguage"
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Statemachine :
|
||||
'events'
|
||||
(events+=Event)*
|
||||
|
|
|
@ -65,7 +65,7 @@ Combination1:
|
|||
Combination2:
|
||||
"#14" val1=ID (("kw1" val2=ID) | (val3+=ID val4+=ID)*);
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
Combination3:
|
||||
"#15" (val1=ID | val2=INT | val3=STRING)*;
|
||||
|
||||
|
@ -75,7 +75,7 @@ Combination4:
|
|||
List1:
|
||||
"#17" val1+=ID ("," val1+=ID)*;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
List2:
|
||||
"#18" (val1+=ID ("," val1+=ID)*)?;
|
||||
|
||||
|
@ -94,21 +94,21 @@ AltList1:
|
|||
AltList2:
|
||||
"#23" (val1+=ID val2=ID | "kw" val1+=ID ("," val1+=ID)* val3=ID);
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TransientObject:
|
||||
"#24" (val1=ID nested=TransientObjectSub)?;
|
||||
|
||||
TransientObjectSub:
|
||||
val2=ID val3=ID;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
TransientSerializeables1:
|
||||
"#25" (val1=ID enum1=TransientSerializeables1Enum)? (val2=ID int1=INT)?;
|
||||
|
||||
enum TransientSerializeables1Enum:
|
||||
lit1 | lit2;
|
||||
|
||||
/* Suppress[potentialOverride] */
|
||||
/* SuppressWarnings[potentialOverride] */
|
||||
StaticSimplification:
|
||||
"#26" ("kw1"|{EmptyAlternativeSub}|val1=ID) ("kw2"|val2=ID) ("kw3" ("kw4" (val3=ID)+)?);
|
||||
|
||||
|
@ -122,7 +122,7 @@ TwoVersionNo2 returns TwoVersion:
|
|||
shared1=ID? shared2=ID "long" (shared3+=ID shared3+=ID*)?
|
||||
"extra" extra1=ID? ((extra2=ID extra3=ID) | "two" extra4=ID)?;
|
||||
|
||||
/* Suppress[noInstantiation] */
|
||||
/* SuppressWarnings[noInstantiation] */
|
||||
Heuristic1:
|
||||
"#28" ("kw1" a+=ID b+=ID)* ("kw2" a+=ID c+=ID)* ("kw3" b+=ID c+=ID)*;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class Bug287082Test extends AbstractValidationMessageAcceptingTestCase {
|
|||
public void acceptWarning(String message, EObject object, EStructuralFeature feature, int index, String code,
|
||||
String... issueData) {
|
||||
if (code.equals(OverriddenValueInspector.ISSUE_CODE)) {
|
||||
String expectation = "";
|
||||
String expectation = "The assigned value of feature 'feature' will possibly override itself because it is used inside of a loop.";
|
||||
assertEquals(expectation, message);
|
||||
} else {
|
||||
super.acceptWarning(message, object, feature, index, code, issueData);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class XtextValidationTest extends AbstractValidationMessageAcceptingTestC
|
|||
"generate metamodel 'myURI'\n" +
|
||||
|
||||
"Model: child=Child;\n" +
|
||||
"/* Suppress[noInstantiation] */\n" +
|
||||
"/* SuppressWarnings[noInstantiation] */\n" +
|
||||
"Child: name=ID?;");
|
||||
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
|
||||
assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
|
||||
|
@ -120,7 +120,7 @@ public class XtextValidationTest extends AbstractValidationMessageAcceptingTestC
|
|||
"grammar org.acme.Bar with org.eclipse.xtext.common.Terminals\n" +
|
||||
"generate metamodel 'myURI'\n" +
|
||||
|
||||
"/* Suppress[potentialOverride] */\n" +
|
||||
"/* SuppressWarnings[potentialOverride] */\n" +
|
||||
"Parens: \n" +
|
||||
" ('(' Parens ')'|name=ID) em='!'?;");
|
||||
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
|
||||
|
|
|
@ -9,7 +9,7 @@ grammar org.eclipse.xtext.xtext.ecoreInference.DataTypeRuleWithEnumResultTestLan
|
|||
with org.eclipse.xtext.enumrules.EnumRulesTestLanguage
|
||||
|
||||
import 'http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest'
|
||||
/* Suppress[external] */
|
||||
/* SuppressWarnings[external] */
|
||||
import 'classpath:/org/eclipse/xtext/enumrules/enums.ecore'
|
||||
|
||||
Model:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
grammar org.eclipse.xtext.xtext.ecoreInference.Test with org.eclipse.xtext.common.Terminals
|
||||
generate root "http://root"
|
||||
/* Suppress[external] */
|
||||
/* SuppressWarnings[external] */
|
||||
import "classpath:/org/eclipse/xtext/xtext/ecoreInference/test.ecore" as test
|
||||
|
||||
Root :
|
||||
|
|
Loading…
Reference in a new issue