All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [eclipse-poky][master]Add more comprehensive error message for invalid project name
@ 2013-03-14  9:06 Ioana Grigoropol
  2013-03-14 10:29 ` Timo Müller
  0 siblings, 1 reply; 4+ messages in thread
From: Ioana Grigoropol @ 2013-03-14  9:06 UTC (permalink / raw)
  To: yocto

[Yocto #4008]

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../sdk/ide/wizard/NewYoctoCProjectTemplate.java   |   34 +++++++++++++++++---
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
index 5ffd6b7..8ab5972 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
@@ -10,6 +10,8 @@
  *******************************************************************************/
 package org.yocto.sdk.ide.wizard;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
 
@@ -46,11 +48,11 @@ import org.yocto.sdk.ide.YoctoProfileElement;
 import org.yocto.sdk.ide.YoctoSDKChecker;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
+import org.yocto.sdk.ide.YoctoSDKPlugin;
+import org.yocto.sdk.ide.YoctoUIElement;
 import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
-import org.yocto.sdk.ide.YoctoSDKPlugin;
-import org.yocto.sdk.ide.YoctoUIElement;
 
 
 @SuppressWarnings("restriction")
@@ -58,11 +60,20 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
 	protected boolean savedAutoBuildingValue;
 	protected ProjectCreatedActions pca;
 	protected IManagedBuildInfo info;
+	protected List<Character> illegalChars = Arrays.asList('$', '"','#','%','&','\'','(',')','*', '+', ',','.','/',':',';','<','=','>','?','@','[','\\',']','^','`','{','|','}','~');
 	
 	public NewYoctoCProjectTemplate() {
 		pca = new ProjectCreatedActions();
 	}
-	
+	private String printIllegalChars(){
+		String print = "";
+		for (int i = 0; i < illegalChars.size(); i++) {
+			print += illegalChars.get(i);
+			if (i != illegalChars.size() - 1)
+				print += " ,";
+		}
+		return print;
+	}
 	public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
 
 		String projectName = args[0].getSimpleValue();
