Bug 549226 - Bugs on lack of "return"
Summary: Bugs on lack of "return"
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.10   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-12 11:09 EDT by Miaoying Wang CLA
Modified: 2023-06-26 01:21 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miaoying Wang CLA 2019-07-12 11:09:28 EDT
The situation behind is caused by a mark "~" that occupies the position of keyword "return", which means the function faces two bugs, one is the lack of return, the other one is the redundant character.

 public static String parseName(  String pattern,  GregorianCalendar cal){
    Map map=cal == null ? getTokenMap("") : getTokenMap(cal);
    return parseName(pattern,map);
  }
  public static boolean matchPattern(  String name,  String pattern,  String extension){
    if (!name.endsWith(extension)) {
      return false;
    }
 else {
      name=name.substring(0,name.length() - extension.length());
    }
    HashMap map=new HashMap();
    for (int i=0; i < TOKENS.length; i++) {
      int l=TOKENS[i].length() - 2;
      String rep="";
      for (int j=0; j < l; j++) {
        rep+='%';
      }
      map.put(TOKENS[i],rep);
    }
    String parsed=parseName(pattern,map);
    if (parsed.length() > name.length()) {
      ~ false;
    }
 else     if (parsed.length() < name.length()) {
      String suffix=name.substring(parsed.length());
      if (suffix.charAt(0) != SUFFIX_SEPARATOR) {
        return false;
      }
 else {
        for (int i=1; i < suffix.length(); i++) {
          if (!isNumber(suffix.charAt(i))) {
            return false;
          }
        }
      }
    }
    for (int i=0; i < parsed.length(); i++) {
      char pc=parsed.charAt(i);
      char nc=name.charAt(i);
      if (pc != nc && (pc != '%' || !isNumber(nc))) {
        return false;
      }
    }
    return true;
  }

However, the response from ECJ is quite strange for blaming it on the lack of "throw". The report is shown below.

----------
1. ERROR in C:\DataG\ArchiveNameHelper.java (at line 80)
	if (parsed.length() > name.length()) {
	                                     ^
Syntax error on token "{", throw expected after this token
----------
1 problem (1 error)

The report cannot fetch this to any solutions whether add a command with "return" to complete the consumption of the function, or just delete the curious '~' to help the function more close to compiled.
Comment 1 Eclipse Genie CLA 2021-07-02 16:58:20 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 2 Sarika Sinha CLA 2021-07-05 05:40:30 EDT
Moving to JDT Core, problem still exists. Stripped snippet:

public static boolean matchPattern(  String name,  String parsed){
		  
	    if (parsed.length() > name.length()) {
	        ~ false;
	      }
	    for (int i=0; i < parsed.length(); i++) {
	      char pc=parsed.charAt(i);
	      char nc=name.charAt(i);
	      if (pc != nc && (pc != '%' )) {
	        return false;
	      }
	    }
	    return true;
	  }

ECJ reports 2 errors instead of expected 1.
Comment 3 Eclipse Genie CLA 2023-06-26 01:21:31 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.