Skip to content

Commit

Permalink
improved expression handling and more
Browse files Browse the repository at this point in the history
* handle global title in label provider
* improved expression validation
* no error for optional pilot episode
* follow up news variable validation
* validation support for global variables
* support betty love modifier
* validation function dot missing and <all> is first language
  • Loading branch information
nittka committed Dec 7, 2024
1 parent 882203b commit e281175
Show file tree
Hide file tree
Showing 12 changed files with 334 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ private String withFictional(Person p, String name) {

private String fromTitle(Title t) {
if (t != null) {
if(t.getGlobal()!=null) {
return t.getGlobal();
}
EList<LanguageString> lStrings = t.getLstrings();
if (!lStrings.isEmpty()) {
return lStrings.get(0).getText();
Expand Down
9 changes: 9 additions & 0 deletions org.tvtower.db/src/org/tvtower/db/Database.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ PersonLocalization:
'<''programmeroles''>'
roles+=RoleLocale*
'</''programmeroles''>'
('<''globalvariables''>'
variables+=GlobalVariable*
'</''globalvariables''>')?
;

GlobalVariable:
'<'var=IDorKeyword'>'
=> content=TextContent
'</'IDorKeyword'>'
;

MayContainVariables:NewsItem|ScriptTemplate;
Expand Down
6 changes: 6 additions & 0 deletions org.tvtower.db/src/org/tvtower/db/DatabaseRuntimeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
package org.tvtower.db;

import org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.naming.SimpleNameProvider;
import org.eclipse.xtext.parser.antlr.Lexer;
Expand All @@ -14,6 +15,7 @@
import org.tvtower.db.parser.antlr.internal.InternalDatabaseLexer;
import org.tvtower.db.resource.DatabaseResourceDescriptionStrategy;
import org.tvtower.db.resource.DatabaseResourceServiceProvider;
import org.tvtower.db.scoping.DatabaseLinkingDiagnosticMessageProvider;
import org.tvtower.db.validation.DatabaseConfigurableIssueCodesProvider;

import com.google.inject.Binder;
Expand Down Expand Up @@ -59,4 +61,8 @@ public Class<? extends ConfigurableIssueCodesProvider> bindConfigurableIssueCode
return DatabaseConfigurableIssueCodesProvider.class;
}

public Class<? extends ILinkingDiagnosticMessageProvider> bindLinkingErrorMessageProvider() {
return DatabaseLinkingDiagnosticMessageProvider.class;
}

}
4 changes: 3 additions & 1 deletion org.tvtower.db/src/org/tvtower/db/constants/EffectType.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class EffectType extends TVTEnum {
public static final String NEWS_AVAILABILITY="modifyNewsAvailability";
public static final String PROGRAMME_AVAILABILITY="modifyProgrammeAvailability";
public static final String SCRIPT_AVAILABILITY="modifyScriptAvailability";
public static final String BETTY_LOVE="modifyBettyLove";

EffectType() {
add(NEWS, "news");
Expand All @@ -17,10 +18,11 @@ public class EffectType extends TVTEnum {
add(SCRIPT_AVAILABILITY, "script availability");
add(PERSON, "change person popularity");
add(GENRE, "change genre popularity");
add(BETTY_LOVE, "change betty love");
}

public boolean isNewsTrigger(String type) {
return type!=null && type.startsWith(NEWS);
return NEWS.equals(type) || NEWS_CHOICE.equals(type);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.tvtower.db.scoping;

import org.eclipse.xtext.diagnostics.DiagnosticMessage;
import org.eclipse.xtext.linking.impl.LinkingDiagnosticMessageProvider;
import org.tvtower.db.database.Effect;

public class DatabaseLinkingDiagnosticMessageProvider extends LinkingDiagnosticMessageProvider {

@Override
public DiagnosticMessage getUnresolvedProxyMessage(ILinkingDiagnosticContext context) {
// do not try to resolve variables within effects
if (context.getContext() instanceof Effect) {
if (context.getLinkText() != null && context.getLinkText().matches("\\$\\{\\w+\\}")) {
return null;
}
}
return super.getUnresolvedProxyMessage(context);
}
}
Loading

0 comments on commit e281175

Please sign in to comment.