Skip to content

Commit

Permalink
eclipse-archived#190 In progress TqCL - syntax (insert) and library s…
Browse files Browse the repository at this point in the history
…ervices
  • Loading branch information
rtotaro committed Jan 14, 2017
1 parent b58db2f commit 14eb95e
Show file tree
Hide file tree
Showing 27 changed files with 243 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ public void addPort(PortDescriptor port)
{
ports.add(port);
}

public List<PortDescriptor> getPorts() {
return ports;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface TqCLLibraryProvider {

public List<String> getPortTypes(String library) throws TqCLLibraryException;

public List<String> getActorPorts(String actor) throws TqCLLibraryException;
public List<PortDescriptor> getActorPorts(String actor) throws TqCLLibraryException;

public List<String> getActorParameters(String actor) throws TqCLLibraryException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.triquetrum.commands.api.services.DirectorDescriptor;
import org.eclipse.triquetrum.commands.api.services.EntityDescriptor;
import org.eclipse.triquetrum.commands.api.services.ParameterDescriptor;
import org.eclipse.triquetrum.commands.api.services.PortDescriptor;
import org.eclipse.triquetrum.commands.api.services.TqCLLibraryException;
import org.eclipse.triquetrum.commands.api.services.TqCLLibraryProvider;

Expand Down Expand Up @@ -61,7 +62,7 @@ public List<String> getPortTypes(String library) throws TqCLLibraryException {
}

@Override
public List<String> getActorPorts(String actor) throws TqCLLibraryException {
public List<PortDescriptor> getActorPorts(String actor) throws TqCLLibraryException {
for (TqCLLibraryProvider provider : libraryProviders.values()) {
boolean hasElement = provider.hasElement(actor);
if (hasElement) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2016 Totaro Rodolfo
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* generated by Xtext 2.10.0
*
* Contributors:
* Rodolfo Totaro - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.triquetrum.commands.ui;

import org.eclipse.ui.plugin.AbstractUIPlugin;

/**
* Use this class to register components to be used within the Eclipse IDE.
*/
public class TqclUiModule extends AbstractTqclUiModule {

public TqclUiModule(AbstractUIPlugin plugin) {
super(plugin);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@
import org.eclipse.triquetrum.commands.api.services.DirectorDescriptor;
import org.eclipse.triquetrum.commands.api.services.EntityDescriptor;
import org.eclipse.triquetrum.commands.api.services.ParameterDescriptor;
import org.eclipse.triquetrum.commands.api.services.PortDescriptor;
import org.eclipse.triquetrum.commands.api.services.TqCLLibraryException;
import org.eclipse.triquetrum.commands.api.services.TqCLLibraryProvider;
import org.eclipse.triquetrum.commands.tqcl.Category;
import org.eclipse.triquetrum.commands.tqcl.Connect;
import org.eclipse.triquetrum.commands.tqcl.ConnectionPort;
import org.eclipse.triquetrum.commands.tqcl.Insert;
import org.eclipse.triquetrum.commands.tqcl.Library;
import org.eclipse.triquetrum.commands.tqcl.Parameter;
import org.eclipse.triquetrum.commands.tqcl.TriquetrumScript;
import org.eclipse.triquetrum.commands.validation.TqCLUtils;
import org.eclipse.xtext.Assignment;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;

Expand Down Expand Up @@ -147,6 +152,33 @@ public void completeInsert_Name(EObject model, Assignment assignment, ContentAss
}
}

@Override
public void completeConnectionPort_Port(EObject model, Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
// TODO Auto-generated method stub
super.completeConnectionPort_Port(model, assignment, context, acceptor);
if (model instanceof ConnectionPort) {
ConnectionPort connectionPort = (ConnectionPort) model;
Insert actor = connectionPort.getActor();
String actorClass = actor.getEntityClass();
try {
List<PortDescriptor> actorPorts = TqCLServices.getInstance().getTqclLibraryProvider()
.getActorPorts(TqCLUtils.cleanEntityName(actorClass));
for (PortDescriptor portDescriptor : actorPorts) {
ICompletionProposal completionProposal = createCompletionProposal(portDescriptor.getDisplayName(),
context);
acceptor.accept(completionProposal);
}

} catch (TqCLLibraryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}

@Override
public void completeInsert_Parameters(EObject model, Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
Expand Down
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,6 @@ public Class<? extends IGenerator2> bindIGenerator2() {
return TqclGenerator.class;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Workflow {
component = XtextGenerator {
cleaner = {
enabled = true

}

configuration = {
Expand Down Expand Up @@ -116,6 +117,8 @@ Workflow {
generateXtendStub = false
}

generateXtendStubs = false

contentAssist=
{
generateStub=true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2016 Totaro Rodolfo
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* generated by Xtext 2.10.0
*
* Contributors:
* Rodolfo Totaro - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.triquetrum.commands;

import org.eclipse.xtext.naming.IQualifiedNameProvider;

/**
* Use this class to register components to be used at runtime / without the Equinox extension registry.
*/
public class TqclRuntimeModule extends AbstractTqclRuntimeModule {

@Override
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return org.eclipse.triquetrum.commands.scoping.TqclQualifiedNameProvider.class;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2016 Totaro Rodolfo
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* generated by Xtext 2.10.0
*
* Contributors:
* Rodolfo Totaro - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.triquetrum.commands;


/**
* Initialization support for running Xtext languages without Equinox extension registry.
*/
public class TqclStandaloneSetup extends TqclStandaloneSetupGenerated {

public static void doSetup() {
new TqclStandaloneSetup().createInjectorAndDoEMFRegistration();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.eclipse.triquetrum.commands.scoping;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.triquetrum.commands.tqcl.Insert;
import org.eclipse.triquetrum.commands.validation.TqCLUtils;
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
import org.eclipse.xtext.naming.QualifiedName;

public class TqclQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {

@Override
public QualifiedName apply(EObject eObject) {
// if (eObject instanceof Insert) {
// return getFullyQualifiedName(eObject);
// }
return super.apply(eObject);
}

@Override
public QualifiedName getFullyQualifiedName(EObject eObject) {
// if (eObject instanceof Insert) {
// Insert insert = (Insert) eObject;
// return QualifiedName.create(TqCLUtils.cleanEntityName(insert.getName()));
// }
return super.getFullyQualifiedName(eObject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@
*/
package org.eclipse.triquetrum.commands.scoping;

import java.util.ArrayList;
import java.util.function.Consumer;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.triquetrum.commands.tqcl.Category;
import org.eclipse.triquetrum.commands.tqcl.Connect;
import org.eclipse.triquetrum.commands.tqcl.Insert;
import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.Scopes;
import org.eclipse.xtext.scoping.impl.FilteringScope;

import com.google.common.base.Predicate;


/**
* This class contains custom scoping description.
Expand All @@ -33,19 +42,34 @@ public class TqclScopeProvider extends AbstractTqclScopeProvider {
@Override
public IScope getScope(EObject context, EReference reference) {
if (context instanceof Connect && reference == TqclPackage.Literals.CONNECTION_PORT__ACTOR) {
Connect connect = (Connect) context;
// Collect a list of candidates by going through the model
// EcoreUtil2 provides useful functionality to do that
// For example searching for all elements within the root Object's tree
EObject rootElement = EcoreUtil2.getRootContainer(context);
Iterable<Insert> candidates = EcoreUtil2.getAllContentsOfType(rootElement, Insert.class);
// Create IEObjectDescriptions and puts them into an IScope instance
return Scopes.scopeFor(candidates);
//
Predicate<IEObjectDescription> predicate = new Predicate<IEObjectDescription>() {

@Override
public boolean apply(IEObjectDescription objectDescription) {
EObject eObjectOrProxy = objectDescription.getEObjectOrProxy();
if (eObjectOrProxy instanceof Insert) {
Insert insert = (Insert) eObjectOrProxy;
return Category.ACTOR.equals(insert.getCategory());
}
return false;
}
};
IScope scope = Scopes.scopeFor(candidates);

return new FilteringScope(scope,predicate);

}
return super.getScope(context, reference);
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public static String cleanParameterName(String id) {
return null;
}

public static String createEditorEntityName(String entityName) {
return entityName.contains(" ") ? ("\"" + entityName + "\"") : entityName;

}

}
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 14eb95e

Please sign in to comment.