Skip to content
Browse files

Merge pull request #193 from zulus/bug_192

Fix #192
  • Loading branch information...
2 parents 2b7e01b + 646cdcd commit bee28e34205ac0857317df793fcc2654c734b4a8 @pulse00 committed Feb 18, 2014
View
46 com.dubture.symfony.core/plugin.xml
@@ -16,7 +16,7 @@
id="com.dubture.symfony.core.symfonyBuilder">
</builder>
</extension>
-
+
<!-- The Symfony2 core builder - visits xml and yml files to parse the configuration -->
<extension
point="org.eclipse.dltk.core.language">
@@ -25,7 +25,7 @@
nature="org.eclipse.php.core.PHPNature"
priority="100">
</language>
- </extension>
+ </extension>
<extension
id="symfonyBuilder"
name="Symfony Builder"
@@ -37,16 +37,16 @@
</run>
</builder>
</extension>
-
-
+
+
<!-- Preferences -->
<extension point="org.eclipse.core.runtime.preferences">
<initializer class="com.dubture.symfony.core.preferences.PreferenceInitializer">
</initializer>
- </extension>
-
- <!-- The Symfony2 dltk builder - traverses AST nodes during building to parse model elements like Bundles/AppKernel etc. -->
-
+ </extension>
+
+ <!-- The Symfony2 dltk builder - traverses AST nodes during building to parse model elements like Bundles/AppKernel etc. -->
+
<!-- org.eclipse.php.core.PHPNature -->
<extension
point="org.eclipse.dltk.core.buildParticipant">
@@ -55,6 +55,9 @@
id="com.dubture.symfony.core.buildParticipant"
name="Symfony Builder"
nature="org.eclipse.php.core.PHPNature">
+ <requires
+ id="org.eclipse.php.core.buildParticipant.parser">
+ </requires>
</buildParticipant>
</extension>
<extension
@@ -65,40 +68,25 @@
targetId="org.eclipse.dltk.core.index.sql.indexer">
</indexerParticipant>
</extension>
-
-
+
+
<!-- The Symfony2 indexing visitor - traverses the AST nodes to contribute model elements to the index like Routings and Annotations -->
<extension
point="org.eclipse.php.core.phpIndexingVisitors">
<visitor
class="com.dubture.symfony.core.index.SymfonyIndexingVisitorExtension">
</visitor>
</extension>
-
- <!-- PDT SourceElementRequestor - not used at the moment -->
+
+ <!-- PDT SourceElementRequestor - not used at the moment -->
<extension
point="org.eclipse.php.core.phpSourceElementRequestors">
<requestor
class="com.dubture.symfony.core.compiler.SourceElementRequestor">
</requestor>
</extension>
-
- <!-- Code assist -->
- <extension
- point="org.eclipse.php.core.completionStrategyFactories">
- <factory
- class="com.dubture.symfony.core.codeassist.SymfonyCompletionStrategyFactory">
- </factory>
- </extension>
-
- <extension
- point="org.eclipse.php.core.completionContextResolvers">
- <resolver
- class="com.dubture.symfony.core.codeassist.SymfonyCompletionContextResolver"></resolver>
- </extension>
-
<extension
point="org.eclipse.php.core.goalEvaluatorFactories">
<factory
@@ -124,9 +112,9 @@
class="com.dubture.symfony.core.goals.SymfonyEntityResolver">
</resolver>
</extension>
-
+
<!-- End code assist -->
-
+
<extension id="serviceMarker" point="org.eclipse.core.resources.markers" name="Service Marker">
<super
type="org.eclipse.core.resources.problemmarker">
View
41 com.dubture.symfony.core/src/com/dubture/symfony/core/builder/SymfonyBuildParticipant.java
@@ -1,58 +1,51 @@
/*******************************************************************************
* This file is part of the Symfony eclipse plugin.
- *
+ *
* (c) Robert Gruendler <r.gruendler@gmail.com>
- *
+ *
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
******************************************************************************/
package com.dubture.symfony.core.builder;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.parser.IModuleDeclaration;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.SourceParserUtil;
import org.eclipse.dltk.core.builder.IBuildContext;
import org.eclipse.dltk.core.builder.IBuildParticipant;
+import org.eclipse.php.internal.core.compiler.ast.nodes.PHPModuleDeclaration;
import com.dubture.symfony.core.log.Logger;
import com.dubture.symfony.core.visitor.AnnotationVisitor;
/**
- *
+ *
* Not used yet.
- *
+ *
* @author Robert Gruendler <r.gruendler@gmail.com>
*
*/
+@SuppressWarnings("restriction")
public class SymfonyBuildParticipant implements IBuildParticipant {
+ private PHPModuleDeclaration getModuleDeclaration(IBuildContext context) {
+ if (context.get(IBuildContext.ATTR_MODULE_DECLARATION) instanceof PHPModuleDeclaration) {
+ return (PHPModuleDeclaration) context.get(IBuildContext.ATTR_MODULE_DECLARATION);
+ }
-
- private ModuleDeclaration getModuleDeclaration(IBuildContext context) {
-
- ISourceModule sourceModule = context.getSourceModule();
- ModuleDeclaration moduleDeclaration = SourceParserUtil.getModuleDeclaration(sourceModule);
-
- return moduleDeclaration;
-
+ return null;
}
-
+
@Override
public void build(IBuildContext context) throws CoreException {
-
try {
-
- IFile file = context.getFile();
-
- ModuleDeclaration module = getModuleDeclaration(context);
-
- if (file.getFileExtension().equals("php")) {
- module.traverse(new AnnotationVisitor(context));
+ PHPModuleDeclaration module = getModuleDeclaration(context);
+
+ if (module != null) {
+ module.traverse(new AnnotationVisitor(context));
}
-
} catch (Exception e) {
-
Logger.logException(e);
}
}
View
121 com.dubture.symfony.test/src/com/dubture/symfony/test/AbstractCodeAssistTest.java
@@ -4,6 +4,8 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
@@ -38,8 +40,13 @@
import org.eclipse.dltk.core.WorkingCopyOwner;
import org.eclipse.dltk.core.tests.FileUtil;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.php.core.codeassist.ICompletionContextResolver;
+import org.eclipse.php.core.codeassist.ICompletionStrategyFactory;
import org.eclipse.php.internal.core.PHPVersion;
import org.eclipse.php.internal.core.codeassist.AliasType;
+import org.eclipse.php.internal.core.codeassist.IPHPCompletionRequestorExtension;
+import org.eclipse.php.internal.core.codeassist.contexts.CompletionContextResolver;
+import org.eclipse.php.internal.core.codeassist.strategies.CompletionStrategyFactory;
import org.eclipse.php.internal.core.facet.PHPFacets;
import org.eclipse.php.internal.core.project.PHPNature;
import org.eclipse.php.internal.core.project.ProjectOptions;
@@ -50,14 +57,16 @@
import com.dubture.symfony.core.SymfonyCorePlugin;
import com.dubture.symfony.core.SymfonyVersion;
import com.dubture.symfony.core.builder.SymfonyNature;
+import com.dubture.symfony.core.codeassist.SymfonyCompletionContextResolver;
+import com.dubture.symfony.core.codeassist.SymfonyCompletionStrategyFactory;
import com.dubture.symfony.core.facet.FacetManager;
import com.dubture.symfony.core.preferences.CorePreferenceConstants.Keys;
import com.dubture.symfony.test.codeassist.CodeAssistPdttFile;
import com.dubture.symfony.test.codeassist.CodeAssistPdttFile.ExpectedProposal;
@SuppressWarnings("restriction")
abstract public class AbstractCodeAssistTest extends TestCase {
-
+
protected boolean displayName = false;
protected String endChar = ",";
@@ -76,19 +85,19 @@
protected IFile testFile;
public void setUp() throws Exception {
-
+
if (this.discard) {
this.workingCopies = null;
}
-
+
this.discard = true;
-
+
if (project != null && project.exists()) {
return;
}
-
+
project = setUpProject(projectName);
-
+
IProjectDescription desc = project.getDescription();
desc.setNatureIds(new String[] { PHPNature.ID, SymfonyNature.NATURE_ID, DoctrineNature.NATURE_ID });
project.setDescription(desc, null);
@@ -97,7 +106,7 @@ public void setUp() throws Exception {
PHPFacets.setFacetedVersion(project, PHPVersion.PHP5_3);
FacetManager.installFacets(project, PHPVersion.PHP5_3, SymfonyVersion.Symfony2_2_1, new NullProgressMonitor());
-
+
IEclipsePreferences node = new ProjectScope(project).getNode(SymfonyCorePlugin.ID);
node.put(Keys.DUMPED_CONTAINER, "dumpedContainer.xml");
node.flush();
@@ -106,28 +115,28 @@ public void setUp() throws Exception {
project.build(IncrementalProjectBuilder.FULL_BUILD, null);
SymfonyTestPlugin.waitForIndexer();
-
+
}
public void tearDown() throws Exception {
-
+
if (this.discard && this.workingCopies != null) {
discardWorkingCopies(this.workingCopies);
this.wcOwner = null;
}
-
+
if (testFile != null) {
testFile.delete(true, null);
testFile = null;
}
-
+
for (IResource res : project.members()) {
if (res.getName().startsWith(".")) {
continue;
}
res.delete(true, null);
}
-
+
project.refreshLocal(IResource.DEPTH_INFINITE, null);
project.close(null);
project.delete(true, true, null);
@@ -141,7 +150,7 @@ public AbstractCodeAssistTest(String projectName) {
/**
* Creates test file with the specified content and calculates the offset at
* OFFSET_CHAR. Offset character itself is stripped off.
- *
+ *
* @param data
* File data
* @return offset where's the offset character set.
@@ -170,41 +179,55 @@ protected ISourceModule getSourceModule() {
return DLTKCore.createSourceModuleFrom(testFile);
}
- public CompletionProposal[] getProposals(String data)
- throws Exception {
+ public CompletionProposal[] getProposals(String data) throws Exception {
int offset = createFile(data);
return getProposals(offset);
}
- public CompletionProposal[] getProposals(int offset)
- throws ModelException {
+ public CompletionProposal[] getProposals(int offset) throws ModelException {
return getProposals(getSourceModule(), offset);
}
- public CompletionProposal[] getProposals(ISourceModule sourceModule,
- int offset) throws ModelException {
+ abstract class TestCompletionRequestor extends CompletionRequestor implements IPHPCompletionRequestorExtension {
+
+ @Override
+ public ICompletionContextResolver[] getContextResolvers() {
+ List<ICompletionContextResolver> asList = new ArrayList<ICompletionContextResolver>(Arrays.asList(CompletionContextResolver.getActive()));
+ asList.add(new SymfonyCompletionContextResolver());
+ return asList.toArray(new ICompletionContextResolver[asList.size()]);
+ }
+
+ @Override
+ public ICompletionStrategyFactory[] getStrategyFactories() {
+ List<ICompletionStrategyFactory> asList = new ArrayList<ICompletionStrategyFactory>(Arrays.asList(CompletionStrategyFactory.getActive()));
+ asList.add(new SymfonyCompletionStrategyFactory());
+ return asList.toArray(new ICompletionStrategyFactory[asList.size()]);
+ }
+
+ }
+
+ public CompletionProposal[] getProposals(ISourceModule sourceModule, int offset) throws ModelException {
final List<CompletionProposal> proposals = new LinkedList<CompletionProposal>();
- sourceModule.codeComplete(offset, new CompletionRequestor() {
+ sourceModule.codeComplete(offset, new TestCompletionRequestor() {
public void accept(CompletionProposal proposal) {
proposals.add(proposal);
}
});
-
+
return (CompletionProposal[]) proposals.toArray(new CompletionProposal[proposals.size()]);
}
public void compareProposals(CompletionProposal[] proposals, CodeAssistPdttFile pdttFile) throws Exception {
-
+
ExpectedProposal[] expectedProposals = pdttFile.getExpectedProposals();
boolean proposalsEqual = true;
if (proposals.length == expectedProposals.length) {
- for (ExpectedProposal expectedProposal : pdttFile
- .getExpectedProposals()) {
+ for (ExpectedProposal expectedProposal : pdttFile.getExpectedProposals()) {
boolean found = false;
for (CompletionProposal proposal : proposals) {
IModelElement modelElement = proposal.getModelElement();
-
+
if (modelElement == null) {
if (new String(proposal.getName().trim()).equalsIgnoreCase(expectedProposal.name)) { // keyword
found = true;
@@ -227,7 +250,8 @@ public void compareProposals(CompletionProposal[] proposals, CodeAssistPdttFile
break;
}
}
- } else if (modelElement.getElementType() == expectedProposal.type&& new String(proposal.getName()).trim().equalsIgnoreCase(expectedProposal.name)) {
+ } else if (modelElement.getElementType() == expectedProposal.type
+ && new String(proposal.getName()).trim().equalsIgnoreCase(expectedProposal.name)) {
// for phar include
found = true;
break;
@@ -249,7 +273,7 @@ public void compareProposals(CompletionProposal[] proposals, CodeAssistPdttFile
errorBuf.append("\nACTUAL COMPLETIONS LIST:\n-----------------------------\n");
for (CompletionProposal p : proposals) {
IModelElement modelElement = p.getModelElement();
- if (modelElement == null|| modelElement.getElementName() == null) {
+ if (modelElement == null || modelElement.getElementName() == null) {
errorBuf.append("keyword(").append(p.getName()).append(")\n");
} else {
switch (modelElement.getElementType()) {
@@ -264,20 +288,16 @@ public void compareProposals(CompletionProposal[] proposals, CodeAssistPdttFile
break;
}
if (modelElement instanceof AliasType) {
- errorBuf.append('(')
- .append(((AliasType) modelElement).getAlias())
- .append(")\n");
+ errorBuf.append('(').append(((AliasType) modelElement).getAlias()).append(")\n");
} else {
- errorBuf.append('(')
- .append(modelElement.getElementName())
- .append(")\n");
+ errorBuf.append('(').append(modelElement.getElementName()).append(")\n");
}
}
}
fail(errorBuf.toString());
}
}
-
+
protected String[] getPDTTFiles(String testsDirectory) {
return getPDTTFiles(testsDirectory, Platform.getBundle(SymfonyTestPlugin.PLUGIN_ID));
}
@@ -290,7 +310,7 @@ public void compareProposals(CompletionProposal[] proposals, CodeAssistPdttFile
return getFiles(testsDirectory, Platform.getBundle(SymfonyTestPlugin.PLUGIN_ID), ext);
}
- protected String[] getFiles(String testsDirectory, Bundle bundle, String ext) {
+ protected String[] getFiles(String testsDirectory, Bundle bundle, String ext) {
List<String> files = new LinkedList<String>();
Enumeration<String> entryPaths = bundle.getEntryPaths(testsDirectory);
if (entryPaths != null) {
@@ -320,14 +340,12 @@ protected void assertContents(String expected, String actual) {
fail(diff);
}
}
-
- public IProject setUpProject(final String projectName)
- throws CoreException, IOException {
+
+ public IProject setUpProject(final String projectName) throws CoreException, IOException {
return setUpProjectTo(projectName, projectName);
}
-
- protected IProject setUpProjectTo(final String projectName,
- final String fromName) throws CoreException, IOException {
+
+ protected IProject setUpProjectTo(final String projectName, final String fromName) throws CoreException, IOException {
// copy files in project from source workspace to target workspace
final File sourceWorkspacePath = getSourceWorkspacePath();
final File targetWorkspacePath = getWorkspaceRoot().getLocation().toFile();
@@ -338,19 +356,16 @@ protected IProject setUpProjectTo(final String projectName,
copyDirectory(source, new File(targetWorkspacePath, projectName));
return createProject(projectName);
}
-
+
public File getSourceWorkspacePath() {
return new File(getPluginDirectoryPath(), "workspace");
}
-
protected File getPluginDirectoryPath() {
try {
final Bundle bundle = Platform.getBundle(this.bundleName);
if (bundle == null) {
- throw new IllegalStateException(NLS.bind(
- "Bundle \"{0}\" with test data not found",
- bundleName));
+ throw new IllegalStateException(NLS.bind("Bundle \"{0}\" with test data not found", bundleName));
}
URL platformURL = bundle.getEntry("/");
return new File(FileLocator.toFileURL(platformURL).getFile());
@@ -359,7 +374,7 @@ protected File getPluginDirectoryPath() {
}
return null;
}
-
+
protected void copyDirectory(File source, File target) throws IOException {
FileUtil.copyDirectory(source, target);
}
@@ -371,13 +386,12 @@ public IWorkspace getWorkspace() {
public IWorkspaceRoot getWorkspaceRoot() {
return getWorkspace().getRoot();
}
-
+
public IProject getProject(String project) {
return getWorkspaceRoot().getProject(project);
}
-
- protected IProject createProject(final String projectName)
- throws CoreException {
+
+ protected IProject createProject(final String projectName) throws CoreException {
final IProject project = getProject(projectName);
IWorkspaceRunnable create = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
@@ -389,15 +403,14 @@ public void run(IProgressMonitor monitor) throws CoreException {
return project;
}
- protected void discardWorkingCopies(ISourceModule[] units)
- throws ModelException {
+ protected void discardWorkingCopies(ISourceModule[] units) throws ModelException {
if (units == null)
return;
for (int i = 0, length = units.length; i < length; i++)
if (units[i] != null)
units[i].discardWorkingCopy();
}
-
+
protected void runPdttTest(String filename) throws Exception {
File projectFile = new File(getSourceWorkspacePath().toString(), projectName);
IPath path = new Path(projectFile.getAbsolutePath());
View
2 com.dubture.symfony.test/workspace/annotation/testDICompletion.pdtt
@@ -14,7 +14,7 @@ class SomeController {
}
?>
--EXPECT--
-type(Inject)
keyword(ignore)
keyword(internal)
+type(Inject)
View
2 com.dubture.symfony.test/workspace/annotation/testRouteCompletion.pdtt
@@ -14,5 +14,5 @@ class SomeController {
}
?>
--EXPECT--
-type(Route)
keyword(return)
+type(Route)
View
23 ...mfony.ui/src/com/dubture/symfony/ui/contentassist/SymfonyCompletionProposalCollector.java
@@ -17,10 +17,15 @@
import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposal;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.php.core.codeassist.ICompletionContextResolver;
+import org.eclipse.php.core.codeassist.ICompletionStrategyFactory;
+import org.eclipse.php.internal.core.codeassist.IPHPCompletionRequestorExtension;
import org.eclipse.php.internal.ui.editor.contentassist.PHPCompletionProposalCollector;
import org.eclipse.swt.graphics.Image;
import com.dubture.symfony.core.builder.SymfonyNature;
+import com.dubture.symfony.core.codeassist.SymfonyCompletionContextResolver;
+import com.dubture.symfony.core.codeassist.SymfonyCompletionStrategyFactory;
/**
* The {@link SymfonyCompletionProposalCollector} is
@@ -33,7 +38,7 @@
*/
@SuppressWarnings("restriction")
public class SymfonyCompletionProposalCollector extends
- PHPCompletionProposalCollector {
+ PHPCompletionProposalCollector implements IPHPCompletionRequestorExtension {
private SymfonyCompletionProposalLabelProvider labelProvider;
@@ -99,4 +104,20 @@ private ScriptCompletionProposal generateSymfonyProposal(CompletionProposal type
protected String getNatureId() {
return SymfonyNature.NATURE_ID;
}
+
+
+ @Override
+ public ICompletionContextResolver[] getContextResolvers() {
+ return new ICompletionContextResolver[] {
+ new SymfonyCompletionContextResolver()
+ };
+ }
+
+
+ @Override
+ public ICompletionStrategyFactory[] getStrategyFactories() {
+ return new ICompletionStrategyFactory[] {
+ new SymfonyCompletionStrategyFactory()
+ };
+ }
}
View
20 ...ymfony.ui/src/com/dubture/symfony/ui/contentassist/SymfonyCompletionProposalComputer.java
@@ -1,15 +1,20 @@
/*******************************************************************************
* This file is part of the Symfony eclipse plugin.
- *
+ *
* (c) Robert Gruendler <r.gruendler@gmail.com>
- *
+ *
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
******************************************************************************/
package com.dubture.symfony.ui.contentassist;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposalCollector;
import org.eclipse.dltk.ui.text.completion.ScriptContentAssistInvocationContext;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.php.internal.ui.editor.contentassist.PHPCompletionProposalComputer;
@@ -20,12 +25,17 @@
public class SymfonyCompletionProposalComputer extends
PHPCompletionProposalComputer {
-
+
@Override
protected ScriptCompletionProposalCollector createCollector(
ScriptContentAssistInvocationContext context) {
-
+
return new SymfonyCompletionProposalCollector(context.getDocument(), context.getSourceModule(), true);
-
+
+ }
+
+ @Override
+ protected List<ICompletionProposal> computeTemplateCompletionProposals(int offset, ScriptContentAssistInvocationContext context, IProgressMonitor monitor) {
+ return Collections.emptyList();
}
}
View
95 ...ubture.symfony.ui/src/com/dubture/symfony/ui/wizards/importer/SymfonyImportFirstPage.java
@@ -34,6 +34,7 @@
import com.dubture.getcomposer.core.ComposerPackage;
import com.dubture.getcomposer.core.VersionedPackage;
import com.dubture.getcomposer.core.collection.Dependencies;
+import com.dubture.getcomposer.json.ParseException;
import com.dubture.symfony.core.SymfonyVersion;
import com.dubture.symfony.core.log.Logger;
import com.dubture.symfony.ui.SymfonyPluginImages;
@@ -55,14 +56,14 @@ public ValidationException(String string) {
private StringButtonDialogField sourceButton;
private StringButtonDialogField containerButton;
private StringButtonDialogField consoleButton;
-
+
protected IPath sourcePath;
protected IPath consolePath;
protected IPath containerPath;
protected String projectName;
protected PHPVersion phpVersion;
protected SymfonyVersion symfonyVersion;
-
+
private SymfonyProjectScanner scanner;
private StringDialogField projectNameField;
private IWorkspace workspace;
@@ -87,14 +88,14 @@ public void createControl(Composite parent) {
projectNameField.setLabelText("Project name");
projectNameField.doFillIntoGrid(container, 3);
projectNameField.setDialogFieldListener(new IDialogFieldListener() {
-
+
@Override
public void dialogFieldChanged(DialogField field) {
projectName = projectNameField.getText();
validateSettings();
}
});
-
+
sourceButton = new StringButtonDialogField(new IStringButtonAdapter() {
@Override
public void changeControlPressed(DialogField field) {
@@ -130,15 +131,15 @@ public void changeControlPressed(DialogField field) {
if (result != null && relativePath != null) {
containerButton.setText(relativePath);
containerPath= new Path(relativePath);
- validateSettings();
+ validateSettings();
}
} catch (Exception e) {
Logger.logException(e);
}
-
+
}
});
-
+
LayoutUtil.setHorizontalGrabbing(sourceButton.getTextControl(null));
containerButton.setButtonLabel("Browse");
@@ -154,48 +155,48 @@ public void changeControlPressed(DialogField field) {
if (result != null && relativePath != null) {
consoleButton.setText(relativePath);
consolePath = new Path(relativePath);
- validateSettings();
+ validateSettings();
}
}
});
-
+
LayoutUtil.setHorizontalGrabbing(containerButton.getTextControl(null));
consoleButton.setButtonLabel("Browse");
consoleButton.setLabelText("Symfony console");
consoleButton.doFillIntoGrid(container, 3);
-
+
LayoutUtil.setHorizontalGrabbing(consoleButton.getTextControl(null));
-
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(container, SymfonyUiPlugin.PLUGIN_ID + "." + "import_firstpage");
-
+
disableButtons();
-
+
setControl(container);
}
-
+
protected String getRelativePath(String path) {
-
+
if (path == null) {
return null;
}
-
+
IPath container = new Path(path);
if (!sourcePath.isPrefixOf(container)) {
return null;
}
-
+
return container.setDevice(null).removeFirstSegments(sourcePath.segmentCount()).toOSString();
}
-
+
protected void enableButtons() {
consoleButton.setEnabled(true);
consoleButton.getTextControl(null).setEnabled(false);
-
+
containerButton.setEnabled(true);
containerButton.getTextControl(null).setEnabled(false);
}
-
+
protected void disableButtons() {
consoleButton.setEnabled(false);
containerButton.setEnabled(false);
@@ -206,24 +207,24 @@ protected void scanSourceFolder() throws InvocationTargetException, InterruptedE
if (sourcePath == null) {
return;
}
-
+
getWizard().getContainer().run(true, true, scanner);
-
+
if (scanner.getConsole() != null && scanner.getConsole().exists()) {
IPath newConsolePath = new Path(scanner.getConsole().getAbsolutePath());
newConsolePath = newConsolePath.removeFirstSegments(sourcePath.segmentCount());
consoleButton.setText(newConsolePath.setDevice(null).toOSString());
consolePath = newConsolePath;
}
-
+
if (scanner.getContainer() != null && scanner.getContainer().exists()) {
IPath newContainerPath = new Path(scanner.getContainer().getAbsolutePath());
newContainerPath = newContainerPath.setDevice(null).removeFirstSegments(sourcePath.segmentCount());
containerButton.setText(newContainerPath.toOSString());
containerPath = newContainerPath;
}
-
- validateSettings();
+
+ validateSettings();
}
protected class SymfonyProjectScanner implements IRunnableWithProgress {
@@ -274,12 +275,12 @@ protected void scanForConsole() {
}
}
}
-
- protected void scanVersions() throws IOException {
+
+ protected void scanVersions() throws IOException, ParseException {
IPath composerPath = sourcePath.append("composer.json");
ComposerPackage composer = new ComposerPackage(composerPath.toFile());
Dependencies require = composer.getRequire();
-
+
for (VersionedPackage versioned: require) {
if ("symfony/symfony".equals(versioned.getName())) {
if (versioned.getVersion().startsWith("2.1")) {
@@ -297,15 +298,15 @@ protected void scanVersions() throws IOException {
}
}
}
-
+
protected void scanForExistingProjectFile() throws IOException {
-
+
IPath projectPath = sourcePath.append(".project");
-
+
if (projectPath.toFile().exists()) {
ProjectDescriptionReader reader = new ProjectDescriptionReader();
final ProjectDescription projectDescription = reader.read(projectPath);
-
+
if (projectDescription != null && projectDescription.getName() != null) {
getShell().getDisplay().asyncExec(new Runnable() {
@Override
@@ -330,29 +331,29 @@ public File getContainer() {
public IPath getSourcePath() {
return sourcePath;
}
-
+
public IPath getContainerPath() {
return containerPath;
}
-
+
public IPath getConsolePath() {
return consolePath;
}
-
+
public String getProjectName() {
return projectName;
}
-
+
public PHPVersion getPHPVersion() {
return phpVersion;
}
-
+
public SymfonyVersion getSymfonyVersion() {
return symfonyVersion;
}
-
+
public void validateProjectName() throws ValidationException {
-
+
try {
IProject project = workspace.getRoot().getProject(projectName);
if (project != null && project.exists()) {
@@ -362,36 +363,36 @@ public void validateProjectName() throws ValidationException {
throw new ValidationException(e.getMessage());
}
}
-
+
public void validateContainerPath() throws ValidationException {
try {
validatePath(containerPath.toOSString());
} catch (Exception e) {
throw new ValidationException("The selected service container does not exist.");
}
}
-
+
public void validateConsolePath() throws ValidationException {
try {
validatePath(consolePath.toOSString());
} catch (Exception e) {
throw new ValidationException("The selected Symfony console does not exist.");
}
}
-
+
public void validatePath(String path) throws ValidationException {
if (sourcePath == null) {
throw new ValidationException("");
}
-
+
File absolute = new File(sourcePath.toOSString(), path);
-
+
if (absolute.exists() == false) {
- throw new ValidationException("");
+ throw new ValidationException("");
}
}
-
+
public void validateSettings() {
try {
@@ -402,7 +403,7 @@ public void validateSettings() {
setPageComplete(false);
return;
}
-
+
setPageComplete(true);
setErrorMessage(null);
}
View
30 ....symfony.ui/src/com/dubture/symfony/ui/wizards/project/SymfonyProjectWizardFirstPage.java
@@ -22,30 +22,30 @@
import org.eclipse.ui.PlatformUI;
import com.dubture.composer.core.ComposerPlugin;
-import com.dubture.composer.core.preferences.CorePreferenceConstants.Keys;
import com.dubture.composer.ui.converter.String2KeywordsConverter;
import com.dubture.composer.ui.wizard.ValidationException;
import com.dubture.composer.ui.wizard.ValidationException.Severity;
import com.dubture.composer.ui.wizard.project.template.PackageProjectWizardFirstPage;
import com.dubture.composer.ui.wizard.project.template.Validator;
import com.dubture.getcomposer.core.ComposerPackage;
+import com.dubture.symfony.core.preferences.CorePreferenceConstants.Keys;
import com.dubture.symfony.ui.SymfonyUiPlugin;
@SuppressWarnings("restriction")
public class SymfonyProjectWizardFirstPage extends PackageProjectWizardFirstPage implements IShellProvider {
private Validator projectTemplateValidator;
-
+
public SymfonyProjectWizardFirstPage() {
setPageComplete(false);
setTitle("Basic Symfony settings");
setDescription("Create a new Symfony project and select the target location");
}
-
-
+
+
@Override
public void createControl(Composite parent) {
-
+
final Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
composite.setLayout(initGridLayout(new GridLayout(1, false), false));
@@ -55,16 +55,16 @@ public void createControl(Composite parent) {
nameGroup = new NameGroup(composite, initialName, getShell());
nameGroup.addObserver(this);
PHPLocationGroup = new SymfonyLocationGroup(composite, nameGroup, getShell());
-
+
CompositeData data = new CompositeData();
data.setParetnt(composite);
data.setSettings(getDialogSettings());
data.setObserver(PHPLocationGroup);
versionGroup = new SymfonyVersionGroup(this, composite);
-
+
nameGroup.addObserver(PHPLocationGroup);
-
+
nameGroup.notifyObservers();
projectTemplateValidator = new Validator(this) {
@Override
@@ -77,26 +77,26 @@ protected void finishValidation() throws ValidationException {
}
}
};
-
+
nameGroup.addObserver(projectTemplateValidator);
PHPLocationGroup.addObserver(projectTemplateValidator);
Dialog.applyDialogFont(composite);
-
+
setControl(composite);
composerPackage = new ComposerPackage();
keywordConverter = new String2KeywordsConverter(composerPackage);
-
+
setHelpContext(composite);
setPageComplete(false);
-
+
}
@Override
protected void setHelpContext(Control container) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(container, SymfonyUiPlugin.PLUGIN_ID + "." + "newproject_firstpage");
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(container, SymfonyUiPlugin.PLUGIN_ID + "." + "newproject_firstpage");
}
-
+
@Override
public boolean doesOverrideComposer() {
return true;
@@ -105,7 +105,7 @@ public boolean doesOverrideComposer() {
public String getSymfonyVersion() {
return ((SymfonyVersionGroup)versionGroup).getSymfonyVersion();
}
-
+
public String getVirtualHost() {
return ((SymfonyLocationGroup)PHPLocationGroup).getVirtualHost();
}
View
97 ...symfony.ui/src/com/dubture/symfony/ui/wizards/project/SymfonyProjectWizardSecondPage.java
@@ -54,6 +54,7 @@
import com.dubture.composer.ui.wizard.AbstractWizardSecondPage;
import com.dubture.composer.ui.wizard.project.BasicSettingsGroup;
import com.dubture.getcomposer.core.ComposerPackage;
+import com.dubture.getcomposer.json.ParseException;
import com.dubture.symfony.core.SymfonyCorePlugin;
import com.dubture.symfony.core.SymfonyVersion;
import com.dubture.symfony.core.facet.FacetManager;
@@ -64,9 +65,9 @@
import com.dubture.symfony.ui.job.NopJob;
/**
- *
+ *
* @author Robert Gruendler <r.gruendler@gmail.com>
- *
+ *
*/
@SuppressWarnings("restriction")
public class SymfonyProjectWizardSecondPage extends AbstractWizardSecondPage {
@@ -80,23 +81,23 @@ public SymfonyProjectWizardSecondPage(AbstractWizardFirstPage mainPage, String t
@Override
public void update(Observable o, Object arg) {
-
+
}
-
+
@Override
public void createControl(Composite parent) {
-
+
final Composite composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
GridLayout layout = new GridLayout(1, false);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
-
+
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
+
overrideComposer = new SelectionButtonDialogField(SWT.CHECK);
overrideComposer.setLabelText("Override composer.json values");
overrideComposer.doFillIntoGrid(composite, 3);
@@ -106,13 +107,13 @@ public void dialogFieldChanged(DialogField field) {
settingsGroup.setEnabled(overrideComposer.isSelected());
}
});
-
+
settingsGroup = new BasicSettingsGroup(composite, getShell());
settingsGroup.addObserver(this);
settingsGroup.setEnabled(false);
-
+
setControl(composite);
-
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, SymfonyUiPlugin.PLUGIN_ID + "." + "newproject_secondpage");
}
@@ -130,13 +131,13 @@ protected String getPageDescription() {
protected void beforeFinish(IProgressMonitor monitor) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
-
+
SymfonyProjectWizardFirstPage symfonyPage = (SymfonyProjectWizardFirstPage) firstPage;
monitor.beginTask("Initializing Symfony project", 2);
monitor.setTaskName("Running create-project command...");
monitor.worked(1);
IPath path = null;
-
+
if (symfonyPage.isInLocalServer()) {
path = symfonyPage.getPath().removeLastSegments(1);
} else {
@@ -159,28 +160,28 @@ public void jobFailed() {
latch.countDown();
}
});
-
+
projectJob.addJobChangeListener(new JobChangeAdapter() {
-
+
@Override
public void done(IJobChangeEvent event) {
-
+
if (event.getResult() == null || event.getResult().getCode() == Status.ERROR) {
Logger.log(Logger.ERROR, "Could not run composer create-project");
return;
}
-
+
if (getProject() == null || getProject().getName() == null) {
Logger.log(Logger.ERROR, "Unable to initialize symfony project, cannot retrieve project");
return;
}
-
+
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getProject().getName());
if (project == null) {
Logger.log(Logger.WARNING, "Unable to retrieve project for running the console after project initialization");
return;
}
-
+
refreshProject(getProject().getName());
NopJob job = new NopJob();
job.setProject(project);
@@ -193,14 +194,14 @@ public void done(IJobChangeEvent event) {
Logger.log(Logger.WARNING, "Could not retrieve project for saving the debug container");
return;
}
-
+
IFile dumpedContainer = project.getFile(SymfonyCoreConstants.DEFAULT_CONTAINER);
-
+
if (dumpedContainer == null || dumpedContainer.exists() == false) {
Logger.log(Logger.WARNING, "Could not retrieve project for saving the debug container");
return;
}
-
+
try {
Logger.debugMSG("Setting dumped service container");
IEclipsePreferences node = new ProjectScope(project).getNode(SymfonyCorePlugin.ID);
@@ -211,81 +212,81 @@ public void done(IJobChangeEvent event) {
}
}
});
-
+
job.schedule();
}
});
-
+
projectJob.schedule();
-
+
try {
latch.await();
} catch (InterruptedException e) {
-
+
}
-
+
monitor.worked(1);
}
@Override
protected void finishPage(IProgressMonitor monitor) throws Exception {
-
+
IPath vendorPath = getSymfonyFolderPath(getProject(), SymfonyCoreConstants.VENDOR_PATH);
-
+
IBuildpathEntry sourceEntry = DLTKCore.newSourceEntry(vendorPath, new IPath[] {
new Path(SymfonyCoreConstants.SKELETON_PATTERN),
new Path(SymfonyCoreConstants.TEST_PATTERN),
new Path(SymfonyCoreConstants.CG_FIXTURE_PATTERN)
- });
-
+ });
+
BuildPathManager.setExclusionPattern(getScriptProject(), sourceEntry);
String version = ((SymfonyProjectWizardFirstPage)firstPage).getSymfonyVersion();
SymfonyVersion symfonyVersion = SymfonyVersion.Symfony2_2_1;
if (version.startsWith("v2.1")) {
symfonyVersion = SymfonyVersion.Symfony2_1_9;
}
-
+
try {
-
+
FacetManager.installFacets(getProject(), firstPage.getPHPVersionValue(), symfonyVersion, monitor);
-
+
if (overrideComposer.isSelected()) {
updateComposerJson(monitor);
}
-
+
createProjectSettings();
-
+
if (!firstPage.isInLocalServer()) {
return;
}
-
+
Server server = createServer();
LaunchConfigurationHelper.createLaunchConfiguration(getProject(), server, getProject().getFile(new Path("web/app_dev.php")));
-
+
} catch (Exception e) {
Logger.logException(e);
}
}
-
+
protected void createProjectSettings() throws BackingStoreException {
-
+
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(SymfonyCorePlugin.ID);
String executable = preferences.get(Keys.PHP_EXECUTABLE, null);
-
+
IEclipsePreferences node = new ProjectScope(getProject()).getNode(SymfonyCorePlugin.ID);
node.put(Keys.PHP_EXECUTABLE, executable);
node.put(Keys.CONSOLE, SymfonyCoreConstants.DEFAULT_CONSOLE);
node.put(Keys.USE_PROJECT_PHAR, Boolean.FALSE.toString());
node.flush();
-
+
}
-
- private void updateComposerJson(IProgressMonitor monitor) throws IOException, CoreException {
+
+ private void updateComposerJson(IProgressMonitor monitor) throws IOException, CoreException, ParseException {
IFile composerJson = getProject().getFile("composer.json");
ComposerPackage composerPackage = new ComposerPackage(composerJson.getRawLocation().makeAbsolute().toFile());
- String2KeywordsConverter keywordConverter = new String2KeywordsConverter(composerPackage);
-
+ String2KeywordsConverter keywordConverter = new String2KeywordsConverter(composerPackage);
+
if (settingsGroup.getVendor() != null && firstPage.nameGroup.getName() != null) {
composerPackage.setName(String.format("%s/%s", settingsGroup.getVendor(), firstPage.nameGroup.getName()));
}
@@ -309,11 +310,11 @@ private void updateComposerJson(IProgressMonitor monitor) throws IOException, Co
String json = composerPackage.toJson();
ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes());
-
+
monitor.beginTask("Updating composer.json", 1);
composerJson.setContents(bis, IResource.FORCE, monitor);
monitor.worked(1);
-
+
}
private IPath getSymfonyFolderPath(IProject project, String folderPath) {
@@ -324,7 +325,7 @@ private IPath getSymfonyFolderPath(IProject project, String folderPath) {
return null;
}
-
+
protected Server createServer() throws MalformedURLException {
Server server = ServersManager.createServer(getProject().getName(), ((SymfonyProjectWizardFirstPage)firstPage).getVirtualHost());
server.setDocumentRoot(getProject().getRawLocation().append("web").toOSString());
View
15 pom.xml
@@ -10,7 +10,7 @@
<prerequisites>
<maven>3.0</maven>
</prerequisites>
-
+
<modules>
<module>com.dubture.symfony.core</module>
<module>com.dubture.symfony.debug</module>
@@ -22,7 +22,7 @@
</modules>
<properties>
- <tycho-version>0.17.0</tycho-version>
+ <tycho-version>0.19.0</tycho-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -34,11 +34,16 @@
<url>http://dzwiupza59who.cloudfront.net/repository</url>
</repository>
<repository>
- <id>dltk</id>
+ <id>dltk-snaphot</id>
<layout>p2</layout>
<url>https://hudson.eclipse.org/hudson/job/dltk-nightly/lastSuccessfulBuild/artifact/org.eclipse.dltk.releng/build/update.site/target/site/</url>
</repository>
<repository>
+ <id>dltk-stable</id>
+ <layout>p2</layout>
+ <url>http://download.eclipse.org/technology/dltk/updates-dev/5.0/</url>
+ </repository>
+ <repository>
<id>pex</id>
<layout>p2</layout>
<url>http://p2-dev.pdt-extensions.org/</url>
@@ -59,7 +64,7 @@
<repository>
<id>orbit</id>
<layout>p2</layout>
- <url>http://download.eclipse.org/tools/orbit/downloads/drops/S20130427215344/repository</url>
+ <url>http://download.eclipse.org/tools/orbit/downloads/drops/R20140114142710/repository</url>
</repository>
</repositories>
@@ -96,7 +101,7 @@
<version>${tycho-version}</version>
<configuration>
- <pomDependencies>consider</pomDependencies>
+ <pomDependencies>consider</pomDependencies>
<environments>
<environment>
<os>linux</os>

0 comments on commit bee28e3

Please sign in to comment.
Something went wrong with that request. Please try again.