Search in sources :

Example 11 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class XmlPrettyPrinterPerformanceTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    ReflectionFactory.deployWholePlatform();
    String packagePath = StringUtils.packagePath(XmlPrettyPrinterPerformanceTest.class.getPackage().getName());
    IPersistenceProvider pp = new ClasspathPersistenceProvider(packagePath + "/content.xml");
    xmlModel = XmlSourcePersistenceKit.instance().readModel(pp);
}
Also used : ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) IPersistenceProvider(org.whole.lang.codebase.IPersistenceProvider) BeforeClass(org.junit.BeforeClass)

Example 12 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class LegacyContributionExtensionsDeployer method deploy.

public void deploy(ReflectionFactory platform) {
    try {
        InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/html/HTML5Semantics.xwl")));
        InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/html/HTML5Actions.xwl")));
        InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/javascript/JavaScriptSemantics.xwl")));
        InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/javascript/JavaScriptActions.xwl")));
        InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/mediawiki/MediaWikiActions.xwl")));
        InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/ui/CaretActionsSemantics.xwl")));
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
    platform.addPersistenceKit("org.whole.lang.html.Html5Editor", HtmlPersistenceKit.instance());
    platform.addOperationFactory(LegacyMetaModelsDeployer.HTML5_URI, PrettyPrinterOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            return new HtmlPrettyPrinterVisitor((PrettyPrinterOperation) operation);
        }
    });
    platform.addOperationFactory(JavaScriptLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            if (stage == 0)
                return new JavaScriptInterpreterVisitor();
            else
                return null;
        }
    });
}
Also used : IOperation(org.whole.lang.operations.IOperation) PrettyPrinterOperation(org.whole.lang.operations.PrettyPrinterOperation) IVisitor(org.whole.lang.visitors.IVisitor) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) JavaScriptInterpreterVisitor(org.whole.lang.javascript.visitors.JavaScriptInterpreterVisitor) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) HtmlPrettyPrinterVisitor(org.whole.lang.html.visitors.HtmlPrettyPrinterVisitor)

Example 13 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class ArtifactsGeneratorTest method testGenerate.

@Test
public void testGenerate() throws Exception {
    IBindingManager env = BindingManagerFactory.instance.createArguments();
    env.wDefValue("projectName", "testProject");
    env.wDefValue("sourceFolderName", "src");
    env.wDefValue("packageName", "org.whole.lang.templates.codebase");
    IEntity templates = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/templates/codebase/TemplateManagerArtifactsTemplates.xwl"));
    ArtifactsGeneratorOperation.generate(templates, env);
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Example 14 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class GenericForwardSpecificBuilderTest method testMultiLanguage.

@Test
public void testMultiLanguage() throws Exception {
    IEntity entity = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/queries/util/BindVariablesInPathTemplates.xwl"));
    ModelBuilderOperation mop = new ModelBuilderOperation();
    ModelTemplate template = new ModelTemplate(entity);
    template.apply(new GenericForwardSpecificBuilder(mop));
    IEntity newEntity = mop.wGetResult();
    // to match variables fill variables with defaults
    IEntityIterator<IEntity> variableIterator = IteratorFactory.<IEntity>descendantOrSelfMatcherIterator().withPattern(GenericMatcherFactory.instance.isVariableMatcher());
    variableIterator.reset(entity);
    IEntityIterator<IEntity> newVariableIterator = IteratorFactory.<IEntity>descendantOrSelfMatcherIterator().withPattern(GenericMatcherFactory.instance.isVariableMatcher());
    newVariableIterator.reset(newEntity);
    while (variableIterator.hasNext()) {
        assertTrue(newVariableIterator.hasNext());
        Variable variable = (Variable) variableIterator.next().wGetAdaptee(false);
        Variable newVariable = (Variable) newVariableIterator.next().wGetAdaptee(false);
        EntityDescriptor<?> ed = variable.getVarType().getValue();
        EntityDescriptor<?> newEd = newVariable.getVarType().getValue();
        assertEquals(ed, newEd);
        String name = variable.getVarName().getValue();
        String newName = newVariable.getVarName().getValue();
        assertEquals(name, newName);
        IEntity replacement = GenericEntityFactory.instance.create(ed);
        variableIterator.set(replacement);
        newVariableIterator.set(EntityUtils.clone(replacement));
    }
    assertTrue(Matcher.match(entity, newEntity));
}
Also used : ModelTemplate(org.whole.lang.templates.ModelTemplate) Variable(org.whole.lang.commons.model.Variable) IEntity(org.whole.lang.model.IEntity) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Example 15 with ClasspathPersistenceProvider

use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.

the class IteratorFactoryTest method testFragmentRootIterator.

@Test
public void testFragmentRootIterator() throws Exception {
    IEntity e = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/templates/codebase/TemplateManagerArtifactsTemplates.xwl"));
    CompilationUnit cu = Matcher.find(JavaEntityDescriptorEnum.CompilationUnit, e, false);
    ImportModifier im = Matcher.find(JavaEntityDescriptorEnum.ImportModifier, e, false);
    IEntityIterator<IEntity> i1 = IteratorFactory.rootIterator();
    i1.reset(im);
    assertTrue(i1.hasNext());
    assertSame(e, i1.next());
    IEntityIterator<IEntity> i2 = IteratorFactory.fragmentRootIterator();
    i2.reset(im);
    assertTrue(i2.hasNext());
    assertSame(cu, i2.next());
}
Also used : CompilationUnit(org.whole.lang.java.model.CompilationUnit) IEntity(org.whole.lang.model.IEntity) ImportModifier(org.whole.lang.java.model.ImportModifier) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Aggregations

ClasspathPersistenceProvider (org.whole.lang.codebase.ClasspathPersistenceProvider)15 IEntity (org.whole.lang.model.IEntity)12 Test (org.junit.Test)11 IBindingManager (org.whole.lang.bindings.IBindingManager)4 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)2 PathExpression (org.whole.lang.queries.model.PathExpression)2 IVisitor (org.whole.lang.visitors.IVisitor)2 ModelToXmlSchemaQuery (org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery)2 File (java.io.File)1 HashSet (java.util.HashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)1 MPerspective (org.eclipse.e4.ui.model.application.ui.advanced.MPerspective)1 MPerspectiveStack (org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 MPartSashContainer (org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer)1 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)1 MTrimBar (org.eclipse.e4.ui.model.application.ui.basic.MTrimBar)1 MTrimmedWindow (org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow)1