5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.twig.codeassist.strategies;
10 |
11 | import org.eclipse.dltk.core.ISourceRange;
12 | import org.eclipse.jface.text.BadLocationException;
13 |
14 | import com.dubture.symfony.twig.codeassist.context.ViewPathArgumentContext;
15 | import com.dubture.twig.core.codeassist.ICompletionContext;
16 | import com.dubture.twig.core.codeassist.ICompletionReporter;
17 | import com.dubture.twig.core.codeassist.strategies.AbstractTwigCompletionStrategy;
18 |
19 |
20 | /**
21 | * A viewpath completion strategy for Twig templates:
22 | *
23 | *
24 | * {% extends '| <-- shows available Bundles etc.
25 | *
26 | *
27 | * @author Robert Gruendler
28 | */
29 | public class ViewPathCompletionStrategy extends AbstractTwigCompletionStrategy
30 | {
31 | public ViewPathCompletionStrategy(ICompletionContext context)
32 | {
33 | super(context);
34 | }
35 |
36 | @Override
37 | public void apply(ICompletionReporter reporter) throws BadLocationException
38 | {
39 | ViewPathArgumentContext context = (ViewPathArgumentContext) getContext();
40 | ISourceRange range = getReplacementRange(context);
41 | // CodeassistUtils.reportViewpath(new ICompletionRepo, context.getViewPath(),
42 | // context.getPrefix(), range, context.getScriptProject());
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/com.dubture.symfony.ui/src/com/dubture/symfony/ui/preferences/CoreOptionsConfigurationBlock.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.ui.preferences;
10 |
11 |
12 | import org.eclipse.core.resources.IProject;
13 | import org.eclipse.php.internal.ui.preferences.IStatusChangeListener;
14 | import org.eclipse.php.internal.ui.preferences.OptionsConfigurationBlock;
15 | import org.eclipse.php.internal.ui.preferences.util.Key;
16 | import org.eclipse.swt.widgets.Composite;
17 | import org.eclipse.swt.widgets.Control;
18 | import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
19 |
20 | import com.dubture.symfony.core.SymfonyCorePlugin;
21 |
22 | @SuppressWarnings("restriction")
23 | public abstract class CoreOptionsConfigurationBlock extends
24 | OptionsConfigurationBlock {
25 |
26 |
27 | public CoreOptionsConfigurationBlock(IStatusChangeListener context, IProject project,
28 | Key[] allKeys, IWorkbenchPreferenceContainer container) {
29 | super(context, project, allKeys, container);
30 |
31 | }
32 |
33 | @Override
34 | protected abstract Control createContents(Composite parent);
35 |
36 | @Override
37 | protected abstract void validateSettings(Key changedKey, String oldValue,
38 | String newValue);
39 |
40 | @Override
41 | protected abstract String[] getFullBuildDialogStrings(boolean workspaceSettings);
42 |
43 | protected final static Key getSymfonyCoreKey(String key) {
44 | return getKey(SymfonyCorePlugin.ID, key);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/com.dubture.symfony.core/src/com/dubture/symfony/core/preferences/SymfonyCorePreferences.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.core.preferences;
10 |
11 | /**
12 | * Utility class to access the plugins preferences.
13 | *
14 | *
15 | * @author Robert Gruendler
16 | *
17 | */
18 | public class SymfonyCorePreferences {
19 |
20 |
21 | public static final String SCHEMA_VERSION = "schema_version";
22 |
23 |
24 |
25 | // public static JSONObject getSyntheticServices() {
26 | //
27 | // try {
28 | //
29 | // if (synthetic != null)
30 | // return synthetic;
31 | //
32 | // //TODO: store in preferences and build a preference page for synthetic services
33 | // // where users can change the default implementations
34 | //
35 | //// String stored = Platform.getPreferencesService().getString("org.eclipse.symfony.ui",
36 | //// SymfonyCoreConstants.SYNTHETIC_SERVICES, "", null);
37 | //
38 | // String stored = "{\"request\" : \"Symfony\\Component\\HttpFoundation\\Request\"}";
39 | //
40 | // if (stored == null || stored.length() == 0)
41 | // return new JSONObject();
42 | //
43 | // JSONParser parser = new JSONParser();
44 | // JSONObject prefs = (JSONObject) parser.parse(stored);
45 | //
46 | // synthetic = prefs;
47 | // return synthetic;
48 | //
49 | // } catch (Exception e) {
50 | //
51 | // Logger.logException(e);
52 | // }
53 | //
54 | // return new JSONObject();
55 | //
56 | // }
57 | }
58 |
--------------------------------------------------------------------------------
/com.dubture.symfony.core/src/com/dubture/symfony/core/model/EntityAlias.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.core.model;
10 |
11 | public class EntityAlias {
12 |
13 | private String bundleAlias;
14 | private String entity;
15 |
16 | public EntityAlias(String bundle, String e) {
17 |
18 | setBundleAlias(bundle);
19 | setEntity(e);
20 |
21 | }
22 |
23 | public EntityAlias(String shortcut) {
24 |
25 | if (shortcut != null) {
26 | if (shortcut.contains(":") == false)
27 | return;
28 |
29 | if (shortcut.endsWith(":")) {
30 | bundleAlias = shortcut.replace(":", "");
31 | entity = null;
32 | } else {
33 |
34 | String[] parts = shortcut.split(":");
35 |
36 | bundleAlias = parts[0];
37 | entity = parts[1];
38 | }
39 | }
40 | }
41 |
42 | public String getEntity() {
43 | return entity;
44 | }
45 |
46 | public void setEntity(String entity) {
47 | this.entity = entity;
48 | }
49 |
50 | public String getBundleAlias() {
51 | return bundleAlias;
52 | }
53 |
54 | public void setBundleAlias(String bundleAlias) {
55 | this.bundleAlias = bundleAlias;
56 | }
57 |
58 | public boolean hasBundle() {
59 |
60 | return bundleAlias != null;
61 |
62 | }
63 |
64 | @Override
65 | public String toString() {
66 |
67 | return String.format("%s:%s", bundleAlias, entity);
68 |
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/com.dubture.symfony.core/src/com/dubture/symfony/core/goals/evaluator/TemplateVariableGoalEvaluator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.core.goals.evaluator;
10 |
11 | import org.eclipse.dltk.ti.GoalState;
12 | import org.eclipse.dltk.ti.goals.GoalEvaluator;
13 | import org.eclipse.dltk.ti.goals.IGoal;
14 | import org.eclipse.php.internal.core.typeinference.PHPClassType;
15 |
16 | import com.dubture.symfony.core.index.SymfonyElementResolver.TemplateField;
17 |
18 |
19 | /**
20 | *
21 | * Evaluates templatevariables.
22 | *
23 | * $form->| <-- evalutates to Symfony\Component\Form\Form
24 | * if it's instantiated in the corresponding controller
25 | *
26 | *
27 | * @author Robert Gruendler
28 | *
29 | */
30 | @SuppressWarnings("restriction")
31 | public class TemplateVariableGoalEvaluator extends GoalEvaluator {
32 |
33 | private TemplateField element;
34 |
35 | public TemplateVariableGoalEvaluator(IGoal goal, TemplateField element) {
36 | super(goal);
37 |
38 | this.element = element;
39 |
40 | }
41 |
42 | @Override
43 | public IGoal[] init() {
44 |
45 | return null;
46 | }
47 |
48 | @Override
49 | public IGoal[] subGoalDone(IGoal subgoal, Object result, GoalState state) {
50 |
51 | return IGoal.NO_GOALS;
52 | }
53 |
54 | @Override
55 | public Object produceResult() {
56 |
57 | if (element == null)
58 | return null;
59 |
60 | return new PHPClassType(element.getQualifier(), element.getClassName());
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/com.dubture.symfony.ui/src/com/dubture/symfony/ui/editor/template/ExtendsStatementVariableResolver.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.ui.editor.template;
10 |
11 | import org.eclipse.jface.text.templates.TemplateContext;
12 | import org.eclipse.jface.text.templates.TemplateVariable;
13 | import org.eclipse.jface.text.templates.TemplateVariableResolver;
14 |
15 |
16 | /**
17 | *
18 | * Resolves ${extends} variables in code templates.
19 | *
20 | * @author Robert Gruendler
21 | *
22 | */
23 | public class ExtendsStatementVariableResolver extends TemplateVariableResolver {
24 |
25 | public ExtendsStatementVariableResolver(String type, String description) {
26 |
27 | super(type, description);
28 | }
29 |
30 |
31 | @Override
32 | public void resolve(TemplateVariable variable, TemplateContext context) {
33 |
34 |
35 | if (context instanceof SymfonyTemplateContext) {
36 |
37 | SymfonyTemplateContext symfonyContext = (SymfonyTemplateContext) context;
38 |
39 | try {
40 |
41 | String value = (String) symfonyContext.getTemplateVariable("extends");
42 |
43 | if (value != null && value.length() > 0) {
44 |
45 | String statement = "extends " + value;
46 | variable.setValue(statement);
47 | } else {
48 | variable.setValue("");
49 | }
50 |
51 | variable.setResolved(true);
52 |
53 |
54 | } catch (Exception e) {
55 |
56 | e.printStackTrace();
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/com.dubture.symfony.ui/src/com/dubture/symfony/ui/contentassist/TranslationProposalInfo.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.ui.contentassist;
10 |
11 | import java.util.List;
12 |
13 | import org.eclipse.core.runtime.IProgressMonitor;
14 | import org.eclipse.dltk.core.CompletionProposal;
15 | import org.eclipse.dltk.core.IScriptProject;
16 | import org.eclipse.dltk.ui.text.completion.MemberProposalInfo;
17 |
18 | import com.dubture.symfony.core.model.SymfonyModelAccess;
19 | import com.dubture.symfony.core.model.Translation;
20 | import com.dubture.symfony.index.model.TransUnit;
21 | import com.dubture.symfony.ui.utils.HTMLUtils;
22 |
23 | public class TranslationProposalInfo extends MemberProposalInfo {
24 |
25 | public TranslationProposalInfo(IScriptProject project,
26 | CompletionProposal proposal) {
27 | super(project, proposal);
28 |
29 | }
30 |
31 | @Override
32 | public String getInfo(IProgressMonitor monitor) {
33 |
34 | try {
35 |
36 | Translation translation = (Translation) getModelElement();
37 |
38 | SymfonyModelAccess model = SymfonyModelAccess.getDefault();
39 | List units = model.findTranslations(translation);
40 |
41 | String html = HTMLUtils.translation2Html(translation, units);
42 |
43 | if (html != null && html.length() > 0)
44 | return html;
45 |
46 | return translation.getElementName();
47 |
48 |
49 | } catch (Exception e) {
50 | e.printStackTrace();
51 | }
52 |
53 | return "";
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/com.dubture.symfony.ui/src/com/dubture/symfony/ui/quickassist/XMLMarkerResolution.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.ui.quickassist;
10 |
11 | import org.eclipse.core.resources.IMarker;
12 | import org.eclipse.core.runtime.CoreException;
13 | import org.eclipse.swt.graphics.Image;
14 | import org.eclipse.ui.IMarkerResolution2;
15 |
16 | import com.dubture.symfony.core.log.Logger;
17 | import com.dubture.symfony.core.resources.SymfonyMarker;
18 | import com.dubture.symfony.ui.utils.DialogUtils;
19 |
20 | public class XMLMarkerResolution implements IMarkerResolution2
21 | {
22 |
23 | protected IMarker marker;
24 |
25 | public XMLMarkerResolution(IMarker marker)
26 | {
27 | this.marker = marker;
28 | }
29 |
30 | @Override
31 | public String getLabel()
32 | {
33 | try {
34 | String label = (String) marker
35 | .getAttribute(SymfonyMarker.RESOLUTION_TEXT);
36 | return label;
37 | } catch (CoreException e) {
38 | Logger.logException(e);
39 | }
40 |
41 | return "Create class ";
42 | }
43 |
44 | @Override
45 | public void run(IMarker marker)
46 | {
47 | DialogUtils.launchClassWizardFromMarker(marker);
48 | }
49 |
50 | @Override
51 | public String getDescription()
52 | {
53 | return "Open the 'New PHP Class' dialog";
54 | }
55 |
56 | @Override
57 | public Image getImage()
58 | {
59 | // TODO Auto-generated method stub
60 | return null;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/com.dubture.symfony.core/src/com/dubture/symfony/core/codeassist/SymfonyCompletionContextResolver.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.core.codeassist;
10 |
11 | import org.eclipse.php.core.codeassist.ICompletionContext;
12 | import org.eclipse.php.core.codeassist.ICompletionContextResolver;
13 | import org.eclipse.php.internal.core.codeassist.contexts.CompletionContextResolver;
14 |
15 | import com.dubture.symfony.core.codeassist.contexts.EntityCompletionContext;
16 | import com.dubture.symfony.core.codeassist.contexts.RouteCompletionContext;
17 | import com.dubture.symfony.core.codeassist.contexts.ServiceContainerContext;
18 | import com.dubture.symfony.core.codeassist.contexts.TemplateVariableContext;
19 | import com.dubture.symfony.core.codeassist.contexts.TransUnitCompletionContext;
20 | import com.dubture.symfony.core.codeassist.contexts.ViewPathArgumentContext;
21 |
22 | /**
23 | *
24 | * Context resolver for Symfony2.
25 | *
26 | * @author Robert Gruendler
27 | *
28 | */
29 | @SuppressWarnings("restriction")
30 | public class SymfonyCompletionContextResolver extends CompletionContextResolver
31 | implements ICompletionContextResolver {
32 |
33 |
34 | @Override
35 | public ICompletionContext[] createContexts() {
36 |
37 | return new ICompletionContext[] {
38 | new ServiceContainerContext(),
39 | new TemplateVariableContext(),
40 | new RouteCompletionContext(),
41 | new ViewPathArgumentContext(),
42 | new EntityCompletionContext(),
43 | new TransUnitCompletionContext(),
44 | };
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/com.dubture.symfony.core/src/com/dubture/symfony/core/goals/evaluator/ContainerMethodReturnTypeEvaluator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.core.goals.evaluator;
10 |
11 | import org.eclipse.dltk.ti.GoalState;
12 | import org.eclipse.dltk.ti.goals.IGoal;
13 | import org.eclipse.php.internal.core.typeinference.evaluators.phpdoc.PHPDocMethodReturnTypeEvaluator;
14 |
15 | /**
16 | *
17 | *
18 | *
19 | * @author Robert Gruendler
20 | *
21 | */
22 | @SuppressWarnings("restriction")
23 | public class ContainerMethodReturnTypeEvaluator extends
24 | PHPDocMethodReturnTypeEvaluator {
25 |
26 | public ContainerMethodReturnTypeEvaluator(IGoal goal) {
27 | super(goal);
28 |
29 | }
30 |
31 | @Override
32 | public IGoal[] init() {
33 |
34 | // for (IMethod method : getMethods()) {
35 | //
36 | // try {
37 | // if (method.getParameters().length == 1) {
38 | // IParameter[] params = method.getParameters();
39 | // IParameter param = params[0];
40 | // }
41 | // } catch (ModelException e) {
42 | //
43 | // Logger.logException(e);
44 | // }
45 | // }
46 |
47 | return IGoal.NO_GOALS;
48 | }
49 |
50 |
51 | @Override
52 | public Object produceResult() {
53 |
54 | return super.produceResult();
55 | }
56 |
57 | @Override
58 | public IGoal[] subGoalDone(IGoal subgoal, Object result, GoalState state) {
59 |
60 | return IGoal.NO_GOALS;
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/com.dubture.symfony.core/src/com/dubture/symfony/core/model/Template.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.core.model;
10 |
11 | import org.eclipse.core.runtime.IProgressMonitor;
12 | import org.eclipse.dltk.ast.Modifiers;
13 | import org.eclipse.dltk.core.IModelElement;
14 | import org.eclipse.dltk.core.ISourceModule;
15 | import org.eclipse.dltk.core.ModelException;
16 | import org.eclipse.dltk.internal.core.ModelElement;
17 | import org.eclipse.dltk.internal.core.SourceType;
18 | import org.eclipse.dltk.internal.core.hierarchy.FakeType;
19 |
20 | @SuppressWarnings("restriction")
21 | public class Template extends SourceType {
22 |
23 | public Template(ModelElement parent, String name) {
24 | super(parent, name);
25 | // TODO Auto-generated constructor stub
26 | }
27 |
28 | @Override
29 | public int getFlags() throws ModelException {
30 |
31 | return Modifiers.AccPublic;
32 | }
33 |
34 | @Override
35 | public Object getElementInfo() throws ModelException {
36 |
37 | return new FakeTypeElementInfo();
38 | }
39 |
40 | @Override
41 | protected Object openWhenClosed(Object info, IProgressMonitor monitor)
42 | throws ModelException {
43 |
44 | return new FakeTypeElementInfo();
45 |
46 | }
47 |
48 | @Override
49 | public ISourceModule getSourceModule() {
50 |
51 | return super.getSourceModule();
52 | }
53 |
54 | @Override
55 | public IModelElement getParent() {
56 |
57 | // avoid showing the same name twice in each codeassist
58 | // popup row, ie:
59 | // AcmeDemoBundle - AcmeDemoBundle
60 | return new FakeType(parent, "");
61 |
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/com.dubture.symfony.debug/src/com/dubture/symfony/debug/launch/LaunchDelegateListener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.debug.launch;
10 |
11 | import org.eclipse.core.runtime.IProgressMonitor;
12 | import org.eclipse.debug.core.ILaunch;
13 | import org.eclipse.debug.core.ILaunchConfiguration;
14 | import org.eclipse.php.debug.core.debugger.launching.ILaunchDelegateListener;
15 |
16 | /**
17 | *
18 | * A PHP Debug launchDelegate that injects the correct Launch URL
19 | * for a corresponding Symfony route.
20 | *
21 | * @author Robert Gruendler
22 | *
23 | */
24 | public class LaunchDelegateListener implements ILaunchDelegateListener {
25 |
26 |
27 | @Override
28 | public int preLaunch(ILaunchConfiguration configuration, String mode,
29 | ILaunch launch, IProgressMonitor monitor) {
30 |
31 | // EditorUtility utility = new EditorUtility();
32 | /*
33 | Route route = utility.getRouteAtCursor();
34 | IScriptProject project = utility.getProject();
35 |
36 | String env = "";
37 | try {
38 | env = configuration.getAttribute(SymfonyServer.ENVIRONMENT, "");
39 | } catch (CoreException e) {
40 | Logger.logException(e);
41 | }
42 |
43 | AppKernel kernel = null;
44 |
45 | if (env.length() != 0) {
46 | kernel = SymfonyKernelAccess.getDefault().getKernel(project, env);
47 | } else {
48 | kernel = SymfonyKernelAccess.getDefault().getDevelopmentKernel(project);
49 | }
50 |
51 | if (kernel != null) {
52 | ServerUtils.injectRoutingURL(configuration, kernel, project, route);
53 | }
54 | */
55 |
56 | return 0;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/com.dubture.symfony.core/src/com/dubture/symfony/core/model/SymfonyResourceAccess.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.core.model;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.eclipse.dltk.core.IScriptProject;
15 |
16 | import com.dubture.symfony.core.log.Logger;
17 | import com.dubture.symfony.index.SymfonyIndexer;
18 | import com.dubture.symfony.index.handler.IResourceHandler;
19 | import com.dubture.symfony.index.model.RoutingResource;
20 |
21 |
22 | public class SymfonyResourceAccess {
23 |
24 | private static SymfonyResourceAccess instance = null;
25 | private SymfonyIndexer index;
26 |
27 | private SymfonyResourceAccess() {
28 |
29 | try {
30 | index = SymfonyIndexer.getInstance();
31 | } catch (Exception e) {
32 | Logger.logException(e);
33 | }
34 | }
35 |
36 | public static SymfonyResourceAccess getDefault() {
37 |
38 |
39 | if (instance == null)
40 | instance = new SymfonyResourceAccess();
41 |
42 | return instance;
43 |
44 | }
45 |
46 | public List getResources(IScriptProject project) {
47 |
48 | final List resources = new ArrayList();
49 |
50 | index.findResources(project.getPath(), new IResourceHandler() {
51 |
52 | @Override
53 | public void handle(RoutingResource resource) {
54 |
55 | Resource r = new Resource();
56 | r.type = Resource.ROUTE_RESOURCE;
57 | r.path = resource.getPath();
58 | r.prefix = resource.getPrefix();
59 | resources.add(r);
60 |
61 | }
62 | });
63 |
64 | return resources;
65 |
66 | }
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/com.dubture.symfony.ui/src/com/dubture/symfony/ui/Messages.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.ui;
10 |
11 | import org.eclipse.osgi.util.NLS;
12 |
13 | public class Messages extends NLS {
14 | private static final String BUNDLE_NAME = "com.dubture.symfony.ui.messages"; //$NON-NLS-1$
15 | public static String SYMFONY_VERSION_2_0;
16 | public static String SYMFONY_VERSION_2_1;
17 | public static String ServiceConfigurationBlock_0;
18 | public static String ServiceConfigurationBlock_1;
19 | public static String ServiceConfigurationBlock_2;
20 | public static String ServiceConfigurationBlock_3;
21 | public static String ServiceConfigurationBlock_4;
22 | public static String ServiceConfigurationBlock_5;
23 | public static String ServiceConfigurationBlock_6;
24 | public static String ServicesPreferencePage_0;
25 | public static String LibraryConfigurationBlock_0;
26 | public static String LibraryPreferencePage_1;
27 | public static String LibraryPreferencePage_2;
28 | public static String LibraryPreferencePage_4;
29 | public static String SymfonyPreferencePage_0;
30 | public static String SymfonyPreferencePage_1;
31 | public static String SymfonyPreferencePage_2;
32 | public static String SymfonyPreferencePage_3;
33 | public static String SymfonyServiceConfigurationBlock_0;
34 | public static String SymfonyServiceConfigurationBlock_1;
35 | public static String SymfonyServiceConfigurationBlock_2;
36 | public static String SymfonyVersionComboName;
37 | static {
38 | // initialize resource bundle
39 | NLS.initializeMessages(BUNDLE_NAME, Messages.class);
40 | }
41 |
42 | private Messages() {
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/com.dubture.symfony.test/Resources/config/config.yml:
--------------------------------------------------------------------------------
1 | imports:
2 | - { resource: parameters.ini }
3 | - { resource: security.yml }
4 |
5 | framework:
6 | secret: %secret%
7 | charset: UTF-8
8 | router: { resource: "%kernel.root_dir%/config/routing.yml" }
9 | form: true
10 | csrf_protection: true
11 | validation: { enable_annotations: true }
12 | templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
13 | session:
14 | default_locale: %locale%
15 | lifetime: 3600
16 | auto_start: true
17 |
18 | # Twig Configuration
19 | twig:
20 | debug: %kernel.debug%
21 | strict_variables: %kernel.debug%
22 |
23 | # Assetic Configuration
24 | assetic:
25 | debug: %kernel.debug%
26 | use_controller: false
27 | filters:
28 | cssrewrite: ~
29 | # closure:
30 | # jar: %kernel.root_dir%/java/compiler.jar
31 | # yui_css:
32 | # jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar
33 |
34 | # Doctrine Configuration
35 | doctrine:
36 | dbal:
37 | driver: %database_driver%
38 | host: %database_host%
39 | dbname: %database_name%
40 | user: %database_user%
41 | password: %database_password%
42 |
43 | orm:
44 | auto_generate_proxy_classes: %kernel.debug%
45 | auto_mapping: true
46 |
47 | # Swiftmailer Configuration
48 | swiftmailer:
49 | transport: %mailer_transport%
50 | host: %mailer_host%
51 | username: %mailer_user%
52 | password: %mailer_password%
53 |
54 | jms_security_extra:
55 | secure_controllers: true
56 | secure_all_services: false
57 |
58 |
59 | parameters:
60 | my_mailer.class: Acme\HelloBundle\Mailer
61 | my_mailer.transport: sendmail
62 |
63 | services:
64 | my_service:
65 | class: Acme\DemoBundle\MyService
66 | my_mailer:
67 | class: %my_mailer.class%
68 | arguments: [%my_mailer.transport%]
--------------------------------------------------------------------------------
/com.dubture.symfony.index/src/com/dubture/symfony/index/dao/sql/BaseDao.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.index.dao.sql;
10 |
11 | import java.sql.Connection;
12 | import java.sql.PreparedStatement;
13 | import java.sql.SQLException;
14 | import java.util.HashMap;
15 | import java.util.Map;
16 |
17 | import com.dubture.symfony.index.dao.IDao;
18 | import com.dubture.symfony.index.log.Logger;
19 |
20 | abstract public class BaseDao implements IDao {
21 |
22 | /** Cache for insert element reference queries */
23 | protected static final Map D_INSERT_QUERY_CACHE = new HashMap();
24 | protected final Map batchStatements;
25 | protected final String LIKE_WILDCARD = "%"; //$NON-NLS-1$
26 |
27 | public BaseDao() {
28 | this.batchStatements = new HashMap();
29 | }
30 |
31 | public void commitInsertions() throws Exception {
32 | synchronized (batchStatements) {
33 | try {
34 | for (PreparedStatement statement : batchStatements.values()) {
35 | try {
36 | statement.executeBatch();
37 | } finally {
38 | statement.close();
39 | }
40 | }
41 | } finally {
42 | batchStatements.clear();
43 | }
44 | }
45 | }
46 |
47 | protected String escapeLikePattern(String pattern) {
48 | return pattern.replaceAll("[\\\\%_]", "\\\\$0"); //$NON-NLS-1$ //$NON-NLS-2$
49 | }
50 |
51 | protected void closeIfExists(Connection connection) {
52 | if (connection != null) {
53 | try {
54 | connection.close();
55 | } catch (SQLException e) {
56 | Logger.logException(e);
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/com.dubture.symfony.ui/src/com/dubture/symfony/ui/editor/template/NamespaceVariableResolver.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.ui.editor.template;
10 |
11 |
12 | import org.eclipse.core.runtime.IPath;
13 | import org.eclipse.dltk.core.ISourceModule;
14 | import org.eclipse.jface.text.templates.TemplateContext;
15 | import org.eclipse.jface.text.templates.TemplateVariable;
16 | import org.eclipse.jface.text.templates.TemplateVariableResolver;
17 |
18 | import com.dubture.symfony.core.model.SymfonyModelAccess;
19 |
20 | /**
21 | *
22 | * Resolves "namespace" variables in new classes.
23 | *
24 | *
25 | * @author Robert Gründler
26 | *
27 | */
28 | public class NamespaceVariableResolver extends TemplateVariableResolver {
29 |
30 | protected NamespaceVariableResolver(String type, String description) {
31 |
32 | super(type, description);
33 |
34 | }
35 |
36 |
37 | @Override
38 | public void resolve(TemplateVariable variable, TemplateContext context) {
39 |
40 | if (context instanceof SymfonyTemplateContext) {
41 |
42 | try {
43 |
44 | SymfonyTemplateContext symfonyContext = (SymfonyTemplateContext) context;
45 | ISourceModule module = symfonyContext.getSourceModule();
46 | IPath path = module.getPath().removeLastSegments(1);
47 | String ns = SymfonyModelAccess.getDefault().findNameSpace(module.getScriptProject(), path);
48 |
49 | if (ns != null) {
50 | variable.setValue(ns);
51 | variable.setResolved(true);
52 | }
53 |
54 |
55 | } catch (Exception e) {
56 |
57 | e.printStackTrace();
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/com.dubture.symfony.ui/src/com/dubture/symfony/ui/quickassist/XMLQuickassistProcessor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.ui.quickassist;
10 |
11 | import org.eclipse.core.resources.IMarker;
12 | import org.eclipse.core.runtime.CoreException;
13 | import org.eclipse.ui.IMarkerResolution;
14 | import org.eclipse.ui.IMarkerResolutionGenerator2;
15 |
16 | import com.dubture.symfony.core.log.Logger;
17 | import com.dubture.symfony.core.resources.SymfonyMarker;
18 |
19 | /**
20 | *
21 | * Provides a quick-fix proposal in the "Problem" view of eclipse.
22 | *
23 | * @author Robert Gruendler
24 | *
25 | */
26 | public class XMLQuickassistProcessor implements IMarkerResolutionGenerator2
27 | {
28 |
29 | @Override
30 | public IMarkerResolution[] getResolutions(IMarker marker)
31 | {
32 |
33 | try {
34 | if (SymfonyMarker.MISSING_SERVICE_CLASS.equals(marker.getType())) {
35 |
36 | XMLMarkerResolution resolution = new XMLMarkerResolution(marker);
37 | return new XMLMarkerResolution[]{resolution};
38 |
39 | }
40 | } catch (CoreException e) {
41 | Logger.logException(e);
42 | }
43 |
44 | return null;
45 |
46 | }
47 |
48 | @Override
49 | public boolean hasResolutions(IMarker marker)
50 | {
51 | try {
52 | if (SymfonyMarker.MISSING_SERVICE_CLASS.equals(marker.getType())) {
53 | return true;
54 | }
55 | } catch (CoreException e) {
56 | Logger.logException(e);
57 | }
58 |
59 | return false;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/com.dubture.symfony.core/src/com/dubture/symfony/core/codeassist/strategies/TemplateVariableStrategy.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the Symfony eclipse plugin.
3 | *
4 | * (c) Robert Gruendler
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | ******************************************************************************/
9 | package com.dubture.symfony.core.codeassist.strategies;
10 |
11 |
12 | import org.eclipse.dltk.ast.Modifiers;
13 | import org.eclipse.dltk.core.ISourceRange;
14 | import org.eclipse.php.core.codeassist.ICompletionContext;
15 | import org.eclipse.php.core.codeassist.ICompletionReporter;
16 | import org.eclipse.php.internal.core.codeassist.strategies.ElementsStrategy;
17 | import org.eclipse.php.internal.core.typeinference.FakeField;
18 |
19 | import com.dubture.symfony.core.codeassist.contexts.TemplateVariableContext;
20 | import com.dubture.symfony.core.index.SymfonyElementResolver.TemplateField;
21 |
22 | /**
23 | *
24 | * Completes variables in templates declared in
25 | * Symfony2 controllers.
26 | *
27 | *
28 | * @author "Robert Gruendler "
29 | *
30 | */
31 | @SuppressWarnings({ "restriction" })
32 | public class TemplateVariableStrategy extends ElementsStrategy {
33 |
34 | public TemplateVariableStrategy(ICompletionContext context) {
35 | super(context);
36 |
37 | }
38 |
39 | @Override
40 | public void apply(ICompletionReporter reporter) throws Exception {
41 |
42 | TemplateVariableContext ctxt = (TemplateVariableContext) getContext();
43 | ISourceRange range = getReplacementRange(getContext());
44 | String viewPath = ctxt.getViewPath();
45 |
46 | for(TemplateField element : ctxt.getVariables()) {
47 |
48 | if (viewPath.equals(element.getViewPath())) {
49 | reporter.reportField(new FakeField(element, element.getElementName(), Modifiers.AccPublic), "", range, false);
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------