@@ -74,9 +85,10 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
 		boolean isEmptryProject = Boolean.valueOf(isEmptyProjetValue).booleanValue();
 		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
 		try {
-			if (projectName.contains(" ")) {
+			if (!isValidProjectName(projectName)) {
 				project.delete(true, null);
-				throw new ProcessFailureException(projectName + " contains space(s).  Project name can't contain space(s)");
+				throw new ProcessFailureException("Project name " + "\""+ projectName +"\"" +" is invalid! " +
+						"\nNone of these characters are accepted inside project names: whitespaces, " + printIllegalChars());
 			}
 			if (!project.exists()) {
 				IWorkspace workspace = ResourcesPlugin.getWorkspace();
@@ -166,6 +178,18 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
 			throw new OperationCanceledException(Messages.getString("NewManagedProject.3") + e.getMessage());
 		}
 	}
+	private boolean isValidProjectName(String projectName) {
+		if (projectName.contains("\\s+"))
+			return false;
+
+		char[] chars = projectName.toCharArray();
+		if (!Character.isJavaIdentifierStart(chars[0]))
+			return false;
+		for (int i = 1; i < chars.length; i++)
+			if (illegalChars.contains(chars[i]))
+				return false;
+		return true;
+}
 
 	protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException {
 		IWorkspaceDescription workspaceDesc = workspace.getDescription();
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [eclipse-poky][master]Add more comprehensive error message for invalid project name
  2013-03-14  9:06 [PATCH] [eclipse-poky][master]Add more comprehensive error message for invalid project name Ioana Grigoropol
@ 2013-03-14 10:29 ` Timo Müller
  2013-03-14 10:36   ` Timo Müller
  2013-03-14 12:08   ` Grigoropol, IoanaX
  0 siblings, 2 replies; 4+ messages in thread
From: Timo Müller @ 2013-03-14 10:29 UTC (permalink / raw)
  To: Ioana Grigoropol; +Cc: yocto

Hi Ioana,

Ioana Grigoropol wrote, On 14.03.2013 10:06:
> [Yocto #4008]
>
> Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
> ---
>   .../sdk/ide/wizard/NewYoctoCProjectTemplate.java   |   34 +++++++++++++++++---
>   1 file changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
> index 5ffd6b7..8ab5972 100644
> --- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
> +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
> @@ -10,6 +10,8 @@
>    *******************************************************************************/
>   package org.yocto.sdk.ide.wizard;
>
> +import java.util.ArrayList;
> +import java.util.Arrays;
>   import java.util.LinkedHashMap;
>   import java.util.List;
>
> @@ -46,11 +48,11 @@ import org.yocto.sdk.ide.YoctoProfileElement;
>   import org.yocto.sdk.ide.YoctoSDKChecker;
>   import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
>   import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
> +import org.yocto.sdk.ide.YoctoSDKPlugin;
> +import org.yocto.sdk.ide.YoctoUIElement;
>   import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
>   import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
>   import org.yocto.sdk.ide.utils.YoctoSDKUtils;
> -import org.yocto.sdk.ide.YoctoSDKPlugin;
> -import org.yocto.sdk.ide.YoctoUIElement;
>
>
>   @SuppressWarnings("restriction")
> @@ -58,11 +60,20 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
>   	protected boolean savedAutoBuildingValue;
>   	protected ProjectCreatedActions pca;
>   	protected IManagedBuildInfo info;
> +	protected List<Character> illegalChars = Arrays.asList('$', '"','#','%','&','\'','(',')','*', '+', ',','.','/',':',';','<','=','>','?','@','[','\\',']','^','`','{','|','}','~');
>   	
>   	public NewYoctoCProjectTemplate() {
>   		pca = new ProjectCreatedActions();
>   	}
> -	
> +	private String printIllegalChars(){
> +		String print = "";
> +		for (int i = 0; i < illegalChars.size(); i++) {
> +			print += illegalChars.get(i);
> +			if (i != illegalChars.size() - 1)
> +				print += " ,";
> +		}
> +		return print;
> +	}

I think the contained "if" isn't really necessary. You can remove the 
last ", " afterwards. Then you can also use a for each loop to append 
the characters.

private String printIllegalChars(){
	String print = "";

	for (Character character : illegalChars) {
		print += character + ", ";
	}
		
	if (!illegalChars.isEmpty()) {
		print = print.substring(0, print.lastIndexOf(",") - 1);
	}
		
	return print;
}

>   	public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
>
>   		String projectName = args[0].getSimpleValue();
> @@ -74,9 +85,10 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
>   		boolean isEmptryProject = Boolean.valueOf(isEmptyProjetValue).booleanValue();
>   		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
>   		try {
> -			if (projectName.contains(" ")) {
> +			if (!isValidProjectName(projectName)) {
>   				project.delete(true, null);
> -				throw new ProcessFailureException(projectName + " contains space(s).  Project name can't contain space(s)");
> +				throw new ProcessFailureException("Project name " + "\""+ projectName +"\"" +" is invalid! " +
> +						"\nNone of these characters are accepted inside project names: whitespaces, " + printIllegalChars());

Would be nice if we can wrap this up with the YoctoSDKMessages to be 
able to internationalize the string later.

>   			}
>   			if (!project.exists()) {
>   				IWorkspace workspace = ResourcesPlugin.getWorkspace();
> @@ -166,6 +178,18 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
>   			throw new OperationCanceledException(Messages.getString("NewManagedProject.3") + e.getMessage());
>   		}
>   	}
> +	private boolean isValidProjectName(String projectName) {
> +		if (projectName.contains("\\s+"))
> +			return false;
> +
> +		char[] chars = projectName.toCharArray();
> +		if (!Character.isJavaIdentifierStart(chars[0]))
> +			return false;
> +		for (int i = 1; i < chars.length; i++)
> +			if (illegalChars.contains(chars[i]))
> +				return false;
> +		return true;
> +}

I think it would be better to use functionality from java.util.regex to 
do the name checking. The Pattern could be compiled once as a static 
member and we could than use the matcher to check whether the project 
name is fine.

Something like this:

private static Pattern pattern = Pattern.compile(".*(\\$|\").*");

private boolean isValidProjectName(String projectName) {
   Matcher matcher = pattern.matcher(projectName);
	
   if (matcher.matches()) {
     return false;
   }

   return true;
}

>
>   	protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException {
>   		IWorkspaceDescription workspaceDesc = workspace.getDescription();
>

Best regards,
Timo



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [eclipse-poky][master]Add more comprehensive error message for invalid project name
  2013-03-14 10:29 ` Timo Müller
@ 2013-03-14 10:36   ` Timo Müller
  2013-03-14 12:08   ` Grigoropol, IoanaX
  1 sibling, 0 replies; 4+ messages in thread
From: Timo Müller @ 2013-03-14 10:36 UTC (permalink / raw)
  To: Ioana Grigoropol; +Cc: yocto

Hi Ioana,

Timo Müller wrote, On 14.03.2013 11:29:
> Hi Ioana,
>
> Ioana Grigoropol wrote, On 14.03.2013 10:06:
>> [Yocto #4008]
>>
>> Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
>> ---
>>   .../sdk/ide/wizard/NewYoctoCProjectTemplate.java   |   34
>> +++++++++++++++++---
>>   1 file changed, 29 insertions(+), 5 deletions(-)
>>
>> diff --git
>> a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
>> b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
>>
>> index 5ffd6b7..8ab5972 100644
>> ---
>> a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
>>
>> +++
>> b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
>>
>> @@ -10,6 +10,8 @@
>>
>> *******************************************************************************/
>>
>>   package org.yocto.sdk.ide.wizard;
>>
>> +import java.util.ArrayList;
>> +import java.util.Arrays;
>>   import java.util.LinkedHashMap;
>>   import java.util.List;
>>
>> @@ -46,11 +48,11 @@ import org.yocto.sdk.ide.YoctoProfileElement;
>>   import org.yocto.sdk.ide.YoctoSDKChecker;
>>   import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
>>   import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
>> +import org.yocto.sdk.ide.YoctoSDKPlugin;
>> +import org.yocto.sdk.ide.YoctoUIElement;
>>   import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
>>   import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
>>   import org.yocto.sdk.ide.utils.YoctoSDKUtils;
>> -import org.yocto.sdk.ide.YoctoSDKPlugin;
>> -import org.yocto.sdk.ide.YoctoUIElement;
>>
>>
>>   @SuppressWarnings("restriction")
>> @@ -58,11 +60,20 @@ public class NewYoctoCProjectTemplate extends
>> ProcessRunner {
>>       protected boolean savedAutoBuildingValue;
>>       protected ProjectCreatedActions pca;
>>       protected IManagedBuildInfo info;
>> +    protected List<Character> illegalChars = Arrays.asList('$',
>> '"','#','%','&','\'','(',')','*', '+',
>> ',','.','/',':',';','<','=','>','?','@','[','\\',']','^','`','{','|','}','~');
>>
>>
>>       public NewYoctoCProjectTemplate() {
>>           pca = new ProjectCreatedActions();
>>       }
>> -
>> +    private String printIllegalChars(){
>> +        String print = "";
>> +        for (int i = 0; i < illegalChars.size(); i++) {
>> +            print += illegalChars.get(i);
>> +            if (i != illegalChars.size() - 1)
>> +                print += " ,";
>> +        }
>> +        return print;
>> +    }
>
> I think the contained "if" isn't really necessary. You can remove the
> last ", " afterwards. Then you can also use a for each loop to append
> the characters.
>
> private String printIllegalChars(){
>      String print = "";
>
>      for (Character character : illegalChars) {
>          print += character + ", ";
>      }
>
>      if (!illegalChars.isEmpty()) {
>          print = print.substring(0, print.lastIndexOf(",") - 1);
>      }
>
>      return print;
> }
>
>>       public void process(TemplateCore template, ProcessArgument[]
>> args, String processId, IProgressMonitor monitor) throws
>> ProcessFailureException {
>>
>>           String projectName = args[0].getSimpleValue();
>> @@ -74,9 +85,10 @@ public class NewYoctoCProjectTemplate extends
>> ProcessRunner {
>>           boolean isEmptryProject =
>> Boolean.valueOf(isEmptyProjetValue).booleanValue();
>>           IProject project =
>> ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
>>           try {
>> -            if (projectName.contains(" ")) {
>> +            if (!isValidProjectName(projectName)) {
>>                   project.delete(true, null);
>> -                throw new ProcessFailureException(projectName + "
>> contains space(s).  Project name can't contain space(s)");
>> +                throw new ProcessFailureException("Project name " +
>> "\""+ projectName +"\"" +" is invalid! " +
>> +                        "\nNone of these characters are accepted
>> inside project names: whitespaces, " + printIllegalChars());
>
> Would be nice if we can wrap this up with the YoctoSDKMessages to be
> able to internationalize the string later.
>
>>               }
>>               if (!project.exists()) {
>>                   IWorkspace workspace = ResourcesPlugin.getWorkspace();
>> @@ -166,6 +178,18 @@ public class NewYoctoCProjectTemplate extends
>> ProcessRunner {
>>               throw new
>> OperationCanceledException(Messages.getString("NewManagedProject.3") +
>> e.getMessage());
>>           }
>>       }
>> +    private boolean isValidProjectName(String projectName) {
>> +        if (projectName.contains("\\s+"))
>> +            return false;
>> +
>> +        char[] chars = projectName.toCharArray();
>> +        if (!Character.isJavaIdentifierStart(chars[0]))
>> +            return false;
>> +        for (int i = 1; i < chars.length; i++)
>> +            if (illegalChars.contains(chars[i]))
>> +                return false;
>> +        return true;
>> +}
>
> I think it would be better to use functionality from java.util.regex to
> do the name checking. The Pattern could be compiled once as a static
> member and we could than use the matcher to check whether the project
> name is fine.
>
> Something like this:
>
> private static Pattern pattern = Pattern.compile(".*(\\$|\").*");
>
> private boolean isValidProjectName(String projectName) {
>    Matcher matcher = pattern.matcher(projectName);
>
>    if (matcher.matches()) {
>      return false;
>    }
>
>    return true;
> }
>
>>
>>       protected final void turnOffAutoBuild(IWorkspace workspace)
>> throws CoreException {
>>           IWorkspaceDescription workspaceDesc =
>> workspace.getDescription();
>>
>
> Best regards,
> Timo


I forgot to mention. I found a way to create projects with invalid names.

# Create a new Yocto C Project
# Enter a wrong name eg. Test"
# Press next
# Press finish
# --> Error Message is shown, press ok
# Press back
# Change the name to an also invalid name eg. Test$
# Click finish

Best regards,
Timo



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [eclipse-poky][master]Add more comprehensive error message for invalid project name
  2013-03-14 10:29 ` Timo Müller
  2013-03-14 10:36   ` Timo Müller
@ 2013-03-14 12:08   ` Grigoropol, IoanaX
  1 sibling, 0 replies; 4+ messages in thread
From: Grigoropol, IoanaX @ 2013-03-14 12:08 UTC (permalink / raw)
  To: Timo Müller; +Cc: yocto@yoctoproject.org

Hi Timo,

Thank you for the comments. I have sent a new version of the patch to the list.

Ioana
________________________________________
From: Timo Müller [mail@timomueller.eu]
Sent: Thursday, March 14, 2013 12:29 PM
To: Grigoropol, IoanaX
Cc: yocto@yoctoproject.org
Subject: Re: [yocto] [PATCH] [eclipse-poky][master]Add more comprehensive error message for invalid project name

Hi Ioana,

Ioana Grigoropol wrote, On 14.03.2013 10:06:
> [Yocto #4008]
>
> Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
> ---
>   .../sdk/ide/wizard/NewYoctoCProjectTemplate.java   |   34 +++++++++++++++++---
>   1 file changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
> index 5ffd6b7..8ab5972 100644
> --- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
> +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
> @@ -10,6 +10,8 @@
>    *******************************************************************************/
>   package org.yocto.sdk.ide.wizard;
>
> +import java.util.ArrayList;
> +import java.util.Arrays;
>   import java.util.LinkedHashMap;
>   import java.util.List;
>
> @@ -46,11 +48,11 @@ import org.yocto.sdk.ide.YoctoProfileElement;
>   import org.yocto.sdk.ide.YoctoSDKChecker;
>   import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
>   import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
> +import org.yocto.sdk.ide.YoctoSDKPlugin;
> +import org.yocto.sdk.ide.YoctoUIElement;
>   import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
>   import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
>   import org.yocto.sdk.ide.utils.YoctoSDKUtils;
> -import org.yocto.sdk.ide.YoctoSDKPlugin;
> -import org.yocto.sdk.ide.YoctoUIElement;
>
>
>   @SuppressWarnings("restriction")
> @@ -58,11 +60,20 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
>       protected boolean savedAutoBuildingValue;
>       protected ProjectCreatedActions pca;
>       protected IManagedBuildInfo info;
> +     protected List<Character> illegalChars = Arrays.asList('$', '"','#','%','&','\'','(',')','*', '+', ',','.','/',':',';','<','=','>','?','@','[','\\',']','^','`','{','|','}','~');
>
>       public NewYoctoCProjectTemplate() {
>               pca = new ProjectCreatedActions();
>       }
> -
> +     private String printIllegalChars(){
> +             String print = "";
> +             for (int i = 0; i < illegalChars.size(); i++) {
> +                     print += illegalChars.get(i);
> +                     if (i != illegalChars.size() - 1)
> +                             print += " ,";
> +             }
> +             return print;
> +     }

I think the contained "if" isn't really necessary. You can remove the
last ", " afterwards. Then you can also use a for each loop to append
the characters.

private String printIllegalChars(){
        String print = "";

        for (Character character : illegalChars) {
                print += character + ", ";
        }

        if (!illegalChars.isEmpty()) {
                print = print.substring(0, print.lastIndexOf(",") - 1);
        }

        return print;
}

>       public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
>
>               String projectName = args[0].getSimpleValue();
> @@ -74,9 +85,10 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
>               boolean isEmptryProject = Boolean.valueOf(isEmptyProjetValue).booleanValue();
>               IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
>               try {
> -                     if (projectName.contains(" ")) {
> +                     if (!isValidProjectName(projectName)) {
>                               project.delete(true, null);
> -                             throw new ProcessFailureException(projectName + " contains space(s).  Project name can't contain space(s)");
> +                             throw new ProcessFailureException("Project name " + "\""+ projectName +"\"" +" is invalid! " +
> +                                             "\nNone of these characters are accepted inside project names: whitespaces, " + printIllegalChars());

Would be nice if we can wrap this up with the YoctoSDKMessages to be
able to internationalize the string later.

>                       }
>                       if (!project.exists()) {
>                               IWorkspace workspace = ResourcesPlugin.getWorkspace();
> @@ -166,6 +178,18 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
>                       throw new OperationCanceledException(Messages.getString("NewManagedProject.3") + e.getMessage());
>               }
>       }
> +     private boolean isValidProjectName(String projectName) {
> +             if (projectName.contains("\\s+"))
> +                     return false;
> +
> +             char[] chars = projectName.toCharArray();
> +             if (!Character.isJavaIdentifierStart(chars[0]))
> +                     return false;
> +             for (int i = 1; i < chars.length; i++)
> +                     if (illegalChars.contains(chars[i]))
> +                             return false;
> +             return true;
> +}

I think it would be better to use functionality from java.util.regex to
do the name checking. The Pattern could be compiled once as a static
member and we could than use the matcher to check whether the project
name is fine.

Something like this:

private static Pattern pattern = Pattern.compile(".*(\\$|\").*");

private boolean isValidProjectName(String projectName) {
   Matcher matcher = pattern.matcher(projectName);

   if (matcher.matches()) {
     return false;
   }

   return true;
}

>
>       protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException {
>               IWorkspaceDescription workspaceDesc = workspace.getDescription();
>

Best regards,
Timo



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-14 12:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-14  9:06 [PATCH] [eclipse-poky][master]Add more comprehensive error message for invalid project name Ioana Grigoropol
2013-03-14 10:29 ` Timo Müller
2013-03-14 10:36   ` Timo Müller
2013-03-14 12:08   ` Grigoropol, IoanaX

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.