-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix defines which contain own name freezing IDE
Version 1.15
- Loading branch information
Showing
6 changed files
with
99 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package glslplugin.lang.parser; | ||
|
||
import com.intellij.lang.ForeignLeafType; | ||
import com.intellij.psi.tree.IElementType; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* | ||
*/ | ||
public class RedefinedTokenType extends ForeignLeafType { | ||
|
||
/** Names of #defines through which this token was created. | ||
* Used to break recursive definitions, eg. #define FOO FOO. */ | ||
public final String[] redefinedThrough; | ||
|
||
public RedefinedTokenType(@NotNull ForeignLeafType delegate, String redefinedThrough) { | ||
super(delegate.getDelegate(), delegate.getValue()); | ||
this.redefinedThrough = new String[]{redefinedThrough}; | ||
} | ||
|
||
public RedefinedTokenType(@NotNull IElementType delegate, @NotNull CharSequence value, String[] redefinedThrough) { | ||
super(delegate, value); | ||
this.redefinedThrough = redefinedThrough; | ||
} | ||
|
||
public RedefinedTokenType redefineAlsoThrough(String name) { | ||
final String[] through = new String[redefinedThrough.length + 1]; | ||
System.arraycopy(this.redefinedThrough, 0, through, 0, this.redefinedThrough.length); | ||
through[this.redefinedThrough.length] = name; | ||
return new RedefinedTokenType(getDelegate(), getValue(), through); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "RedefinedTokenType("+getDelegate()+", '"+getValue()+"', "+ Arrays.toString(redefinedThrough)+")"; | ||
} | ||
} |