Giter VIP home page Giter VIP logo

Comments (6)

lcampos avatar lcampos commented on June 19, 2024 1

Thanks for the quick response @mcartoixa , I'm attaching a comparison (using your code sample) between the new language grammar rules (left) and the ones we currently ship with (right). I'm using 'Dark +' theme on the screenshots but similar results can be seen with any theme since the new tokens follow TextMate's guidelines. This are the first set of language grammar changes we'll be shipping since we feel they already provide a better experience. They will be part of this week's v42.16.0 release (May 17th).

Thanks for your feedback and let us know what you think once you try out the changes.
new-old-titles
close-curlybrace

from salesforcedx-vscode.

vazexqi avatar vazexqi commented on June 19, 2024

@mcartoixa - Thanks for reporting this. We are aware of the current limitations and are planning to address parts of them. The syntax highlighter that we are using (https://github.com/forcedotcom/salesforcedx-vscode/blob/develop/packages/salesforcedx-vscode-apex/syntaxes/apex.tmLanguage) is based on some old TextMate grammar (it's a modified copy of https://github.com/superfell/ApexMate/blob/master/plugin/Syntaxes/Apex.tmLanguage).

@ntotten - Per our discussion yesterday.

from salesforcedx-vscode.

vazexqi avatar vazexqi commented on June 19, 2024

Tracked internally as W-4800460

from salesforcedx-vscode.

lcampos avatar lcampos commented on June 19, 2024

Hi @mcartoixa, I'm working on fixing the tokenization issues you mentioned, I'm running some tests and would like to test with the code you used. Could you share a code sample so I can test against it?

from salesforcedx-vscode.

mcartoixa avatar mcartoixa commented on June 19, 2024

Found it 😉

/**
 * Used to read a delimited file.
 */
public class SSSCsvReader {
	private String delim = ',';
	// the input data
	private String[] buffer;
	
	public SSSCsvReader(String data){
		this.buffer = data.split('\n'); 
	}
	
	public SSSCsvReader(String data, String delim){
		this.buffer = data.split('\n'); 
		this.delim = delim;
	}
	
	/**
	 * Read and parse next available line.  Return null if end of stream.
	 */
	public String[] readLine(){
		if(buffer.size() == 0)
			return null;
		String line = this.buffer.remove(0);
		String[] parts = new String[] {};
		while(line != ''){
			Integer next = 0;
			if(line.startsWith('"')){
				line = line.substring(1); // strip initial
				Integer quoteIndex = findQuote(line, 0);
				while(quoteIndex == -1){
					if(buffer.size() == 0){
						// EOT!
						quoteIndex = line.length();
					} else { 
						// grab the next line
						Integer skip = line.length();
						line += '\n' + this.buffer.remove(0);
						quoteIndex = findQuote(line, skip);
					}
				}
				// advance to comma
				next = quoteIndex + 1;
				parts.add(line.substring(0, quoteIndex).replace('""', '"'));
			} else {
				next = line.indexOf(this.delim, next);
				if(next == -1)
					next = line.length();
				// NB in Substring, "endindex" is the index of the character AFTER the last index to get
				parts.add(line.substring(0, next));
			}		
			if(next == line.length() - 1)
				// case of a terminating comma.
				parts.add('');
			line = next < line.length() ? line.substring(next+1) : '';
		}
		if(parts.size() == 0)
			// empty string - we still want to return something...
			parts.add('');
		return parts;
	}
	
	static private Pattern quotePattern = Pattern.compile('(?<!")"(?!")');
	/**
	 * Find next quote in the line
	 */
	private Integer findQuote(String line, Integer skip){
		Matcher m = quotePattern.matcher(line);
		m.region(skip, m.regionEnd());
		if(!m.find())
			return -1;
		return m.start();
	}
}

from salesforcedx-vscode.

vazexqi avatar vazexqi commented on June 19, 2024

We are closing this as part of #415

@mcartoixa - If you see any other issues, please open a new issue for this. Thanks again for reporting this.

from salesforcedx-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.